Re: [U-Boot] RFC: Alternative boot_jump_linux() function

2018-05-25 Thread Ramon Fried
On Sat, May 26, 2018 at 5:18 AM, Tom Rini  wrote:
> On Fri, May 25, 2018 at 05:41:31PM +0300, Ramon Fried wrote:
>> On Fri, May 25, 2018 at 3:11 PM, Tom Rini  wrote:
>> > On Thu, May 17, 2018 at 07:48:45PM +0300, Ramon Fried wrote:
>> >> On Thu, May 17, 2018 at 5:22 PM, Tom Rini  wrote:
>> >> > On Thu, May 17, 2018 at 02:01:55PM +0300, Ramon Fried wrote:
>> >> >
>> >> >> Hi.
>> >> >> I'm currently working on snapdragon bootloader support and in the
>> >> >> particular case where U-boot is running in Aarch32 and the kernel is
>> >> >> Aarch64 the specific implementation is to jump to Linux through SCM
>> >> >> call.
>> >> >>
>> >> >> I try to find the best possible way to provide an alternative boot 
>> >> >> function.
>> >> >> Adding #ifdef ARCH_SNAPDRAGON will just be too specific in
>> >> >> arm/lib/bootm.c in my opinion and I'm thinking of introducing kind of
>> >> >> a callback function in gd. that if exists will jump there instead of
>> >> >> executing boot_jump_linux().
>> >> >>
>> >> >> What do you think ?
>> >> >
>> >> > So, to be clear, we're on an aarch64 SoC, but U-Boot has been entered in
>> >> > 32bit mode.  And we need to boot a 64bit Linux Kernel.  What else, if
>> >> > anything, is also loaded/still in residence/etc?  Can you explain the
>> >> > overall usecase a bit more and why we're in 32bit mode?  Thanks!
>> >> >
>> >> OK.
>> >> Basically, Qualcomm has the following boot flow:
>> >>
>> >> PBL -> SBL -> LK -> Linux Kernel
>> >>
>> >> PBL - 32bit Primary boot loader(ROM) loads the SBL from eMMC.
>> >>
>> >> SBL - 32bit Secondary boot loader(eMMC/UFS), proprietary closed source,
>> >> Initializes the DDR, starts the trustzone and can load either a 32bit
>> >> or a 64bit (1)
>> >> ELF bootloader, given that it's signed.
>> >>
>> >> LK - Little kernel, 32bit. Qualcomm maintains a downstream version, open 
>> >> source.
>> >> Loads 64bit Android boot image from eMMC and jumps to it using SMC
>> >> call made to Trustzone.
>> >>
>> >> This was used primarily for Android, but when Dragonboards boards came
>> >> out, Qualcomm and Linaro started
>> >> distributing 64bit Linux OE & Debian builds that were booted by LK.
>> >> Because U-boot is much more useful than LK, the first U-boot
>> >> contribution was made by Mateusz Kulikowski.
>> >>
>> >> Basically, Mateusz port is wrapping U-boot to appear as a kernel so LK
>> >> boots it, then it boots Linux.
>> >> So basically, LK did the 32 -> 64 transition.
>> >>
>> >> Now, here where I appear in the story... :)
>> >
>> > Thanks for the detailed background.
>> >
>> >> I'm trying to get rid of LK and use U-boot as the real bootloader for 
>> >> Linux.
>> >> I succeeded in that, and I have all the patches ready for submission,
>> >> I just need to add a dedicated boot function
>> >> that does the SMC call, hence this discussion.
>> >>
>> >> (1) - It implies that we can in practice just use 64bit U-boot for 
>> >> Snapdragon.
>> >> The only problem I have right now is that there's isn't any
>> >> open-source tool to sign the Bootloader that supports ELF64
>> >> executable.
>> >
>> > Is it possible to just write that tool, or update an existing tool to do
>> > that signature?
>> Yes. It should be possible.
>>
>> Actually, when I did have access to qcom internal tool for doing so I
>> was able to run U-boot
>> on 64bit mode. I had problems booting the kernel, as after the boot
>> weird things were happening,
>> like other cpu weren't responding, eMMC driver wasn't working etc.
>> I suspect it's related to low level initialization that was lacking,
>> or something similar.
>>
>> I ended up working on the 32bit mode because I no longer have access
>> to the internal tool.
>> I believe that in the end we will end up with a working 64bit version.
>> I'm just thinking that meanwhile It maybe worthwhile to also have the
>> 32bit version.
>>
>> What do you think ?
>
> How long might we be in this interim odd spot?  It sounds like we need
> some odd hoops to go and be able to boot a 64bit Linux when we're in
> 32bit mode.  If this is just for a short period of time, maybe we just
> accept that the Linaro tree will have to hold a patch or two for now
> until we can just be a good and clean 64bit binary?

I added Nicolas from Linaro to the thread so he can comment regarding
the signing tool.

I agree with you that the jump through SCM call is very specific.
I didn't send any of the 32bit patches yet, I was waiting to see if
the required supported
changes will get accepted.
It's up to you to decide if you're willing to accept that as in
intermediate solution until we get
a working 64bit version.
I do know that there is high demand in the community for such support.

The 32bit potentially waiting to be upstreamed is in my github repo here:
https://github.com/mellowcandle/u-boot/tree/upstream

Thanks,
Ramon.

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

Re: [U-Boot] [PATCH v1 1/2] buildman: Extract environment as part of each build

2018-05-25 Thread Alex Kiernan
On Sat, May 26, 2018 at 3:07 AM Simon Glass  wrote:

> Hi Alex,

> On 24 May 2018 at 22:57, Alex Kiernan  wrote:
> > As we're building the boards, extract the default U-Boot environment to
> > uboot.env so we can interrogate it later.
> >
> > Signed-off-by: Alex Kiernan 
> > ---
> >
> >  tools/buildman/builderthread.py | 10 ++
> >  1 file changed, 10 insertions(+)

> I wonder if this should be an option? Is the file large?


Only as big as the things that are defined - it's not the full size of
CONFIG_ENV_SIZE. The biggest one I've got sitting around is just under 6k,
which for that particular board is about 2.5% of the disk use for the whole
result directory - doesn't feel like a huge increase.

> Also please update the README to mention this.


Will do.

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


Re: [U-Boot] [PATCH] x86: use EFI calling convention for efi_main on x86_64

2018-05-25 Thread Heinrich Schuchardt
On 05/25/2018 11:28 PM, Ivan Gorinov wrote:
> Save the arguments passed in %rcx and %rdx for efi_main() on x86_64;
> consistently use EFI calling convention for efi_main().
> 
> Signed-off-by: Ivan Gorinov 

One big difference between the ms_abi and the sysv_abi calling
convention is the set of volatile registers. So shouldn't _relocate()
also be declared as EFIAPI to ensure that we do not mess up the callers
registers?

Best regards

Heinrich

> ---
>  arch/x86/lib/crt0_x86_64_efi.S | 8 
>  lib/efi/efi_app.c  | 3 ++-
>  lib/efi/efi_stub.c | 3 ++-
>  3 files changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/x86/lib/crt0_x86_64_efi.S b/arch/x86/lib/crt0_x86_64_efi.S
> index 989799f..2d53d1b 100644
> --- a/arch/x86/lib/crt0_x86_64_efi.S
> +++ b/arch/x86/lib/crt0_x86_64_efi.S
> @@ -16,19 +16,19 @@ _start:
>   subq $8, %rsp
>   pushq %rcx
>   pushq %rdx
> + pushq %rsi
> + pushq %rdi
>  
>  0:
>   lea image_base(%rip), %rdi
>   lea _DYNAMIC(%rip), %rsi
>  
> - popq %rcx
> - popq %rdx
> - pushq %rcx
> - pushq %rdx
>   call _relocate
>  
>   popq %rdi
>   popq %rsi
> + popq %rdx
> + popq %rcx
>  
>   call efi_main
>   addq $8, %rsp
> diff --git a/lib/efi/efi_app.c b/lib/efi/efi_app.c
> index c828093..3eb8eeb 100644
> --- a/lib/efi/efi_app.c
> +++ b/lib/efi/efi_app.c
> @@ -96,7 +96,8 @@ static void free_memory(struct efi_priv *priv)
>   * U-Boot. If it returns, EFI will continue. Another way to get back to EFI
>   * is via reset_cpu().
>   */
> -efi_status_t efi_main(efi_handle_t image, struct efi_system_table *sys_table)
> +efi_status_t EFIAPI efi_main(efi_handle_t image,
> +  struct efi_system_table *sys_table)
>  {
>   struct efi_priv local_priv, *priv = _priv;
>   efi_status_t ret;
> diff --git a/lib/efi/efi_stub.c b/lib/efi/efi_stub.c
> index 3138739..399d16b 100644
> --- a/lib/efi/efi_stub.c
> +++ b/lib/efi/efi_stub.c
> @@ -268,7 +268,8 @@ static void add_entry_addr(struct efi_priv *priv, enum 
> efi_entry_t type,
>   * This function is called by our EFI start-up code. It handles running
>   * U-Boot. If it returns, EFI will continue.
>   */
> -efi_status_t efi_main(efi_handle_t image, struct efi_system_table *sys_table)
> +efi_status_t EFIAPI efi_main(efi_handle_t image,
> +  struct efi_system_table *sys_table)
>  {
>   struct efi_priv local_priv, *priv = _priv;
>   struct efi_boot_services *boot = sys_table->boottime;
> 

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


Re: [U-Boot] RFC: Alternative boot_jump_linux() function

2018-05-25 Thread Tom Rini
On Fri, May 25, 2018 at 05:41:31PM +0300, Ramon Fried wrote:
> On Fri, May 25, 2018 at 3:11 PM, Tom Rini  wrote:
> > On Thu, May 17, 2018 at 07:48:45PM +0300, Ramon Fried wrote:
> >> On Thu, May 17, 2018 at 5:22 PM, Tom Rini  wrote:
> >> > On Thu, May 17, 2018 at 02:01:55PM +0300, Ramon Fried wrote:
> >> >
> >> >> Hi.
> >> >> I'm currently working on snapdragon bootloader support and in the
> >> >> particular case where U-boot is running in Aarch32 and the kernel is
> >> >> Aarch64 the specific implementation is to jump to Linux through SCM
> >> >> call.
> >> >>
> >> >> I try to find the best possible way to provide an alternative boot 
> >> >> function.
> >> >> Adding #ifdef ARCH_SNAPDRAGON will just be too specific in
> >> >> arm/lib/bootm.c in my opinion and I'm thinking of introducing kind of
> >> >> a callback function in gd. that if exists will jump there instead of
> >> >> executing boot_jump_linux().
> >> >>
> >> >> What do you think ?
> >> >
> >> > So, to be clear, we're on an aarch64 SoC, but U-Boot has been entered in
> >> > 32bit mode.  And we need to boot a 64bit Linux Kernel.  What else, if
> >> > anything, is also loaded/still in residence/etc?  Can you explain the
> >> > overall usecase a bit more and why we're in 32bit mode?  Thanks!
> >> >
> >> OK.
> >> Basically, Qualcomm has the following boot flow:
> >>
> >> PBL -> SBL -> LK -> Linux Kernel
> >>
> >> PBL - 32bit Primary boot loader(ROM) loads the SBL from eMMC.
> >>
> >> SBL - 32bit Secondary boot loader(eMMC/UFS), proprietary closed source,
> >> Initializes the DDR, starts the trustzone and can load either a 32bit
> >> or a 64bit (1)
> >> ELF bootloader, given that it's signed.
> >>
> >> LK - Little kernel, 32bit. Qualcomm maintains a downstream version, open 
> >> source.
> >> Loads 64bit Android boot image from eMMC and jumps to it using SMC
> >> call made to Trustzone.
> >>
> >> This was used primarily for Android, but when Dragonboards boards came
> >> out, Qualcomm and Linaro started
> >> distributing 64bit Linux OE & Debian builds that were booted by LK.
> >> Because U-boot is much more useful than LK, the first U-boot
> >> contribution was made by Mateusz Kulikowski.
> >>
> >> Basically, Mateusz port is wrapping U-boot to appear as a kernel so LK
> >> boots it, then it boots Linux.
> >> So basically, LK did the 32 -> 64 transition.
> >>
> >> Now, here where I appear in the story... :)
> >
> > Thanks for the detailed background.
> >
> >> I'm trying to get rid of LK and use U-boot as the real bootloader for 
> >> Linux.
> >> I succeeded in that, and I have all the patches ready for submission,
> >> I just need to add a dedicated boot function
> >> that does the SMC call, hence this discussion.
> >>
> >> (1) - It implies that we can in practice just use 64bit U-boot for 
> >> Snapdragon.
> >> The only problem I have right now is that there's isn't any
> >> open-source tool to sign the Bootloader that supports ELF64
> >> executable.
> >
> > Is it possible to just write that tool, or update an existing tool to do
> > that signature?
> Yes. It should be possible.
> 
> Actually, when I did have access to qcom internal tool for doing so I
> was able to run U-boot
> on 64bit mode. I had problems booting the kernel, as after the boot
> weird things were happening,
> like other cpu weren't responding, eMMC driver wasn't working etc.
> I suspect it's related to low level initialization that was lacking,
> or something similar.
> 
> I ended up working on the 32bit mode because I no longer have access
> to the internal tool.
> I believe that in the end we will end up with a working 64bit version.
> I'm just thinking that meanwhile It maybe worthwhile to also have the
> 32bit version.
> 
> What do you think ?

How long might we be in this interim odd spot?  It sounds like we need
some odd hoops to go and be able to boot a 64bit Linux when we're in
32bit mode.  If this is just for a short period of time, maybe we just
accept that the Linaro tree will have to hold a patch or two for now
until we can just be a good and clean 64bit binary?

-- 
Tom


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


Re: [U-Boot] [PATCH v2 5/6] cmd: iotrace: add dump trace command

2018-05-25 Thread Simon Glass
On 25 May 2018 at 04:41, Ramon Fried  wrote:
> Add dump trace command which dump all trace
> buffer content in a much more readable fashion
> than md.
>
> Signed-off-by: Ramon Fried 
> ---
> v2: fixed printf zero field width.
>
>  cmd/iotrace.c | 36 +++-
>  1 file changed, 35 insertions(+), 1 deletion(-)
>

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


Re: [U-Boot] [PATCH v1 1/2] buildman: Extract environment as part of each build

2018-05-25 Thread Simon Glass
Hi Alex,

On 24 May 2018 at 22:57, Alex Kiernan  wrote:
> As we're building the boards, extract the default U-Boot environment to
> uboot.env so we can interrogate it later.
>
> Signed-off-by: Alex Kiernan 
> ---
>
>  tools/buildman/builderthread.py | 10 ++
>  1 file changed, 10 insertions(+)

I wonder if this should be an option? Is the file large?

Also please update the README to mention this.

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


Re: [U-Boot] [PATCH 3/6] common: iotrace: add timestamp to iotrace records

2018-05-25 Thread Simon Glass
HI Ramon,

On 25 May 2018 at 04:41, Ramon Fried  wrote:
> Add timestamp to each iotrace record to aid in debugging
> of IO timing access bugs.
>
> Signed-off-by: Ramon Fried 
> ---
>  common/iotrace.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/common/iotrace.c b/common/iotrace.c
> index f39885663a..3530688ab1 100644
> --- a/common/iotrace.c
> +++ b/common/iotrace.c
> @@ -27,11 +27,13 @@ enum iotrace_flags {
>   * struct iotrace_record - Holds a single I/O trace record
>   *
>   * @flags: I/O access type
> + * @timestamp: Timestamp of access
>   * @addr: Address of access
>   * @value: Value written or read
>   */
>  struct iotrace_record {
> enum iotrace_flags flags;
> +   u64 timestamp;
> phys_addr_t addr;
> iovalue_t value;
>  };
> @@ -82,6 +84,7 @@ static void add_record(int flags, const void *ptr, ulong 
> value)
> sizeof(value));
> }
>
> +   rec->timestamp = get_ticks();

Would it not be better to use timer_get_us() here?

> rec->flags = flags;
> rec->addr = map_to_sysmem(ptr);
> rec->value = value;
> --
> 2.17.0
>

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


Re: [U-Boot] [PATCH] regmap: Separate memory-based operations

2018-05-25 Thread Simon Glass
Hi Alexey,

On 25 May 2018 at 03:45, Alexey Brodkin  wrote:
> Hi Simon,
>
> On Thu, 2018-05-24 at 20:42 -0600, Simon Glass wrote:
>> Hi Alexey,
>>
>> On 24 May 2018 at 06:36, Alexey Brodkin  wrote:
>> > One of important features of regmap [at least in Linux kernel]
>> > is an ability to seamlessly communicate to devices connected
>> > via different buses like: MMIO, SPI, I2C and many others.
>> >
>> > Current implementation in U-Boot only supports memory-mapped registers
>> > which is a vere valid case but we'll need more in the future.
>> >
>> > This change paves the way for support of other buses. Still all existing
>> > users of regmap in U-Boot shouldn't be affected because for now we don't
>> > change API which might be required once we start adding support of more
>> > complicated cases like 8/16/32/64-bit accessors, big- and little-endian
>> > flavours etc.
>> >
>> > It was inspired by discussion [1] of addition of even more accessors to
>> > a standard 16550 UART.
>> >
>> > [1] 
>> > https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.denx.de_pipermail_u-2Dboot_2018-2DMarch_322322.html=DwIBaQ=DPL6_X_6JkXFx7AXWqB0
>> > tg=lqdeeSSEes0GFDDl656eViXO7breS55ytWkhpk5R81I=JMITUQeA5TvqyeIBTH0jtI2TOsSfOS-0qPz4kntF5Hc=yadG7Ir9EqQaMUpUychW3TY3B7acDOog8IQYDKvOI-8=
>> >
>> > Signed-off-by: Alexey Brodkin 
>> > Cc: Simon Glass 
>> > ---
>> >  drivers/core/Makefile   |  2 +-
>> >  drivers/core/{regmap.c => regmap-mem.c} | 79 ++-
>> >  drivers/core/regmap.c   | 85 +
>> >  include/regmap.h|  9 +++
>> >  4 files changed, 31 insertions(+), 144 deletions(-)
>> >  copy drivers/core/{regmap.c => regmap-mem.c} (60%)
>> >
>>
>> Are there any changes needed to the regmap test with this?
>
> Given this change doesn't touch API I'm not sure what can we
> test more than it's currently done. Any thoughts?
>
>> [..]
>>
>> > diff --git a/include/regmap.h b/include/regmap.h
>> > index 493a5d8eff84..f01c5733afac 100644
>> > --- a/include/regmap.h
>> > +++ b/include/regmap.h
>> > @@ -31,6 +31,8 @@ struct regmap {
>> > phys_addr_t base;
>> > int range_count;
>> > struct regmap_range *range, base_range;
>> > +   int (*reg_read)(struct regmap *map, uint reg, uint *val);
>> > +   int (*reg_write)(struct regmap *map, uint reg, uint val);
>>
>> Can we use driver model for these somehow? E.g. we could create a
>> UCLASS_SIMPLE_REG driver for each of memory, i2c, SPI, etc.
>
> Probably we can do it here in U-Boot.
> But at least in Linux kernel I see users of regmap (i.e. particular drivers)
> initialize required regmap instance "manually", see for example:
> https://elixir.bootlin.com/linux/latest/source/drivers/media/dvb-frontends/af9033.c#L1105
>
>> When we want to use a particular I2C bus via regmap, we could bind the
>> I2C -> regmap driver as a child of the I2C bus driver.
>
> I guess that will require us to do corresponding changes in Device Tree
> descriptions, right? And that will deviate those .dts-es from their kernel
> counterparts [if they exist for a particular board].

Actually I don't think so. You can have a helper function that you
call to bind the regmap to an I2C device, for example. That can be
called from code, without needing any DT changes.

My objection is mostly to using function pointers to call what look
like driver functions. The design of DM in U-Boot is supposed to
support child drivers for exactly this purpose. So we should try to
use it, unless we hit some terrible design flaw.

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


Re: [U-Boot] [PATCH v1 2/2] buildman: Add support for environment delta in summary

2018-05-25 Thread Simon Glass
On 24 May 2018 at 22:57, Alex Kiernan  wrote:
> When summarising the builds, add the -U option to emit delta lines for
> the default environment built into U-Boot at each commit.
>
> Signed-off-by: Alex Kiernan 
> ---
>
>  tools/buildman/builder.py | 128 +-
>  tools/buildman/cmdline.py |   2 +
>  tools/buildman/control.py |   3 +-
>  3 files changed, 117 insertions(+), 16 deletions(-)

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


Re: [U-Boot] [PATCH v3 2/2] test/py: add test for whitelist of variables while importing environment

2018-05-25 Thread Simon Glass
Hi,

On 25 May 2018 at 02:38, Quentin Schulz  wrote:
> This tests that the importing of an environment with a specified
> whitelist works as intended.
>
> If there are variables passed as parameter to the env import command,
>those only should be imported in the current environment.
>
> For each variable passed as parameter, if
>  - foo is bar in current env and bar2 in exported env, after importing
>  exported env, foo shall be bar2,
>  - foo does not exist in current env and foo is bar2 in exported env,
>  after importing exported env, foo shall be bar2,
>  - foo is bar in current env and does not exist in exported env (but is
>  passed as parameter), after importing exported env, foo shall be empty,
>
> Any variable not passed as parameter should be left untouched.
>
> Two other tests are made to test that size cannot be '-' if the checksum
> protection is enabled.
>
> Signed-off-by: Quentin Schulz 
> ---
>
> v3:
>   - update whitelist test to reflect changes made in patch 1,
>   - add two tests for no size parameter passed but checksum protection is
>   enabled because I added the possibility to have a sentinel in place of
>   size parameter,
>   - I intentionally didn't put the Reviewed and Acked-by of Simon and
>   Stephen since the code changed since v2,
>
> added in v2
>
>  test/py/tests/test_env.py | 50 -
>  1 file changed, 50 insertions(+)

Reviewed-by: Simon Glass 

Some nits below

>
> diff --git a/test/py/tests/test_env.py b/test/py/tests/test_env.py
> index bfb5fc0..b83d2b1 100644
> --- a/test/py/tests/test_env.py
> +++ b/test/py/tests/test_env.py
> @@ -5,6 +5,7 @@
>  # Test operation of shell commands relating to environment variables.
>
>  import pytest
> +import u_boot_utils
>
>  # FIXME: This might be useful for other tests;
>  # perhaps refactor it into ConsoleBase or some other state object?
> @@ -239,3 +240,52 @@ def test_env_expansion_spaces(state_test_env):
>  unset_var(state_test_env, var_space)
>  if var_test:
>  unset_var(state_test_env, var_test)
> +
> +def test_env_import_checksum_no_size(state_test_env):
> +"""Test that omitted ('-') size parameter with checksum validation fails 
> the
> +   env import function.
> +"""
> +c = state_test_env.u_boot_console
> +ram_base = u_boot_utils.find_ram_base(state_test_env.u_boot_console)
> +addr = '%08x' % ram_base
> +
> +with c.disable_check('error_notification'):
> +response = c.run_command('env import -c %s -' % addr)
> +assert(response == '## Error: external checksum format must pass size')
> +
> +def test_env_import_whitelist_checksum_no_size(state_test_env):
> +"""Test that omitted ('-') size parameter with checksum validation fails 
> the
> +   env import function when variables are passed as parameters.
> +"""
> +c = state_test_env.u_boot_console
> +ram_base = u_boot_utils.find_ram_base(state_test_env.u_boot_console)
> +addr = '%08x' % ram_base
> +
> +with c.disable_check('error_notification'):
> +response = c.run_command('env import -c %s - foo1 foo2 foo4' % addr)
> +assert(response == '## Error: external checksum format must pass size')
> +
> +def test_env_import_whitelist(state_test_env):
> +"""Test importing only a handful of env variables from an environment."""
> +c = state_test_env.u_boot_console
> +ram_base = u_boot_utils.find_ram_base(state_test_env.u_boot_console)
> +addr = '%08x' % ram_base
> +
> +set_var(state_test_env, "foo1", "bar1")

Please use ' for strings rather than ", except for the function/class comments

> +set_var(state_test_env, "foo2", "bar2")
> +set_var(state_test_env, "foo3", "bar3")
> +
> +c.run_command('env export %s' % addr)
> +
> +unset_var(state_test_env, "foo1")
> +set_var(state_test_env, "foo2", "test2")
> +set_var(state_test_env, "foo4", "bar4")
> +
> +#no foo1 in current env, foo2 overridden, foo3 should be of the value
> +#before exporting and foo4 should be deleted

Spaces after each #

> +c.run_command('env import %s - foo1 foo2 foo4' % addr)
> +
> +validate_set(state_test_env, "foo1", "bar1")
> +validate_set(state_test_env, "foo2", "bar2")
> +validate_set(state_test_env, "foo3", "bar3")
> +validate_empty(state_test_env, "foo4")
> --
> git-series 0.9.1
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v3 6/6] test: dm: Fix wrong aliases property names

2018-05-25 Thread Simon Glass
Hi,

On 24 May 2018 at 16:04, Eugeniu Rosca  wrote:
> Hi Simon,
>
> On Tue, May 22, 2018 at 05:30:40PM -0600, Simon Glass wrote:
>> Hi Eugeniu,
>>
>> On 19 May 2018 at 06:13, Eugeniu Rosca  wrote:
>
> --snip--
>
>> > v2->v3:
>> > * Fixed an issue in the test code (test/dm/test-fdt.c) generated by the
>> >   DTS update (arch/sandbox/dts/test.dts) in [PATCH v2].
>> > * Changed commit summary line, to cover test/dm/test-fdt.c.
>> > * Added: Reported-by: Petr Vorel 
>> > * [Due to update] Dropped: Reviewed-by: Simon Glass 
>> >
>> > v1->v2:
>> > * Newly pushed
>> >
>> >  arch/sandbox/dts/test.dts | 8 
>> >  test/dm/test-fdt.c| 2 +-
>> >  2 files changed, 5 insertions(+), 5 deletions(-)
>> >
>>
>> Reviewed-by: Simon Glass 
>>
>> See below
>>
>> > diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
>> > index 683b1970e0af..3e87c5c0f3fd 100644
>> > --- a/arch/sandbox/dts/test.dts
>> > +++ b/arch/sandbox/dts/test.dts
>> > @@ -27,10 +27,10 @@
>> > testfdt3 = "/b-test";
>> > testfdt5 = "/some-bus/c-test@5";
>> > testfdt8 = "/a-test";
>> > -   fdt_dummy0 = "/translation-test@8000/dev@0,0";
>> > -   fdt_dummy1 = "/translation-test@8000/dev@1,100";
>> > -   fdt_dummy2 = "/translation-test@8000/dev@2,200";
>> > -   fdt_dummy3 = 
>> > "/translation-test@8000/noxlatebus@3,300/dev@42";
>> > +   fdt-dummy0 = "/translation-test@8000/dev@0,0";
>> > +   fdt-dummy1 = "/translation-test@8000/dev@1,100";
>> > +   fdt-dummy2 = "/translation-test@8000/dev@2,200";
>> > +   fdt-dummy3 = 
>> > "/translation-test@8000/noxlatebus@3,300/dev@42";
>> > usb0 = _0;
>> > usb1 = _1;
>> > usb2 = _2;
>> > diff --git a/test/dm/test-fdt.c b/test/dm/test-fdt.c
>> > index 8196844e89a7..66d0df5629a2 100644
>> > --- a/test/dm/test-fdt.c
>> > +++ b/test/dm/test-fdt.c
>> > @@ -425,7 +425,7 @@ static const struct udevice_id fdt_dummy_ids[] = {
>> >  };
>> >
>> >  UCLASS_DRIVER(fdt_dummy) = {
>> > -   .name   = "fdt_dummy",
>> > +   .name   = "fdt-dummy",
>>
>> You should not need to change this one, and I worry that it is
>> confusing since this is the driver name, not a compatible string.
>
> I am not familiar with the in-tree U-boot unit tests, but doing a small
> experiment I get clear evidence that there is a tight
> relationship/dependency between the name of the entries in the aliases
> DTS node and the "name" field of UCLASS_DRIVER using that DTS.

Yes you are right - the alias uses the uclass name, sorry.

>
> The experiment is running 'ut dm' in sandbox before and after below
> patch (I also had to fix two null pointer dereferences in
> test/dm/bus.c to avoid segmentation faults with the patch applied):
>
> diff --git a/test/dm/test-fdt.c b/test/dm/test-fdt.c
> index 8196844e89a7..5b715e965269 100644
> --- a/test/dm/test-fdt.c
> +++ b/test/dm/test-fdt.c
> @@ -94,7 +94,7 @@ int testfdt_ping(struct udevice *dev, int pingval, int 
> *pingret)
>  }
>
>  UCLASS_DRIVER(testfdt) = {
> -   .name   = "testfdt",
> +   .name   = "test_fdt",
> .id = UCLASS_TEST_FDT,
> .flags  = DM_UC_FLAG_SEQ_ALIAS,
>  };
>
> Before the patch, I get: Failures: 9
> After the patch, I get: Failures: 25
>
> So, while the aliases entries are certainly not compatible strings,
> not keeping them aligned to UCLASS_DRIVER->name values leads to test
> failures. I am not sure if this is something specific to architecture of
> the tests or applies generically to any driver which fetches its
> configuration from DTS. I was hoping to get an assessment from somebody
> with more experience in this area.
>
> Besides the above, it is not clear to me if your Reviewed-by applies to
> to this patch partially (since you expressed some concerns) or applies
> globally, in which case the concerns are not major?

It means that I've reviewed the patch and I'd like some changes, but
don't want to review it after you have made those changes, so you
should add the Reviewed-by tag when doing the next version.

But in this case your change is correct, so please don't worry. It's
unfortunate that the uclass name needs a hypen, but I understand why.

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


Re: [U-Boot] [PATCH 6/6] common: iotrace: fix behaviour when buffer is full

2018-05-25 Thread Simon Glass
Hi Ramon,

On 25 May 2018 at 04:41, Ramon Fried  wrote:
> When the buffer is full, there supposed to be no more
> writes, the code however misses the else statement and
> subsequently writes to arbitrary pointer location and increases
> the offset.

I don't think so. It writes to a local variable in this case. The
point of this is to detect how much space would be needed to hold the
I/O trace. Unless the pointer is incremented, there is no way to know.

Perhaps instead, iotrace_get_buffer() should be updated to also return
the number of valid records, as well as the pointer value?

> This patch fixes that by returning immediately.
>
> Signed-off-by: Ramon Fried 
> ---
>  common/iotrace.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/common/iotrace.c b/common/iotrace.c
> index 74408a5dbb..5f06d2b250 100644
> --- a/common/iotrace.c
> +++ b/common/iotrace.c
> @@ -55,6 +55,8 @@ static void add_record(int flags, const void *ptr, ulong 
> value)
> rec = (struct iotrace_record *)map_sysmem(
> iotrace.start + iotrace.offset,
> sizeof(value));
> +   } else {
> +   return;
> }
>
> rec->timestamp = get_ticks();
> --
> 2.17.0
>

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


Re: [U-Boot] [PATCH 4/6] iotrace: move record definitons to header file

2018-05-25 Thread Simon Glass
On 25 May 2018 at 04:41, Ramon Fried  wrote:
> The header definitions are needed for reading
> record information in cmd/iotrace.c
>
> Signed-off-by: Ramon Fried 
> ---
>  common/iotrace.c  | 27 ---
>  include/iotrace.h | 28 
>  2 files changed, 28 insertions(+), 27 deletions(-)

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


Re: [U-Boot] [PATCH 5/5] cmd: iotrace: add dump trace command

2018-05-25 Thread Simon Glass
Hi Ramon,

On 24 May 2018 at 13:36, Ramon Fried  wrote:
> Add dump trace command which dump all trace
> buffer content in a much more readable fashion
> than md.
>
> Signed-off-by: Ramon Fried 
> ---
>  cmd/iotrace.c | 36 +++-
>  1 file changed, 35 insertions(+), 1 deletion(-)
>

Please see bootstage - I think the timestamp should be in microseconds.

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


Re: [U-Boot] [PATCH 2/6] iotrace: add IO region limit

2018-05-25 Thread Simon Glass
On 25 May 2018 at 04:41, Ramon Fried  wrote:
> When dealing with a lot of IO regions, sometimes
> it makes sense only to trace a specific one.
> This patch adds support for region limits.
> If region is not set, the iotrace works the same as it was.
> If region is set, the iotrace only logs io operation that falls
> in the defined region.
>
> Signed-off-by: Ramon Fried 
> ---
>  common/iotrace.c  | 27 +++
>  include/iotrace.h | 24 
>  2 files changed, 51 insertions(+)
>

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


Re: [U-Boot] [PATCH 1/6] cmd: iotrace: add set region command

2018-05-25 Thread Simon Glass
On 25 May 2018 at 04:41, Ramon Fried  wrote:
> Signed-off-by: Ramon Fried 
> ---
>  cmd/iotrace.c | 22 ++
>  1 file changed, 22 insertions(+)
>


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


Re: [U-Boot] [PATCH] malloc: Use malloc simple before malloc is fully initialized in memalign()

2018-05-25 Thread Simon Glass
+Masahiro

On 25 May 2018 at 02:50, Ley Foon Tan  wrote:
>
> On Fri, May 25, 2018 at 11:33 AM, Simon Glass  wrote:
> > Hi,
> >
> > On 24 May 2018 at 21:24, Ley Foon Tan  wrote:
> >>
> >> On Thu, May 24, 2018 at 12:33 AM, Simon Glass  wrote:
> >> > Hi,
> >> >
> >> > On 23 May 2018 at 00:32, Ley Foon Tan  wrote:
> >> >> On Sat, May 19, 2018 at 10:37 PM, Simon Glass  wrote:
> >> >>> Hi Ley,
> >> >>>
> >> >>> On 18 May 2018 at 04:03, Ley Foon Tan  wrote:
> >>  Follow implementation in mALLOc(). Check GD_FLG_FULL_MALLOC_INIT flag 
> >>  and use
> >>  malloc_simple if GD_FLG_FULL_MALLOC_INIT is unset. Adjust the malloc 
> >>  bytes
> >>  to align with the requested alignment.
> >> 
> >>  The original memalign() function will access mchunkptr struct to 
> >>  adjust the
> >>  alignment if there is misalignment happen, but mchunkptr struct is 
> >>  not being
> >>  initialized before full malloc is initialized. This cause the system 
> >>  crash.
> >> 
> >>  Signed-off-by: Ley Foon Tan 
> >>  ---
> >>   common/dlmalloc.c |7 +++
> >>   1 files changed, 7 insertions(+), 0 deletions(-)
> >> 
> >>  diff --git a/common/dlmalloc.c b/common/dlmalloc.c
> >>  index b395eef..edaad29 100644
> >>  --- a/common/dlmalloc.c
> >>  +++ b/common/dlmalloc.c
> >>  @@ -1891,6 +1891,13 @@ Void_t* mEMALIGn(alignment, bytes) size_t 
> >>  alignment; size_t bytes;
> >> 
> >> if ((long)bytes < 0) return NULL;
> >> 
> >>  +#if CONFIG_VAL(SYS_MALLOC_F_LEN)
> >> >>>
> >> >>> How about:
> >> >>>
> >> >>> if (IS_ENABLED(CONFIG_SYS_MALLOC_F))
> >> >>
> >> >> I think this is the reason it uses #if CONFIG_VAL(SYS_MALLOC_F_LEN),
> >> >> same for malloc().
> >> >>
> >> >> "spl: make SPL and normal u-boot stage use independent SYS_MALLOC_F_LEN"
> >> >>
> >> >> http://git.denx.de/?p=u-boot.git;a=commit;h=f1896c45cb2f7d8dbed27e784a6459a129fc0762
> >> >
> >> > So how about
> >> >
> >> > if (CONFIG_IS_ENABLED(SYS_MALLOC_F_LEN)
> >> >
> >> > Or you could use #if if you need to
> >>
> >> Tested both #if (CONFIG_IS_ENABLED(SYS_MALLOC_F_LEN)) and if
> >> (CONFIG_IS_ENABLED(SYS_MALLOC_F_LEN)), both are not working.
> >
> > Sorry I mean
> >
> > CONFIG_IS_ENABLED(SYS_MALLOC_F)
> >
> > That tells you whether the feature is enabled in U-Boot or SPL.
>
> #if CONFIG_IS_ENABLED(SYS_MALLOC_F) if not working in SPL build.
> CONFIG_IS_ENABLED() expects config with "y" or "m", but SPL config is
> with "1".

That seems very strange, since it defeats the purpose of the macro.

Masahiro, do you know what going on here?

>  Need to use #ifdef CONFIG_SYS_MALLOC_F. Do you want to change to this?

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


Re: [U-Boot] [PATCH v2 7/7] video_display: Add Xilinx LogiCore DP TX

2018-05-25 Thread Anatolij Gustschin
Hi Mario,

Please test the patch with ./scripts/checkpatch.pl, there are warnings/
errors reported that need fixing:
 ...
 total: 1 errors, 31 warnings, 26 checks, 2746 lines checked

On Wed, 23 May 2018 14:10:47 +0200
Mario Six mario@gdsys.cc wrote:
...
> diff --git a/drivers/video/Makefile b/drivers/video/Makefile
> index cf7ad281c3b..fa4ac715fcf 100644
> --- a/drivers/video/Makefile
> +++ b/drivers/video/Makefile
> @@ -21,6 +21,7 @@ obj-$(CONFIG_VIDEO_IVYBRIDGE_IGD) += ivybridge_igd.o
> 
>  obj-$(CONFIG_ATI_RADEON_FB) += ati_radeon_fb.o videomodes.o
>  obj-$(CONFIG_ATMEL_HLCD) += atmel_hlcdfb.o
> +obj-$(CONFIG_LOGICORE_DP_TX) += logicore_dp_tx.o

Please add new driver entry sorted alphabetically. I know there are
already not sorted entries in the list here, but we shouldn't add more.

...
> diff --git a/drivers/video/logicore_dp_dpcd.h 
> b/drivers/video/logicore_dp_dpcd.h
> new file mode 100644
> index 000..68582945514
> --- /dev/null
> +++ b/drivers/video/logicore_dp_dpcd.h
...
> +struct main_stream_attributes {
> + /* Pixel clock of the stream (in Hz). */
> + u32 pixel_clock_hz;
> + /* Miscellaneous stream attributes 0 as specified by the DisplayPort
> +  * 1.2 specification.
> +  */

Please fix multi-line comment style throughout this patch, we use this style:
/*
 * multi-line
 * comment
 */

...
> +static u32 get_reg(struct udevice *dev, u32 reg)
> +{
> + struct dp_tx *dp_tx = dev_get_priv(dev);
> + u32 value = 0;
> + int res;
> +
> + // TODO error handling

please no C++ comments.

...
> +bool is_connected(struct udevice *dev)
> +{

shouldn't it be static?

...
> +
> +bool is_link_rate_valid(struct udevice *dev, u8 link_rate)
> +{

...
> +bool is_lane_count_valid(struct udevice *dev, u8 lane_count)
> +{

Are these functions supposed to be used externally? If not, please add
static. Otherwise move them to /* external API */ section.

...
> +int logicore_dp_tx_enable(struct udevice *dev, int panel_bpp,
> +   const struct display_timing *timing)
> +{

should be static?

...
> +int logicore_dp_tx_probe(struct udevice *dev)
> +{

should be static?

...
> +struct dm_display_ops logicore_dp_tx_ops = {
> + .enable = logicore_dp_tx_enable,
> +};

should be static, too.

...
> diff --git a/drivers/video/logicore_dp_tx_regif.h 
> b/drivers/video/logicore_dp_tx_regif.h
> new file mode 100644
> index 000..c4105605c9b
> --- /dev/null
> +++ b/drivers/video/logicore_dp_tx_regif.h
...
> + /* core ID */
> + REG_VERSION =   0x0F8,
> + REG_CORE_ID =   0x0FC,

here a space and tabs follow '=', please use tabs only.

...
> + REG_USER_PIXEL_WIDTH =  0x1B8,
> + REG_USER_DATA_COUNT_PER_LANE =0x1BC,

spaces around '=', checkpatch will report style issues like this.

...
> +/*
> + * PHY_STATUS_ALL_LANES_READY_MASK seems zo be missing lanes 0 and 1 in

s/zo/to  ?

Thanks,

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


[U-Boot] [PATCH] x86: enable cpu-specific functions for x86_64 target

2018-05-25 Thread Ivan Gorinov
Add __weak prefix to the following functions to allow override:
misc_init_r(), checkcpu(), print_cpuinfo().

Signed-off-by: Ivan Gorinov 
---
 arch/x86/cpu/x86_64/cpu.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/x86/cpu/x86_64/cpu.c b/arch/x86/cpu/x86_64/cpu.c
index 18b3e94..6f14efc 100644
--- a/arch/x86/cpu/x86_64/cpu.c
+++ b/arch/x86/cpu/x86_64/cpu.c
@@ -59,17 +59,17 @@ int x86_mp_init(void)
return 0;
 }
 
-int misc_init_r(void)
+__weak int misc_init_r(void)
 {
return 0;
 }
 
-int checkcpu(void)
+__weak int checkcpu(void)
 {
return 0;
 }
 
-int print_cpuinfo(void)
+__weak int print_cpuinfo(void)
 {
return 0;
 }
-- 
2.7.4

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


[U-Boot] [PATCH v1] rockchip: utilize CONFIG_DEFAULT_FDT_FILE

2018-05-25 Thread Klaus Goger
Currently the fdtfile environment variable is set to
CONFIG_DEFAULT_DEVICE_TREE which is Ñ–nternally used as U-Boot devicetree
source. The OS can use a different filename and Kconfig gives us the
ability to select a default devicetree via CONFIG_DEFAULT_FDT_FILE.
This also gives user configuring U-Boot via menuconfig the behaviour
someone would expect.

Signed-off-by: Klaus Goger 

---

 configs/chromebit_mickey_defconfig  | 1 +
 configs/chromebook_jerry_defconfig  | 1 +
 configs/chromebook_minnie_defconfig | 1 +
 configs/evb-px5_defconfig   | 1 +
 configs/evb-rk3036_defconfig| 1 +
 configs/evb-rk3128_defconfig| 1 +
 configs/evb-rk3229_defconfig| 1 +
 configs/evb-rk3288_defconfig| 1 +
 configs/evb-rk3328_defconfig| 1 +
 configs/evb-rk3399_defconfig| 1 +
 configs/evb-rv1108_defconfig| 1 +
 configs/fennec-rk3288_defconfig | 1 +
 configs/firefly-rk3288_defconfig| 1 +
 configs/firefly-rk3399_defconfig| 1 +
 configs/geekbox_defconfig   | 1 +
 configs/kylin-rk3036_defconfig  | 1 +
 configs/lion-rk3368_defconfig   | 1 +
 configs/miqi-rk3288_defconfig   | 1 +
 configs/phycore-rk3288_defconfig| 1 +
 configs/popmetal-rk3288_defconfig   | 1 +
 configs/puma-rk3399_defconfig   | 1 +
 configs/rock2_defconfig | 1 +
 configs/rock_defconfig  | 1 +
 configs/sheep-rk3368_defconfig  | 1 +
 configs/tinker-rk3288_defconfig | 1 +
 configs/vyasa-rk3288_defconfig  | 1 +
 include/configs/rk3036_common.h | 1 +
 include/configs/rk3128_common.h | 1 +
 include/configs/rk3188_common.h | 1 +
 include/configs/rk322x_common.h | 1 +
 include/configs/rk3288_common.h | 2 +-
 include/configs/rk3328_common.h | 1 +
 include/configs/rk3368_common.h | 1 +
 include/configs/rk3399_common.h | 2 +-
 34 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/configs/chromebit_mickey_defconfig 
b/configs/chromebit_mickey_defconfig
index d1728ef639..27b0dcaac4 100644
--- a/configs/chromebit_mickey_defconfig
+++ b/configs/chromebit_mickey_defconfig
@@ -11,6 +11,7 @@ CONFIG_SPL_STACK_R_ADDR=0x8
 CONFIG_DEFAULT_DEVICE_TREE="rk3288-veyron-mickey"
 CONFIG_DEBUG_UART=y
 # CONFIG_ANDROID_BOOT_IMAGE is not set
+CONFIG_DEFAULT_FDT_FILE="rk3288-veyron-mickey.dtb"
 # CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_SPL_STACK_R=y
diff --git a/configs/chromebook_jerry_defconfig 
b/configs/chromebook_jerry_defconfig
index 43d93f4637..95fe4bcb26 100644
--- a/configs/chromebook_jerry_defconfig
+++ b/configs/chromebook_jerry_defconfig
@@ -12,6 +12,7 @@ CONFIG_DEFAULT_DEVICE_TREE="rk3288-veyron-jerry"
 CONFIG_DEBUG_UART=y
 # CONFIG_ANDROID_BOOT_IMAGE is not set
 CONFIG_SILENT_CONSOLE=y
+CONFIG_DEFAULT_FDT_FILE="rk3288-veyron-jerry.dtb"
 # CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_BOARD_EARLY_INIT_F=y
diff --git a/configs/chromebook_minnie_defconfig 
b/configs/chromebook_minnie_defconfig
index 706809ca53..bc3bb292c8 100644
--- a/configs/chromebook_minnie_defconfig
+++ b/configs/chromebook_minnie_defconfig
@@ -12,6 +12,7 @@ CONFIG_DEFAULT_DEVICE_TREE="rk3288-veyron-minnie"
 CONFIG_DEBUG_UART=y
 # CONFIG_ANDROID_BOOT_IMAGE is not set
 CONFIG_SILENT_CONSOLE=y
+CONFIG_DEFAULT_FDT_FILE="rk3288-veyron-minnie.dtb"
 # CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_SPL_STACK_R=y
diff --git a/configs/evb-px5_defconfig b/configs/evb-px5_defconfig
index c03682c927..a75c3e047f 100644
--- a/configs/evb-px5_defconfig
+++ b/configs/evb-px5_defconfig
@@ -7,6 +7,7 @@ CONFIG_TARGET_EVB_PX5=y
 CONFIG_DEFAULT_DEVICE_TREE="rk3368-px5-evb"
 CONFIG_DEBUG_UART=y
 CONFIG_ANDROID_BOOT_IMAGE=y
+CONFIG_DEFAULT_FDT_FILE="rockchip/rk3368-px5-evb.dtb"
 # CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_ARCH_EARLY_INIT_R=y
diff --git a/configs/evb-rk3036_defconfig b/configs/evb-rk3036_defconfig
index 33775e8cdd..840c731032 100644
--- a/configs/evb-rk3036_defconfig
+++ b/configs/evb-rk3036_defconfig
@@ -11,6 +11,7 @@ CONFIG_DEFAULT_DEVICE_TREE="rk3036-sdk"
 CONFIG_DEBUG_UART=y
 CONFIG_SPL_SYS_MALLOC_F_LEN=0x0
 # CONFIG_ANDROID_BOOT_IMAGE is not set
+CONFIG_DEFAULT_FDT_FILE="rk3036-evb.dtb"
 # CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 # CONFIG_SPL_FRAMEWORK is not set
diff --git a/configs/evb-rk3128_defconfig b/configs/evb-rk3128_defconfig
index 796d0ec92e..f4b132faf7 100644
--- a/configs/evb-rk3128_defconfig
+++ b/configs/evb-rk3128_defconfig
@@ -5,6 +5,7 @@ CONFIG_ROCKCHIP_RK3128=y
 CONFIG_DEFAULT_DEVICE_TREE="rk3128-evb"
 CONFIG_DEBUG_UART=y
 CONFIG_FIT=y
+CONFIG_DEFAULT_FDT_FILE="rk3128-evb.dtb"
 # CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_FASTBOOT_BUF_ADDR=0x60800800
diff --git a/configs/evb-rk3229_defconfig b/configs/evb-rk3229_defconfig
index 710b0b4e1a..f6cb5fd897 100644
--- a/configs/evb-rk3229_defconfig
+++ 

[U-Boot] [PATCH] x86: use EFI calling convention for efi_main on x86_64

2018-05-25 Thread Ivan Gorinov
Save the arguments passed in %rcx and %rdx for efi_main() on x86_64;
consistently use EFI calling convention for efi_main().

Signed-off-by: Ivan Gorinov 
---
 arch/x86/lib/crt0_x86_64_efi.S | 8 
 lib/efi/efi_app.c  | 3 ++-
 lib/efi/efi_stub.c | 3 ++-
 3 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/arch/x86/lib/crt0_x86_64_efi.S b/arch/x86/lib/crt0_x86_64_efi.S
index 989799f..2d53d1b 100644
--- a/arch/x86/lib/crt0_x86_64_efi.S
+++ b/arch/x86/lib/crt0_x86_64_efi.S
@@ -16,19 +16,19 @@ _start:
subq $8, %rsp
pushq %rcx
pushq %rdx
+   pushq %rsi
+   pushq %rdi
 
 0:
lea image_base(%rip), %rdi
lea _DYNAMIC(%rip), %rsi
 
-   popq %rcx
-   popq %rdx
-   pushq %rcx
-   pushq %rdx
call _relocate
 
popq %rdi
popq %rsi
+   popq %rdx
+   popq %rcx
 
call efi_main
addq $8, %rsp
diff --git a/lib/efi/efi_app.c b/lib/efi/efi_app.c
index c828093..3eb8eeb 100644
--- a/lib/efi/efi_app.c
+++ b/lib/efi/efi_app.c
@@ -96,7 +96,8 @@ static void free_memory(struct efi_priv *priv)
  * U-Boot. If it returns, EFI will continue. Another way to get back to EFI
  * is via reset_cpu().
  */
-efi_status_t efi_main(efi_handle_t image, struct efi_system_table *sys_table)
+efi_status_t EFIAPI efi_main(efi_handle_t image,
+struct efi_system_table *sys_table)
 {
struct efi_priv local_priv, *priv = _priv;
efi_status_t ret;
diff --git a/lib/efi/efi_stub.c b/lib/efi/efi_stub.c
index 3138739..399d16b 100644
--- a/lib/efi/efi_stub.c
+++ b/lib/efi/efi_stub.c
@@ -268,7 +268,8 @@ static void add_entry_addr(struct efi_priv *priv, enum 
efi_entry_t type,
  * This function is called by our EFI start-up code. It handles running
  * U-Boot. If it returns, EFI will continue.
  */
-efi_status_t efi_main(efi_handle_t image, struct efi_system_table *sys_table)
+efi_status_t EFIAPI efi_main(efi_handle_t image,
+struct efi_system_table *sys_table)
 {
struct efi_priv local_priv, *priv = _priv;
struct efi_boot_services *boot = sys_table->boottime;
-- 
2.7.4

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


[U-Boot] [PATCH v2] efi_selftest: check for buffer overflow in efi_get_variable

2018-05-25 Thread Ivan Gorinov
Allocate a buffer on the stack instead of an array of uninitialized
pointers; check if GetVariable writes past the end of the buffer.

Signed-off-by: Ivan Gorinov 
---
 lib/efi_selftest/efi_selftest_variables.c | 18 +-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/lib/efi_selftest/efi_selftest_variables.c 
b/lib/efi_selftest/efi_selftest_variables.c
index f5e8eb6..146378f 100644
--- a/lib/efi_selftest/efi_selftest_variables.c
+++ b/lib/efi_selftest/efi_selftest_variables.c
@@ -49,7 +49,7 @@ static int execute(void)
u32 attr;
u8 v[16] = {0x5d, 0xd1, 0x5e, 0x51, 0x5a, 0x05, 0xc7, 0x0c,
0x35, 0x4a, 0xae, 0x87, 0xa5, 0xdf, 0x0f, 0x65,};
-   u8 *data[EFI_ST_MAX_DATA_SIZE];
+   u8 data[EFI_ST_MAX_DATA_SIZE];
u16 varname[EFI_ST_MAX_VARNAME_SIZE];
int flag;
efi_guid_t guid;
@@ -72,6 +72,22 @@ static int execute(void)
efi_st_error("SetVariable failed\n");
return EFI_ST_FAILURE;
}
+   data[3] = 0xff;
+   len = 3;
+   ret = runtime->get_variable(L"efi_st_var0", _vendor0,
+   , , data);
+   if (ret != EFI_SUCCESS) {
+   efi_st_error("GetVariable failed\n");
+   return EFI_ST_FAILURE;
+   }
+   if (efi_st_memcmp(data, v + 4, 3)) {
+   efi_st_error("GetVariable returned wrong value\n");
+   return EFI_ST_FAILURE;
+   }
+   if (data[3] != 0xff) {
+   efi_st_error("GetVariable wrote past the end of the buffer\n");
+   return EFI_ST_FAILURE;
+   }
/* Set variable 1 */
ret = runtime->set_variable(L"efi_st_var1", _vendor1,
EFI_VARIABLE_BOOTSERVICE_ACCESS,
-- 
2.7.4

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


[U-Boot] [PATCH v2] arm, imx6: fix NOR/OneNAND boot mode mix-up

2018-05-25 Thread Jay Carlson
From: Jay Carlson 

This patch fixes the ordering of the EMI enum to match Table 8-8 in 
the i.MX6ULL Reference Manual, and has been spot-checked in two other 
i.MX reference manuals for accuracy.

Signed-off-by: Jay Carlson 
---
 arch/arm/include/asm/mach-imx/sys_proto.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/include/asm/mach-imx/sys_proto.h 
b/arch/arm/include/asm/mach-imx/sys_proto.h
index d1d6cbc462..0acc3640f9 100644
--- a/arch/arm/include/asm/mach-imx/sys_proto.h
+++ b/arch/arm/include/asm/mach-imx/sys_proto.h
@@ -63,8 +63,8 @@ enum imx6_bmode_serial_rom {
 };
 
 enum imx6_bmode_emi {
-   IMX6_BMODE_ONENAND,
IMX6_BMODE_NOR,
+   IMX6_BMODE_ONENAND
 };
 
 enum imx6_bmode {
-- 
2.16.1.windows.4

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


[U-Boot] [PATCH v2] arm, imx6: add support for SD/MMC Manufacture Mode

2018-05-25 Thread Jay Carlson
From: Jay Carlson 

This patch adds support for booting blank i.MX6 devices in SD/MMC Manufacture
Mode: a fallback mode which the boot ROM enters when no fuses or boot mode 
pins have been set, the USB serial downloader connection is inactive, and there
is an SD card inserted into uSDHC1. The i.MX7 and i.MX8, which both have 
a Boot_SW_Info data structure which can be parsed to determine boot source, is
unaffected by this patch.

Signed-off-by: Jay Carlson 
---
 arch/arm/mach-imx/spl.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/arch/arm/mach-imx/spl.c b/arch/arm/mach-imx/spl.c
index a20b30d154..8ecae8605c 100644
--- a/arch/arm/mach-imx/spl.c
+++ b/arch/arm/mach-imx/spl.c
@@ -43,6 +43,16 @@ u32 spl_boot_device(void)
 */
if (is_usbotg_phy_active())
return BOOT_DEVICE_BOARD;
+   
+   /**
+* To support SD/MMC Manufacture Mode, we check that BOOT_MODE == 0
+* and that BT_FUSE_SEL == 0. If this was disabled via
+* blowing DISABLE_SDMMC_MFG, or if SDMMC MFG mode failed,
+* we would be in USB download mode, which the previous line would 
+* have detected.
+*/
+   if (((bmode >> 24) & 0x03) == 0x00 && (bmode >> 4) == 0x00)
+   return BOOT_DEVICE_MMC1;
 
/* BOOT_CFG1[7:4] - see IMX6DQRM Table 8-8 */
switch ((reg & IMX6_BMODE_MASK) >> IMX6_BMODE_SHIFT) {
-- 
2.16.1.windows.4

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


Re: [U-Boot] RFC: Alternative boot_jump_linux() function

2018-05-25 Thread Ramon Fried
On Fri, May 25, 2018 at 3:11 PM, Tom Rini  wrote:
> On Thu, May 17, 2018 at 07:48:45PM +0300, Ramon Fried wrote:
>> On Thu, May 17, 2018 at 5:22 PM, Tom Rini  wrote:
>> > On Thu, May 17, 2018 at 02:01:55PM +0300, Ramon Fried wrote:
>> >
>> >> Hi.
>> >> I'm currently working on snapdragon bootloader support and in the
>> >> particular case where U-boot is running in Aarch32 and the kernel is
>> >> Aarch64 the specific implementation is to jump to Linux through SCM
>> >> call.
>> >>
>> >> I try to find the best possible way to provide an alternative boot 
>> >> function.
>> >> Adding #ifdef ARCH_SNAPDRAGON will just be too specific in
>> >> arm/lib/bootm.c in my opinion and I'm thinking of introducing kind of
>> >> a callback function in gd. that if exists will jump there instead of
>> >> executing boot_jump_linux().
>> >>
>> >> What do you think ?
>> >
>> > So, to be clear, we're on an aarch64 SoC, but U-Boot has been entered in
>> > 32bit mode.  And we need to boot a 64bit Linux Kernel.  What else, if
>> > anything, is also loaded/still in residence/etc?  Can you explain the
>> > overall usecase a bit more and why we're in 32bit mode?  Thanks!
>> >
>> OK.
>> Basically, Qualcomm has the following boot flow:
>>
>> PBL -> SBL -> LK -> Linux Kernel
>>
>> PBL - 32bit Primary boot loader(ROM) loads the SBL from eMMC.
>>
>> SBL - 32bit Secondary boot loader(eMMC/UFS), proprietary closed source,
>> Initializes the DDR, starts the trustzone and can load either a 32bit
>> or a 64bit (1)
>> ELF bootloader, given that it's signed.
>>
>> LK - Little kernel, 32bit. Qualcomm maintains a downstream version, open 
>> source.
>> Loads 64bit Android boot image from eMMC and jumps to it using SMC
>> call made to Trustzone.
>>
>> This was used primarily for Android, but when Dragonboards boards came
>> out, Qualcomm and Linaro started
>> distributing 64bit Linux OE & Debian builds that were booted by LK.
>> Because U-boot is much more useful than LK, the first U-boot
>> contribution was made by Mateusz Kulikowski.
>>
>> Basically, Mateusz port is wrapping U-boot to appear as a kernel so LK
>> boots it, then it boots Linux.
>> So basically, LK did the 32 -> 64 transition.
>>
>> Now, here where I appear in the story... :)
>
> Thanks for the detailed background.
>
>> I'm trying to get rid of LK and use U-boot as the real bootloader for Linux.
>> I succeeded in that, and I have all the patches ready for submission,
>> I just need to add a dedicated boot function
>> that does the SMC call, hence this discussion.
>>
>> (1) - It implies that we can in practice just use 64bit U-boot for 
>> Snapdragon.
>> The only problem I have right now is that there's isn't any
>> open-source tool to sign the Bootloader that supports ELF64
>> executable.
>
> Is it possible to just write that tool, or update an existing tool to do
> that signature?
Yes. It should be possible.

Actually, when I did have access to qcom internal tool for doing so I
was able to run U-boot
on 64bit mode. I had problems booting the kernel, as after the boot
weird things were happening,
like other cpu weren't responding, eMMC driver wasn't working etc.
I suspect it's related to low level initialization that was lacking,
or something similar.

I ended up working on the 32bit mode because I no longer have access
to the internal tool.
I believe that in the end we will end up with a working 64bit version.
I'm just thinking that meanwhile It maybe worthwhile to also have the
32bit version.

What do you think ?
>
> --
> Tom
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] U-Boot thumb interlink patches

2018-05-25 Thread klaus . goger
Hi Tom,

> On 25.05.2018, at 14:01, Tom Rini  wrote:
> 
> Hey guys,
> 
> So, I want to be sure that I get all of the patches that we need in
> order to fix the thumb interlink problems on older ARM cores applied.
> 
> I believe that we have:
> https://patchwork.ozlabs.org/patch/905299/

Applied on todays master and tested with a Thumb build of a mxs U-Boot.

> Which could still apply, but I'm wondering if the kernel needs this as
> well then (in arch/arm/lib/copy_template.S) ?

Can’t say by just looking at it. And since I did this patches while working
on a ARM926EJS I can’t test it on that board as Linux requires ARMv7(M)
to build a Thumb2 only kernel. Will try it once I’m in front of a suitable
board again. Thanks for the hint.

> And then:
> https://patchwork.ozlabs.org/patch/909652/
> 
> has been reviewed and could be applied.  Is there anything else I'm
> missing?  Thanks!
> 
> --
> Tom



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


Re: [U-Boot] Signed FIT image boots without public key

2018-05-25 Thread Teddy Reed
I also use the verified-boot features for several boards. The behavior
you're describing is my understanding too.

But I think the expectation: "do not enforce signature checks if there
are no public keys" is OK. The expectation "enforce a signature check
if there's a signature" doesn't seem complete to me.

On Fri, May 25, 2018 at 7:46 AM, Nelson, Mark  wrote:
> Let me preface this by saying I'm using the xilinx-u-boot repo based on the 
> 2017.4 tag.
>
> I've been studying how to sign FIT images, using mkimage. I successfully 
> signed an image and verified the signature as follows:
>
> ${UBTOOLS4}/mkimage -T multi -A arm64 -O linux -f images/linux/fitimage.its 
> -K images/linux/public.dtb -k ${SEC_KEYSTORE} -r images/linux/image_secure.ub
>
> ${UBTOOLS4}/fit_check_sign -f images/linux/image_secure.ub  -k 
> images/linux/public.dtb
>
> I'm signing the configuration in the fitimage.its as follows:
> conf@1 {
> description = "Boot Linux kernel with FDT blob + 
> ramdisk";
> kernel = "kernel@0";
> fdt = "fdt@0";
> ramdisk = "ramdisk@0";
> signature@1 {
> algo = "sha256,rsa2048";
> key-name-hint = "linux_rsa_priv";
> sign-images = "kernel", "fdt", "ramdisk";
> };
> };
>
>
>
> However, when I tested booting the FIT image without providing the public key 
> in Uboots control fdt, it booted successfully. It obviously should not boot a 
> signed image without the key information. When I looked into this, I found 
> that there are two routines called to verify required signatures when 
> booting: fit_image_verify_required_sigs() and 
> fit_config_verify_required_sigs(). The latter is for verifying the signatures 
> in configuration nodes. Each of these routines begins with this logic:
>/* Work out what we need to verify */
>*no_sigsp = 1;
>sig_node = fdt_subnode_offset(sig_blob, 0, FIT_SIG_NODENAME);
>if (sig_node < 0) {
>  debug("%s: No signature node found: %s\n", __func__,
>fdt_strerror(sig_node));
>  return 0;
>}
>
> The problem is that if the fdt signature node(with the public key info) is 
> not provided, this simply returns 0 for success, and the boot process 
> continues successfully after it checks the hashes of the images. To fix the 
> problem, I simply changed fit_config_verify_required_sigs() to return 
> sig_node instead. If the signature is not there, the returned value is 
> FDT_ERR_NOTFOUND, and the boot processing ends with:
> Bad Data Hash
> ERROR: can't get kernel image!
>
> Notice that I didn't change the logic in fit_image_verify_required_sigs(), 
> because I'm not including signatures on the images, just hashes. In that 
> case, I want it to ignore the fact that it didn't find a signature node.
>
> But surely, this solution is not the correct way. I know that 
> IMAGE_ENABLE_VERIFY is used to gate access to 
> fit_image_verify_required_sigs(), but there is nothing gating access to 
> fit_config_verify_required_sigs() that I can see. I don't see any way to tell 
> u-boot which signature method it should be using to verify: images or 
> configs. It would seem that an additional preprocessor directive is needed. 
> Am I missing something?
>

The suggestion of a build-time option to enforce a signature check
regardless of the availability of public keys is interesting. A
complementary build option to choose image or config could work too.

This could enforce a failure if (A) there are no public keys available
and also (B) there are no signatures available for verifying. I am
interested in others' thoughts!

>
> [cid:image002.png@01D357D5.908FF380]
> Mark Nelson
> Principal Engineer
> CommScope
> 250 Apollo Drive, Suite 100
> Chelmsford, MA  01824
> Mobile: 352-444-0150
>
>
> ___
> U-Boot mailing list
> U-Boot@lists.denx.de
> https://lists.denx.de/listinfo/u-boot
>



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


[U-Boot] [PATCH v6 11/11] board: ti: am57xx: remove USB platform code

2018-05-25 Thread Jean-Jacques Hiblot
Signed-off-by: Jean-Jacques Hiblot 

---

Changes in v6:
- Supports DM USB for peripherals
- Removed DTS changes that disabled USB1 on DRA7 because DM_USB_DEV is
  now supported

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

 board/ti/am57xx/board.c | 87 -
 1 file changed, 87 deletions(-)

diff --git a/board/ti/am57xx/board.c b/board/ti/am57xx/board.c
index 828a36c..00b8a79 100644
--- a/board/ti/am57xx/board.c
+++ b/board/ti/am57xx/board.c
@@ -883,93 +883,6 @@ int spl_start_uboot(void)
 }
 #endif
 
-#ifdef CONFIG_USB_DWC3
-static struct dwc3_device usb_otg_ss2 = {
-   .maximum_speed = USB_SPEED_HIGH,
-   .base = DRA7_USB_OTG_SS2_BASE,
-   .tx_fifo_resize = false,
-   .index = 1,
-};
-
-static struct dwc3_omap_device usb_otg_ss2_glue = {
-   .base = (void *)DRA7_USB_OTG_SS2_GLUE_BASE,
-   .utmi_mode = DWC3_OMAP_UTMI_MODE_SW,
-   .index = 1,
-};
-
-static struct ti_usb_phy_device usb_phy2_device = {
-   .usb2_phy_power = (void *)DRA7_USB2_PHY2_POWER,
-   .index = 1,
-};
-
-int usb_gadget_handle_interrupts(int index)
-{
-   u32 status;
-
-   status = dwc3_omap_uboot_interrupt_status(index);
-   if (status)
-   dwc3_uboot_handle_interrupt(index);
-
-   return 0;
-}
-#endif /* CONFIG_USB_DWC3 */
-
-#if defined(CONFIG_USB_DWC3) || defined(CONFIG_USB_XHCI_OMAP)
-int board_usb_init(int index, enum usb_init_type init)
-{
-   enable_usb_clocks(index);
-   switch (index) {
-   case 0:
-   if (init == USB_INIT_DEVICE) {
-   printf("port %d can't be used as device\n", index);
-   disable_usb_clocks(index);
-   return -EINVAL;
-   }
-   break;
-   case 1:
-   if (init == USB_INIT_DEVICE) {
-#ifdef CONFIG_USB_DWC3
-   usb_otg_ss2.dr_mode = USB_DR_MODE_PERIPHERAL;
-   usb_otg_ss2_glue.vbus_id_status = OMAP_DWC3_VBUS_VALID;
-   ti_usb_phy_uboot_init(_phy2_device);
-   dwc3_omap_uboot_init(_otg_ss2_glue);
-   dwc3_uboot_init(_otg_ss2);
-#endif
-   } else {
-   printf("port %d can't be used as host\n", index);
-   disable_usb_clocks(index);
-   return -EINVAL;
-   }
-
-   break;
-   default:
-   printf("Invalid Controller Index\n");
-   }
-
-   return 0;
-}
-
-int board_usb_cleanup(int index, enum usb_init_type init)
-{
-#ifdef CONFIG_USB_DWC3
-   switch (index) {
-   case 0:
-   case 1:
-   if (init == USB_INIT_DEVICE) {
-   ti_usb_phy_uboot_exit(index);
-   dwc3_uboot_exit(index);
-   dwc3_omap_uboot_exit(index);
-   }
-   break;
-   default:
-   printf("Invalid Controller Index\n");
-   }
-#endif
-   disable_usb_clocks(index);
-   return 0;
-}
-#endif /* defined(CONFIG_USB_DWC3) || defined(CONFIG_USB_XHCI_OMAP) */
-
 #ifdef CONFIG_DRIVER_TI_CPSW
 
 /* Delay value to add to calibrated value */
-- 
2.7.4

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


[U-Boot] [PATCH v6 05/11] board: ti: dra7xx-evm: turn on USB clocks in late init stage

2018-05-25 Thread Jean-Jacques Hiblot
For USB ports that use the Driver Model, turn on the clocks during the
late init stage.

Signed-off-by: Jean-Jacques Hiblot 
Reviewed-by: Tom Rini 
---

Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 board/ti/dra7xx/evm.c | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/board/ti/dra7xx/evm.c b/board/ti/dra7xx/evm.c
index 6918f4d..21ceb01 100644
--- a/board/ti/dra7xx/evm.c
+++ b/board/ti/dra7xx/evm.c
@@ -646,6 +646,19 @@ int dram_init_banksize(void)
return 0;
 }
 
+#if CONFIG_IS_ENABLED(DM_USB) && CONFIG_IS_ENABLED(OF_CONTROL)
+static int device_okay(const char *path)
+{
+   int node;
+
+   node = fdt_path_offset(gd->fdt_blob, path);
+   if (node < 0)
+   return 0;
+
+   return fdtdec_get_is_enabled(gd->fdt_blob, node);
+}
+#endif
+
 int board_late_init(void)
 {
 #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
@@ -685,6 +698,12 @@ int board_late_init(void)
if (board_is_dra71x_evm())
palmas_i2c_write_u8(LP873X_I2C_SLAVE_ADDR, 0x9, 0x7);
 #endif
+#if CONFIG_IS_ENABLED(DM_USB) && CONFIG_IS_ENABLED(OF_CONTROL)
+   if (device_okay("/ocp/omap_dwc3_1@4888"))
+   enable_usb_clocks(0);
+   if (device_okay("/ocp/omap_dwc3_2@488c"))
+   enable_usb_clocks(1);
+#endif
return 0;
 }
 
-- 
2.7.4

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


[U-Boot] [PATCH v6 09/11] configs: am57xx_evm: Enable DM_USB and DM_USB_DEV

2018-05-25 Thread Jean-Jacques Hiblot
Enable DM_USB and DM_USB_DEV for AM57xx based boards.

Signed-off-by: Vignesh R 
Signed-off-by: Jean-Jacques Hiblot 


---

Changes in v6:
- AM57 configs: enable DM_USB and DM_USB_DEV. Use DWC3_GENERIC in place of
DWC3_OF_SIMPLE. disable non DM USB options

Changes in v5:
- Rebased on latest u-boot
- Removed patches that have already been merged

Changes in v4:
- Remove dependency on MISC
- Remove omap specific glue layer and use dwc3-of-simple glue layer

Changes in v3: None
Changes in v2:
- Enable DM_USB in am57xx_evm_defconfig. USB3 (super speed) is supported.

 configs/am57xx_evm_defconfig | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/configs/am57xx_evm_defconfig b/configs/am57xx_evm_defconfig
index 0e99268..7f629c0 100644
--- a/configs/am57xx_evm_defconfig
+++ b/configs/am57xx_evm_defconfig
@@ -47,6 +47,7 @@ CONFIG_DFU_MMC=y
 CONFIG_DFU_RAM=y
 CONFIG_DM_GPIO=y
 CONFIG_DM_I2C=y
+CONFIG_MISC=y
 CONFIG_DM_MMC=y
 CONFIG_MMC_OMAP_HS=y
 CONFIG_DM_SPI_FLASH=y
@@ -57,6 +58,9 @@ CONFIG_PHY_MICREL=y
 CONFIG_PHY_MICREL_KSZ90X1=y
 CONFIG_DM_ETH=y
 CONFIG_DRIVER_TI_CPSW=y
+CONFIG_PHY=y
+CONFIG_PIPE3_PHY=y
+CONFIG_OMAP_USB2_PHY=y
 CONFIG_DM_PMIC=y
 CONFIG_PMIC_PALMAS=y
 CONFIG_DM_REGULATOR=y
@@ -67,13 +71,13 @@ CONFIG_SPI=y
 CONFIG_DM_SPI=y
 CONFIG_TI_QSPI=y
 CONFIG_USB=y
+CONFIG_DM_USB=y
+CONFIG_DM_USB_DEV=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_DWC3=y
 CONFIG_USB_DWC3_GADGET=y
-CONFIG_USB_DWC3_OMAP=y
-CONFIG_USB_DWC3_PHY_OMAP=y
-CONFIG_OMAP_USB_PHY=y
+CONFIG_USB_DWC3_GENERIC=y
 CONFIG_USB_STORAGE=y
 CONFIG_USB_GADGET=y
 CONFIG_USB_GADGET_MANUFACTURER="Texas Instruments"
-- 
2.7.4

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


[U-Boot] [PATCH v6 10/11] board: ti: dra7-evm: remove USB platform code

2018-05-25 Thread Jean-Jacques Hiblot
Signed-off-by: Jean-Jacques Hiblot 
---

Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 board/ti/dra7xx/evm.c | 104 --
 1 file changed, 104 deletions(-)

diff --git a/board/ti/dra7xx/evm.c b/board/ti/dra7xx/evm.c
index 21ceb01..10fe494 100644
--- a/board/ti/dra7xx/evm.c
+++ b/board/ti/dra7xx/evm.c
@@ -915,110 +915,6 @@ const struct mmc_platform_fixups 
*platform_fixups_mmc(uint32_t addr)
 }
 #endif
 
-#ifdef CONFIG_USB_DWC3
-static struct dwc3_device usb_otg_ss1 = {
-   .maximum_speed = USB_SPEED_SUPER,
-   .base = DRA7_USB_OTG_SS1_BASE,
-   .tx_fifo_resize = false,
-   .index = 0,
-};
-
-static struct dwc3_omap_device usb_otg_ss1_glue = {
-   .base = (void *)DRA7_USB_OTG_SS1_GLUE_BASE,
-   .utmi_mode = DWC3_OMAP_UTMI_MODE_SW,
-   .index = 0,
-};
-
-static struct ti_usb_phy_device usb_phy1_device = {
-   .pll_ctrl_base = (void *)DRA7_USB3_PHY1_PLL_CTRL,
-   .usb2_phy_power = (void *)DRA7_USB2_PHY1_POWER,
-   .usb3_phy_power = (void *)DRA7_USB3_PHY1_POWER,
-   .index = 0,
-};
-
-static struct dwc3_device usb_otg_ss2 = {
-   .maximum_speed = USB_SPEED_SUPER,
-   .base = DRA7_USB_OTG_SS2_BASE,
-   .tx_fifo_resize = false,
-   .index = 1,
-};
-
-static struct dwc3_omap_device usb_otg_ss2_glue = {
-   .base = (void *)DRA7_USB_OTG_SS2_GLUE_BASE,
-   .utmi_mode = DWC3_OMAP_UTMI_MODE_SW,
-   .index = 1,
-};
-
-static struct ti_usb_phy_device usb_phy2_device = {
-   .usb2_phy_power = (void *)DRA7_USB2_PHY2_POWER,
-   .index = 1,
-};
-
-int board_usb_init(int index, enum usb_init_type init)
-{
-   enable_usb_clocks(index);
-   switch (index) {
-   case 0:
-   if (init == USB_INIT_DEVICE) {
-   usb_otg_ss1.dr_mode = USB_DR_MODE_PERIPHERAL;
-   usb_otg_ss1_glue.vbus_id_status = OMAP_DWC3_VBUS_VALID;
-   } else {
-   usb_otg_ss1.dr_mode = USB_DR_MODE_HOST;
-   usb_otg_ss1_glue.vbus_id_status = OMAP_DWC3_ID_GROUND;
-   }
-
-   ti_usb_phy_uboot_init(_phy1_device);
-   dwc3_omap_uboot_init(_otg_ss1_glue);
-   dwc3_uboot_init(_otg_ss1);
-   break;
-   case 1:
-   if (init == USB_INIT_DEVICE) {
-   usb_otg_ss2.dr_mode = USB_DR_MODE_PERIPHERAL;
-   usb_otg_ss2_glue.vbus_id_status = OMAP_DWC3_VBUS_VALID;
-   } else {
-   usb_otg_ss2.dr_mode = USB_DR_MODE_HOST;
-   usb_otg_ss2_glue.vbus_id_status = OMAP_DWC3_ID_GROUND;
-   }
-
-   ti_usb_phy_uboot_init(_phy2_device);
-   dwc3_omap_uboot_init(_otg_ss2_glue);
-   dwc3_uboot_init(_otg_ss2);
-   break;
-   default:
-   printf("Invalid Controller Index\n");
-   }
-
-   return 0;
-}
-
-int board_usb_cleanup(int index, enum usb_init_type init)
-{
-   switch (index) {
-   case 0:
-   case 1:
-   ti_usb_phy_uboot_exit(index);
-   dwc3_uboot_exit(index);
-   dwc3_omap_uboot_exit(index);
-   break;
-   default:
-   printf("Invalid Controller Index\n");
-   }
-   disable_usb_clocks(index);
-   return 0;
-}
-
-int usb_gadget_handle_interrupts(int index)
-{
-   u32 status;
-
-   status = dwc3_omap_uboot_interrupt_status(index);
-   if (status)
-   dwc3_uboot_handle_interrupt(index);
-
-   return 0;
-}
-#endif
-
 #if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_OS_BOOT)
 int spl_start_uboot(void)
 {
-- 
2.7.4

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


[U-Boot] [PATCH v6 07/11] dts: dra7x: make ocp2scp@4a080000 compatible with simple-bus

2018-05-25 Thread Jean-Jacques Hiblot
This is required when DM_USB is used, to bind the USB phys.

Signed-off-by: Jean-Jacques Hiblot 

---

Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2:
- split dts changes in 2 commits: one for binding the children of
  ocp2scp@4a08, and one to disable USB1  on all DRA7 EVMs

 arch/arm/dts/omap5-u-boot.dtsi | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/dts/omap5-u-boot.dtsi b/arch/arm/dts/omap5-u-boot.dtsi
index bf2684c..a6a7801 100644
--- a/arch/arm/dts/omap5-u-boot.dtsi
+++ b/arch/arm/dts/omap5-u-boot.dtsi
@@ -15,6 +15,10 @@
ocp {
u-boot,dm-spl;
 
+   ocp2scp@4a08 {
+   compatible = "ti,omap-ocp2scp", "simple-bus";
+   };
+
ocp2scp@4a09 {
compatible = "ti,omap-ocp2scp", "simple-bus";
};
-- 
2.7.4

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


[U-Boot] [PATCH v6 01/11] syscon: dm: Add a new method to get a regmap from DTS

2018-05-25 Thread Jean-Jacques Hiblot
syscon_regmap_lookup_by_phandle() can be used to get the regmap of a syscon
device from a reference in the DTS. It operates similarly to the linux
version of the namesake function.

Signed-off-by: Jean-Jacques Hiblot 

---

Changes in v6: None
Changes in v5: None
Changes in v4:
- Fix word missing in commit log

Changes in v3:
- in syscon_regmap_lookup_by_phandle(), use dev_dbg() instead of printf()
- added unit test for syscon_regmap_lookup_by_phandle()

Changes in v2: None

 arch/sandbox/dts/test.dts|  6 --
 drivers/core/syscon-uclass.c | 23 +++
 include/syscon.h | 13 +
 test/dm/syscon.c | 29 +
 4 files changed, 69 insertions(+), 2 deletions(-)

diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index 5a0f187..9812e30 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -327,6 +327,8 @@
 
test4 {
compatible = "denx,u-boot-probe-test";
+   first-syscon = <>;
+   second-sys-ctrl = <_system_controller>;
};
};
 
@@ -396,12 +398,12 @@
};
};
 
-   syscon@0 {
+   syscon0: syscon@0 {
compatible = "sandbox,syscon0";
reg = <0x10 4>;
};
 
-   syscon@1 {
+   another_system_controller: syscon@1 {
compatible = "sandbox,syscon1";
reg = <0x20 5
0x28 6
diff --git a/drivers/core/syscon-uclass.c b/drivers/core/syscon-uclass.c
index 303e166..661cf61 100644
--- a/drivers/core/syscon-uclass.c
+++ b/drivers/core/syscon-uclass.c
@@ -53,6 +53,29 @@ static int syscon_pre_probe(struct udevice *dev)
 #endif
 }
 
+struct regmap *syscon_regmap_lookup_by_phandle(struct udevice *dev,
+  const char *name)
+{
+   struct udevice *syscon;
+   struct regmap *r;
+   int err;
+
+   err = uclass_get_device_by_phandle(UCLASS_SYSCON, dev,
+  name, );
+   if (err) {
+   dev_dbg(dev, "unable to find syscon device\n");
+   return ERR_PTR(err);
+   }
+
+   r = syscon_get_regmap(syscon);
+   if (!r) {
+   dev_dbg(dev, "unable to find regmap\n");
+   return ERR_PTR(-ENODEV);
+   }
+
+   return r;
+}
+
 int syscon_get_by_driver_data(ulong driver_data, struct udevice **devp)
 {
struct udevice *dev;
diff --git a/include/syscon.h b/include/syscon.h
index 2aa73e5..3df96e3 100644
--- a/include/syscon.h
+++ b/include/syscon.h
@@ -74,6 +74,19 @@ int syscon_get_by_driver_data(ulong driver_data, struct 
udevice **devp);
 struct regmap *syscon_get_regmap_by_driver_data(ulong driver_data);
 
 /**
+ * syscon_regmap_lookup_by_phandle() - Look up a controller by a phandle
+ *
+ * This operates by looking up the given name in the device (device
+ * tree property) of the device using the system controller.
+ *
+ * @dev:   Device using the system controller
+ * @name:  Name of property referring to the system controller
+ * @return A pointer to the regmap if found, ERR_PTR(-ve) on error
+ */
+struct regmap *syscon_regmap_lookup_by_phandle(struct udevice *dev,
+  const char *name);
+
+/**
  * syscon_get_first_range() - get the first memory range from a syscon regmap
  *
  * @driver_data:   Driver data value to look up
diff --git a/test/dm/syscon.c b/test/dm/syscon.c
index 77c7928..b958bbe 100644
--- a/test/dm/syscon.c
+++ b/test/dm/syscon.c
@@ -6,6 +6,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -43,3 +44,31 @@ static int dm_test_syscon_by_driver_data(struct 
unit_test_state *uts)
return 0;
 }
 DM_TEST(dm_test_syscon_by_driver_data, DM_TESTF_SCAN_PDATA | 
DM_TESTF_SCAN_FDT);
+
+/* Test system controller by phandle */
+static int dm_test_syscon_by_phandle(struct unit_test_state *uts)
+{
+   struct udevice *dev;
+   struct regmap *map;
+
+   ut_assertok(uclass_get_device_by_name(UCLASS_TEST_PROBE, "test4",
+ ));
+   if (!dev || IS_ERR(dev))
+   return -ENODEV;
+
+   ut_assertok_ptr(syscon_regmap_lookup_by_phandle(dev, "first-syscon"));
+   map = syscon_regmap_lookup_by_phandle(dev, "first-syscon");
+   if (map && !IS_ERR(map))
+   ut_asserteq(1, map->range_count);
+
+   ut_assertok_ptr(syscon_regmap_lookup_by_phandle(dev,
+   "second-sys-ctrl"));
+   map = syscon_regmap_lookup_by_phandle(dev, "second-sys-controller");
+   if (map && !IS_ERR(map))
+   ut_asserteq(4, map->range_count);
+
+   ut_assert(IS_ERR(syscon_regmap_lookup_by_phandle(dev, "not-present")));
+
+   return 0;
+}
+DM_TEST(dm_test_syscon_by_phandle, DM_TESTF_SCAN_PDATA 

[U-Boot] [PATCH v6 06/11] board; ti: am57xx: turn on USB clocks

2018-05-25 Thread Jean-Jacques Hiblot
From: Vignesh R 

Enable USB clocks in late init stage to support ports under DM_USB.

Signed-off-by: Vignesh R 

Signed-off-by: Jean-Jacques Hiblot 
---

Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2:
- am57xx boards: when DM_USB is used, turn on the required USB clocks

 board/ti/am57xx/board.c | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/board/ti/am57xx/board.c b/board/ti/am57xx/board.c
index fd9d207..828a36c 100644
--- a/board/ti/am57xx/board.c
+++ b/board/ti/am57xx/board.c
@@ -675,6 +675,19 @@ out:
return;
 }
 
+#if CONFIG_IS_ENABLED(DM_USB) && CONFIG_IS_ENABLED(OF_CONTROL)
+static int device_okay(const char *path)
+{
+   int node;
+
+   node = fdt_path_offset(gd->fdt_blob, path);
+   if (node < 0)
+   return 0;
+
+   return fdtdec_get_is_enabled(gd->fdt_blob, node);
+}
+#endif
+
 int board_late_init(void)
 {
setup_board_eeprom_env();
@@ -714,6 +727,12 @@ int board_late_init(void)
board_ti_set_ethaddr(2);
 #endif
 
+#if CONFIG_IS_ENABLED(DM_USB) && CONFIG_IS_ENABLED(OF_CONTROL)
+   if (device_okay("/ocp/omap_dwc3_1@4888"))
+   enable_usb_clocks(0);
+   if (device_okay("/ocp/omap_dwc3_2@488c"))
+   enable_usb_clocks(1);
+#endif
return 0;
 }
 
-- 
2.7.4

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


[U-Boot] [PATCH v6 08/11] configs: enable DM_USB and DM_USB_DEV for all DRA7 platforms

2018-05-25 Thread Jean-Jacques Hiblot
Signed-off-by: Jean-Jacques Hiblot 

---

Changes in v6:
- DRA7 configs: enable DM_USB and DM_USB_DEV. Use DWC3_GENERIC in place of
DWC3_OF_SIMPLE. disable non DM USB options

Changes in v5: None
Changes in v4:
- Remove dependency on MISC
- Renamed the commit (DM_USB is already enabled, the only missing option
  is for the USB2 phy driver)

Changes in v3: None
Changes in v2: None

 configs/dra7xx_evm_defconfig| 8 
 configs/dra7xx_hs_evm_defconfig | 8 
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/configs/dra7xx_evm_defconfig b/configs/dra7xx_evm_defconfig
index 9b81b0c..c27b470 100644
--- a/configs/dra7xx_evm_defconfig
+++ b/configs/dra7xx_evm_defconfig
@@ -53,6 +53,7 @@ CONFIG_DFU_SF=y
 CONFIG_DM_GPIO=y
 CONFIG_PCF8575_GPIO=y
 CONFIG_DM_I2C=y
+CONFIG_MISC=y
 CONFIG_DM_MMC=y
 CONFIG_MMC_IO_VOLTAGE=y
 CONFIG_MMC_UHS_SUPPORT=y
@@ -68,6 +69,7 @@ CONFIG_DRIVER_TI_CPSW=y
 CONFIG_PHY_GIGE=y
 CONFIG_SPL_PHY=y
 CONFIG_PIPE3_PHY=y
+CONFIG_OMAP_USB2_PHY=y
 CONFIG_PMIC_PALMAS=y
 CONFIG_PMIC_LP873X=y
 CONFIG_DM_REGULATOR_FIXED=y
@@ -84,14 +86,12 @@ CONFIG_TIMER=y
 CONFIG_OMAP_TIMER=y
 CONFIG_USB=y
 CONFIG_DM_USB=y
+CONFIG_DM_USB_DEV=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
-CONFIG_USB_XHCI_DRA7XX_INDEX=1
 CONFIG_USB_DWC3=y
 CONFIG_USB_DWC3_GADGET=y
-CONFIG_USB_DWC3_OMAP=y
-CONFIG_USB_DWC3_PHY_OMAP=y
-CONFIG_OMAP_USB_PHY=y
+CONFIG_USB_DWC3_GENERIC=y
 CONFIG_USB_STORAGE=y
 CONFIG_USB_GADGET=y
 CONFIG_USB_GADGET_MANUFACTURER="Texas Instruments"
diff --git a/configs/dra7xx_hs_evm_defconfig b/configs/dra7xx_hs_evm_defconfig
index 536946e..1eca973 100644
--- a/configs/dra7xx_hs_evm_defconfig
+++ b/configs/dra7xx_hs_evm_defconfig
@@ -53,6 +53,7 @@ CONFIG_DFU_SF=y
 CONFIG_DM_GPIO=y
 CONFIG_PCF8575_GPIO=y
 CONFIG_DM_I2C=y
+CONFIG_MISC=y
 CONFIG_DM_MMC=y
 CONFIG_MMC_IO_VOLTAGE=y
 CONFIG_MMC_UHS_SUPPORT=y
@@ -67,6 +68,7 @@ CONFIG_DRIVER_TI_CPSW=y
 CONFIG_PHY_GIGE=y
 CONFIG_SPL_PHY=y
 CONFIG_PIPE3_PHY=y
+CONFIG_OMAP_USB2_PHY=y
 CONFIG_PMIC_PALMAS=y
 CONFIG_PMIC_LP873X=y
 CONFIG_DM_REGULATOR_FIXED=y
@@ -83,14 +85,12 @@ CONFIG_TIMER=y
 CONFIG_OMAP_TIMER=y
 CONFIG_USB=y
 CONFIG_DM_USB=y
+CONFIG_DM_USB_DEV=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
-CONFIG_USB_XHCI_DRA7XX_INDEX=1
 CONFIG_USB_DWC3=y
 CONFIG_USB_DWC3_GADGET=y
-CONFIG_USB_DWC3_OMAP=y
-CONFIG_USB_DWC3_PHY_OMAP=y
-CONFIG_OMAP_USB_PHY=y
+CONFIG_USB_DWC3_GENERIC=y
 CONFIG_USB_STORAGE=y
 CONFIG_USB_GADGET=y
 CONFIG_USB_GADGET_MANUFACTURER="Texas Instruments"
-- 
2.7.4

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


[U-Boot] [PATCH v6 04/11] dwc3-generic: Add support for the TI DWC3 glue

2018-05-25 Thread Jean-Jacques Hiblot
Signed-off-by: Jean-Jacques Hiblot 
---

Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 drivers/usb/dwc3/dwc3-generic.c | 86 +
 1 file changed, 86 insertions(+)

diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
index 9227501..b487f72 100644
--- a/drivers/usb/dwc3/dwc3-generic.c
+++ b/drivers/usb/dwc3/dwc3-generic.c
@@ -28,6 +28,7 @@ struct dwc3_generic_peripheral {
struct dwc3 dwc3;
struct phy *phys;
int num_phys;
+   fdt_addr_t base;
 };
 
 int dm_usb_gadget_handle_interrupts(struct udevice *dev)
@@ -119,6 +120,90 @@ struct dwc3_glue_ops {
   enum usb_dr_mode mode);
 };
 
+void dwc3_ti_select_dr_mode(struct udevice *dev, int index,
+   enum usb_dr_mode mode)
+{
+#define USBOTGSS_UTMI_OTG_STATUS   0x0084
+#define USBOTGSS_UTMI_OTG_OFFSET   0x0480
+
+/* UTMI_OTG_STATUS REGISTER */
+#define USBOTGSS_UTMI_OTG_STATUS_SW_MODE   BIT(31)
+#define USBOTGSS_UTMI_OTG_STATUS_POWERPRESENT  BIT(9)
+#define USBOTGSS_UTMI_OTG_STATUS_TXBITSTUFFENABLE BIT(8)
+#define USBOTGSS_UTMI_OTG_STATUS_IDDIG BIT(4)
+#define USBOTGSS_UTMI_OTG_STATUS_SESSEND   BIT(3)
+#define USBOTGSS_UTMI_OTG_STATUS_SESSVALID BIT(2)
+#define USBOTGSS_UTMI_OTG_STATUS_VBUSVALID BIT(1)
+enum dwc3_omap_utmi_mode {
+   DWC3_OMAP_UTMI_MODE_UNKNOWN = 0,
+   DWC3_OMAP_UTMI_MODE_HW,
+   DWC3_OMAP_UTMI_MODE_SW,
+};
+
+   u32 use_id_pin;
+   u32 host_mode;
+   u32 reg;
+   u32 utmi_mode;
+   u32 utmi_status_offset = USBOTGSS_UTMI_OTG_STATUS;
+
+   struct dwc3_glue_data *glue = dev_get_platdata(dev);
+   void *base = map_physmem(glue->regs, 0x1, MAP_NOCACHE);
+
+   if (device_is_compatible(dev, "ti,am437x-dwc3"))
+   utmi_status_offset += USBOTGSS_UTMI_OTG_OFFSET;
+
+   utmi_mode = dev_read_u32_default(dev, "utmi-mode",
+DWC3_OMAP_UTMI_MODE_UNKNOWN);
+   if (utmi_mode != DWC3_OMAP_UTMI_MODE_HW) {
+   debug("%s: OTG is not supported. defaulting to PERIPHERAL\n",
+ dev->name);
+   mode = USB_DR_MODE_PERIPHERAL;
+   }
+
+   switch (mode)  {
+   case USB_DR_MODE_PERIPHERAL:
+   use_id_pin = 0;
+   host_mode = 0;
+   break;
+   case USB_DR_MODE_HOST:
+   use_id_pin = 0;
+   host_mode = 1;
+   break;
+   case USB_DR_MODE_OTG:
+   default:
+   use_id_pin = 1;
+   host_mode = 0;
+   break;
+   }
+
+   reg = readl(base + utmi_status_offset);
+
+   reg &= ~(USBOTGSS_UTMI_OTG_STATUS_SW_MODE);
+   if (!use_id_pin)
+   reg |= USBOTGSS_UTMI_OTG_STATUS_SW_MODE;
+
+   writel(reg, base + utmi_status_offset);
+
+   reg &= ~(USBOTGSS_UTMI_OTG_STATUS_SESSEND |
+   USBOTGSS_UTMI_OTG_STATUS_VBUSVALID |
+   USBOTGSS_UTMI_OTG_STATUS_IDDIG);
+
+   reg |= USBOTGSS_UTMI_OTG_STATUS_SESSVALID |
+   USBOTGSS_UTMI_OTG_STATUS_POWERPRESENT;
+
+   if (!host_mode)
+   reg |= USBOTGSS_UTMI_OTG_STATUS_IDDIG |
+   USBOTGSS_UTMI_OTG_STATUS_VBUSVALID;
+
+   writel(reg, base + utmi_status_offset);
+
+   unmap_physmem(base, MAP_NOCACHE);
+}
+
+struct dwc3_glue_ops ti_ops = {
+   .select_dr_mode = dwc3_ti_select_dr_mode,
+};
+
 static int dwc3_glue_bind(struct udevice *parent)
 {
const void *fdt = gd->fdt_blob;
@@ -258,6 +343,7 @@ static int dwc3_glue_remove(struct udevice *dev)
 
 static const struct udevice_id dwc3_glue_ids[] = {
{ .compatible = "xlnx,zynqmp-dwc3" },
+   { .compatible = "ti,dwc3", .data = (ulong)_ops },
{ }
 };
 
-- 
2.7.4

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


[U-Boot] [PATCH v6 03/11] phy: Add a new driver for OMAP's USB2 PHYs

2018-05-25 Thread Jean-Jacques Hiblot
This drivers supports the USB2 PHY found on omap5 and dra7 SOCs.

Signed-off-by: Jean-Jacques Hiblot 

---

Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2:
- omap-usb2-phy: Implement power_on and power_off callbacks

 drivers/phy/Kconfig |   8 ++
 drivers/phy/Makefile|   1 +
 drivers/phy/omap-usb2-phy.c | 196 
 3 files changed, 205 insertions(+)
 create mode 100644 drivers/phy/omap-usb2-phy.c

diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index 8fc2295..bc35850 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -131,4 +131,12 @@ config MESON_GXL_USB_PHY
  This is the generic phy driver for the Amlogic Meson GXL
  USB2 and USB3 PHYS.
 
+config OMAP_USB2_PHY
+   bool "Support OMAP's USB2 PHY"
+   depends on PHY
+   depends on SYSCON
+   help
+ Support for the OMAP's USB2 PHY.
+ This PHY is found on OMAP devices supporting USB2.
+
 endmenu
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index ba0803c..6ebaf31 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -14,3 +14,4 @@ obj-$(CONFIG_$(SPL_)PIPE3_PHY) += ti-pipe3-phy.o
 obj-$(CONFIG_STI_USB_PHY) += sti_usb_phy.o
 obj-$(CONFIG_PHY_STM32_USBPHYC) += phy-stm32-usbphyc.o
 obj-$(CONFIG_MESON_GXL_USB_PHY) += meson-gxl-usb2.o meson-gxl-usb3.o
+obj-$(CONFIG_OMAP_USB2_PHY) += omap-usb2-phy.o
diff --git a/drivers/phy/omap-usb2-phy.c b/drivers/phy/omap-usb2-phy.c
new file mode 100644
index 000..671539b
--- /dev/null
+++ b/drivers/phy/omap-usb2-phy.c
@@ -0,0 +1,196 @@
+/*
+ * OMAP USB2 PHY LAYER
+ * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
+ * Written by Jean-Jacques Hiblot  
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define OMAP_USB2_CALIBRATE_FALSE_DISCONNECT   BIT(0)
+
+#define OMAP_DEV_PHY_PDBIT(0)
+#define OMAP_USB2_PHY_PD   BIT(28)
+
+#define USB2PHY_DISCON_BYP_LATCH   BIT(31)
+#define USB2PHY_ANA_CONFIG1(0x4c)
+
+DECLARE_GLOBAL_DATA_PTR;
+
+struct omap_usb2_phy {
+   struct regmap *pwr_regmap;
+   ulong flags;
+   void *phy_base;
+   u32 pwr_reg_offset;
+};
+
+struct usb_phy_data {
+   const char *label;
+   u8 flags;
+   u32 mask;
+   u32 power_on;
+   u32 power_off;
+};
+
+static const struct usb_phy_data omap5_usb2_data = {
+   .label = "omap5_usb2",
+   .flags = 0,
+   .mask = OMAP_DEV_PHY_PD,
+   .power_off = OMAP_DEV_PHY_PD,
+};
+
+static const struct usb_phy_data dra7x_usb2_data = {
+   .label = "dra7x_usb2",
+   .flags = OMAP_USB2_CALIBRATE_FALSE_DISCONNECT,
+   .mask = OMAP_DEV_PHY_PD,
+   .power_off = OMAP_DEV_PHY_PD,
+};
+
+static const struct usb_phy_data dra7x_usb2_phy2_data = {
+   .label = "dra7x_usb2_phy2",
+   .flags = OMAP_USB2_CALIBRATE_FALSE_DISCONNECT,
+   .mask = OMAP_USB2_PHY_PD,
+   .power_off = OMAP_USB2_PHY_PD,
+};
+
+static const struct udevice_id omap_usb2_id_table[] = {
+   {
+   .compatible = "ti,omap5-usb2",
+   .data = (ulong)_usb2_data,
+   },
+   {
+   .compatible = "ti,dra7x-usb2",
+   .data = (ulong)_usb2_data,
+   },
+   {
+   .compatible = "ti,dra7x-usb2-phy2",
+   .data = (ulong)_usb2_phy2_data,
+   },
+   {},
+};
+
+static int omap_usb_phy_power(struct phy *usb_phy, bool on)
+{
+   struct udevice *dev = usb_phy->dev;
+   const struct usb_phy_data *data;
+   const struct omap_usb2_phy *phy = dev_get_priv(dev);
+   u32 val;
+   int rc;
+
+   data = (const struct usb_phy_data *)dev_get_driver_data(dev);
+   if (!data)
+   return -EINVAL;
+
+   rc = regmap_read(phy->pwr_regmap, phy->pwr_reg_offset, );
+   if (rc)
+   return rc;
+   val &= ~data->mask;
+   if (on)
+   val |= data->power_on;
+   else
+   val |= data->power_off;
+   rc = regmap_write(phy->pwr_regmap, phy->pwr_reg_offset, val);
+   if (rc)
+   return rc;
+
+   return 0;
+}
+
+static int omap_usb2_phy_init(struct phy *usb_phy)
+{
+   struct udevice *dev = usb_phy->dev;
+   struct omap_usb2_phy *priv = dev_get_priv(dev);
+   u32 val;
+
+   if (priv->flags & OMAP_USB2_CALIBRATE_FALSE_DISCONNECT) {
+   /*
+*
+* Reduce the sensitivity of internal PHY by enabling the
+* DISCON_BYP_LATCH of the USB2PHY_ANA_CONFIG1 register. This
+* resolves issues with certain devices which can otherwise
+* be prone to false disconnects.
+*
+*/
+   val = readl(priv->phy_base + USB2PHY_ANA_CONFIG1);
+   val |= USB2PHY_DISCON_BYP_LATCH;
+

[U-Boot] [PATCH v6 02/11] phy: ti-pip3-phy: Add support for USB3 PHY

2018-05-25 Thread Jean-Jacques Hiblot
From: Vignesh R 

Add support to handle USB3 PHYs present on AM57xx/DRA7xx SoCs. This is
needed to move AM57xx to DM_USB.

Signed-off-by: Vignesh R 

Signed-off-by: Jean-Jacques Hiblot 
---

Changes in v6:
- ti-pipe3-phy: take PLL out of IDLE in pipe3_init(). The PLL may have
  been put into idle by pipe3_exit()

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2:
- Add USB3 support to ti-pipe3-phy driver

 drivers/phy/ti-pipe3-phy.c | 32 
 1 file changed, 24 insertions(+), 8 deletions(-)

diff --git a/drivers/phy/ti-pipe3-phy.c b/drivers/phy/ti-pipe3-phy.c
index b22bbaf..e7e78e3 100644
--- a/drivers/phy/ti-pipe3-phy.c
+++ b/drivers/phy/ti-pipe3-phy.c
@@ -141,7 +141,7 @@ static int omap_pipe3_dpll_program(struct omap_pipe3 *pipe3)
omap_pipe3_writel(pipe3->pll_ctrl_base, PLL_CONFIGURATION1, val);
 
val = omap_pipe3_readl(pipe3->pll_ctrl_base, PLL_CONFIGURATION2);
-   val &= ~PLL_SELFREQDCO_MASK;
+   val &= ~(PLL_SELFREQDCO_MASK | PLL_IDLE);
val |= dpll_params->freq << PLL_SELFREQDCO_SHIFT;
omap_pipe3_writel(pipe3->pll_ctrl_base, PLL_CONFIGURATION2, val);
 
@@ -265,10 +265,13 @@ static int pipe3_exit(struct phy *phy)
return -EBUSY;
}
 
-   val = readl(pipe3->pll_reset_reg);
-   writel(val | SATA_PLL_SOFT_RESET, pipe3->pll_reset_reg);
-   mdelay(1);
-   writel(val & ~SATA_PLL_SOFT_RESET, pipe3->pll_reset_reg);
+   if (pipe3->pll_reset_reg) {
+   val = readl(pipe3->pll_reset_reg);
+   writel(val | SATA_PLL_SOFT_RESET, pipe3->pll_reset_reg);
+   mdelay(1);
+   writel(val & ~SATA_PLL_SOFT_RESET, pipe3->pll_reset_reg);
+   }
+
return 0;
 }
 
@@ -331,9 +334,11 @@ static int pipe3_phy_probe(struct udevice *dev)
if (!pipe3->power_reg)
return -EINVAL;
 
-   pipe3->pll_reset_reg = get_reg(dev, "syscon-pllreset");
-   if (!pipe3->pll_reset_reg)
-   return -EINVAL;
+   if (device_is_compatible(dev, "ti,phy-pipe3-sata")) {
+   pipe3->pll_reset_reg = get_reg(dev, "syscon-pllreset");
+   if (!pipe3->pll_reset_reg)
+   return -EINVAL;
+   }
 
pipe3->dpll_map = (struct pipe3_dpll_map *)dev_get_driver_data(dev);
 
@@ -350,8 +355,19 @@ static struct pipe3_dpll_map dpll_map_sata[] = {
{ },/* Terminator */
 };
 
+static struct pipe3_dpll_map dpll_map_usb[] = {
+   {1200, {1250, 5, 4, 20, 0} },   /* 12 MHz */
+   {1680, {3125, 20, 4, 20, 0} },  /* 16.8 MHz */
+   {1920, {1172, 8, 4, 20, 65537} },   /* 19.2 MHz */
+   {2000, {1000, 7, 4, 10, 0} },   /* 20 MHz */
+   {2600, {1250, 12, 4, 20, 0} },  /* 26 MHz */
+   {3840, {3125, 47, 4, 20, 92843} },  /* 38.4 MHz */
+   { },/* Terminator */
+};
+
 static const struct udevice_id pipe3_phy_ids[] = {
{ .compatible = "ti,phy-pipe3-sata", .data = (ulong)_map_sata },
+   { .compatible = "ti,omap-usb3", .data = (ulong)_map_usb},
{ }
 };
 
-- 
2.7.4

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


[U-Boot] [PATCH] MAINTAINERS: Add board/synopsys/

2018-05-25 Thread Alexey Brodkin
As of today 'board/synopsys/' folder contains only Synopsys ARC
boards supported by the same people who support 'arch/arc'.

Signed-off-by: Alexey Brodkin 
---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 5670917b41b9..cc1331f16d6b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -60,6 +60,7 @@ S:Maintained
 L: uboot-snps-...@synopsys.com
 T: git git://git.denx.de/u-boot-arc.git
 F: arch/arc/
+F: board/synopsys/
 
 ARC HSDK CGU CLOCK
 M: Eugeniy Paltsev 
-- 
2.17.0

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


[U-Boot] [PATCH v2] board_f: Only reserve memory for U-Boot if we're going to relocate

2018-05-25 Thread Alexey Brodkin
In case of no relocation we'll just waste some space at the very end
of usable memory area. If target device has very limited amount of memory
(for example 256 kB) this loss will be pretty inconvenient.

Signed-off-by: Alexey Brodkin 
Reviewed-by: Simon Glass 
Cc: Bin Meng 
Cc: Heiko Schocher 
Cc: York Sun 
Cc: Stefan Roese 
---

Changes v1 -> v2:
 * Updated commit message as suggested by Simon

 common/board_f.c | 28 +++-
 1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/common/board_f.c b/common/board_f.c
index fa667c764bc6..e943347ce3df 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -394,19 +394,21 @@ static int reserve_trace(void)
 
 static int reserve_uboot(void)
 {
-   /*
-* reserve memory for U-Boot code, data & bss
-* round down to next 4 kB limit
-*/
-   gd->relocaddr -= gd->mon_len;
-   gd->relocaddr &= ~(4096 - 1);
-#if defined(CONFIG_E500) || defined(CONFIG_MIPS)
-   /* round down to next 64 kB limit so that IVPR stays aligned */
-   gd->relocaddr &= ~(65536 - 1);
-#endif
-
-   debug("Reserving %ldk for U-Boot at: %08lx\n", gd->mon_len >> 10,
- gd->relocaddr);
+   if (!(gd->flags & GD_FLG_SKIP_RELOC)) {
+   /*
+* reserve memory for U-Boot code, data & bss
+* round down to next 4 kB limit
+*/
+   gd->relocaddr -= gd->mon_len;
+   gd->relocaddr &= ~(4096 - 1);
+   #if defined(CONFIG_E500) || defined(CONFIG_MIPS)
+   /* round down to next 64 kB limit so that IVPR stays aligned */
+   gd->relocaddr &= ~(65536 - 1);
+   #endif
+
+   debug("Reserving %ldk for U-Boot at: %08lx\n",
+ gd->mon_len >> 10, gd->relocaddr);
+   }
 
gd->start_addr_sp = gd->relocaddr;
 
-- 
2.17.0

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


Re: [U-Boot] [PATCH] arm, imx6: add support for SD/MMC Manufacture Mode

2018-05-25 Thread Otavio Salvador
On Thu, May 24, 2018 at 6:48 PM, Jay Carlson  wrote:
> From: Jay Carlson 
>
> This patch adds support for booting blank i.MX6 devices in SD/MMC Manufacture 
> Mode: a fallback mode which the boot ROM enters when no fuses or boot mode 
> pins have been set, the USB serial downloader connection is inactive, and 
> there is an SD card inserted into uSDHC1. The i.MX7 and i.MX8, which both 
> have a Boot_SW_Info data structure which can be parsed to determine boot 
> source, is unaffected by this patch.

Please wrap lines in 80 cols and add the missing signed-off-by.

-- 
Otavio Salvador O.S. Systems
http://www.ossystems.com.brhttp://code.ossystems.com.br
Mobile: +55 (53) 9 9981-7854  Mobile: +1 (347) 903-9750
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] arm, imx6: fix NOR/OneNAND boot mode mix-up

2018-05-25 Thread Otavio Salvador
On Thu, May 24, 2018 at 7:00 PM, Jay Carlson  wrote:
> From: Jay Carlson 
>
> This patch fixes the ordering of the EMI enum to match Table 8-8 in the the 
> i.MX6ULL Reference Manual, and has been spot-checked in two other i.MX 
> reference manuals for accuracy.

Same as the other patch.

-- 
Otavio Salvador O.S. Systems
http://www.ossystems.com.brhttp://code.ossystems.com.br
Mobile: +55 (53) 9 9981-7854  Mobile: +1 (347) 903-9750
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] Signed FIT image boots without public key

2018-05-25 Thread Nelson, Mark
Let me preface this by saying I'm using the xilinx-u-boot repo based on the 
2017.4 tag.

I've been studying how to sign FIT images, using mkimage. I successfully signed 
an image and verified the signature as follows:

${UBTOOLS4}/mkimage -T multi -A arm64 -O linux -f images/linux/fitimage.its -K 
images/linux/public.dtb -k ${SEC_KEYSTORE} -r images/linux/image_secure.ub

${UBTOOLS4}/fit_check_sign -f images/linux/image_secure.ub  -k 
images/linux/public.dtb

I'm signing the configuration in the fitimage.its as follows:
conf@1 {
description = "Boot Linux kernel with FDT blob + 
ramdisk";
kernel = "kernel@0";
fdt = "fdt@0";
ramdisk = "ramdisk@0";
signature@1 {
algo = "sha256,rsa2048";
key-name-hint = "linux_rsa_priv";
sign-images = "kernel", "fdt", "ramdisk";
};
};



However, when I tested booting the FIT image without providing the public key 
in Uboots control fdt, it booted successfully. It obviously should not boot a 
signed image without the key information. When I looked into this, I found that 
there are two routines called to verify required signatures when booting: 
fit_image_verify_required_sigs() and fit_config_verify_required_sigs(). The 
latter is for verifying the signatures in configuration nodes. Each of these 
routines begins with this logic:
   /* Work out what we need to verify */
   *no_sigsp = 1;
   sig_node = fdt_subnode_offset(sig_blob, 0, FIT_SIG_NODENAME);
   if (sig_node < 0) {
 debug("%s: No signature node found: %s\n", __func__,
   fdt_strerror(sig_node));
 return 0;
   }

The problem is that if the fdt signature node(with the public key info) is not 
provided, this simply returns 0 for success, and the boot process continues 
successfully after it checks the hashes of the images. To fix the problem, I 
simply changed fit_config_verify_required_sigs() to return sig_node instead. If 
the signature is not there, the returned value is FDT_ERR_NOTFOUND, and the 
boot processing ends with:
Bad Data Hash
ERROR: can't get kernel image!

Notice that I didn't change the logic in fit_image_verify_required_sigs(), 
because I'm not including signatures on the images, just hashes. In that case, 
I want it to ignore the fact that it didn't find a signature node.

But surely, this solution is not the correct way. I know that 
IMAGE_ENABLE_VERIFY is used to gate access to fit_image_verify_required_sigs(), 
but there is nothing gating access to fit_config_verify_required_sigs() that I 
can see. I don't see any way to tell u-boot which signature method it should be 
using to verify: images or configs. It would seem that an additional 
preprocessor directive is needed. Am I missing something?


[cid:image002.png@01D357D5.908FF380]
Mark Nelson
Principal Engineer
CommScope
250 Apollo Drive, Suite 100
Chelmsford, MA  01824
Mobile: 352-444-0150

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


Re: [U-Boot] U-Boot thumb interlink patches

2018-05-25 Thread Tom Rini
On Fri, May 25, 2018 at 01:17:45PM +0100, Måns Rullgård wrote:
> Tom Rini  writes:
> 
> > And then:
> > https://patchwork.ozlabs.org/patch/909652/
> >
> > has been reviewed and could be applied.  Is there anything else I'm
> > missing?  Thanks!
> 
> I'd be more comfortable with this one if someone actually tested it.
> I can't since I don't have such hardware.

True, Chris, do you have a board you can test this on as well?  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] tests: Make test_log.py tests depend on cmd_log not log

2018-05-25 Thread Tom Rini
While the tests in this testcase are for the log subsystem they are only
able to be run if CONFIG_CMD_LOG is enabled as well as CONFIG_LOG, so
update the buildconfigspec requirement.

Signed-off-by: Tom Rini 
---
 test/py/tests/test_log.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/test/py/tests/test_log.py b/test/py/tests/test_log.py
index d1c2a36d8f25..605275b03992 100644
--- a/test/py/tests/test_log.py
+++ b/test/py/tests/test_log.py
@@ -12,7 +12,7 @@ import pytest
 
 LOGL_FIRST, LOGL_WARNING, LOGL_INFO = (0, 4, 6)
 
-@pytest.mark.buildconfigspec('log')
+@pytest.mark.buildconfigspec('cmd_log')
 def test_log(u_boot_console):
 """Test that U-Boot logging works correctly."""
 def check_log_entries(lines, mask, max_level=LOGL_INFO):
@@ -98,7 +98,7 @@ def test_log(u_boot_console):
 test8()
 test9()
 
-@pytest.mark.buildconfigspec('log')
+@pytest.mark.buildconfigspec('cmd_log')
 def test_log_format(u_boot_console):
 """Test the 'log format' and 'log rec' commands"""
 def run_with_format(fmt, expected_output):
-- 
2.7.4

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


[U-Boot] [PATCH] sandbox_flattree: Switch to TPMv2 support

2018-05-25 Thread Tom Rini
In order to have the test.py tests for TPMv2 run automatically we need
to have one of our sandbox builds use TPMv2 rather than TPMv1.  Switch
sandbox_flattree over to this style of TPM.

Cc: Simon Glass 
Signed-off-by: Tom Rini 
---
I'm tempted to switch the main sandbox target over instead as I don't
quite see where we're running the tpm1.x tests automatically.  Would
that be a better idea?
---
 configs/sandbox_flattree_defconfig | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/configs/sandbox_flattree_defconfig 
b/configs/sandbox_flattree_defconfig
index 08072e8f0312..ca67de1be8aa 100644
--- a/configs/sandbox_flattree_defconfig
+++ b/configs/sandbox_flattree_defconfig
@@ -51,8 +51,8 @@ CONFIG_CMD_BOOTSTAGE=y
 CONFIG_CMD_PMIC=y
 CONFIG_CMD_REGULATOR=y
 CONFIG_CMD_TPM=y
-CONFIG_CMD_TPM_TEST=y
 CONFIG_CMD_EXT4_WRITE=y
+CONFIG_CMD_LOG=y
 CONFIG_MAC_PARTITION=y
 CONFIG_AMIGA_PARTITION=y
 CONFIG_OF_CONTROL=y
@@ -156,7 +156,8 @@ CONFIG_SYSRESET=y
 CONFIG_TIMER=y
 CONFIG_TIMER_EARLY=y
 CONFIG_SANDBOX_TIMER=y
-CONFIG_TPM_TIS_SANDBOX=y
+# CONFIG_TPM_V1 is not set
+CONFIG_TPM_V2=y
 CONFIG_TPM2_TIS_SANDBOX=y
 CONFIG_USB=y
 CONFIG_DM_USB=y
-- 
2.7.4

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


Re: [U-Boot] U-Boot thumb interlink patches

2018-05-25 Thread Måns Rullgård
Tom Rini  writes:

> And then:
> https://patchwork.ozlabs.org/patch/909652/
>
> has been reviewed and could be applied.  Is there anything else I'm
> missing?  Thanks!

I'd be more comfortable with this one if someone actually tested it.
I can't since I don't have such hardware.

-- 
Måns Rullgård
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v3 1/2] cmd: nvedit: env import can now import only variables passed as parameters

2018-05-25 Thread Alex Kiernan
On Fri, May 25, 2018 at 12:26 PM Lothar Waßmann 
wrote:

> Hi,

> On Fri, 25 May 2018 11:52:17 +0100 Alex Kiernan wrote:
> > On Fri, May 25, 2018 at 9:38 AM Quentin Schulz <
quentin.sch...@bootlin.com>
> > wrote:
> >
> > > While the `env export` can take as parameters variables to be
exported,
> > > `env import` does not have such a mechanism of variable selection.
> >
> > > Let's add the ability to add parameters at the end of the command for
> > > variables to be imported.
> >
> > > Every env variable from the env to be imported passed by parameter to
> > > this command will override the value of the variable in the current
env.
> >
> > > If a variable exists in the current env but not in the imported env,
if
> > > this variable is passed as a parameter to env import, the variable
will
> > > be unset.
> >
> > > If a variable exists in the imported env, the variable in the current
> > > env will be set to the value of the one from the imported env.
> >
> > > All the remaining variables are left untouched.
> >
> > > As the size parameter of env import is positional but optional, let's
> > > add the possibility to use the sentinel '-' for when we don't want to
> > > give the size parameter (when the env is '\0' terminated) but we pass
a
> > > list of variables at the end of the command.
> >
> > > env import addr
> > > env import addr -
> > > env import addr size
> > > env import addr - foo1 foo2
> > > env import addr size foo1 foo2
> >
> > > are all valid.
> >
> > > env import -c addr
> > > env import -c addr -
> > > env import -c addr - foo1 foo2
> >
> > > are all invalid because they don't pass the size parameter required
for
> > > checking, while the following are valid.
> >
> > > env import addr size
> > > env import addr size foo1 foo2
> >
> > > Nothing's changed for the other parameters or the overall behaviour.
> >
> > > One of its use case could be to load a secure environment from the
> > > signed U-Boot binary and load only a handful of variables from an
> > > other, unsecure, environment without completely losing control of
> > > U-Boot.
> >
> > > Signed-off-by: Quentin Schulz 
> > > ---
> >
> > > v3:
> > >- migrate to env import addr size var... instead of env import -w
addr
> > >size so that the list of variables to load is more explicit and the
> > >behaviour of env import is closer to the one of env export,
> >
> > > v2:
> > >- use strdup instead of malloc + strcpy,
> > >- NULL-check the result of strdup,
> > >- add common exit path for freeing memory in one unique place,
> > >- store token pointer from strtok within the char** array instead
of
> > >strdup-ing token within elements of array,
> >
> > >   cmd/nvedit.c | 22 --
> > >   1 file changed, 16 insertions(+), 6 deletions(-)
> >
> > > diff --git a/cmd/nvedit.c b/cmd/nvedit.c
> > > index 11489b0..18cc4db 100644
> > > --- a/cmd/nvedit.c
> > > +++ b/cmd/nvedit.c
> > > @@ -1001,7 +1001,7 @@ sep_err:
> >
> > >   #ifdef CONFIG_CMD_IMPORTENV
> > >   /*
> > > - * env import [-d] [-t [-r] | -b | -c] addr [size]
> > > + * env import [-d] [-t [-r] | -b | -c] addr [size] [var ...]
> > >* -d: delete existing environment before importing;
> > >* otherwise overwrite / append to existing definitions
> > >* -t: assume text format; either "size" must be given or
the
> > > @@ -1015,6 +1015,11 @@ sep_err:
> > >* addr:   memory address to read from
> > >* size:   length of input data; if missing, proper '\0'
> > >* termination is mandatory
> > > + * if var is set and size should be missing (i.e. '\0'
> > > + * termination), set size to '-'
> > > + * var...  List of the names of the only variables that get
imported
> > from
> > > + * the environment at address 'addr'. Without arguments,
the
> > whole
> > > + * environment gets imported.
> > >*/
> > >   static int do_env_import(cmd_tbl_t *cmdtp, int flag,
> > >   int argc, char * const argv[])
> > > @@ -1026,6 +1031,7 @@ static int do_env_import(cmd_tbl_t *cmdtp, int
flag,
> > >  int fmt = 0;
> > >  int del = 0;
> > >  int crlf_is_lf = 0;
> > > +   int wl = 0;
> > >  size_t  size;
> >
> > >  cmd = *argv;
> > > @@ -1074,9 +1080,9 @@ static int do_env_import(cmd_tbl_t *cmdtp, int
flag,
> > >  addr = simple_strtoul(argv[0], NULL, 16);
> > >  ptr = map_sysmem(addr, 0);
> >
> > > -   if (argc == 2) {
> > > +   if (argc >= 2 && strcmp(argv[1], "-")) {
> > >  size = simple_strtoul(argv[1], NULL, 16);
> > > -   } else if (argc == 1 && chk) {
> > > +   } else if (chk) {
> > >  puts("## Error: external checksum format must pass
> > size\n");
> > >  return CMD_RET_FAILURE;
> > >  } else {
> > > @@ -1098,6 +1104,9 @@ 

Re: [U-Boot] [PATCH v3 1/2] cmd: nvedit: env import can now import only variables passed as parameters

2018-05-25 Thread Quentin Schulz
Hi Lothar and Alex,

On Fri, May 25, 2018 at 01:26:20PM +0200, Lothar Waßmann wrote:
> Hi,
> 
> On Fri, 25 May 2018 11:52:17 +0100 Alex Kiernan wrote:
> > On Fri, May 25, 2018 at 9:38 AM Quentin Schulz 
> > wrote:
> > 
> > > While the `env export` can take as parameters variables to be exported,
> > > `env import` does not have such a mechanism of variable selection.
> > 
> > > Let's add the ability to add parameters at the end of the command for
> > > variables to be imported.
> > 
> > > Every env variable from the env to be imported passed by parameter to
> > > this command will override the value of the variable in the current env.
> > 
> > > If a variable exists in the current env but not in the imported env, if
> > > this variable is passed as a parameter to env import, the variable will
> > > be unset.
> > 
> > > If a variable exists in the imported env, the variable in the current
> > > env will be set to the value of the one from the imported env.
> > 
> > > All the remaining variables are left untouched.
> > 
> > > As the size parameter of env import is positional but optional, let's
> > > add the possibility to use the sentinel '-' for when we don't want to
> > > give the size parameter (when the env is '\0' terminated) but we pass a
> > > list of variables at the end of the command.
> > 
> > > env import addr
> > > env import addr -
> > > env import addr size
> > > env import addr - foo1 foo2
> > > env import addr size foo1 foo2
> > 
> > > are all valid.
> > 
> > > env import -c addr
> > > env import -c addr -
> > > env import -c addr - foo1 foo2
> > 
> > > are all invalid because they don't pass the size parameter required for
> > > checking, while the following are valid.
> > 
> > > env import addr size
> > > env import addr size foo1 foo2
> > 
> > > Nothing's changed for the other parameters or the overall behaviour.
> > 
> > > One of its use case could be to load a secure environment from the
> > > signed U-Boot binary and load only a handful of variables from an
> > > other, unsecure, environment without completely losing control of
> > > U-Boot.
> > 
> > > Signed-off-by: Quentin Schulz 
> > > ---
> > 
> > > v3:
> > >- migrate to env import addr size var... instead of env import -w addr
> > >size so that the list of variables to load is more explicit and the
> > >behaviour of env import is closer to the one of env export,
> > 
> > > v2:
> > >- use strdup instead of malloc + strcpy,
> > >- NULL-check the result of strdup,
> > >- add common exit path for freeing memory in one unique place,
> > >- store token pointer from strtok within the char** array instead of
> > >strdup-ing token within elements of array,
> > 
> > >   cmd/nvedit.c | 22 --
> > >   1 file changed, 16 insertions(+), 6 deletions(-)
> > 
> > > diff --git a/cmd/nvedit.c b/cmd/nvedit.c
> > > index 11489b0..18cc4db 100644
> > > --- a/cmd/nvedit.c
> > > +++ b/cmd/nvedit.c
> > > @@ -1001,7 +1001,7 @@ sep_err:
> > 
> > >   #ifdef CONFIG_CMD_IMPORTENV
> > >   /*
> > > - * env import [-d] [-t [-r] | -b | -c] addr [size]
> > > + * env import [-d] [-t [-r] | -b | -c] addr [size] [var ...]
> > >* -d: delete existing environment before importing;
> > >* otherwise overwrite / append to existing definitions
> > >* -t: assume text format; either "size" must be given or the
> > > @@ -1015,6 +1015,11 @@ sep_err:
> > >* addr:   memory address to read from
> > >* size:   length of input data; if missing, proper '\0'
> > >* termination is mandatory
> > > + * if var is set and size should be missing (i.e. '\0'
> > > + * termination), set size to '-'
> > > + * var...  List of the names of the only variables that get imported
> > from
> > > + * the environment at address 'addr'. Without arguments, the
> > whole
> > > + * environment gets imported.
> > >*/
> > >   static int do_env_import(cmd_tbl_t *cmdtp, int flag,
> > >   int argc, char * const argv[])
> > > @@ -1026,6 +1031,7 @@ static int do_env_import(cmd_tbl_t *cmdtp, int flag,
> > >  int fmt = 0;
> > >  int del = 0;
> > >  int crlf_is_lf = 0;
> > > +   int wl = 0;
> > >  size_t  size;
> > 
> > >  cmd = *argv;
> > > @@ -1074,9 +1080,9 @@ static int do_env_import(cmd_tbl_t *cmdtp, int flag,
> > >  addr = simple_strtoul(argv[0], NULL, 16);
> > >  ptr = map_sysmem(addr, 0);
> > 
> > > -   if (argc == 2) {
> > > +   if (argc >= 2 && strcmp(argv[1], "-")) {
> > >  size = simple_strtoul(argv[1], NULL, 16);
> > > -   } else if (argc == 1 && chk) {
> > > +   } else if (chk) {
> > >  puts("## Error: external checksum format must pass
> > size\n");
> > >  return CMD_RET_FAILURE;
> > >  } else {
> > > @@ 

Re: [U-Boot] RFC: Alternative boot_jump_linux() function

2018-05-25 Thread Tom Rini
On Thu, May 17, 2018 at 07:48:45PM +0300, Ramon Fried wrote:
> On Thu, May 17, 2018 at 5:22 PM, Tom Rini  wrote:
> > On Thu, May 17, 2018 at 02:01:55PM +0300, Ramon Fried wrote:
> >
> >> Hi.
> >> I'm currently working on snapdragon bootloader support and in the
> >> particular case where U-boot is running in Aarch32 and the kernel is
> >> Aarch64 the specific implementation is to jump to Linux through SCM
> >> call.
> >>
> >> I try to find the best possible way to provide an alternative boot 
> >> function.
> >> Adding #ifdef ARCH_SNAPDRAGON will just be too specific in
> >> arm/lib/bootm.c in my opinion and I'm thinking of introducing kind of
> >> a callback function in gd. that if exists will jump there instead of
> >> executing boot_jump_linux().
> >>
> >> What do you think ?
> >
> > So, to be clear, we're on an aarch64 SoC, but U-Boot has been entered in
> > 32bit mode.  And we need to boot a 64bit Linux Kernel.  What else, if
> > anything, is also loaded/still in residence/etc?  Can you explain the
> > overall usecase a bit more and why we're in 32bit mode?  Thanks!
> >
> OK.
> Basically, Qualcomm has the following boot flow:
> 
> PBL -> SBL -> LK -> Linux Kernel
> 
> PBL - 32bit Primary boot loader(ROM) loads the SBL from eMMC.
> 
> SBL - 32bit Secondary boot loader(eMMC/UFS), proprietary closed source,
> Initializes the DDR, starts the trustzone and can load either a 32bit
> or a 64bit (1)
> ELF bootloader, given that it's signed.
> 
> LK - Little kernel, 32bit. Qualcomm maintains a downstream version, open 
> source.
> Loads 64bit Android boot image from eMMC and jumps to it using SMC
> call made to Trustzone.
> 
> This was used primarily for Android, but when Dragonboards boards came
> out, Qualcomm and Linaro started
> distributing 64bit Linux OE & Debian builds that were booted by LK.
> Because U-boot is much more useful than LK, the first U-boot
> contribution was made by Mateusz Kulikowski.
> 
> Basically, Mateusz port is wrapping U-boot to appear as a kernel so LK
> boots it, then it boots Linux.
> So basically, LK did the 32 -> 64 transition.
> 
> Now, here where I appear in the story... :)

Thanks for the detailed background.

> I'm trying to get rid of LK and use U-boot as the real bootloader for Linux.
> I succeeded in that, and I have all the patches ready for submission,
> I just need to add a dedicated boot function
> that does the SMC call, hence this discussion.
> 
> (1) - It implies that we can in practice just use 64bit U-boot for Snapdragon.
> The only problem I have right now is that there's isn't any
> open-source tool to sign the Bootloader that supports ELF64
> executable.

Is it possible to just write that tool, or update an existing tool to do
that signature?

-- 
Tom


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


[U-Boot] U-Boot thumb interlink patches

2018-05-25 Thread Tom Rini
Hey guys,

So, I want to be sure that I get all of the patches that we need in
order to fix the thumb interlink problems on older ARM cores applied.

I believe that we have:
https://patchwork.ozlabs.org/patch/905299/

Which could still apply, but I'm wondering if the kernel needs this as
well then (in arch/arm/lib/copy_template.S) ?

And then:
https://patchwork.ozlabs.org/patch/909652/

has been reviewed and could be applied.  Is there anything else I'm
missing?  Thanks!

-- 
Tom


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


Re: [U-Boot] [PATCH 1/2] fit: allow fit to call hardware accelerated hash

2018-05-25 Thread Tom Rini
On Thu, May 24, 2018 at 02:43:24PM +0100, Ben Whitten wrote:

> Move to calling the abstraction which allows for hardware acceleration.
> 
> Signed-off-by: Ben Whitten 
> ---
>  common/image-fit.c | 26 --
>  1 file changed, 16 insertions(+), 10 deletions(-)
> 
> diff --git a/common/image-fit.c b/common/image-fit.c
> index 8c15ed1..01ea864 100644
> --- a/common/image-fit.c
> +++ b/common/image-fit.c
> @@ -1082,19 +1082,25 @@ int fit_set_timestamp(void *fit, int noffset, time_t 
> timestamp)
>  int calculate_hash(const void *data, int data_len, const char *algo,
>   uint8_t *value, int *value_len)
>  {
> + struct hash_algo *hash_algo;
> + int ret;
> +
> + ret = hash_lookup_algo(algo, _algo);
> + if (ret)
> + return ret;
> +
>   if (IMAGE_ENABLE_CRC32 && strcmp(algo, "crc32") == 0) {
> - *((uint32_t *)value) = crc32_wd(0, data, data_len,
> - CHUNKSZ_CRC32);
> - *((uint32_t *)value) = cpu_to_uimage(*((uint32_t *)value));
> - *value_len = 4;
> + hash_algo->hash_func_ws((unsigned char *)data, data_len,
> + (unsigned char *)value, hash_algo->chunk_size);
> + *value_len = hash_algo->digest_size;
>   } else if (IMAGE_ENABLE_SHA1 && strcmp(algo, "sha1") == 0) {
> - sha1_csum_wd((unsigned char *)data, data_len,
> -  (unsigned char *)value, CHUNKSZ_SHA1);
> - *value_len = 20;
> + hash_algo->hash_func_ws((unsigned char *)data, data_len,
> + (unsigned char *)value, hash_algo->chunk_size);
> + *value_len = hash_algo->digest_size;
>   } else if (IMAGE_ENABLE_SHA256 && strcmp(algo, "sha256") == 0) {
> - sha256_csum_wd((unsigned char *)data, data_len,
> -(unsigned char *)value, CHUNKSZ_SHA256);
> - *value_len = SHA256_SUM_LEN;
> + hash_algo->hash_func_ws((unsigned char *)data, data_len,
> + (unsigned char *)value, hash_algo->chunk_size);
> + *value_len = hash_algo->digest_size;
>   } else if (IMAGE_ENABLE_MD5 && strcmp(algo, "md5") == 0) {
>   md5_wd((unsigned char *)data, data_len, value, CHUNKSZ_MD5);
>   *value_len = 16;

I think we can vastly simplify this function to just, roughly:
+   struct hash_algo *hash_algo;
+   int ret;
+
+   ret = hash_lookup_algo(algo, _algo);
+   if (ret)
+   return ret;
+
ret = hash_algo->hash_func_ws((unsigned char *)data, data_len,
(unsigned char *)value, hash_algo->chunk_size);
if (!ret)
*value_len = hash_algo->digest_size;

return ret;

But I didn't confirm that md5 will be covered, but I assume it is.

-- 
Tom


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


Re: [U-Boot] [PATCH v3 1/2] cmd: nvedit: env import can now import only variables passed as parameters

2018-05-25 Thread Lothar Waßmann
Hi,

On Fri, 25 May 2018 11:52:17 +0100 Alex Kiernan wrote:
> On Fri, May 25, 2018 at 9:38 AM Quentin Schulz 
> wrote:
> 
> > While the `env export` can take as parameters variables to be exported,
> > `env import` does not have such a mechanism of variable selection.
> 
> > Let's add the ability to add parameters at the end of the command for
> > variables to be imported.
> 
> > Every env variable from the env to be imported passed by parameter to
> > this command will override the value of the variable in the current env.
> 
> > If a variable exists in the current env but not in the imported env, if
> > this variable is passed as a parameter to env import, the variable will
> > be unset.
> 
> > If a variable exists in the imported env, the variable in the current
> > env will be set to the value of the one from the imported env.
> 
> > All the remaining variables are left untouched.
> 
> > As the size parameter of env import is positional but optional, let's
> > add the possibility to use the sentinel '-' for when we don't want to
> > give the size parameter (when the env is '\0' terminated) but we pass a
> > list of variables at the end of the command.
> 
> > env import addr
> > env import addr -
> > env import addr size
> > env import addr - foo1 foo2
> > env import addr size foo1 foo2
> 
> > are all valid.
> 
> > env import -c addr
> > env import -c addr -
> > env import -c addr - foo1 foo2
> 
> > are all invalid because they don't pass the size parameter required for
> > checking, while the following are valid.
> 
> > env import addr size
> > env import addr size foo1 foo2
> 
> > Nothing's changed for the other parameters or the overall behaviour.
> 
> > One of its use case could be to load a secure environment from the
> > signed U-Boot binary and load only a handful of variables from an
> > other, unsecure, environment without completely losing control of
> > U-Boot.
> 
> > Signed-off-by: Quentin Schulz 
> > ---
> 
> > v3:
> >- migrate to env import addr size var... instead of env import -w addr
> >size so that the list of variables to load is more explicit and the
> >behaviour of env import is closer to the one of env export,
> 
> > v2:
> >- use strdup instead of malloc + strcpy,
> >- NULL-check the result of strdup,
> >- add common exit path for freeing memory in one unique place,
> >- store token pointer from strtok within the char** array instead of
> >strdup-ing token within elements of array,
> 
> >   cmd/nvedit.c | 22 --
> >   1 file changed, 16 insertions(+), 6 deletions(-)
> 
> > diff --git a/cmd/nvedit.c b/cmd/nvedit.c
> > index 11489b0..18cc4db 100644
> > --- a/cmd/nvedit.c
> > +++ b/cmd/nvedit.c
> > @@ -1001,7 +1001,7 @@ sep_err:
> 
> >   #ifdef CONFIG_CMD_IMPORTENV
> >   /*
> > - * env import [-d] [-t [-r] | -b | -c] addr [size]
> > + * env import [-d] [-t [-r] | -b | -c] addr [size] [var ...]
> >* -d: delete existing environment before importing;
> >* otherwise overwrite / append to existing definitions
> >* -t: assume text format; either "size" must be given or the
> > @@ -1015,6 +1015,11 @@ sep_err:
> >* addr:   memory address to read from
> >* size:   length of input data; if missing, proper '\0'
> >* termination is mandatory
> > + * if var is set and size should be missing (i.e. '\0'
> > + * termination), set size to '-'
> > + * var...  List of the names of the only variables that get imported
> from
> > + * the environment at address 'addr'. Without arguments, the
> whole
> > + * environment gets imported.
> >*/
> >   static int do_env_import(cmd_tbl_t *cmdtp, int flag,
> >   int argc, char * const argv[])
> > @@ -1026,6 +1031,7 @@ static int do_env_import(cmd_tbl_t *cmdtp, int flag,
> >  int fmt = 0;
> >  int del = 0;
> >  int crlf_is_lf = 0;
> > +   int wl = 0;
> >  size_t  size;
> 
> >  cmd = *argv;
> > @@ -1074,9 +1080,9 @@ static int do_env_import(cmd_tbl_t *cmdtp, int flag,
> >  addr = simple_strtoul(argv[0], NULL, 16);
> >  ptr = map_sysmem(addr, 0);
> 
> > -   if (argc == 2) {
> > +   if (argc >= 2 && strcmp(argv[1], "-")) {
> >  size = simple_strtoul(argv[1], NULL, 16);
> > -   } else if (argc == 1 && chk) {
> > +   } else if (chk) {
> >  puts("## Error: external checksum format must pass
> size\n");
> >  return CMD_RET_FAILURE;
> >  } else {
> > @@ -1098,6 +1104,9 @@ static int do_env_import(cmd_tbl_t *cmdtp, int flag,
> >  printf("## Info: input data size = %zu = 0x%zX\n", size,
> size);
> >  }
> 
> > +   if (argc > 2)
> > +   wl = 1;
> > +
> >  if (chk) {
> >  uint32_t crc;
> >  env_t *ep 

Re: [U-Boot] [PATCH v2 1/5] drivers: Add OSD uclass

2018-05-25 Thread Mario Six
Hi Simon,

On Wed, May 23, 2018 at 6:33 PM, Simon Glass  wrote:
> On 23 May 2018 at 06:09, Mario Six  wrote:
>> Some devices offer a text-based OSD (on-screen display) that can be
>> programmatically controlled (i.e. text displayed on).
>>
>> Add a uclass to support such devices.
>>
>> Signed-off-by: Mario Six 
>>
>> ---
>>
>> v1 -> v2:
>> * Use singular case for UCLASS_VIDEO_OSD description
>> * Expanded description of video_osd_set_mem with example
>> * Replaced all left-over mentions of pixels with text
>> * Renamed x and y parameters to col and row
>> * Expaneded description of color parameter
>> * Added general description of the OSD uclass
>> * Expanded description of video_osd_info
>>
>> ---
>>  drivers/video/Kconfig|   8 ++
>>  drivers/video/Makefile   |   2 +
>>  drivers/video/video_osd-uclass.c |  46 ++
>>  include/dm/uclass-id.h   |   1 +
>>  include/video_osd.h  | 193 
>> +++
>>  5 files changed, 250 insertions(+)
>>  create mode 100644 drivers/video/video_osd-uclass.c
>>  create mode 100644 include/video_osd.h
>
> Why drop the 'u' on 'colour'?
>

# git grep color | wc -l
794

# git grep colour | wc -l
191

;-)

> Reviewed-by: Simon Glass 
>

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


Re: [U-Boot] [PATCH v2 5/5] cmd: Add osd commands

2018-05-25 Thread Mario Six
Hi Simon,

On Wed, May 23, 2018 at 6:33 PM, Simon Glass  wrote:
> Hi Mario,
>
> On 23 May 2018 at 06:09, Mario Six  wrote:
>> Add command to query information from and write text to on-screen
>> display (OSD) devices.
>>
>> Signed-off-by: Mario Six 
>>
>> ---
>>
>> v1 -> v2:
>> * Added explanation for what a OSD is
>> * Added explanation of the color parameter
>> * Moved GDSYS_LEGACY_OSD_CMDS to gdsys Kconfig
>>
>> ---
>>  board/gdsys/mpc8308/Kconfig |  11 ++
>>  cmd/Kconfig |   8 +
>>  cmd/Makefile|   1 +
>>  cmd/osd.c   | 378 
>> 
>>  4 files changed, 398 insertions(+)
>>  create mode 100644 cmd/osd.c
>
> To me it seems unfortunate that the legacy and new commands are named
> the same. I suppose that is unavoidable?
>
> I wonder if the legacy code could be moved to board/gdsys instead? It
> is out of the way then.
>

Sounds like a good idea. I'll separate the commands for v3.

> Regards,
> Simon
>

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


Re: [U-Boot] [PATCH v2 4/5] lib: Import hexdump.c from Linux

2018-05-25 Thread Mario Six
Hi Simon,

On Wed, May 23, 2018 at 6:33 PM, Simon Glass  wrote:
> Hi Mario,
>
> On 23 May 2018 at 06:09, Mario Six  wrote:
>> Especially for commands, it is useful to be able to turn a hexadecimal
>> string into its binary representation.
>>
>> Hence, import the hex_to_bin, bin2hex, and hex2bin functions from the
>> Linux kernel.
>>
>> Signed-off-by: Mario Six 
>>
>> ---
>>
>> v1 -> v2:
>> New in v2
>>
>> ---
>>  include/linux/kernel.h |   4 +
>>  lib/Makefile   |   1 +
>>  lib/hexdump.c  | 321 
>> +
>>  3 files changed, 326 insertions(+)
>>  create mode 100644 lib/hexdump.c
>
> Does Linux have any tests for this code?
>

No, there are no tests for this. I'll write some for v3, then.

> Regards,
> Simon
>

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


Re: [U-Boot] [PATCH v2 2/5] video_osd: Add ihs_video_out driver

2018-05-25 Thread Mario Six
Hi Simon,

On Wed, May 23, 2018 at 6:33 PM, Simon Glass  wrote:
> Hi Mario,
>
> On 23 May 2018 at 06:09, Mario Six  wrote:
>> Add a driver for IHS OSDs on IHS FPGAs.
>>
>> Signed-off-by: Mario Six 
>>
>> ---
>>
>> v1 -> v2:
>> * Renamed x and y parameters to col and row
>> * Removed duplicate IHS_VIDEO_OUT definition
>> * Switched error return code of ihs_video_out_set_mem to E2BIG
>> * Dropped blank lines between dev_read_u32_default calls
>> * Documented members of ihs_video_out_priv
>> * Turned printfs into debugs
>> * Don't display OSD until something has been written to it
>> * Made the code a bit more readable
>> * Added binding file
>> * Expanded documentation and help
>> * Switched to display_enable
>> * Switched to regmap usage (instead of fpgamap uclass)
>> * Renamed 'dp_tx' property to 'video_tx'
>>
>> ---
>>  .../video/osd/gdsys,ihs_video_out.txt  |  22 ++
>>  drivers/video/Kconfig  |   9 +
>>  drivers/video/Makefile |   1 +
>>  drivers/video/ihs_video_out.c  | 277 
>> +
>>  4 files changed, 309 insertions(+)
>>  create mode 100644 
>> doc/device-tree-bindings/video/osd/gdsys,ihs_video_out.txt
>>  create mode 100644 drivers/video/ihs_video_out.c
>>
>
> Reviewed-by: Simon Glass 
>
> You could perhaps s/dev_read_prop/dev_read_string/ to avoid the cast.
> Also is there a binding file for your driver's device-tree node
> somewhere?
>

Sure, no problem, and, no, there isn't. I will write a binding file for v3.

> Regards,
> Simon
>

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


Re: [U-Boot] [PATCH v2 3/5] video_osd: Add osd sandbox driver and tests

2018-05-25 Thread Mario Six
Hi Simon,

On Wed, May 23, 2018 at 6:33 PM, Simon Glass  wrote:
> Hi Mario,
>
> On 23 May 2018 at 06:09, Mario Six  wrote:
>> Add sandbox driver and tests for the new OSD uclass.
>>
>> Signed-off-by: Mario Six 
>>
>> ---
>>
>> v1 -> v2:
>> New in v2
>>
>> ---
>>  arch/sandbox/dts/test.dts  |   4 +
>>  configs/sandbox64_defconfig|   3 +
>>  configs/sandbox_defconfig  |   3 +
>>  configs/sandbox_flattree_defconfig |   3 +
>>  configs/sandbox_noblk_defconfig|   3 +
>>  configs/sandbox_spl_defconfig  |   3 +
>>  drivers/video/Kconfig  |   6 ++
>>  drivers/video/Makefile |   1 +
>>  drivers/video/sandbox_osd.c| 157 
>>  drivers/video/sandbox_osd.h|  14 +++
>>  drivers/video/video_osd-uclass.c   |   9 ++
>>  include/video_osd.h|   7 ++
>>  test/dm/Makefile   |   1 +
>>  test/dm/osd.c  | 208 
>> +
>>  14 files changed, 422 insertions(+)
>>  create mode 100644 drivers/video/sandbox_osd.c
>>  create mode 100644 drivers/video/sandbox_osd.h
>>  create mode 100644 test/dm/osd.c
>
> This looks good. But you can't add a new get_mem() operation just for sandbox.
>
> Instead, how about a back-door function that allows sandbox to get its
> information. You can call it sandbox_video_osd_get_mem(), for example,
> and just directly call it from you test code and implement it in your
> driver.
>
> There are some functions like this in arch/sandbox/include/asm/test.h
>

OK, I will do that for v3.

> Regards,
> Simon
>

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


Re: [U-Boot] [U-Boot, v3, 1/3] mmc: dwmmc: socfpga: Add reset ctrl to driver

2018-05-25 Thread Tom Rini
On Fri, May 25, 2018 at 10:45:53AM +0800, Ley Foon Tan wrote:
> On Thu, May 24, 2018 at 8:39 PM, Tom Rini  wrote:
> > On Tue, May 08, 2018 at 11:19:24AM +0800, Ley Foon Tan wrote:
> >
> >> Add code to reset all reset signals as in mmc 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 
> >> Reviewed-by: Simon Glass 
> >> ---
> >>  drivers/mmc/socfpga_dw_mmc.c |   17 +
> >>  1 files changed, 17 insertions(+), 0 deletions(-)
> >>
> >> diff --git a/drivers/mmc/socfpga_dw_mmc.c b/drivers/mmc/socfpga_dw_mmc.c
> >> index fa0e449..eb7e64e 100644
> >> --- a/drivers/mmc/socfpga_dw_mmc.c
> >> +++ b/drivers/mmc/socfpga_dw_mmc.c
> >> @@ -13,6 +13,7 @@
> >>  #include 
> >>  #include 
> >>  #include 
> >> +#include 
> >>
> >>  DECLARE_GLOBAL_DATA_PTR;
> >>
> >> @@ -33,6 +34,20 @@ struct dwmci_socfpga_priv_data {
> >>   unsigned intsmplsel;
> >>  };
> >>
> >> +static void socfpga_dwmci_reset(struct udevice *dev)
> >> +{
> >> + struct reset_ctl_bulk reset_bulk;
> >> + int ret;
> >> +
> >> + ret = reset_get_bulk(dev, _bulk);
> >> + if (ret) {
> >> + dev_warn(dev, "Can't get reset: %d\n", ret);
> >> + return;
> >> + }
> >> +
> >> + reset_deassert_bulk(_bulk);
> >> +}
> >
> > The driver doesn't depend on DM_RESET and this code hunk doesn't either
> > so it fails to build on a number of platforms.  This type of comment
> > applies to the whole series, and may be fixed differently in different
> > cases (it might be OK to enforce DM_RESET for this driver, but not for
> > the ns16550 driver).
> >
> > --
> > Tom
> >
> include/reset.h has the DM_RESET wrapper, so it will not cause the
> compilation error if the CONFIG_DM_RESET is disabled.
> 
> I have tried compile the uboot with CONFIG_DM_RESET disabled,
> compilation is fine.

This whole series causes a good percent of the world to fail to link, so
something is off about the wrappers or use of them.  See:
https://travis-ci.org/trini/u-boot/jobs/382783645

-- 
Tom


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


Re: [U-Boot] [PATCH v3 1/2] cmd: nvedit: env import can now import only variables passed as parameters

2018-05-25 Thread Alex Kiernan
On Fri, May 25, 2018 at 9:38 AM Quentin Schulz 
wrote:

> While the `env export` can take as parameters variables to be exported,
> `env import` does not have such a mechanism of variable selection.

> Let's add the ability to add parameters at the end of the command for
> variables to be imported.

> Every env variable from the env to be imported passed by parameter to
> this command will override the value of the variable in the current env.

> If a variable exists in the current env but not in the imported env, if
> this variable is passed as a parameter to env import, the variable will
> be unset.

> If a variable exists in the imported env, the variable in the current
> env will be set to the value of the one from the imported env.

> All the remaining variables are left untouched.

> As the size parameter of env import is positional but optional, let's
> add the possibility to use the sentinel '-' for when we don't want to
> give the size parameter (when the env is '\0' terminated) but we pass a
> list of variables at the end of the command.

> env import addr
> env import addr -
> env import addr size
> env import addr - foo1 foo2
> env import addr size foo1 foo2

> are all valid.

> env import -c addr
> env import -c addr -
> env import -c addr - foo1 foo2

> are all invalid because they don't pass the size parameter required for
> checking, while the following are valid.

> env import addr size
> env import addr size foo1 foo2

> Nothing's changed for the other parameters or the overall behaviour.

> One of its use case could be to load a secure environment from the
> signed U-Boot binary and load only a handful of variables from an
> other, unsecure, environment without completely losing control of
> U-Boot.

> Signed-off-by: Quentin Schulz 
> ---

> v3:
>- migrate to env import addr size var... instead of env import -w addr
>size so that the list of variables to load is more explicit and the
>behaviour of env import is closer to the one of env export,

> v2:
>- use strdup instead of malloc + strcpy,
>- NULL-check the result of strdup,
>- add common exit path for freeing memory in one unique place,
>- store token pointer from strtok within the char** array instead of
>strdup-ing token within elements of array,

>   cmd/nvedit.c | 22 --
>   1 file changed, 16 insertions(+), 6 deletions(-)

> diff --git a/cmd/nvedit.c b/cmd/nvedit.c
> index 11489b0..18cc4db 100644
> --- a/cmd/nvedit.c
> +++ b/cmd/nvedit.c
> @@ -1001,7 +1001,7 @@ sep_err:

>   #ifdef CONFIG_CMD_IMPORTENV
>   /*
> - * env import [-d] [-t [-r] | -b | -c] addr [size]
> + * env import [-d] [-t [-r] | -b | -c] addr [size] [var ...]
>* -d: delete existing environment before importing;
>* otherwise overwrite / append to existing definitions
>* -t: assume text format; either "size" must be given or the
> @@ -1015,6 +1015,11 @@ sep_err:
>* addr:   memory address to read from
>* size:   length of input data; if missing, proper '\0'
>* termination is mandatory
> + * if var is set and size should be missing (i.e. '\0'
> + * termination), set size to '-'
> + * var...  List of the names of the only variables that get imported
from
> + * the environment at address 'addr'. Without arguments, the
whole
> + * environment gets imported.
>*/
>   static int do_env_import(cmd_tbl_t *cmdtp, int flag,
>   int argc, char * const argv[])
> @@ -1026,6 +1031,7 @@ static int do_env_import(cmd_tbl_t *cmdtp, int flag,
>  int fmt = 0;
>  int del = 0;
>  int crlf_is_lf = 0;
> +   int wl = 0;
>  size_t  size;

>  cmd = *argv;
> @@ -1074,9 +1080,9 @@ static int do_env_import(cmd_tbl_t *cmdtp, int flag,
>  addr = simple_strtoul(argv[0], NULL, 16);
>  ptr = map_sysmem(addr, 0);

> -   if (argc == 2) {
> +   if (argc >= 2 && strcmp(argv[1], "-")) {
>  size = simple_strtoul(argv[1], NULL, 16);
> -   } else if (argc == 1 && chk) {
> +   } else if (chk) {
>  puts("## Error: external checksum format must pass
size\n");
>  return CMD_RET_FAILURE;
>  } else {
> @@ -1098,6 +1104,9 @@ static int do_env_import(cmd_tbl_t *cmdtp, int flag,
>  printf("## Info: input data size = %zu = 0x%zX\n", size,
size);
>  }

> +   if (argc > 2)
> +   wl = 1;
> +
>  if (chk) {
>  uint32_t crc;
>  env_t *ep = (env_t *)ptr;
> @@ -1112,9 +1121,10 @@ static int do_env_import(cmd_tbl_t *cmdtp, int
flag,
>  ptr = (char *)ep->data;
>  }

> -   if (himport_r(_htab, ptr, size, sep, del ? 0 : H_NOCLEAR,
> -   crlf_is_lf, 0, NULL) == 0) {
> +   if (!himport_r(_htab, ptr, 

[U-Boot] [PATCH v2 5/6] cmd: iotrace: add dump trace command

2018-05-25 Thread Ramon Fried
Add dump trace command which dump all trace
buffer content in a much more readable fashion
than md.

Signed-off-by: Ramon Fried 
---
v2: fixed printf zero field width.

 cmd/iotrace.c | 36 +++-
 1 file changed, 35 insertions(+), 1 deletion(-)

diff --git a/cmd/iotrace.c b/cmd/iotrace.c
index 601b8c8e32..f50a3c3a1a 100644
--- a/cmd/iotrace.c
+++ b/cmd/iotrace.c
@@ -24,6 +24,36 @@ static void do_print_stats(void)
printf("CRC32:  %08lx\n", (ulong)iotrace_get_checksum());
 }
 
+static void do_print_trace(void)
+{
+   ulong start, size, offset, count;
+
+   struct iotrace_record *cur_record;
+
+   iotrace_get_buffer(, , , );
+
+   if (!start || !size || !count)
+   return;
+
+   printf("Timestamp  Value  Address\n");
+
+   cur_record = (struct iotrace_record *)start;
+   for (int i = 0; i < count; i++) {
+   if (cur_record->flags & IOT_WRITE)
+   printf("%08llu: 0x%08lx --> 0x%08lx\n",
+  cur_record->timestamp,
+   cur_record->value,
+   cur_record->addr);
+   else
+   printf("%08llu: 0x%08lx <-- 0x%08lx\n",
+  cur_record->timestamp,
+   cur_record->value,
+   cur_record->addr);
+
+   cur_record++;
+   }
+}
+
 static int do_set_buffer(int argc, char * const argv[])
 {
ulong addr = 0, size = 0;
@@ -76,6 +106,9 @@ int do_iotrace(cmd_tbl_t *cmdtp, int flag, int argc, char * 
const argv[])
case 's':
do_print_stats();
break;
+   case 'd':
+   do_print_trace();
+   break;
default:
return CMD_RET_USAGE;
}
@@ -90,5 +123,6 @@ U_BOOT_CMD(
"iotrace buffer- set iotrace buffer\n"
"iotrace limit - set iotrace region limit\n"
"iotrace pause- pause tracing\n"
-   "iotrace resume   - resume tracing"
+   "iotrace resume   - resume tracing\n"
+   "iotrace dump - dump iotrace buffer"
 );
-- 
2.17.0

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


[U-Boot] [PATCH 4/6] iotrace: move record definitons to header file

2018-05-25 Thread Ramon Fried
The header definitions are needed for reading
record information in cmd/iotrace.c

Signed-off-by: Ramon Fried 
---
 common/iotrace.c  | 27 ---
 include/iotrace.h | 28 
 2 files changed, 28 insertions(+), 27 deletions(-)

diff --git a/common/iotrace.c b/common/iotrace.c
index 3530688ab1..74408a5dbb 100644
--- a/common/iotrace.c
+++ b/common/iotrace.c
@@ -11,33 +11,6 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-/* Support up to the machine word length for now */
-typedef ulong iovalue_t;
-
-enum iotrace_flags {
-   IOT_8 = 0,
-   IOT_16,
-   IOT_32,
-
-   IOT_READ = 0 << 3,
-   IOT_WRITE = 1 << 3,
-};
-
-/**
- * struct iotrace_record - Holds a single I/O trace record
- *
- * @flags: I/O access type
- * @timestamp: Timestamp of access
- * @addr: Address of access
- * @value: Value written or read
- */
-struct iotrace_record {
-   enum iotrace_flags flags;
-   u64 timestamp;
-   phys_addr_t addr;
-   iovalue_t value;
-};
-
 /**
  * struct iotrace - current trace status and checksum
  *
diff --git a/include/iotrace.h b/include/iotrace.h
index 1efb117343..b6e006ced0 100644
--- a/include/iotrace.h
+++ b/include/iotrace.h
@@ -7,6 +7,34 @@
 #define __IOTRACE_H
 
 #include 
+#include 
+
+/* Support up to the machine word length for now */
+typedef ulong iovalue_t;
+
+enum iotrace_flags {
+   IOT_8 = 0,
+   IOT_16,
+   IOT_32,
+
+   IOT_READ = 0 << 3,
+   IOT_WRITE = 1 << 3,
+};
+
+/**
+ * struct iotrace_record - Holds a single I/O trace record
+ *
+ * @flags: I/O access type
+ * @timestamp: Timestamp of access
+ * @addr: Address of access
+ * @value: Value written or read
+ */
+struct iotrace_record {
+   enum iotrace_flags flags;
+   u64 timestamp;
+   phys_addr_t addr;
+   iovalue_t value;
+};
 
 /*
  * This file is designed to be included in arch//include/asm/io.h.
-- 
2.17.0

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


[U-Boot] [PATCH 6/6] common: iotrace: fix behaviour when buffer is full

2018-05-25 Thread Ramon Fried
When the buffer is full, there supposed to be no more
writes, the code however misses the else statement and
subsequently writes to arbitrary pointer location and increases
the offset.
This patch fixes that by returning immediately.

Signed-off-by: Ramon Fried 
---
 common/iotrace.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/common/iotrace.c b/common/iotrace.c
index 74408a5dbb..5f06d2b250 100644
--- a/common/iotrace.c
+++ b/common/iotrace.c
@@ -55,6 +55,8 @@ static void add_record(int flags, const void *ptr, ulong 
value)
rec = (struct iotrace_record *)map_sysmem(
iotrace.start + iotrace.offset,
sizeof(value));
+   } else {
+   return;
}
 
rec->timestamp = get_ticks();
-- 
2.17.0

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


[U-Boot] [PATCH 1/6] cmd: iotrace: add set region command

2018-05-25 Thread Ramon Fried
Signed-off-by: Ramon Fried 
---
 cmd/iotrace.c | 22 ++
 1 file changed, 22 insertions(+)

diff --git a/cmd/iotrace.c b/cmd/iotrace.c
index e496787e0d..601b8c8e32 100644
--- a/cmd/iotrace.c
+++ b/cmd/iotrace.c
@@ -15,6 +15,9 @@ static void do_print_stats(void)
iotrace_get_buffer(, , , );
printf("Start:  %08lx\n", start);
printf("Size:   %08lx\n", size);
+   iotrace_get_region(, );
+   printf("Region: %08lx\n", start);
+   printf("Size:   %08lx\n", size);
printf("Offset: %08lx\n", offset);
printf("Output: %08lx\n", start + offset);
printf("Count:  %08lx\n", count);
@@ -37,6 +40,22 @@ static int do_set_buffer(int argc, char * const argv[])
return 0;
 }
 
+static int do_set_region(int argc, char * const argv[])
+{
+   ulong addr = 0, size = 0;
+
+   if (argc == 2) {
+   addr = simple_strtoul(*argv++, NULL, 16);
+   size = simple_strtoul(*argv++, NULL, 16);
+   } else if (argc != 0) {
+   return CMD_RET_USAGE;
+   }
+
+   iotrace_set_region(addr, size);
+
+   return 0;
+}
+
 int do_iotrace(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
const char *cmd = argc < 2 ? NULL : argv[1];
@@ -46,6 +65,8 @@ int do_iotrace(cmd_tbl_t *cmdtp, int flag, int argc, char * 
const argv[])
switch (*cmd) {
case 'b':
return do_set_buffer(argc - 2, argv + 2);
+   case 'l':
+   return do_set_region(argc - 2, argv + 2);
case 'p':
iotrace_set_enabled(0);
break;
@@ -67,6 +88,7 @@ U_BOOT_CMD(
"iotrace utility commands",
"stats- display iotrace stats\n"
"iotrace buffer- set iotrace buffer\n"
+   "iotrace limit - set iotrace region limit\n"
"iotrace pause- pause tracing\n"
"iotrace resume   - resume tracing"
 );
-- 
2.17.0

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


[U-Boot] [PATCH 2/6] iotrace: add IO region limit

2018-05-25 Thread Ramon Fried
When dealing with a lot of IO regions, sometimes
it makes sense only to trace a specific one.
This patch adds support for region limits.
If region is not set, the iotrace works the same as it was.
If region is set, the iotrace only logs io operation that falls
in the defined region.

Signed-off-by: Ramon Fried 
---
 common/iotrace.c  | 27 +++
 include/iotrace.h | 24 
 2 files changed, 51 insertions(+)

diff --git a/common/iotrace.c b/common/iotrace.c
index b16b0d612d..f39885663a 100644
--- a/common/iotrace.c
+++ b/common/iotrace.c
@@ -42,6 +42,8 @@ struct iotrace_record {
  * @start: Start address of iotrace buffer
  * @size:  Size of iotrace buffer in bytes
  * @offset:Current write offset into iotrace buffer
+ * @region_start: Address of IO region to trace
+ * @region_size: Size of region to trace. if 0 will trace all address space
  * @crc32: Current value of CRC chceksum of trace records
  * @enabled:   true if enabled, false if disabled
  */
@@ -49,6 +51,8 @@ static struct iotrace {
ulong start;
ulong size;
ulong offset;
+   ulong region_start;
+   ulong region_size;
u32 crc32;
bool enabled;
 } iotrace;
@@ -66,6 +70,11 @@ static void add_record(int flags, const void *ptr, ulong 
value)
if (!(gd->flags & GD_FLG_RELOC) || !iotrace.enabled)
return;
 
+   if (iotrace.region_size)
+   if ((ulong)ptr < iotrace.region_start ||
+   (ulong)ptr > iotrace.region_start + iotrace.region_size)
+   return;
+
/* Store it if there is room */
if (iotrace.offset + sizeof(*rec) < iotrace.size) {
rec = (struct iotrace_record *)map_sysmem(
@@ -142,6 +151,24 @@ u32 iotrace_get_checksum(void)
return iotrace.crc32;
 }
 
+void iotrace_set_region(ulong start, ulong size)
+{
+   iotrace.region_start = start;
+   iotrace.region_size = size;
+}
+
+void iotrace_reset_region(void)
+{
+   iotrace.region_start = 0;
+   iotrace.region_size = 0;
+}
+
+void iotrace_get_region(ulong *start, ulong *size)
+{
+   *start = iotrace.region_start;
+   *size = iotrace.region_size;
+}
+
 void iotrace_set_enabled(int enable)
 {
iotrace.enabled = enable;
diff --git a/include/iotrace.h b/include/iotrace.h
index 9fe5733f87..1efb117343 100644
--- a/include/iotrace.h
+++ b/include/iotrace.h
@@ -58,6 +58,30 @@ void iotrace_reset_checksum(void);
  */
 u32 iotrace_get_checksum(void);
 
+/**
+ * iotrace_set_region() - Set whether iotrace is limited to a specific
+ * io region.
+ *
+ * Defines the address and size of the limited region.
+ *
+ * @start: address of the beginning of the region
+ * @size: size of the region in bytes.
+ */
+void iotrace_set_region(ulong start, ulong size);
+
+/**
+ * iotrace_reset_region() - Reset the region limit
+ */
+void iotrace_reset_region(void);
+
+/**
+ * iotrace_get_region() - Get region information
+ *
+ * @start: Returns start address of region
+ * @size: Returns size of region in bytes
+ */
+void iotrace_get_region(ulong *start, ulong *size);
+
 /**
  * iotrace_set_enabled() - Set whether iotracing is enabled or not
  *
-- 
2.17.0

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


[U-Boot] [PATCH 3/6] common: iotrace: add timestamp to iotrace records

2018-05-25 Thread Ramon Fried
Add timestamp to each iotrace record to aid in debugging
of IO timing access bugs.

Signed-off-by: Ramon Fried 
---
 common/iotrace.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/common/iotrace.c b/common/iotrace.c
index f39885663a..3530688ab1 100644
--- a/common/iotrace.c
+++ b/common/iotrace.c
@@ -27,11 +27,13 @@ enum iotrace_flags {
  * struct iotrace_record - Holds a single I/O trace record
  *
  * @flags: I/O access type
+ * @timestamp: Timestamp of access
  * @addr: Address of access
  * @value: Value written or read
  */
 struct iotrace_record {
enum iotrace_flags flags;
+   u64 timestamp;
phys_addr_t addr;
iovalue_t value;
 };
@@ -82,6 +84,7 @@ static void add_record(int flags, const void *ptr, ulong 
value)
sizeof(value));
}
 
+   rec->timestamp = get_ticks();
rec->flags = flags;
rec->addr = map_to_sysmem(ptr);
rec->value = value;
-- 
2.17.0

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


[U-Boot] [PATCH v2 0/6] Iotrace improvements

2018-05-25 Thread Ramon Fried
These set of patches add few improvements to iotrace.
* Region limiting - allows setting an address and size where only
io operations that falls into that 
address are
logged.
* Timestamping - Timestamp every iotrace record with current timestamp
* dumping - iotrace dump command for dumping all records from buffer
in a readable fashion.

In terms of backwards compatibility, the timestamp is not backward
compatible as it changes the iotrace record. so if one developed an
offline parsing tool it will be broken.
I though of adding #ifdef specific for that, but eventually I didn't.

v2:
* fixed printf format
* added a fix when the buffer is full

Ramon Fried (6):
  cmd: iotrace: add set region command
  iotrace: add IO region limit
  common: iotrace: add timestamp to iotrace records
  iotrace: move record definitons to header file
  cmd: iotrace: add dump trace command
  common: iotrace: fix behaviour when buffer is full

 cmd/iotrace.c | 58 ++-
 common/iotrace.c  | 55 
 include/iotrace.h | 52 ++
 3 files changed, 139 insertions(+), 26 deletions(-)

-- 
2.17.0

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


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

2018-05-25 Thread Alex Kiernan
On Fri, May 25, 2018 at 3:42 AM Simon Glass  wrote:

> Hi Alex,

> On 24 May 2018 at 07:29, Alex Kiernan  wrote:
> >
> > Introduce CONFIG_IMAGE_SPARSE and CONFIG_CMD_MMC_SWRITE so the "mmc
> > swrite" command is separated from the fastboot code.
> >
> > Move image-sparse from common to lib so it's clear it's library code.
> >
> > Rename CONFIG_FASTBOOT_FLASH_FILLBUF_SIZE to
CONFIG_IMAGE_SPARSE_FILLBUF_SIZE
> > and migrate it to Kconfig.
> >
> > Signed-off-by: Alex Kiernan 
> > Acked-by: Jassi Brar 
> > ---
> >
> > Changes in v7: None
> > Changes in v6: None
> > Changes in v5:
> > - rename CONFIG_FASTBOOT_FLASH_FILLBUF_SIZE to
CONFIG_IMAGE_SPARSE_FILLBUF_SIZE
> >   and migrate it to Kconfig.
> >
> > Changes in v4:
> > - new
> >
> > Changes in v3: None
> > Changes in v2: None
> >
> >  cmd/Kconfig|  8 
> >  cmd/mmc.c  | 12 ++--
> >  common/Makefile|  1 -
> >  drivers/fastboot/Kconfig   |  1 +
> >  lib/Kconfig| 11 +++
> >  lib/Makefile   |  1 +
> >  {common => lib}/image-sparse.c |  6 +-
> >  scripts/config_whitelist.txt   |  1 -
> >  8 files changed, 28 insertions(+), 13 deletions(-)
> >  rename {common => lib}/image-sparse.c (97%)

> Reviewed-by: Simon Glass 

> I'm not 100% sure about moving image-sparce to lib/ but I suppose it is
OK.


My reasoning was it's really a compression mechanism, and thats where we
have the other compression stuff (I should probably have written this in
the commit message).

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


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

2018-05-25 Thread Simon Glass
Hi Alex,

On 24 May 2018 at 07:29, Alex Kiernan  wrote:
>
> Introduce CONFIG_IMAGE_SPARSE and CONFIG_CMD_MMC_SWRITE so the "mmc
> swrite" command is separated from the fastboot code.
>
> Move image-sparse from common to lib so it's clear it's library code.
>
> Rename CONFIG_FASTBOOT_FLASH_FILLBUF_SIZE to CONFIG_IMAGE_SPARSE_FILLBUF_SIZE
> and migrate it to Kconfig.
>
> Signed-off-by: Alex Kiernan 
> Acked-by: Jassi Brar 
> ---
>
> Changes in v7: None
> Changes in v6: None
> Changes in v5:
> - rename CONFIG_FASTBOOT_FLASH_FILLBUF_SIZE to 
> CONFIG_IMAGE_SPARSE_FILLBUF_SIZE
>   and migrate it to Kconfig.
>
> Changes in v4:
> - new
>
> Changes in v3: None
> Changes in v2: None
>
>  cmd/Kconfig|  8 
>  cmd/mmc.c  | 12 ++--
>  common/Makefile|  1 -
>  drivers/fastboot/Kconfig   |  1 +
>  lib/Kconfig| 11 +++
>  lib/Makefile   |  1 +
>  {common => lib}/image-sparse.c |  6 +-
>  scripts/config_whitelist.txt   |  1 -
>  8 files changed, 28 insertions(+), 13 deletions(-)
>  rename {common => lib}/image-sparse.c (97%)

Reviewed-by: Simon Glass 

I'm not 100% sure about moving image-sparce to lib/ but I suppose it is OK.

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


Re: [U-Boot] [PATCH v7 17/18] usb: fastboot: Convert USB f_fastboot to shared fastboot

2018-05-25 Thread Simon Glass
On 24 May 2018 at 07:29, Alex Kiernan  wrote:
> Convert USB fastboot code to use shared fastboot protocol.
>
> Signed-off-by: Alex Kiernan 
> ---
>
> Changes in v7:
> - set FASTBOOT_CMD_OEM_FORMAT for all existing users of FASTBOOT_FLASH_MMC_DEV
>   that also have CMD_GPT
>
> Changes in v6:
> - merged from RFC USB fastboot series
> - when entering the DATA phase ensure we actually install the correct handler
> - on completion of DATA call new fastboot_data_complete()
> - previous changes:
>   - remove redundant version.h
>   - use new fastboot_get_bytes_remaining() function
>
> Changes in v5: None
> Changes in v4: None
> Changes in v3: None
> Changes in v2: None
>
>  configs/A13-OLinuXino_defconfig   |   1 +
>  configs/A20-OLinuXino-Lime2-eMMC_defconfig|   1 +
>  configs/A20-OLinuXino-Lime2_defconfig |   1 +
>  configs/A20-Olimex-SOM204-EVB-eMMC_defconfig  |   1 +
>  configs/A20-Olimex-SOM204-EVB_defconfig   |   1 +
>  configs/Bananapi_m2m_defconfig|   1 +
>  configs/Cubietruck_defconfig  |   1 +
>  configs/Sinlinx_SinA33_defconfig  |   1 +
>  configs/am335x_boneblack_defconfig|   7 +-
>  configs/am57xx_evm_defconfig  |  13 +-
>  configs/am57xx_hs_evm_defconfig   |  13 +-
>  configs/chromebit_mickey_defconfig|   5 +-
>  configs/chromebook_jerry_defconfig|   5 +-
>  configs/chromebook_minnie_defconfig   |   5 +-
>  configs/dra7xx_evm_defconfig  |  11 +-
>  configs/dra7xx_hs_evm_defconfig   |  11 +-
>  configs/evb-rk3036_defconfig  |   5 +-
>  configs/evb-rk3128_defconfig  |   9 +-
>  configs/evb-rk3229_defconfig  |   5 +-
>  configs/evb-rk3288_defconfig  |   5 +-
>  configs/evb-rk3328_defconfig  |   7 +-
>  configs/fennec-rk3288_defconfig   |   5 +-
>  configs/firefly-rk3288_defconfig  |   5 +-
>  configs/kylin-rk3036_defconfig|   5 +-
>  configs/miqi-rk3288_defconfig |   5 +-
>  configs/parrot_r16_defconfig  |   1 +
>  configs/phycore-rk3288_defconfig  |   5 +-
>  configs/popmetal-rk3288_defconfig |   5 +-
>  configs/rock2_defconfig   |   5 +-
>  configs/stih410-b2260_defconfig   |  11 +-
>  configs/tbs_a711_defconfig|   1 +
>  configs/tinker-rk3288_defconfig   |   5 +-
>  .../xilinx_zynqmp_zc1751_xm015_dc1_defconfig  |   7 +-
>  configs/xilinx_zynqmp_zcu102_rev1_0_defconfig |   7 +-
>  configs/xilinx_zynqmp_zcu102_revA_defconfig   |   7 +-
>  configs/xilinx_zynqmp_zcu102_revB_defconfig   |   7 +-
>  configs/xilinx_zynqmp_zcu106_revA_defconfig   |   7 +-
>  drivers/fastboot/Makefile |   4 +-
>  drivers/usb/gadget/f_fastboot.c   | 318 ++
>  39 files changed, 156 insertions(+), 363 deletions(-)

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


[U-Boot] [PATCH 1/1] efi_selftest: imply FAT, FAT_WRITE

2018-05-25 Thread Heinrich Schuchardt
efi_selftest_block_device accesses a FAT file system.

Signed-off-by: Heinrich Schuchardt 
---
 lib/efi_selftest/Kconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/efi_selftest/Kconfig b/lib/efi_selftest/Kconfig
index 3b5f3a1230b..59f9f36801c 100644
--- a/lib/efi_selftest/Kconfig
+++ b/lib/efi_selftest/Kconfig
@@ -1,6 +1,8 @@
 config CMD_BOOTEFI_SELFTEST
bool "Allow booting an EFI efi_selftest"
depends on CMD_BOOTEFI
+   imply FAT
+   imply FAT_WRITE
help
  This adds an EFI test application to U-Boot that can be executed
  with the 'bootefi selftest' command. It provides extended tests of
-- 
2.17.0

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


Re: [U-Boot] [PATCH v1 1/2] buildman: Extract environment as part of each build

2018-05-25 Thread Alex Kiernan
On Fri, May 25, 2018 at 9:56 AM Alex Kiernan  wrote:


> On Fri, May 25, 2018 at 9:05 AM Lukasz Majewski  wrote:

> > Hi Alex,

> > > As we're building the boards, extract the default U-Boot environment
> > > to uboot.env so we can interrogate it later.

> > If applicable, you may also consider using:
> > scripts/get_default_envs.sh

> > script to extract default envs (to txt file).


> I started with that, but then tripped over boards which have embedded
> newlines in their environment variables, which then made parsing the
> resulting text file much harder, which is why I swapped back to just using
> the NUL terminated blob. Of course I can't now find the one I tripped over
> to point at :(


ge_bx50v3 and mx53ppd (the failbootcmd variable)

> > >
> > > Signed-off-by: Alex Kiernan 
> > > ---
> > >
> > >  tools/buildman/builderthread.py | 10 ++
> > >  1 file changed, 10 insertions(+)
> > >
> > > diff --git a/tools/buildman/builderthread.py
> > > b/tools/buildman/builderthread.py index 0efe80d945..688322ced2 100644
> > > --- a/tools/buildman/builderthread.py
> > > +++ b/tools/buildman/builderthread.py
> > > @@ -351,6 +351,16 @@ class BuilderThread(threading.Thread):
> > >  lines.append(size_result.stdout.splitlines()[1]
> > > + ' ' + rodata_size)
> > >
> > > +# Extract the environment from U-Boot and dump it out
> > > +cmd = ['%sobjcopy' % self.toolchain.cross, '-O',
> > > 'binary',
> > > +   '-j', '.rodata.default_environment',
> > > +   'env/built-in.o', 'uboot.env']
> > > +command.RunPipe([cmd], capture=False,
> > > +capture_stderr=False, cwd=result.out_dir,
> > > +raise_on_error=False, env=env)
> > > +ubootenv = os.path.join(result.out_dir, 'uboot.env')
> > > +self.CopyFiles(result.out_dir, build_dir, '',
> > > ['uboot.env']) +
> > >  # Write out the image sizes file. This is similar to the
> > > output # of binutil's 'size' utility, but it omits the header line and
> > >  # adds an additional hex value at the end of each line
> > > for the




> > Best regards,

> > Lukasz Majewski

> > --

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



> --
> Alex Kiernan



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


Re: [U-Boot] [PATCH] regmap: Separate memory-based operations

2018-05-25 Thread Alexey Brodkin
Hi Simon,

On Thu, 2018-05-24 at 20:42 -0600, Simon Glass wrote:
> Hi Alexey,
> 
> On 24 May 2018 at 06:36, Alexey Brodkin  wrote:
> > One of important features of regmap [at least in Linux kernel]
> > is an ability to seamlessly communicate to devices connected
> > via different buses like: MMIO, SPI, I2C and many others.
> > 
> > Current implementation in U-Boot only supports memory-mapped registers
> > which is a vere valid case but we'll need more in the future.
> > 
> > This change paves the way for support of other buses. Still all existing
> > users of regmap in U-Boot shouldn't be affected because for now we don't
> > change API which might be required once we start adding support of more
> > complicated cases like 8/16/32/64-bit accessors, big- and little-endian
> > flavours etc.
> > 
> > It was inspired by discussion [1] of addition of even more accessors to
> > a standard 16550 UART.
> > 
> > [1] 
> > https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.denx.de_pipermail_u-2Dboot_2018-2DMarch_322322.html=DwIBaQ=DPL6_X_6JkXFx7AXWqB0
> > tg=lqdeeSSEes0GFDDl656eViXO7breS55ytWkhpk5R81I=JMITUQeA5TvqyeIBTH0jtI2TOsSfOS-0qPz4kntF5Hc=yadG7Ir9EqQaMUpUychW3TY3B7acDOog8IQYDKvOI-8=
> > 
> > Signed-off-by: Alexey Brodkin 
> > Cc: Simon Glass 
> > ---
> >  drivers/core/Makefile   |  2 +-
> >  drivers/core/{regmap.c => regmap-mem.c} | 79 ++-
> >  drivers/core/regmap.c   | 85 +
> >  include/regmap.h|  9 +++
> >  4 files changed, 31 insertions(+), 144 deletions(-)
> >  copy drivers/core/{regmap.c => regmap-mem.c} (60%)
> > 
> 
> Are there any changes needed to the regmap test with this?

Given this change doesn't touch API I'm not sure what can we
test more than it's currently done. Any thoughts?

> [..]
> 
> > diff --git a/include/regmap.h b/include/regmap.h
> > index 493a5d8eff84..f01c5733afac 100644
> > --- a/include/regmap.h
> > +++ b/include/regmap.h
> > @@ -31,6 +31,8 @@ struct regmap {
> > phys_addr_t base;
> > int range_count;
> > struct regmap_range *range, base_range;
> > +   int (*reg_read)(struct regmap *map, uint reg, uint *val);
> > +   int (*reg_write)(struct regmap *map, uint reg, uint val);
> 
> Can we use driver model for these somehow? E.g. we could create a
> UCLASS_SIMPLE_REG driver for each of memory, i2c, SPI, etc.

Probably we can do it here in U-Boot.
But at least in Linux kernel I see users of regmap (i.e. particular drivers)
initialize required regmap instance "manually", see for example:
https://elixir.bootlin.com/linux/latest/source/drivers/media/dvb-frontends/af9033.c#L1105

> When we want to use a particular I2C bus via regmap, we could bind the
> I2C -> regmap driver as a child of the I2C bus driver.

I guess that will require us to do corresponding changes in Device Tree
descriptions, right? And that will deviate those .dts-es from their kernel
counterparts [if they exist for a particular board].

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


[U-Boot] [PATCH v1 6/7] dwc3-generic: Handle the PHYs, the clocks and the reset lines

2018-05-25 Thread Jean-Jacques Hiblot
This make the driver more generic. At this point this driver can replace
the dwc3-of-simple implementation.
Make the description in the Kconfig more generic too.

Signed-off-by: Jean-Jacques Hiblot 
---

 drivers/usb/dwc3/Kconfig|   7 +-
 drivers/usb/dwc3/dwc3-generic.c | 159 +---
 2 files changed, 136 insertions(+), 30 deletions(-)

diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
index 943b763..bbd8105 100644
--- a/drivers/usb/dwc3/Kconfig
+++ b/drivers/usb/dwc3/Kconfig
@@ -38,10 +38,11 @@ config USB_DWC3_OMAP
  Say 'Y' here if you have one such device
 
 config USB_DWC3_GENERIC
-   bool "Xilinx ZynqMP and similar Platforms"
-   depends on DM_USB && USB_DWC3
+   bool "Generic implementation of a DWC3 wrapper (aka dwc3 glue)"
+   depends on DM_USB && USB_DWC3 && MISC
help
- Some platforms can reuse this DWC3 generic implementation.
+ Select this for Xilinx ZynqMP and similar Platforms.
+ This wrapper supports Host and Peripheral operation modes.
 
 config USB_DWC3_UNIPHIER
bool "DesignWare USB3 Host Support on UniPhier Platforms"
diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
index 3ec0c0e..977f310 100644
--- a/drivers/usb/dwc3/dwc3-generic.c
+++ b/drivers/usb/dwc3/dwc3-generic.c
@@ -11,59 +11,85 @@
 #include 
 #include 
 #include 
-#include 
-#include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include "core.h"
 #include "gadget.h"
-#include "linux-compat.h"
+#include 
+#include 
 
 #ifdef CONFIG_DM_USB_DEV
 
+struct dwc3_generic_peripheral {
+   struct dwc3 dwc3;
+   struct phy *phys;
+   int num_phys;
+};
+
 int dm_usb_gadget_handle_interrupts(struct udevice *dev)
 {
-   struct dwc3 *priv = dev_get_priv(dev);
+   struct dwc3_generic_peripheral *priv = dev_get_priv(dev);
+   struct dwc3 *dwc3 = >dwc3;
 
-   dwc3_gadget_uboot_handle_interrupt(priv);
+   dwc3_gadget_uboot_handle_interrupt(dwc3);
 
return 0;
 }
 
 static int dwc3_generic_peripheral_probe(struct udevice *dev)
 {
-   struct dwc3 *priv = dev_get_priv(dev);
+   int rc;
+   struct dwc3_generic_peripheral *priv = dev_get_priv(dev);
+   struct dwc3 *dwc3 = >dwc3;
+
+   rc = dwc3_setup_phy(dev, >phys, >num_phys);
+   if (rc)
+   return rc;
+
+   dwc3->regs = map_physmem(priv->base, DWC3_OTG_REGS_END, MAP_NOCACHE);
+   dwc3->regs += DWC3_GLOBALS_REGS_START;
+   dwc3->dev = dev;
+
+   rc =  dwc3_init(dwc3);
+   if (rc) {
+   unmap_physmem(dwc3->regs, MAP_NOCACHE);
+   return rc;
+   }
 
-   return dwc3_init(priv);
+   return 0;
 }
 
 static int dwc3_generic_peripheral_remove(struct udevice *dev)
 {
-   struct dwc3 *priv = dev_get_priv(dev);
+   struct dwc3_generic_peripheral *priv = dev_get_priv(dev);
+   struct dwc3 *dwc3 = >dwc3;
 
-   dwc3_remove(priv);
+   dwc3_remove(dwc3);
+   dwc3_shutdown_phy(dev, priv->phys, priv->num_phys);
+   unmap_physmem(dwc3->regs, MAP_NOCACHE);
 
return 0;
 }
 
 static int dwc3_generic_peripheral_ofdata_to_platdata(struct udevice *dev)
 {
-   struct dwc3 *priv = dev_get_priv(dev);
+   struct dwc3_generic_peripheral *priv = dev_get_priv(dev);
+   struct dwc3 *dwc3 = >dwc3;
int node = dev_of_offset(dev);
 
-   priv->regs = (void *)devfdt_get_addr(dev);
-   priv->regs += DWC3_GLOBALS_REGS_START;
+   priv->base = devfdt_get_addr(dev);
 
-   priv->maximum_speed = usb_get_maximum_speed(node);
-   if (priv->maximum_speed == USB_SPEED_UNKNOWN) {
+   dwc3->maximum_speed = usb_get_maximum_speed(node);
+   if (dwc3->maximum_speed == USB_SPEED_UNKNOWN) {
pr_err("Invalid usb maximum speed\n");
return -ENODEV;
}
 
-   priv->dr_mode = usb_get_dr_mode(node);
-   if (priv->dr_mode == USB_DR_MODE_UNKNOWN) {
+   dwc3->dr_mode = usb_get_dr_mode(node);
+   if (dwc3->dr_mode == USB_DR_MODE_UNKNOWN) {
pr_err("Invalid usb mode setup\n");
return -ENODEV;
}
@@ -77,13 +103,16 @@ U_BOOT_DRIVER(dwc3_generic_peripheral) = {
.ofdata_to_platdata = dwc3_generic_peripheral_ofdata_to_platdata,
.probe = dwc3_generic_peripheral_probe,
.remove = dwc3_generic_peripheral_remove,
-   .platdata_auto_alloc_size = sizeof(struct usb_platdata),
-   .priv_auto_alloc_size = sizeof(struct dwc3),
+   .priv_auto_alloc_size = sizeof(struct dwc3_generic_peripheral),
 };
-
 #endif
 
-static int dwc3_generic_bind(struct udevice *parent)
+struct dwc3_glue_data {
+   struct clk_bulk clks;
+   struct reset_ctl_bulk   resets;
+};
+
+static int dwc3_glue_bind(struct udevice *parent)
 {
const void *fdt = gd->fdt_blob;
int node;
@@ -94,29 +123,32 @@ static int dwc3_generic_bind(struct udevice *parent)

[U-Boot] [PATCH] buildman: Add GCC 8.1.0 version to tools from kernel.org

2018-05-25 Thread Alexey Brodkin
Since May 22th toolchains built from GCC 8.1.0 are available at
https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/8.1.0/

Unfortunately that pretty trivial bump disclosed a few build
issues, see CI job [1] for all the details.

That's a brief analysis if of any interest:
 1) Wrong use of ARRAY_SIZE in drivers/mtd/nand/atmel_nand.c,
see [2].

|   arm:  +   wb45n
|+In file included from include/linux/delay.h:6,
|+ from include/common.h:26,
|+ from drivers/mtd/nand/atmel_nand.c:13:
|+drivers/mtd/nand/atmel_nand.c: In function 'pmecc_get_sigma':
|+include/linux/kernel.h:46:34: error: division 'sizeof (int16_t * {aka 
short int *}) / sizeof (int16_t {aka short int})' does not compute the number 
of array elements [-Werror=sizeof-pointer-div]
|+ #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|+  ^
|+drivers/mtd/nand/atmel_nand.c:252:35: note: in expansion of macro 
'ARRAY_SIZE'
|+  memset(smu, 0, sizeof(int16_t) * ARRAY_SIZE(smu));
|+   ^~
|+drivers/mtd/nand/atmel_nand.c:244:11: note: first 'sizeof' operand was 
declared here
|+  int16_t *smu = host->pmecc_smu;
|+   ^~~

I guess that's because of 'smu' variable not being an array or a
pointer to array. Should be trivial to fix.

 2) Issues with .dts on some ARM boards, see [3]:
|   arm:  +   vinco
|+arch/arm/dts/at91-vinco.dtb: Warning (reg_format): "reg" property in 
/ahb/apb/timer@fc024000/timer@0 has invalid length (4 bytes) (#address-cells == 
2, #size-cells == 1)
...and a couple of more of the similar type.

 3) Assembler issues on efi-x86, see [4]:
|   x86:  +   efi-x86
|+{standard input}: Assembler messages:
|+{standard input}:21624: Error: junk at end of line, first unrecognized 
character is `@'
|+{standard input}:21669: Error: junk at end of line, first unrecognized 
character is `@'
|+{standard input}:21624: Error: can't resolve `end.6766' 
{.u_boot_list_2_fit_loadable_3 section} - `start.6763' 
{.u_boot_list_2_fit_loadable_1 section}
|+{standard input}:21669: Error: can't resolve `end.6766' 
{.u_boot_list_2_fit_loadable_3 section} - `start.6763' 
{.u_boot_list_2_fit_loadable_1 section}

 4) -Werror=tautological-compare on some PowerPC boards, see [5]:
|   powerpc:  +   T1040D4RDB_SPIFLASH
|+drivers/net/fm/t1040.c: In function 'fman_port_enet_if':
|+drivers/net/fm/t1040.c:19:53: error: bitwise comparison always evaluates 
to false [-Werror=tautological-compare]
|+  ((rcwsr13 & FSL_CORENET_RCWSR13_MAC2_GMII_SEL) ==
|+ ^~
|+drivers/net/fm/t1040.c:44:48: error: bitwise comparison always evaluates 
to false [-Werror=tautological-compare]
|+   else if ((rcwsr13 & FSL_CORENET_RCWSR13_EC2) ==
|+

 5) Missing property '#phy-cells' in node in
arch/arm/dts/am335x-boneblack.dts, see [6]:
|   arm:  +   rastaban pxm2 smartweb etamin thuban draco rut
|+arch/arm/dts/am335x-boneblack.dtb: Warning (phys_property): Missing 
property '#phy-cells' in node /ocp/usb@4740/usb-phy@47401300 or bad phandle 
(referred from /ocp/usb@4740/usb@47401000:phys[0])

[1] https://travis-ci.org/abrodkin/u-boot/builds/383423675
[2] https://travis-ci.org/abrodkin/u-boot/jobs/383423678
[3] https://travis-ci.org/abrodkin/u-boot/jobs/383423695
[4] https://travis-ci.org/abrodkin/u-boot/jobs/383423696
[5] https://travis-ci.org/abrodkin/u-boot/jobs/383423714
[6] https://travis-ci.org/abrodkin/u-boot/jobs/383423717

Signed-off-by: Alexey Brodkin 
Cc: Simon Goldschmidt 
Cc: Joe Hershberger 
Cc: Patrice Chotard 
Cc: Jagan Teki 
Cc: Dmitry Korunov 
Cc: Alexander Graf 
Cc: Simon Glass 
Cc: Jason Rush 
Cc: Scott Wood 
Cc: Marek Vasut 
---
 .travis.yml | 2 +-
 tools/buildman/toolchain.py | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 589ca8982443..d5e517574bf3 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -68,7 +68,7 @@ before_script:
   - if [[ "${TOOLCHAIN}" == *sh* ]]; then ./tools/buildman/buildman 
--fetch-arch sh2 ; fi
   - if [[ "${TOOLCHAIN}" == *x86_64* ]]; then
   ./tools/buildman/buildman --fetch-arch x86_64;
-  echo -e "\n[toolchain-prefix]\nx86 = 
${HOME}/.buildman-toolchains/gcc-7.3.0-nolibc/x86_64-linux/bin/x86_64-linux-" 
>> ~/.buildman;
+  echo -e "\n[toolchain-prefix]\nx86 = 
${HOME}/.buildman-toolchains/gcc-8.1.0-nolibc/x86_64-linux/bin/x86_64-linux-" 
>> ~/.buildman;
 fi
   - if [[ "${TOOLCHAIN}" == *arc* ]]; then ./tools/buildman/buildman 
--fetch-arch arc ; fi
   - if [[ "${TOOLCHAIN}" == *xtensa* ]]; then

[U-Boot] [PATCH v1 4/7] dwc3_generic: do not probe the USB device driver when it's bound

2018-05-25 Thread Jean-Jacques Hiblot
The driver will be probed when usb_gadget_initialize() is called.

Signed-off-by: Jean-Jacques Hiblot 
---

 drivers/usb/dwc3/dwc3-generic.c | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
index 43e97be..3ec0c0e 100644
--- a/drivers/usb/dwc3/dwc3-generic.c
+++ b/drivers/usb/dwc3/dwc3-generic.c
@@ -71,21 +71,14 @@ static int 
dwc3_generic_peripheral_ofdata_to_platdata(struct udevice *dev)
return 0;
 }
 
-static int dwc3_generic_peripheral_bind(struct udevice *dev)
-{
-   return device_probe(dev);
-}
-
 U_BOOT_DRIVER(dwc3_generic_peripheral) = {
.name   = "dwc3-generic-peripheral",
.id = UCLASS_USB_DEV_GENERIC,
.ofdata_to_platdata = dwc3_generic_peripheral_ofdata_to_platdata,
.probe = dwc3_generic_peripheral_probe,
.remove = dwc3_generic_peripheral_remove,
-   .bind = dwc3_generic_peripheral_bind,
.platdata_auto_alloc_size = sizeof(struct usb_platdata),
.priv_auto_alloc_size = sizeof(struct dwc3),
-   .flags  = DM_FLAG_ALLOC_PRIV_DMA,
 };
 
 #endif
-- 
2.7.4

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


[U-Boot] [PATCH v1 3/7] usb: udc: implement DM versions of usb_gadget_initialize()/_release()/_handle_interrupt()

2018-05-25 Thread Jean-Jacques Hiblot
When DM_USB_DEV the platform code for the USB device must be replaced by
calls to a USB device driver.

usb_gadget_initialize() probes the USB device driver.
usb_gadget_release() removes the USB device driver.

Signed-off-by: Jean-Jacques Hiblot 
---

 drivers/usb/dwc3/dwc3-generic.c   | 14 ++---
 drivers/usb/gadget/udc/udc-core.c | 44 ++-
 include/linux/usb/gadget.h|  8 +++
 3 files changed, 53 insertions(+), 13 deletions(-)

diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
index 2c1e696..43e97be 100644
--- a/drivers/usb/dwc3/dwc3-generic.c
+++ b/drivers/usb/dwc3/dwc3-generic.c
@@ -23,19 +23,9 @@
 
 #ifdef CONFIG_DM_USB_DEV
 
-int usb_gadget_handle_interrupts(int index)
+int dm_usb_gadget_handle_interrupts(struct udevice *dev)
 {
-   struct dwc3 *priv;
-   struct udevice *dev;
-   int ret;
-
-   ret = uclass_first_device(UCLASS_USB_DEV_GENERIC, );
-   if (!dev || ret) {
-   pr_err("No USB device found\n");
-   return -ENODEV;
-   }
-
-   priv = dev_get_priv(dev);
+   struct dwc3 *priv = dev_get_priv(dev);
 
dwc3_gadget_uboot_handle_interrupt(priv);
 
diff --git a/drivers/usb/gadget/udc/udc-core.c 
b/drivers/usb/gadget/udc/udc-core.c
index f5c30dd..42c9ea9 100644
--- a/drivers/usb/gadget/udc/udc-core.c
+++ b/drivers/usb/gadget/udc/udc-core.c
@@ -18,7 +18,8 @@
 #include 
 #include 
 #include 
-
+#include 
+#include 
 #include 
 #include 
 
@@ -351,3 +352,44 @@ EXPORT_SYMBOL_GPL(usb_gadget_unregister_driver);
 MODULE_DESCRIPTION("UDC Framework");
 MODULE_AUTHOR("Felipe Balbi ");
 MODULE_LICENSE("GPL v2");
+
+#ifdef CONFIG_DM_USB_DEV
+#define MAX_UDC_DEVICES 4
+static struct udevice *dev_array[MAX_UDC_DEVICES];
+int usb_gadget_initialize(int index)
+{
+   int ret;
+   struct udevice *dev = NULL;
+
+   if (index < 0 || index >= ARRAY_SIZE(dev_array))
+   return -EINVAL;
+   if (dev_array[index])
+   return 0;
+   ret = uclass_get_device(UCLASS_USB_DEV_GENERIC, index, );
+   if (!dev || ret) {
+   pr_err("No USB device found\n");
+   return -ENODEV;
+   }
+   dev_array[index] = dev;
+   return 0;
+}
+
+int usb_gadget_release(int index)
+{
+   int ret;
+
+   if (index < 0 || index >= ARRAY_SIZE(dev_array))
+   return -EINVAL;
+   ret = device_remove(dev_array[index], DM_REMOVE_NORMAL);
+   if (!ret)
+   dev_array[index] = NULL;
+   return ret;
+}
+
+int usb_gadget_handle_interrupts(int index)
+{
+   if (index < 0 || index >= ARRAY_SIZE(dev_array))
+   return -EINVAL;
+   return dm_usb_gadget_handle_interrupts(dev_array[index]);
+}
+#endif
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
index 40ca2d3..a094e31 100644
--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gadget.h
@@ -927,6 +927,12 @@ extern void usb_ep_autoconfig_reset(struct usb_gadget *);
 
 extern int usb_gadget_handle_interrupts(int index);
 
+#ifdef CONFIG_DM_USB_DEV
+int usb_gadget_initialize(int index);
+int usb_gadget_release(int index);
+int dm_usb_gadget_handle_interrupts(struct udevice *dev);
+#else
+#include 
 static inline int usb_gadget_initialize(int index)
 {
return board_usb_init(index, USB_INIT_DEVICE);
@@ -936,4 +942,6 @@ static inline int usb_gadget_release(int index)
 {
return board_usb_cleanup(index, USB_INIT_DEVICE);
 }
+#endif
+
 #endif /* __LINUX_USB_GADGET_H */
-- 
2.7.4

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


[U-Boot] [PATCH v1 5/7] dwc3: move phy operation to core.c

2018-05-25 Thread Jean-Jacques Hiblot
Those operations can be used for peripheral operation as well as host
operation.

Signed-off-by: Jean-Jacques Hiblot 
---

 drivers/usb/dwc3/core.c  | 88 -
 drivers/usb/dwc3/ep0.c   |  1 -
 drivers/usb/host/xhci-dwc3.c | 93 +++-
 include/dwc3-uboot.h |  7 
 4 files changed, 99 insertions(+), 90 deletions(-)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index d5ee6d9..538c603 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -19,7 +19,7 @@
 #include 
 #include 
 #include 
-
+#include 
 #include 
 #include 
 
@@ -789,8 +789,92 @@ MODULE_AUTHOR("Felipe Balbi ");
 MODULE_LICENSE("GPL v2");
 MODULE_DESCRIPTION("DesignWare USB3 DRD Controller Driver");
 
-#ifdef CONFIG_DM_USB_DEV
+#ifdef CONFIG_DM_USB
+int dwc3_setup_phy(struct udevice *dev, struct phy **array, int *num_phys)
+{
+   int i, ret, count;
+   struct phy *usb_phys;
+
+   /* Return if no phy declared */
+   if (!dev_read_prop(dev, "phys", NULL))
+   return 0;
+
+   count = dev_count_phandle_with_args(dev, "phys", "#phy-cells");
+   if (count <= 0)
+   return count;
+
+   usb_phys = devm_kcalloc(dev, count, sizeof(struct phy),
+   GFP_KERNEL);
+   if (!usb_phys)
+   return -ENOMEM;
+
+   for (i = 0; i < count; i++) {
+   ret = generic_phy_get_by_index(dev, i, _phys[i]);
+   if (ret && ret != -ENOENT) {
+   pr_err("Failed to get USB PHY%d for %s\n",
+  i, dev->name);
+   return ret;
+   }
+   }
+
+   for (i = 0; i < count; i++) {
+   ret = generic_phy_init(_phys[i]);
+   if (ret) {
+   pr_err("Can't init USB PHY%d for %s\n",
+  i, dev->name);
+   goto phys_init_err;
+   }
+   }
+
+   for (i = 0; i < count; i++) {
+   ret = generic_phy_power_on(_phys[i]);
+   if (ret) {
+   pr_err("Can't power USB PHY%d for %s\n",
+  i, dev->name);
+   goto phys_poweron_err;
+   }
+   }
+
+   *num_phys =  count;
+   return 0;
 
+phys_poweron_err:
+   for (i = count - 1; i >= 0; i--)
+   generic_phy_power_off(_phys[i]);
+
+   for (i = 0; i < count; i++)
+   generic_phy_exit(_phys[i]);
+
+   return ret;
+
+phys_init_err:
+   for (; i >= 0; i--)
+   generic_phy_exit(_phys[i]);
+
+   return ret;
+}
+
+int dwc3_shutdown_phy(struct udevice *dev, struct phy *usb_phys, int num_phys)
+{
+   int i, ret;
+
+   for (i = 0; i < num_phys; i++) {
+   if (!generic_phy_valid(_phys[i]))
+   continue;
+
+   ret = generic_phy_power_off(_phys[i]);
+   ret |= generic_phy_exit(_phys[i]);
+   if (ret) {
+   pr_err("Can't shutdown USB PHY%d for %s\n",
+  i, dev->name);
+   }
+   }
+
+   return 0;
+}
+#endif
+
+#ifdef CONFIG_DM_USB_DEV
 int dwc3_init(struct dwc3 *dwc)
 {
int ret;
diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c
index 4f68887..433e5f6 100644
--- a/drivers/usb/dwc3/ep0.c
+++ b/drivers/usb/dwc3/ep0.c
@@ -19,7 +19,6 @@
 #include 
 #include 
 #include 
-
 #include "core.h"
 #include "gadget.h"
 #include "io.h"
diff --git a/drivers/usb/host/xhci-dwc3.c b/drivers/usb/host/xhci-dwc3.c
index 80754d7..052e704 100644
--- a/drivers/usb/host/xhci-dwc3.c
+++ b/drivers/usb/host/xhci-dwc3.c
@@ -12,6 +12,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "xhci.h"
 #include 
@@ -110,104 +111,20 @@ void dwc3_set_fladj(struct dwc3 *dwc3_reg, u32 val)
 }
 
 #ifdef CONFIG_DM_USB
-static int xhci_dwc3_setup_phy(struct udevice *dev)
-{
-   struct xhci_dwc3_platdata *plat = dev_get_platdata(dev);
-   int i, ret, count;
-
-   /* Return if no phy declared */
-   if (!dev_read_prop(dev, "phys", NULL))
-   return 0;
-
-   count = dev_count_phandle_with_args(dev, "phys", "#phy-cells");
-   if (count <= 0)
-   return count;
-
-   plat->usb_phys = devm_kcalloc(dev, count, sizeof(struct phy),
- GFP_KERNEL);
-   if (!plat->usb_phys)
-   return -ENOMEM;
-
-   for (i = 0; i < count; i++) {
-   ret = generic_phy_get_by_index(dev, i, >usb_phys[i]);
-   if (ret && ret != -ENOENT) {
-   pr_err("Failed to get USB PHY%d for %s\n",
-  i, dev->name);
-   return ret;
-   }
-
-   ++plat->num_phys;
-   }
-
-   for (i = 0; i < plat->num_phys; i++) {
-   ret = 

[U-Boot] [PATCH v1 7/7] dwc3-generic: Add select_dr_mode operation

2018-05-25 Thread Jean-Jacques Hiblot
The select_dr_mode operation is executed when the glue driver is probed.
The role of this optional function is to configure the operating mode
of the controller at the glue level.

Signed-off-by: Jean-Jacques Hiblot 

---

 drivers/usb/dwc3/dwc3-generic.c | 26 ++
 1 file changed, 26 insertions(+)

diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
index 977f310..9227501 100644
--- a/drivers/usb/dwc3/dwc3-generic.c
+++ b/drivers/usb/dwc3/dwc3-generic.c
@@ -8,6 +8,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -110,6 +111,12 @@ U_BOOT_DRIVER(dwc3_generic_peripheral) = {
 struct dwc3_glue_data {
struct clk_bulk clks;
struct reset_ctl_bulk   resets;
+   fdt_addr_t regs;
+};
+
+struct dwc3_glue_ops {
+   void (*select_dr_mode)(struct udevice *dev, int index,
+  enum usb_dr_mode mode);
 };
 
 static int dwc3_glue_bind(struct udevice *parent)
@@ -205,9 +212,14 @@ static int dwc3_glue_clk_init(struct udevice *dev,
 
 static int dwc3_glue_probe(struct udevice *dev)
 {
+   struct dwc3_glue_ops *ops = (struct dwc3_glue_ops 
*)dev_get_driver_data(dev);
struct dwc3_glue_data *glue = dev_get_platdata(dev);
+   struct udevice *child = NULL;
+   int index = 0;
int ret;
 
+   glue->regs = dev_read_addr(dev);
+
ret = dwc3_glue_clk_init(dev, glue);
if (ret)
return ret;
@@ -216,6 +228,20 @@ static int dwc3_glue_probe(struct udevice *dev)
if (ret)
return ret;
 
+   ret = device_find_first_child(dev, );
+   if (ret)
+   return ret;
+
+   while (child) {
+   enum usb_dr_mode dr_mode;
+
+   dr_mode = usb_get_dr_mode(dev_of_offset(child));
+   device_find_next_child();
+   if (ops && ops->select_dr_mode)
+   ops->select_dr_mode(dev, index, dr_mode);
+   index++;
+   }
+
return 0;
 }
 
-- 
2.7.4

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


[U-Boot] [PATCH v1 0/7] Improvements for the dwc3_generic driver

2018-05-25 Thread Jean-Jacques Hiblot
This series aims at bringing improvements to the dwc3_generic driver so
that it can be used by most of the platforms using the dwc3 controller.

I tested this on with DRA7 and AM57x platforms for both Peripheral and Host
operations. The code to enable DM USB host & dev support for those
platforms will be submitted in a separate series.

Enhancements:
- use separate Kconfig option for DM USB Periphal and DM USB Host. This
allow platforms to keep their non-DM USB peripheral code and use the DM
USB host.
- fixes the bind/probe confusion in dwc3_generic. The probe is done when
the USB device is first needed.
- handles PHYs when in the peripheral mode. The code to handle the PHYs is
shared with the host side
- handles clock and reset
- bind host controller to the more generic driver 'xhci-dwc3'



Jean-Jacques Hiblot (7):
  usb: gadget: Do not call board_usb_xxx() directly in USB gadget
drivers
  usb: introduce a separate config option for DM USB device
  usb: udc: implement DM versions of
usb_gadget_initialize()/_release()/_handle_interrupt()
  dwc3_generic: do not probe the USB device driver when it's bound
  dwc3: move phy operation to core.c
  dwc3-generic: Handle the PHYs, the clocks and the reset lines
  dwc3-generic: Add select_dr_mode operation

 cmd/fastboot.c|   4 +-
 cmd/rockusb.c |   4 +-
 cmd/thordown.c|   4 +-
 cmd/usb_gadget_sdp.c  |   4 +-
 cmd/usb_mass_storage.c|   4 +-
 common/dfu.c  |   6 +-
 drivers/usb/Kconfig   |   6 ++
 drivers/usb/dwc3/Kconfig  |   7 +-
 drivers/usb/dwc3/core.c   |  86 +++-
 drivers/usb/dwc3/dwc3-generic.c   | 206 +-
 drivers/usb/dwc3/ep0.c|   1 -
 drivers/usb/gadget/ether.c|  38 +--
 drivers/usb/gadget/udc/udc-core.c |  44 +++-
 drivers/usb/host/xhci-dwc3.c  |  93 ++---
 include/dwc3-uboot.h  |   7 ++
 include/linux/usb/gadget.h|  18 
 16 files changed, 348 insertions(+), 184 deletions(-)

-- 
2.7.4

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


[U-Boot] [PATCH v1 1/7] usb: gadget: Do not call board_usb_xxx() directly in USB gadget drivers

2018-05-25 Thread Jean-Jacques Hiblot
Add 2 functions to wrap the calls to board_usb_init() and
board_usb_cleanup().

Signed-off-by: Jean-Jacques Hiblot 
---

 cmd/fastboot.c |  4 ++--
 cmd/rockusb.c  |  4 ++--
 cmd/thordown.c |  4 ++--
 cmd/usb_gadget_sdp.c   |  4 ++--
 cmd/usb_mass_storage.c |  4 ++--
 common/dfu.c   |  6 +++---
 drivers/usb/gadget/ether.c | 38 +-
 include/linux/usb/gadget.h | 10 ++
 8 files changed, 28 insertions(+), 46 deletions(-)

diff --git a/cmd/fastboot.c b/cmd/fastboot.c
index a5ec5f4..93f97fd 100644
--- a/cmd/fastboot.c
+++ b/cmd/fastboot.c
@@ -24,7 +24,7 @@ static int do_fastboot(cmd_tbl_t *cmdtp, int flag, int argc, 
char *const argv[])
usb_controller = argv[1];
controller_index = simple_strtoul(usb_controller, NULL, 0);
 
-   ret = board_usb_init(controller_index, USB_INIT_DEVICE);
+   ret = usb_gadget_initialize(controller_index);
if (ret) {
pr_err("USB init failed: %d", ret);
return CMD_RET_FAILURE;
@@ -55,7 +55,7 @@ static int do_fastboot(cmd_tbl_t *cmdtp, int flag, int argc, 
char *const argv[])
 exit:
g_dnl_unregister();
g_dnl_clear_detach();
-   board_usb_cleanup(controller_index, USB_INIT_DEVICE);
+   usb_gadget_release(controller_index);
 
return ret;
 }
diff --git a/cmd/rockusb.c b/cmd/rockusb.c
index 8206643..e0c1480 100644
--- a/cmd/rockusb.c
+++ b/cmd/rockusb.c
@@ -33,7 +33,7 @@ static int do_rockusb(cmd_tbl_t *cmdtp, int flag, int argc, 
char *const argv[])
dev_index = simple_strtoul(devnum, NULL, 0);
rockusb_dev_init(devtype, dev_index);
 
-   ret = board_usb_init(controller_index, USB_INIT_DEVICE);
+   ret = usb_gadget_initialize(controller_index);
if (ret) {
printf("USB init failed: %d\n", ret);
return CMD_RET_FAILURE;
@@ -62,7 +62,7 @@ static int do_rockusb(cmd_tbl_t *cmdtp, int flag, int argc, 
char *const argv[])
 exit:
g_dnl_unregister();
g_dnl_clear_detach();
-   board_usb_cleanup(controller_index, USB_INIT_DEVICE);
+   usb_gadget_release(controller_index);
 
return ret;
 }
diff --git a/cmd/thordown.c b/cmd/thordown.c
index e297de2..b7866d1 100644
--- a/cmd/thordown.c
+++ b/cmd/thordown.c
@@ -30,7 +30,7 @@ int do_thor_down(cmd_tbl_t *cmdtp, int flag, int argc, char * 
const argv[])
goto done;
 
int controller_index = simple_strtoul(usb_controller, NULL, 0);
-   ret = board_usb_init(controller_index, USB_INIT_DEVICE);
+   ret = usb_gadget_initialize(controller_index);
if (ret) {
pr_err("USB init failed: %d", ret);
ret = CMD_RET_FAILURE;
@@ -55,7 +55,7 @@ int do_thor_down(cmd_tbl_t *cmdtp, int flag, int argc, char * 
const argv[])
 
 exit:
g_dnl_unregister();
-   board_usb_cleanup(controller_index, USB_INIT_DEVICE);
+   usb_gadget_realease(controller_index);
 done:
dfu_free_entities();
 
diff --git a/cmd/usb_gadget_sdp.c b/cmd/usb_gadget_sdp.c
index ba1f66a..808ed97 100644
--- a/cmd/usb_gadget_sdp.c
+++ b/cmd/usb_gadget_sdp.c
@@ -20,7 +20,7 @@ static int do_sdp(cmd_tbl_t *cmdtp, int flag, int argc, char 
* const argv[])
 
char *usb_controller = argv[1];
int controller_index = simple_strtoul(usb_controller, NULL, 0);
-   board_usb_init(controller_index, USB_INIT_DEVICE);
+   usb_gadget_initialize(controller_index);
 
g_dnl_clear_detach();
g_dnl_register("usb_dnl_sdp");
@@ -37,7 +37,7 @@ static int do_sdp(cmd_tbl_t *cmdtp, int flag, int argc, char 
* const argv[])
 
 exit:
g_dnl_unregister();
-   board_usb_cleanup(controller_index, USB_INIT_DEVICE);
+   usb_gadget_release(controller_index);
 
return ret;
 }
diff --git a/cmd/usb_mass_storage.c b/cmd/usb_mass_storage.c
index 89b9ddf..7c6d0c6 100644
--- a/cmd/usb_mass_storage.c
+++ b/cmd/usb_mass_storage.c
@@ -160,7 +160,7 @@ static int do_usb_mass_storage(cmd_tbl_t *cmdtp, int flag,
 
controller_index = (unsigned int)(simple_strtoul(
usb_controller, NULL, 0));
-   if (board_usb_init(controller_index, USB_INIT_DEVICE)) {
+   if (usb_gadget_initialize(controller_index)) {
pr_err("Couldn't init USB controller.");
rc = CMD_RET_FAILURE;
goto cleanup_ums_init;
@@ -231,7 +231,7 @@ static int do_usb_mass_storage(cmd_tbl_t *cmdtp, int flag,
 cleanup_register:
g_dnl_unregister();
 cleanup_board:
-   board_usb_cleanup(controller_index, USB_INIT_DEVICE);
+   usb_gadget_release(controller_index);
 cleanup_ums_init:
ums_fini();
 
diff --git a/common/dfu.c b/common/dfu.c
index 2620d32..44d1484 100644
--- a/common/dfu.c
+++ b/common/dfu.c
@@ -23,9 +23,9 @@ int run_usb_dnl_gadget(int usbctrl_index, char 
*usb_dnl_gadget)
bool dfu_reset = false;
int ret, i = 0;
 
-   

[U-Boot] [PATCH v1 2/7] usb: introduce a separate config option for DM USB device

2018-05-25 Thread Jean-Jacques Hiblot
Using CONFIG_DM_USB for this purpose prevents using DM_USB for host and not
for device.

Signed-off-by: Jean-Jacques Hiblot 
---

 drivers/usb/Kconfig | 6 ++
 drivers/usb/dwc3/core.c | 2 +-
 drivers/usb/dwc3/dwc3-generic.c | 4 +++-
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig
index 4fbe172..3587ba4 100644
--- a/drivers/usb/Kconfig
+++ b/drivers/usb/Kconfig
@@ -47,6 +47,12 @@ config DM_USB
  declared with the U_BOOT_USB_DEVICE() macro and will be
  automatically probed when found on the bus.
 
+config DM_USB_DEV
+   bool "Enable driver model for USB (Peripheral mode)"
+   depends on DM_USB
+   help
+ Enable driver model for USB (Peripheral mode).
+
 source "drivers/usb/host/Kconfig"
 
 source "drivers/usb/dwc3/Kconfig"
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 1ab5cee..d5ee6d9 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -789,7 +789,7 @@ MODULE_AUTHOR("Felipe Balbi ");
 MODULE_LICENSE("GPL v2");
 MODULE_DESCRIPTION("DesignWare USB3 DRD Controller Driver");
 
-#ifdef CONFIG_DM_USB
+#ifdef CONFIG_DM_USB_DEV
 
 int dwc3_init(struct dwc3 *dwc)
 {
diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
index ca63eac..2c1e696 100644
--- a/drivers/usb/dwc3/dwc3-generic.c
+++ b/drivers/usb/dwc3/dwc3-generic.c
@@ -21,7 +21,7 @@
 #include "gadget.h"
 #include "linux-compat.h"
 
-DECLARE_GLOBAL_DATA_PTR;
+#ifdef CONFIG_DM_USB_DEV
 
 int usb_gadget_handle_interrupts(int index)
 {
@@ -98,6 +98,8 @@ U_BOOT_DRIVER(dwc3_generic_peripheral) = {
.flags  = DM_FLAG_ALLOC_PRIV_DMA,
 };
 
+#endif
+
 static int dwc3_generic_bind(struct udevice *parent)
 {
const void *fdt = gd->fdt_blob;
-- 
2.7.4

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


Re: [U-Boot] [PATCH] arm: Use mtune for Xscale

2018-05-25 Thread Alexey Brodkin
Hello,

Just a short update.

On Fri, 2018-05-25 at 12:04 +0300, Alexey Brodkin wrote:
> Otherwise with GCC 8 we see this warning [which is rendered to an error
> with -Werror, which happens for buildman/travisci], see [1]:
> --->8---
> cc1: warning: switch -mcpu=xscale conflicts with -march=armv5te switch
> --->8---

Even though problem listed above got solved with this patch but it introduces
another issue I missed initially with GCC 8.1.0, see [3]:
--->8---
   arm:  +   h2200
+arch/arm/cpu/pxa/start.S: Assembler messages:
+arch/arm/cpu/pxa/start.S:179: Error: selected processor does not support `strd 
r4,[r1],#8' in ARM mode
--->8---

[3] https://travis-ci.org/abrodkin/u-boot/jobs/383423699

So that doesn't seem to be the easy fix :(

-Alexey

> Interesting enough with GCC 7.3.0 (which is current default in buildman)
> that change leads to another failure, see [2]:
> --->8---
> Error: selected processor does not support `pld [lr]' in ARM mode
> --->8---
> 
> So I guess this change might be put in series with buildman toolchain
> bump.
> 
> [1] https://travis-ci.org/abrodkin/u-boot/jobs/383219348
> [2] https://travis-ci.org/abrodkin/u-boot/jobs/383594006
> 
> Signed-off-by: Alexey Brodkin 
> Cc: Albert Aribaud 
> ---
>  arch/arm/Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm/Makefile b/arch/arm/Makefile
> index 680c6e8516dc..18e0193c43c0 100644
> --- a/arch/arm/Makefile
> +++ b/arch/arm/Makefile
> @@ -37,7 +37,7 @@ tune-$(CONFIG_CPU_ARM920T)  =
>  tune-$(CONFIG_CPU_ARM926EJS) =
>  tune-$(CONFIG_CPU_ARM946ES)  =
>  tune-$(CONFIG_CPU_SA1100)=-mtune=strongarm1100
> -tune-$(CONFIG_CPU_PXA)   =-mcpu=xscale
> +tune-$(CONFIG_CPU_PXA)   =-mtune=xscale
>  tune-$(CONFIG_CPU_ARM1136)   =
>  tune-$(CONFIG_CPU_ARM1176)   =
>  tune-$(CONFIG_CPU_V7A)   =
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 3/4] scsi: ceva: add ls1012a soc support

2018-05-25 Thread andy.tang
From: Yuantian Tang 

Adjust the code structure more general so that more socs can be
added easily.
Add the ls1012a sata support as well.

Signed-off-by: Tang Yuantian 
---
 drivers/ata/sata_ceva.c |   87 +-
 1 files changed, 55 insertions(+), 32 deletions(-)

diff --git a/drivers/ata/sata_ceva.c b/drivers/ata/sata_ceva.c
index a7d45e8..4c9ebe4 100644
--- a/drivers/ata/sata_ceva.c
+++ b/drivers/ata/sata_ceva.c
@@ -18,6 +18,7 @@
 #define AHCI_VEND_PP3C  0xB0
 #define AHCI_VEND_PP4C  0xB4
 #define AHCI_VEND_PP5C  0xB8
+#define AHCI_VEND_AXICC 0xBc
 #define AHCI_VEND_PAXIC 0xC0
 #define AHCI_VEND_PTC   0xC8
 
@@ -72,45 +73,57 @@
 #define DRV_NAME   "ahci-ceva"
 #define CEVA_FLAG_BROKEN_GEN2  1
 
+/* flag bit definition */
+#define FLAG_COHERENT  1
+
+/* register config value */
+#define CEVA_PHY1_CFG  0xa003fffe
+#define CEVA_PHY2_CFG  0x28184d1f
+#define CEVA_PHY3_CFG  0x0e081509
+#define CEVA_TRANS_CFG 0x0829
+#define CEVA_AXICC_CFG 0x3fff
+
+/* ecc addr-val pair */
+#define ECC_DIS_ADDR_CH2   0x8000
+#define ECC_DIS_VAL_CH20x20140520
+
+enum ceva_soc {
+   CEVA_1V84,
+   CEVA_LS1012A,
+};
+
 struct ceva_sata_priv {
ulong base;
+   enum ceva_soc soc;
+   ulong flag;
 };
 
-static int ceva_init_sata(ulong mmio)
+static int ceva_init_sata(struct ceva_sata_priv *priv)
 {
+   ulong base = priv->base;
ulong tmp;
-   int i;
-
-   /*
-* AXI Data bus width to 64
-* Set Mem Addr Read, Write ID for data transfers
-* Transfer limit to 72 DWord
-*/
-   tmp = PAXIC_ADBW_BW64 | PAXIC_MAWIDD | PAXIC_MARIDD | PAXIC_OTL;
-   writel(tmp, mmio + AHCI_VEND_PAXIC);
-
-   /* Set AHCI Enable */
-   tmp = readl(mmio + HOST_CTL);
-   tmp |= HOST_AHCI_EN;
-   writel(tmp, mmio + HOST_CTL);
-
-   for (i = 0; i < NR_PORTS; i++) {
-   /* TPSS TPRS scalars, CISE and Port Addr */
-   tmp = PCFG_TPSS_VAL | PCFG_TPRS_VAL | (PCFG_PAD_VAL + i);
-   writel(tmp, mmio + AHCI_VEND_PCFG);
-
-   /* Port Phy Cfg register enables */
-   tmp = PPCFG_TTA | PPCFG_PSS_EN | PPCFG_ESDF_EN;
-   writel(tmp, mmio + AHCI_VEND_PPCFG);
 
-   /* Rx Watermark setting  */
+   switch (priv->soc) {
+   case CEVA_1V84:
+   tmp = PAXIC_ADBW_BW64 | PAXIC_MAWIDD | PAXIC_MARIDD | PAXIC_OTL;
+   writel(tmp, base + AHCI_VEND_PAXIC);
+   tmp = PCFG_TPSS_VAL | PCFG_TPRS_VAL | PCFG_PAD_VAL;
+   writel(tmp, base + AHCI_VEND_PCFG);
+   tmp = PPCFG_TTA | PPCFG_PSS_EN | PPCFG_ESDF_EN;
+   writel(tmp, base + AHCI_VEND_PPCFG);
tmp = PTC_RX_WM_VAL | PTC_RSVD;
-   writel(tmp, mmio + AHCI_VEND_PTC);
-
-   /* Default to Gen 2 Speed and Gen 1 if Gen2 is broken */
-   tmp = PORT_SCTL_SPD_GEN3 | PORT_SCTL_IPM;
-   writel(tmp, mmio + PORT_SCR_CTL + PORT_BASE + PORT_OFFSET * i);
+   writel(tmp, base + AHCI_VEND_PTC);
+   break;
+
+   case CEVA_LS1012A:
+   writel(ECC_DIS_ADDR_CH2, ECC_DIS_VAL_CH2);
+   writel(CEVA_PHY1_CFG, base + AHCI_VEND_PPCFG);
+   writel(CEVA_TRANS_CFG, base + AHCI_VEND_PTC);
+   if (priv->flag & FLAG_COHERENT)
+   writel(CEVA_AXICC_CFG, base + AHCI_VEND_AXICC);
+   break;
}
+
return 0;
 }
 
@@ -125,24 +138,34 @@ static int sata_ceva_probe(struct udevice *dev)
 {
struct ceva_sata_priv *priv = dev_get_priv(dev);
 
-   ceva_init_sata(priv->base);
+   ceva_init_sata(priv);
 
return ahci_probe_scsi(dev, priv->base);
 }
 
 static const struct udevice_id sata_ceva_ids[] = {
-   { .compatible = "ceva,ahci-1v84" },
+   { .compatible = "ceva,ahci-1v84", .data = CEVA_1V84 },
+   { .compatible = "fsl,ls1012a-ahci", .data = CEVA_LS1012A },
{ }
 };
 
 static int sata_ceva_ofdata_to_platdata(struct udevice *dev)
 {
struct ceva_sata_priv *priv = dev_get_priv(dev);
+   ofnode node = dev_ofnode(dev);
+
+   if (!ofnode_valid(node))
+   return -EINVAL;
+
+   if (ofnode_read_bool(node, "dma-coherent"))
+   priv->flag |= FLAG_COHERENT;
 
priv->base = devfdt_get_addr(dev);
if (priv->base == FDT_ADDR_T_NONE)
return -EINVAL;
 
+   priv->soc = dev_get_driver_data(dev);
+
return 0;
 }
 
-- 
1.7.1

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


[U-Boot] [PATCH 4/4] arm64: ls1012ardb: enable DM support for sata

2018-05-25 Thread andy.tang
From: Yuantian Tang 

Enable related configs to support sata DM feature.

Signed-off-by: Tang Yuantian 
---
 configs/ls1012ardb_qspi_defconfig |7 ++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/configs/ls1012ardb_qspi_defconfig 
b/configs/ls1012ardb_qspi_defconfig
index 6a8485c..7589431 100644
--- a/configs/ls1012ardb_qspi_defconfig
+++ b/configs/ls1012ardb_qspi_defconfig
@@ -30,7 +30,7 @@ CONFIG_OF_CONTROL=y
 CONFIG_ENV_IS_IN_SPI_FLASH=y
 CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_DM=y
-# CONFIG_BLK is not set
+CONFIG_BLK=y
 CONFIG_DM_MMC=y
 CONFIG_FSL_ESDHC=y
 CONFIG_DM_SPI_FLASH=y
@@ -51,3 +51,8 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_STORAGE=y
+CONFIG_DM_SCSI=y
+CONFIG_SATA_CEVA=y
+CONFIG_SCSI_AHCI=y
+CONFIG_SCSI=y
+CONFIG_AHCI=y
-- 
1.7.1

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


[U-Boot] [PATCH 2/4] armv8: dts: fsl-ls1012a: add sata node support

2018-05-25 Thread andy.tang
From: Yuantian Tang 

One ls1012a, there is one SATA 3.0 advanced host controller interface
which is a high-performance SATA solution that delivers comprehensive
and fully-compliant generation 3 (1.5 Gb/s - 6.0 Gb/s) serial ATA
capabilities, in accordance with the serial ATA revision 3.0 of Serial
ATA International Organization.
Add sata node to support this feature.

Signed-off-by: Tang Yuantian 
---
 arch/arm/dts/fsl-ls1012a-rdb.dtsi |4 
 arch/arm/dts/fsl-ls1012a.dtsi |8 
 2 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/arch/arm/dts/fsl-ls1012a-rdb.dtsi 
b/arch/arm/dts/fsl-ls1012a-rdb.dtsi
index 201e5fa..757e2eb 100644
--- a/arch/arm/dts/fsl-ls1012a-rdb.dtsi
+++ b/arch/arm/dts/fsl-ls1012a-rdb.dtsi
@@ -34,3 +34,7 @@
  {
status = "okay";
 };
+
+ {
+   status = "okay";
+};
diff --git a/arch/arm/dts/fsl-ls1012a.dtsi b/arch/arm/dts/fsl-ls1012a.dtsi
index be99076..f22cbf4 100644
--- a/arch/arm/dts/fsl-ls1012a.dtsi
+++ b/arch/arm/dts/fsl-ls1012a.dtsi
@@ -134,6 +134,14 @@
  0x8200 0x0 0x4000 0x40 0x4000 0x0 
0x4000>; /* non-prefetchable memory */
};
 
+   sata: sata@320 {
+   compatible = "fsl,ls1012a-ahci";
+   reg = <0x0 0x320 0x0 0x1>;
+   interrupts = <0 69 4>;
+   clocks = < 4 0>;
+   status = "disabled";
+   };
+
usb0: usb2@860 {
compatible = "fsl-usb2-dr-v2.5", "fsl-usb2-dr";
reg = <0x0 0x860 0x0 0x1000>;
-- 
1.7.1

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


[U-Boot] [PATCH 1/4] armv8: fsl: remove sata support

2018-05-25 Thread andy.tang
From: Yuantian Tang 

Remove the old implementation in order to enable DM for sata

Signed-off-by: Tang Yuantian 
---
 arch/arm/cpu/armv8/fsl-layerscape/soc.c|   54 
 arch/arm/include/asm/arch-fsl-layerscape/soc.h |   32 --
 2 files changed, 0 insertions(+), 86 deletions(-)

diff --git a/arch/arm/cpu/armv8/fsl-layerscape/soc.c 
b/arch/arm/cpu/armv8/fsl-layerscape/soc.c
index bfd6639..8028d52 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/soc.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/soc.c
@@ -6,8 +6,6 @@
 #include 
 #include 
 #include 
-#include 
-#include 
 #include 
 #include 
 #include 
@@ -330,36 +328,6 @@ void fsl_lsch3_early_init_f(void)
 #endif
 }
 
-#ifdef CONFIG_SCSI_AHCI_PLAT
-int sata_init(void)
-{
-   struct ccsr_ahci __iomem *ccsr_ahci;
-
-#ifdef CONFIG_SYS_SATA2
-   ccsr_ahci  = (void *)CONFIG_SYS_SATA2;
-   out_le32(_ahci->ppcfg, AHCI_PORT_PHY_1_CFG);
-   out_le32(_ahci->pp2c, AHCI_PORT_PHY2_CFG);
-   out_le32(_ahci->pp3c, AHCI_PORT_PHY3_CFG);
-   out_le32(_ahci->ptc, AHCI_PORT_TRANS_CFG);
-   out_le32(_ahci->axicc, AHCI_PORT_AXICC_CFG);
-#endif
-
-#ifdef CONFIG_SYS_SATA1
-   ccsr_ahci  = (void *)CONFIG_SYS_SATA1;
-   out_le32(_ahci->ppcfg, AHCI_PORT_PHY_1_CFG);
-   out_le32(_ahci->pp2c, AHCI_PORT_PHY2_CFG);
-   out_le32(_ahci->pp3c, AHCI_PORT_PHY3_CFG);
-   out_le32(_ahci->ptc, AHCI_PORT_TRANS_CFG);
-   out_le32(_ahci->axicc, AHCI_PORT_AXICC_CFG);
-
-   ahci_init((void __iomem *)CONFIG_SYS_SATA1);
-   scsi_scan(false);
-#endif
-
-   return 0;
-}
-#endif
-
 /* Get VDD in the unit mV from voltage ID */
 int get_core_volt_from_fuse(void)
 {
@@ -400,25 +368,6 @@ int get_core_volt_from_fuse(void)
 }
 
 #elif defined(CONFIG_FSL_LSCH2)
-#ifdef CONFIG_SCSI_AHCI_PLAT
-int sata_init(void)
-{
-   struct ccsr_ahci __iomem *ccsr_ahci = (void *)CONFIG_SYS_SATA;
-
-   /* Disable SATA ECC */
-   out_le32((void *)CONFIG_SYS_DCSR_DCFG_ADDR + 0x520, 0x8000);
-   out_le32(_ahci->ppcfg, AHCI_PORT_PHY_1_CFG);
-   out_le32(_ahci->pp2c, AHCI_PORT_PHY2_CFG);
-   out_le32(_ahci->pp3c, AHCI_PORT_PHY3_CFG);
-   out_le32(_ahci->ptc, AHCI_PORT_TRANS_CFG);
-   out_le32(_ahci->axicc, AHCI_PORT_AXICC_CFG);
-
-   ahci_init((void __iomem *)CONFIG_SYS_SATA);
-   scsi_scan(false);
-
-   return 0;
-}
-#endif
 
 static void erratum_a009929(void)
 {
@@ -719,9 +668,6 @@ int qspi_ahb_init(void)
 #ifdef CONFIG_BOARD_LATE_INIT
 int board_late_init(void)
 {
-#ifdef CONFIG_SCSI_AHCI_PLAT
-   sata_init();
-#endif
 #ifdef CONFIG_CHAIN_OF_TRUST
fsl_setenv_chain_of_trust();
 #endif
diff --git a/arch/arm/include/asm/arch-fsl-layerscape/soc.h 
b/arch/arm/include/asm/arch-fsl-layerscape/soc.h
index 9a219a6..6e3a420 100644
--- a/arch/arm/include/asm/arch-fsl-layerscape/soc.h
+++ b/arch/arm/include/asm/arch-fsl-layerscape/soc.h
@@ -85,39 +85,7 @@ struct cpu_type {
 #define SVR_DEV(svr)   ((svr) >> 8)
 #define IS_SVR_DEV(svr, dev)   (((svr) >> 16) == (dev))
 
-/* ahci port register default value */
-#define AHCI_PORT_PHY_1_CFG0xa003fffe
-#define AHCI_PORT_PHY2_CFG 0x28184d1f
-#define AHCI_PORT_PHY3_CFG 0x0e081509
-#define AHCI_PORT_TRANS_CFG0x0829
-#define AHCI_PORT_AXICC_CFG0x3fff
-
 #ifndef __ASSEMBLY__
-/* AHCI (sata) register map */
-struct ccsr_ahci {
-   u32 res1[0xa4/4];   /* 0x0 - 0xa4 */
-   u32 pcfg;   /* port config */
-   u32 ppcfg;  /* port phy1 config */
-   u32 pp2c;   /* port phy2 config */
-   u32 pp3c;   /* port phy3 config */
-   u32 pp4c;   /* port phy4 config */
-   u32 pp5c;   /* port phy5 config */
-   u32 axicc;  /* AXI cache control */
-   u32 paxic;  /* port AXI config */
-   u32 axipc;  /* AXI PROT control */
-   u32 ptc;/* port Trans Config */
-   u32 pts;/* port Trans Status */
-   u32 plc;/* port link config */
-   u32 plc1;   /* port link config1 */
-   u32 plc2;   /* port link config2 */
-   u32 pls;/* port link status */
-   u32 pls1;   /* port link status1 */
-   u32 pcmdc;  /* port CMD config */
-   u32 ppcs;   /* port phy control status */
-   u32 pberr;  /* port 0/1 BIST error */
-   u32 cmds;   /* port 0/1 CMD status error */
-};
-
 #ifdef CONFIG_FSL_LSCH3
 void fsl_lsch3_early_init_f(void);
 int get_core_volt_from_fuse(void);
-- 
1.7.1

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


[U-Boot] [PATCH] arm: Use mtune for Xscale

2018-05-25 Thread Alexey Brodkin
Otherwise with GCC 8 we see this warning [which is rendered to an error
with -Werror, which happens for buildman/travisci], see [1]:
--->8---
cc1: warning: switch -mcpu=xscale conflicts with -march=armv5te switch
--->8---

Interesting enough with GCC 7.3.0 (which is current default in buildman)
that change leads to another failure, see [2]:
--->8---
Error: selected processor does not support `pld [lr]' in ARM mode
--->8---

So I guess this change might be put in series with buildman toolchain
bump.

[1] https://travis-ci.org/abrodkin/u-boot/jobs/383219348
[2] https://travis-ci.org/abrodkin/u-boot/jobs/383594006

Signed-off-by: Alexey Brodkin 
Cc: Albert Aribaud 
---
 arch/arm/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 680c6e8516dc..18e0193c43c0 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -37,7 +37,7 @@ tune-$(CONFIG_CPU_ARM920T)=
 tune-$(CONFIG_CPU_ARM926EJS)   =
 tune-$(CONFIG_CPU_ARM946ES)=
 tune-$(CONFIG_CPU_SA1100)  =-mtune=strongarm1100
-tune-$(CONFIG_CPU_PXA) =-mcpu=xscale
+tune-$(CONFIG_CPU_PXA) =-mtune=xscale
 tune-$(CONFIG_CPU_ARM1136) =
 tune-$(CONFIG_CPU_ARM1176) =
 tune-$(CONFIG_CPU_V7A) =
-- 
2.17.0

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


Re: [U-Boot] [PATCH v1 1/2] buildman: Extract environment as part of each build

2018-05-25 Thread Alex Kiernan
On Fri, May 25, 2018 at 9:05 AM Lukasz Majewski  wrote:

> Hi Alex,

> > As we're building the boards, extract the default U-Boot environment
> > to uboot.env so we can interrogate it later.

> If applicable, you may also consider using:
> scripts/get_default_envs.sh

> script to extract default envs (to txt file).


I started with that, but then tripped over boards which have embedded
newlines in their environment variables, which then made parsing the
resulting text file much harder, which is why I swapped back to just using
the NUL terminated blob. Of course I can't now find the one I tripped over
to point at :(

> >
> > Signed-off-by: Alex Kiernan 
> > ---
> >
> >  tools/buildman/builderthread.py | 10 ++
> >  1 file changed, 10 insertions(+)
> >
> > diff --git a/tools/buildman/builderthread.py
> > b/tools/buildman/builderthread.py index 0efe80d945..688322ced2 100644
> > --- a/tools/buildman/builderthread.py
> > +++ b/tools/buildman/builderthread.py
> > @@ -351,6 +351,16 @@ class BuilderThread(threading.Thread):
> >  lines.append(size_result.stdout.splitlines()[1]
> > + ' ' + rodata_size)
> >
> > +# Extract the environment from U-Boot and dump it out
> > +cmd = ['%sobjcopy' % self.toolchain.cross, '-O',
> > 'binary',
> > +   '-j', '.rodata.default_environment',
> > +   'env/built-in.o', 'uboot.env']
> > +command.RunPipe([cmd], capture=False,
> > +capture_stderr=False, cwd=result.out_dir,
> > +raise_on_error=False, env=env)
> > +ubootenv = os.path.join(result.out_dir, 'uboot.env')
> > +self.CopyFiles(result.out_dir, build_dir, '',
> > ['uboot.env']) +
> >  # Write out the image sizes file. This is similar to the
> > output # of binutil's 'size' utility, but it omits the header line and
> >  # adds an additional hex value at the end of each line
> > for the




> Best regards,

> Lukasz Majewski

> --

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



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


Re: [U-Boot] [PATCH] malloc: Use malloc simple before malloc is fully initialized in memalign()

2018-05-25 Thread Ley Foon Tan
On Fri, May 25, 2018 at 11:33 AM, Simon Glass  wrote:
> Hi,
>
> On 24 May 2018 at 21:24, Ley Foon Tan  wrote:
>>
>> On Thu, May 24, 2018 at 12:33 AM, Simon Glass  wrote:
>> > Hi,
>> >
>> > On 23 May 2018 at 00:32, Ley Foon Tan  wrote:
>> >> On Sat, May 19, 2018 at 10:37 PM, Simon Glass  wrote:
>> >>> Hi Ley,
>> >>>
>> >>> On 18 May 2018 at 04:03, Ley Foon Tan  wrote:
>>  Follow implementation in mALLOc(). Check GD_FLG_FULL_MALLOC_INIT flag 
>>  and use
>>  malloc_simple if GD_FLG_FULL_MALLOC_INIT is unset. Adjust the malloc 
>>  bytes
>>  to align with the requested alignment.
>> 
>>  The original memalign() function will access mchunkptr struct to adjust 
>>  the
>>  alignment if there is misalignment happen, but mchunkptr struct is not 
>>  being
>>  initialized before full malloc is initialized. This cause the system 
>>  crash.
>> 
>>  Signed-off-by: Ley Foon Tan 
>>  ---
>>   common/dlmalloc.c |7 +++
>>   1 files changed, 7 insertions(+), 0 deletions(-)
>> 
>>  diff --git a/common/dlmalloc.c b/common/dlmalloc.c
>>  index b395eef..edaad29 100644
>>  --- a/common/dlmalloc.c
>>  +++ b/common/dlmalloc.c
>>  @@ -1891,6 +1891,13 @@ Void_t* mEMALIGn(alignment, bytes) size_t 
>>  alignment; size_t bytes;
>> 
>> if ((long)bytes < 0) return NULL;
>> 
>>  +#if CONFIG_VAL(SYS_MALLOC_F_LEN)
>> >>>
>> >>> How about:
>> >>>
>> >>> if (IS_ENABLED(CONFIG_SYS_MALLOC_F))
>> >>
>> >> I think this is the reason it uses #if CONFIG_VAL(SYS_MALLOC_F_LEN),
>> >> same for malloc().
>> >>
>> >> "spl: make SPL and normal u-boot stage use independent SYS_MALLOC_F_LEN"
>> >>
>> >> http://git.denx.de/?p=u-boot.git;a=commit;h=f1896c45cb2f7d8dbed27e784a6459a129fc0762
>> >
>> > So how about
>> >
>> > if (CONFIG_IS_ENABLED(SYS_MALLOC_F_LEN)
>> >
>> > Or you could use #if if you need to
>>
>> Tested both #if (CONFIG_IS_ENABLED(SYS_MALLOC_F_LEN)) and if
>> (CONFIG_IS_ENABLED(SYS_MALLOC_F_LEN)), both are not working.
>
> Sorry I mean
>
> CONFIG_IS_ENABLED(SYS_MALLOC_F)
>
> That tells you whether the feature is enabled in U-Boot or SPL.

#if CONFIG_IS_ENABLED(SYS_MALLOC_F) if not working in SPL build.
CONFIG_IS_ENABLED() expects config with "y" or "m", but SPL config is
with "1".
 Need to use #ifdef CONFIG_SYS_MALLOC_F. Do you want to change to this?

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


[U-Boot] [PATCH v3 1/2] cmd: nvedit: env import can now import only variables passed as parameters

2018-05-25 Thread Quentin Schulz
While the `env export` can take as parameters variables to be exported,
`env import` does not have such a mechanism of variable selection.

Let's add the ability to add parameters at the end of the command for
variables to be imported.

Every env variable from the env to be imported passed by parameter to
this command will override the value of the variable in the current env.

If a variable exists in the current env but not in the imported env, if
this variable is passed as a parameter to env import, the variable will
be unset.

If a variable exists in the imported env, the variable in the current
env will be set to the value of the one from the imported env.

All the remaining variables are left untouched.

As the size parameter of env import is positional but optional, let's
add the possibility to use the sentinel '-' for when we don't want to
give the size parameter (when the env is '\0' terminated) but we pass a
list of variables at the end of the command.

env import addr
env import addr -
env import addr size
env import addr - foo1 foo2
env import addr size foo1 foo2

are all valid.

env import -c addr
env import -c addr -
env import -c addr - foo1 foo2

are all invalid because they don't pass the size parameter required for
checking, while the following are valid.

env import addr size
env import addr size foo1 foo2

Nothing's changed for the other parameters or the overall behaviour.

One of its use case could be to load a secure environment from the
signed U-Boot binary and load only a handful of variables from an
other, unsecure, environment without completely losing control of
U-Boot.

Signed-off-by: Quentin Schulz 
---

v3:
  - migrate to env import addr size var... instead of env import -w addr
  size so that the list of variables to load is more explicit and the
  behaviour of env import is closer to the one of env export,

v2:
  - use strdup instead of malloc + strcpy,
  - NULL-check the result of strdup,
  - add common exit path for freeing memory in one unique place,
  - store token pointer from strtok within the char** array instead of
  strdup-ing token within elements of array,

 cmd/nvedit.c | 22 --
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/cmd/nvedit.c b/cmd/nvedit.c
index 11489b0..18cc4db 100644
--- a/cmd/nvedit.c
+++ b/cmd/nvedit.c
@@ -1001,7 +1001,7 @@ sep_err:

 #ifdef CONFIG_CMD_IMPORTENV
 /*
- * env import [-d] [-t [-r] | -b | -c] addr [size]
+ * env import [-d] [-t [-r] | -b | -c] addr [size] [var ...]
  * -d: delete existing environment before importing;
  * otherwise overwrite / append to existing definitions
  * -t: assume text format; either "size" must be given or the
@@ -1015,6 +1015,11 @@ sep_err:
  * addr:   memory address to read from
  * size:   length of input data; if missing, proper '\0'
  * termination is mandatory
+ * if var is set and size should be missing (i.e. '\0'
+ * termination), set size to '-'
+ * var...  List of the names of the only variables that get imported from
+ * the environment at address 'addr'. Without arguments, the whole
+ * environment gets imported.
  */
 static int do_env_import(cmd_tbl_t *cmdtp, int flag,
 int argc, char * const argv[])
@@ -1026,6 +1031,7 @@ static int do_env_import(cmd_tbl_t *cmdtp, int flag,
int fmt = 0;
int del = 0;
int crlf_is_lf = 0;
+   int wl = 0;
size_t  size;

cmd = *argv;
@@ -1074,9 +1080,9 @@ static int do_env_import(cmd_tbl_t *cmdtp, int flag,
addr = simple_strtoul(argv[0], NULL, 16);
ptr = map_sysmem(addr, 0);

-   if (argc == 2) {
+   if (argc >= 2 && strcmp(argv[1], "-")) {
size = simple_strtoul(argv[1], NULL, 16);
-   } else if (argc == 1 && chk) {
+   } else if (chk) {
puts("## Error: external checksum format must pass size\n");
return CMD_RET_FAILURE;
} else {
@@ -1098,6 +1104,9 @@ static int do_env_import(cmd_tbl_t *cmdtp, int flag,
printf("## Info: input data size = %zu = 0x%zX\n", size, size);
}

+   if (argc > 2)
+   wl = 1;
+
if (chk) {
uint32_t crc;
env_t *ep = (env_t *)ptr;
@@ -1112,9 +1121,10 @@ static int do_env_import(cmd_tbl_t *cmdtp, int flag,
ptr = (char *)ep->data;
}

-   if (himport_r(_htab, ptr, size, sep, del ? 0 : H_NOCLEAR,
-   crlf_is_lf, 0, NULL) == 0) {
+   if (!himport_r(_htab, ptr, size, sep, del ? 0 : H_NOCLEAR,
+  crlf_is_lf, wl ? argc - 2 : 0, wl ? [2] : NULL)) {
pr_err("Environment import failed: errno = %d\n", errno);
+
return 1;
}
gd->flags |= GD_FLG_ENV_READY;
@@ -1242,7 +1252,7 @@ static char env_help_text[] =
 #endif
 #endif
 #if 

[U-Boot] [PATCH v3 2/2] test/py: add test for whitelist of variables while importing environment

2018-05-25 Thread Quentin Schulz
This tests that the importing of an environment with a specified
whitelist works as intended.

If there are variables passed as parameter to the env import command,
   those only should be imported in the current environment.

For each variable passed as parameter, if
 - foo is bar in current env and bar2 in exported env, after importing
 exported env, foo shall be bar2,
 - foo does not exist in current env and foo is bar2 in exported env,
 after importing exported env, foo shall be bar2,
 - foo is bar in current env and does not exist in exported env (but is
 passed as parameter), after importing exported env, foo shall be empty,

Any variable not passed as parameter should be left untouched.

Two other tests are made to test that size cannot be '-' if the checksum
protection is enabled.

Signed-off-by: Quentin Schulz 
---

v3:
  - update whitelist test to reflect changes made in patch 1,
  - add two tests for no size parameter passed but checksum protection is
  enabled because I added the possibility to have a sentinel in place of
  size parameter,
  - I intentionally didn't put the Reviewed and Acked-by of Simon and
  Stephen since the code changed since v2,

added in v2

 test/py/tests/test_env.py | 50 -
 1 file changed, 50 insertions(+)

diff --git a/test/py/tests/test_env.py b/test/py/tests/test_env.py
index bfb5fc0..b83d2b1 100644
--- a/test/py/tests/test_env.py
+++ b/test/py/tests/test_env.py
@@ -5,6 +5,7 @@
 # Test operation of shell commands relating to environment variables.
 
 import pytest
+import u_boot_utils
 
 # FIXME: This might be useful for other tests;
 # perhaps refactor it into ConsoleBase or some other state object?
@@ -239,3 +240,52 @@ def test_env_expansion_spaces(state_test_env):
 unset_var(state_test_env, var_space)
 if var_test:
 unset_var(state_test_env, var_test)
+
+def test_env_import_checksum_no_size(state_test_env):
+"""Test that omitted ('-') size parameter with checksum validation fails 
the
+   env import function.
+"""
+c = state_test_env.u_boot_console
+ram_base = u_boot_utils.find_ram_base(state_test_env.u_boot_console)
+addr = '%08x' % ram_base
+
+with c.disable_check('error_notification'):
+response = c.run_command('env import -c %s -' % addr)
+assert(response == '## Error: external checksum format must pass size')
+
+def test_env_import_whitelist_checksum_no_size(state_test_env):
+"""Test that omitted ('-') size parameter with checksum validation fails 
the
+   env import function when variables are passed as parameters.
+"""
+c = state_test_env.u_boot_console
+ram_base = u_boot_utils.find_ram_base(state_test_env.u_boot_console)
+addr = '%08x' % ram_base
+
+with c.disable_check('error_notification'):
+response = c.run_command('env import -c %s - foo1 foo2 foo4' % addr)
+assert(response == '## Error: external checksum format must pass size')
+
+def test_env_import_whitelist(state_test_env):
+"""Test importing only a handful of env variables from an environment."""
+c = state_test_env.u_boot_console
+ram_base = u_boot_utils.find_ram_base(state_test_env.u_boot_console)
+addr = '%08x' % ram_base
+
+set_var(state_test_env, "foo1", "bar1")
+set_var(state_test_env, "foo2", "bar2")
+set_var(state_test_env, "foo3", "bar3")
+
+c.run_command('env export %s' % addr)
+
+unset_var(state_test_env, "foo1")
+set_var(state_test_env, "foo2", "test2")
+set_var(state_test_env, "foo4", "bar4")
+
+#no foo1 in current env, foo2 overridden, foo3 should be of the value
+#before exporting and foo4 should be deleted
+c.run_command('env import %s - foo1 foo2 foo4' % addr)
+
+validate_set(state_test_env, "foo1", "bar1")
+validate_set(state_test_env, "foo2", "bar2")
+validate_set(state_test_env, "foo3", "bar3")
+validate_empty(state_test_env, "foo4")
-- 
git-series 0.9.1
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v1 1/2] buildman: Extract environment as part of each build

2018-05-25 Thread Lukasz Majewski
Hi Alex,

> As we're building the boards, extract the default U-Boot environment
> to uboot.env so we can interrogate it later.

If applicable, you may also consider using:
scripts/get_default_envs.sh

script to extract default envs (to txt file).

> 
> Signed-off-by: Alex Kiernan 
> ---
> 
>  tools/buildman/builderthread.py | 10 ++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/tools/buildman/builderthread.py
> b/tools/buildman/builderthread.py index 0efe80d945..688322ced2 100644
> --- a/tools/buildman/builderthread.py
> +++ b/tools/buildman/builderthread.py
> @@ -351,6 +351,16 @@ class BuilderThread(threading.Thread):
>  lines.append(size_result.stdout.splitlines()[1]
> + ' ' + rodata_size)
>  
> +# Extract the environment from U-Boot and dump it out
> +cmd = ['%sobjcopy' % self.toolchain.cross, '-O',
> 'binary',
> +   '-j', '.rodata.default_environment',
> +   'env/built-in.o', 'uboot.env']
> +command.RunPipe([cmd], capture=False,
> +capture_stderr=False, cwd=result.out_dir,
> +raise_on_error=False, env=env)
> +ubootenv = os.path.join(result.out_dir, 'uboot.env')
> +self.CopyFiles(result.out_dir, build_dir, '',
> ['uboot.env']) +
>  # Write out the image sizes file. This is similar to the
> output # of binutil's 'size' utility, but it omits the header line and
>  # adds an additional hex value at the end of each line
> for the




Best regards,

Lukasz Majewski

--

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


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


[U-Boot] [PATCH v4 1/4] ata: mvebu: move mvebu sata driver to drivers/ata directory

2018-05-25 Thread make
From: Ken Ma 

Currently mvebu sata driver is in arch/arm/mach_mvebu directory, this
patch moves it to drivers/ata directory with renaming "sata.c" to
"ahci_mvebu.c" which is aligned to Linux.
New ahci driver's kconfig option is added as AHCI_MVEBU which selects
SCSI_AHCI and is based on AHCI.

Signed-off-by: Ken Ma 
Reviewed-by: Stefan Roese 
Reviewed-by: Simon Glass 
---

Changes in v4:
- Base on the latest mainline git version
- Let AHCI_MVEBU depend on AHCI and select SCSI_AHCI
ahci_mvebu driver is based on AHCI UCLASS, so let AHCI_MVEBU based on
AHCI; and this driver uses ahci_init() in ahci.c, so let it select
SCSI_AHCI. In this patch, DM_SCSI is not selected and it will be
selected in the later patch which adds scsi support by creating a SCSI
device as a child of mvebu ahci device.

Changes in v3:
- Use the new SPDX tags

Changes in v2:
- Add MAINTAINERS updating

 MAINTAINERS|  1 +
 arch/arm/mach-mvebu/Makefile   |  1 -
 drivers/ata/Kconfig| 10 ++
 drivers/ata/Makefile   |  1 +
 arch/arm/mach-mvebu/sata.c => drivers/ata/ahci_mvebu.c |  0
 5 files changed, 12 insertions(+), 1 deletion(-)
 rename arch/arm/mach-mvebu/sata.c => drivers/ata/ahci_mvebu.c (100%)

diff --git a/MAINTAINERS b/MAINTAINERS
index 5670917..cd40dbd 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -135,6 +135,7 @@ S:  Maintained
 T: git git://git.denx.de/u-boot-marvell.git
 F: arch/arm/mach-kirkwood/
 F: arch/arm/mach-mvebu/
+F: drivers/ata/ahci_mvebu.c
 
 ARM MARVELL PXA
 M: Marek Vasut 
diff --git a/arch/arm/mach-mvebu/Makefile b/arch/arm/mach-mvebu/Makefile
index 3b9a811..ade7b87 100644
--- a/arch/arm/mach-mvebu/Makefile
+++ b/arch/arm/mach-mvebu/Makefile
@@ -7,7 +7,6 @@ ifdef CONFIG_ARM64
 obj-$(CONFIG_ARMADA_3700) += armada3700/
 obj-$(CONFIG_ARMADA_8K) += armada8k/
 obj-y += arm64-common.o
-obj-$(CONFIG_AHCI) += sata.o
 
 else # CONFIG_ARM64
 
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index 86ec628..36e1748 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -99,4 +99,14 @@ config SATA_SIL3114
help
  Enable this driver to support the SIL3114 SATA controllers.
 
+config AHCI_MVEBU
+   bool "Marvell EBU AHCI SATA support"
+   depends on ARCH_MVEBU
+   depends on AHCI
+   select SCSI_AHCI
+   help
+ This option enables support for the Marvell EBU SoC's
+ onboard AHCI SATA.
+
+ If unsure, say N.
 endmenu
diff --git a/drivers/ata/Makefile b/drivers/ata/Makefile
index 02f02c8..10bed53 100644
--- a/drivers/ata/Makefile
+++ b/drivers/ata/Makefile
@@ -17,3 +17,4 @@ obj-$(CONFIG_SATA_MV) += sata_mv.o
 obj-$(CONFIG_SATA_SIL3114) += sata_sil3114.o
 obj-$(CONFIG_SATA_SIL) += sata_sil.o
 obj-$(CONFIG_SANDBOX) += sata_sandbox.o
+obj-$(CONFIG_AHCI_MVEBU) += ahci_mvebu.o
diff --git a/arch/arm/mach-mvebu/sata.c b/drivers/ata/ahci_mvebu.c
similarity index 100%
rename from arch/arm/mach-mvebu/sata.c
rename to drivers/ata/ahci_mvebu.c
-- 
1.9.1

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


[U-Boot] [PATCH v4 0/4] ahci mvebu driver updates

2018-05-25 Thread make
From: Ken Ma 


These patches move ahci mvebu driver to drivers/ata directory with bug
fixing and scsi supporting.

Changes in v4:
- Base on the latest mainline git version
- Let AHCI_MVEBU depend on AHCI and select SCSI_AHCI
ahci_mvebu driver is based on AHCI UCLASS, so let AHCI_MVEBU based on
AHCI; and this driver uses ahci_init() in ahci.c, so let it select
SCSI_AHCI. In this patch, DM_SCSI is not selected and it will be
selected in the later patch which adds scsi support by creating a SCSI
device as a child of mvebu ahci device.
- Let AHCI_MVEBU select DM_SCSI
This patch adds scsi support by creating a SCSI device as a child of
mvebu ahci device; the functions of creating SCSI device need the
kconfig option DM_SCSI, so let AHCI_MVEBU select DM_SCSI.
- Remove CONFIG_AHCI_MVEBU from marvell arm64 default config files
Since AHCI_MVEBU selects SCSI_AHCI and it is added into marvell arm64
default config files, so CONFIG_SCSI_AHCI is removed.

Changes in v3:
- Use the new SPDX tags

Changes in v2:
- Add MAINTAINERS updating

David Sniatkiwicz (1):
  ata: ahci_mvebu: a8040 a0: remove bad port register offsets
workarounds

Ken Ma (3):
  ata: mvebu: move mvebu sata driver to drivers/ata directory
  ata: ahci_mvebu: add scsi support
  arm64: mvebu: defconfig: enable CONFIG_AHCI_MVEBU

 MAINTAINERS   |  1 +
 arch/arm/mach-mvebu/Makefile  |  1 -
 configs/mvebu_db-88f3720_defconfig|  2 +-
 configs/mvebu_db_armada8k_defconfig   |  2 +-
 configs/mvebu_espressobin-88f3720_defconfig   |  2 +-
 configs/mvebu_mcbin-88f8040_defconfig |  2 +-
 drivers/ata/Kconfig   | 11 +++
 drivers/ata/Makefile  |  1 +
 .../arm/mach-mvebu/sata.c => drivers/ata/ahci_mvebu.c | 19 +--
 9 files changed, 30 insertions(+), 11 deletions(-)
 rename arch/arm/mach-mvebu/sata.c => drivers/ata/ahci_mvebu.c (71%)

-- 
1.9.1

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


[U-Boot] [PATCH v4 3/4] ata: ahci_mvebu: add scsi support

2018-05-25 Thread make
From: Ken Ma 

Mvebu AHCI is AHCI driver which uses SCSI under the hood.
This patch adjusts AHCI setup to support SCSI by creating
a SCSI device as a child. Since the functions of creating
SCSI device need the kconfig option DM_SCSI, so let
AHCI_MVEBU select DM_SCSI.

Signed-off-by: Ken Ma 
Reviewed-by: Stefan Roese 
Reviewed-by: Simon Glass 
---

Changes in v4:
- Let AHCI_MVEBU select DM_SCSI
This patch adds scsi support by creating a SCSI device as a child of
mvebu ahci device; the functions of creating SCSI device need the
kconfig option DM_SCSI, so let AHCI_MVEBU select DM_SCSI.

Changes in v3: None
Changes in v2: None

 drivers/ata/Kconfig  |  1 +
 drivers/ata/ahci_mvebu.c | 17 -
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index 36e1748..49a056e 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -104,6 +104,7 @@ config AHCI_MVEBU
depends on ARCH_MVEBU
depends on AHCI
select SCSI_AHCI
+   select DM_SCSI
help
  This option enables support for the Marvell EBU SoC's
  onboard AHCI SATA.
diff --git a/drivers/ata/ahci_mvebu.c b/drivers/ata/ahci_mvebu.c
index c1d215f..6e3f17e 100644
--- a/drivers/ata/ahci_mvebu.c
+++ b/drivers/ata/ahci_mvebu.c
@@ -16,6 +16,20 @@ __weak int board_ahci_enable(void)
return 0;
 }
 
+static int mvebu_ahci_bind(struct udevice *dev)
+{
+   struct udevice *scsi_dev;
+   int ret;
+
+   ret = ahci_bind_scsi(dev, _dev);
+   if (ret) {
+   debug("%s: Failed to bind (err=%d\n)", __func__, ret);
+   return ret;
+   }
+
+   return 0;
+}
+
 static int mvebu_ahci_probe(struct udevice *dev)
 {
/*
@@ -24,7 +38,7 @@ static int mvebu_ahci_probe(struct udevice *dev)
 */
board_ahci_enable();
 
-   ahci_init(devfdt_get_addr_ptr(dev));
+   ahci_probe_scsi(dev, (ulong)devfdt_get_addr_ptr(dev));
 
return 0;
 }
@@ -39,5 +53,6 @@ U_BOOT_DRIVER(ahci_mvebu_drv) = {
.name   = "ahci_mvebu",
.id = UCLASS_AHCI,
.of_match   = mvebu_ahci_ids,
+   .bind   = mvebu_ahci_bind,
.probe  = mvebu_ahci_probe,
 };
-- 
1.9.1

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


[U-Boot] [PATCH v4 4/4] arm64: mvebu: defconfig: enable CONFIG_AHCI_MVEBU

2018-05-25 Thread make
From: Ken Ma 

This patch enables the new ahci mvebu driver for marvell arm64 platform
SOCs(A3k and A8k). And since AHCI_MVEBU selects SCSI_AHCI, so
"CONFIG_SCSI_AHCI=y" is removed from those default config files.

Signed-off-by: Ken Ma 
Reviewed-by: Stefan Roese 
Reviewed-by: Simon Glass 
---

Changes in v4:
- Remove CONFIG_AHCI_MVEBU from marvell arm64 default config files
Since AHCI_MVEBU selects SCSI_AHCI and it is added into marvell arm64
default config files, so CONFIG_SCSI_AHCI is removed.

Changes in v3: None
Changes in v2: None

 configs/mvebu_db-88f3720_defconfig  | 2 +-
 configs/mvebu_db_armada8k_defconfig | 2 +-
 configs/mvebu_espressobin-88f3720_defconfig | 2 +-
 configs/mvebu_mcbin-88f8040_defconfig   | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/configs/mvebu_db-88f3720_defconfig 
b/configs/mvebu_db-88f3720_defconfig
index e6f7cb9..4ba287f 100644
--- a/configs/mvebu_db-88f3720_defconfig
+++ b/configs/mvebu_db-88f3720_defconfig
@@ -30,7 +30,7 @@ CONFIG_CMD_MVEBU_BUBT=y
 CONFIG_CMD_EXT4_WRITE=y
 CONFIG_MAC_PARTITION=y
 CONFIG_ENV_IS_IN_SPI_FLASH=y
-CONFIG_SCSI_AHCI=y
+CONFIG_AHCI_MVEBU=y
 CONFIG_BLOCK_CACHE=y
 CONFIG_DM_GPIO=y
 # CONFIG_MVEBU_GPIO is not set
diff --git a/configs/mvebu_db_armada8k_defconfig 
b/configs/mvebu_db_armada8k_defconfig
index 63f2103..b7694ec 100644
--- a/configs/mvebu_db_armada8k_defconfig
+++ b/configs/mvebu_db_armada8k_defconfig
@@ -30,7 +30,7 @@ CONFIG_CMD_MVEBU_BUBT=y
 CONFIG_CMD_EXT4_WRITE=y
 CONFIG_MAC_PARTITION=y
 CONFIG_ENV_IS_IN_SPI_FLASH=y
-CONFIG_SCSI_AHCI=y
+CONFIG_AHCI_MVEBU=y
 CONFIG_BLOCK_CACHE=y
 CONFIG_DM_I2C=y
 CONFIG_SYS_I2C_MVTWSI=y
diff --git a/configs/mvebu_espressobin-88f3720_defconfig 
b/configs/mvebu_espressobin-88f3720_defconfig
index 5a6d1e6..db11e51 100644
--- a/configs/mvebu_espressobin-88f3720_defconfig
+++ b/configs/mvebu_espressobin-88f3720_defconfig
@@ -30,7 +30,7 @@ CONFIG_CMD_MVEBU_BUBT=y
 CONFIG_CMD_EXT4_WRITE=y
 CONFIG_MAC_PARTITION=y
 CONFIG_ENV_IS_IN_SPI_FLASH=y
-CONFIG_SCSI_AHCI=y
+CONFIG_AHCI_MVEBU=y
 CONFIG_BLOCK_CACHE=y
 CONFIG_DM_GPIO=y
 CONFIG_DM_I2C=y
diff --git a/configs/mvebu_mcbin-88f8040_defconfig 
b/configs/mvebu_mcbin-88f8040_defconfig
index de682d1..545bb4f 100644
--- a/configs/mvebu_mcbin-88f8040_defconfig
+++ b/configs/mvebu_mcbin-88f8040_defconfig
@@ -32,7 +32,7 @@ CONFIG_CMD_REGULATOR=y
 CONFIG_CMD_EXT4_WRITE=y
 CONFIG_MAC_PARTITION=y
 CONFIG_ENV_IS_IN_SPI_FLASH=y
-CONFIG_SCSI_AHCI=y
+CONFIG_AHCI_MVEBU=y
 CONFIG_BLOCK_CACHE=y
 CONFIG_DM_GPIO=y
 CONFIG_DM_I2C=y
-- 
1.9.1

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


[U-Boot] [PATCH v4 2/4] ata: ahci_mvebu: a8040 a0: remove bad port register offsets workarounds

2018-05-25 Thread make
From: David Sniatkiwicz 

This workaround was added for A8040/7040 A0.
A8040/7040 A0 is no longer supported so this workaround
can be removed.

Signed-off-by: David Sniatkiwicz 
Signed-off-by: Ken Ma 
Reviewed-by: Stefan Roese 
Reviewed-by: Simon Glass 
---

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

 drivers/ata/ahci_mvebu.c | 8 
 1 file changed, 8 deletions(-)

diff --git a/drivers/ata/ahci_mvebu.c b/drivers/ata/ahci_mvebu.c
index 3ae8dae..c1d215f 100644
--- a/drivers/ata/ahci_mvebu.c
+++ b/drivers/ata/ahci_mvebu.c
@@ -16,14 +16,6 @@ __weak int board_ahci_enable(void)
return 0;
 }
 
-#ifdef CONFIG_ARMADA_8K
-/* CP110 has different AHCI port addresses */
-void __iomem *ahci_port_base(void __iomem *base, u32 port)
-{
-   return base + 0x1 + (port * 0x1);
-}
-#endif
-
 static int mvebu_ahci_probe(struct udevice *dev)
 {
/*
-- 
1.9.1

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


[U-Boot] [PATCH v4 1/4] ata: mvebu: move mvebu sata driver to drivers/ata directory

2018-05-25 Thread make
From: Ken Ma 

Currently mvebu sata driver is in arch/arm/mach_mvebu directory, this
patch moves it to drivers/ata directory with renaming "sata.c" to
"ahci_mvebu.c" which is aligned to Linux.
New ahci driver's kconfig option is added as AHCI_MVEBU which selects
SCSI_AHCI and is based on AHCI.

Signed-off-by: Ken Ma 
Reviewed-by: Stefan Roese 
Reviewed-by: Simon Glass 
ahci_mvebu driver is based on AHCI UCLASS, so let AHCI_MVEBU based on
AHCI; and this driver uses ahci_init() in ahci.c, so let it select
SCSI_AHCI. In this patch, DM_SCSI is not selected and it will be
selected in the later patch which adds scsi support by creating a SCSI
device as a child of mvebu ahci device.

---

Changes in v4:
- Base on the latest mainline git version
- Let AHCI_MVEBU depend on AHCI and select SCSI_AHCI

Changes in v3:
- Use the new SPDX tags

Changes in v2:
- Add MAINTAINERS updating

 MAINTAINERS|  1 +
 arch/arm/mach-mvebu/Makefile   |  1 -
 drivers/ata/Kconfig| 10 ++
 drivers/ata/Makefile   |  1 +
 arch/arm/mach-mvebu/sata.c => drivers/ata/ahci_mvebu.c |  0
 5 files changed, 12 insertions(+), 1 deletion(-)
 rename arch/arm/mach-mvebu/sata.c => drivers/ata/ahci_mvebu.c (100%)

diff --git a/MAINTAINERS b/MAINTAINERS
index 5670917..cd40dbd 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -135,6 +135,7 @@ S:  Maintained
 T: git git://git.denx.de/u-boot-marvell.git
 F: arch/arm/mach-kirkwood/
 F: arch/arm/mach-mvebu/
+F: drivers/ata/ahci_mvebu.c
 
 ARM MARVELL PXA
 M: Marek Vasut 
diff --git a/arch/arm/mach-mvebu/Makefile b/arch/arm/mach-mvebu/Makefile
index 3b9a811..ade7b87 100644
--- a/arch/arm/mach-mvebu/Makefile
+++ b/arch/arm/mach-mvebu/Makefile
@@ -7,7 +7,6 @@ ifdef CONFIG_ARM64
 obj-$(CONFIG_ARMADA_3700) += armada3700/
 obj-$(CONFIG_ARMADA_8K) += armada8k/
 obj-y += arm64-common.o
-obj-$(CONFIG_AHCI) += sata.o
 
 else # CONFIG_ARM64
 
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index 86ec628..36e1748 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -99,4 +99,14 @@ config SATA_SIL3114
help
  Enable this driver to support the SIL3114 SATA controllers.
 
+config AHCI_MVEBU
+   bool "Marvell EBU AHCI SATA support"
+   depends on ARCH_MVEBU
+   depends on AHCI
+   select SCSI_AHCI
+   help
+ This option enables support for the Marvell EBU SoC's
+ onboard AHCI SATA.
+
+ If unsure, say N.
 endmenu
diff --git a/drivers/ata/Makefile b/drivers/ata/Makefile
index 02f02c8..10bed53 100644
--- a/drivers/ata/Makefile
+++ b/drivers/ata/Makefile
@@ -17,3 +17,4 @@ obj-$(CONFIG_SATA_MV) += sata_mv.o
 obj-$(CONFIG_SATA_SIL3114) += sata_sil3114.o
 obj-$(CONFIG_SATA_SIL) += sata_sil.o
 obj-$(CONFIG_SANDBOX) += sata_sandbox.o
+obj-$(CONFIG_AHCI_MVEBU) += ahci_mvebu.o
diff --git a/arch/arm/mach-mvebu/sata.c b/drivers/ata/ahci_mvebu.c
similarity index 100%
rename from arch/arm/mach-mvebu/sata.c
rename to drivers/ata/ahci_mvebu.c
-- 
1.9.1

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


[U-Boot] [PATCH v4 0/4] ahci mvebu driver updates

2018-05-25 Thread make
From: Ken Ma 


These patches move ahci mvebu driver to drivers/ata directory with bug
fixing and scsi supporting.

Changes in v4:
- Base on the latest mainline git version
- Let AHCI_MVEBU depend on AHCI and select SCSI_AHCI
- Let AHCI_MVEBU select DM_SCSI
- Remove CONFIG_AHCI_MVEBU from marvell arm64 default config files

Changes in v3:
- Use the new SPDX tags

Changes in v2:
- Add MAINTAINERS updating

David Sniatkiwicz (1):
  ata: ahci_mvebu: a8040 a0: remove bad port register offsets
workarounds

Ken Ma (3):
  ata: mvebu: move mvebu sata driver to drivers/ata directory
  ata: ahci_mvebu: add scsi support
  arm64: mvebu: defconfig: enable CONFIG_AHCI_MVEBU

 MAINTAINERS   |  1 +
 arch/arm/mach-mvebu/Makefile  |  1 -
 configs/mvebu_db-88f3720_defconfig|  2 +-
 configs/mvebu_db_armada8k_defconfig   |  2 +-
 configs/mvebu_espressobin-88f3720_defconfig   |  2 +-
 configs/mvebu_mcbin-88f8040_defconfig |  2 +-
 drivers/ata/Kconfig   | 11 +++
 drivers/ata/Makefile  |  1 +
 .../arm/mach-mvebu/sata.c => drivers/ata/ahci_mvebu.c | 19 +--
 9 files changed, 30 insertions(+), 11 deletions(-)
 rename arch/arm/mach-mvebu/sata.c => drivers/ata/ahci_mvebu.c (71%)

-- 
1.9.1

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


  1   2   >