Re: [U-Boot] [PATCH v1 06/11] spi: stm32_qspi: Update mode management

2018-04-30 Thread Jagan Teki
On Thu, Apr 26, 2018 at 8:35 PM, Patrice Chotard  wrote:
> From: Christophe Kerello 
>
> We face issue on Macronix/Spansion spi nors due to bad mode management.
> We solve these issues using following mode configurations:
>  - read_cmd = CMD_READ_QUAD_OUTPUT_FAST => 1-1-4
>  - read_cmd = CMD_READ_DUAL_OUTPUT_FAST => 1-1-2
>  - write_cmd = CMD_QUAD_PAGE_PROGRAM => 1-1-4
>  - others commands => 1-1-1
>
> Signed-off-by: Christophe Kerello 
> Signed-off-by: Patrice Chotard 
> ---
>
>  drivers/spi/stm32_qspi.c | 30 ++
>  1 file changed, 18 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/spi/stm32_qspi.c b/drivers/spi/stm32_qspi.c
> index 6b7232905bc8..46915194f034 100644
> --- a/drivers/spi/stm32_qspi.c
> +++ b/drivers/spi/stm32_qspi.c
> @@ -156,6 +156,10 @@ enum STM32_QSPI_CCR_FMODE {
>  /* default SCK frequency, unit: HZ */
>  #define STM32_QSPI_DEFAULT_SCK_FREQ 10800
>
> +#define STM32_CMD_READ_DUAL_OUTPUT_FAST0x3b
> +#define STM32_CMD_READ_QUAD_OUTPUT_FAST0x6b
> +#define STM32_CMD_QUAD_PP  0x32

NAK, pls don't add flash changes in spi.

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


Re: [U-Boot] Appended DTB Android boot image support

2018-04-30 Thread Ramon Fried
On Tue, May 1, 2018 at 2:12 AM, Simon Glass  wrote:
> Hi Ramon,
>
> On 30 April 2018 at 07:04, Ramon Fried  wrote:
>> Hi all.
>> I'm currently adding support for Qualcomm Dragonboards  to U-boot as a
>> primary bootloader without chain-loading using LK which is currently
>> already supported in mainline U-boot.
>>
>> Qualcomm Android images are regular android images where the DTB's are
>> appended to the image. Qualcomm used the "unused" field in the image
>> header to populate the size of the DTB *.
>>
>> I'm looking for a more standard version for supporting these kind of images.
>> Currently, to boot these images, you must provide DTB somewhere in mem
>> and provide it as argument to bootm for instance.
>>
>> My goal is to add support that U-boot will parse the image, see that
>> the DTB is included and use that as the FDT automatically.
>>
>> I'm looking at the "secondary" fields which are currently not used as
>> a valid option to point to the DTB and it's size.
>>
>> Do you know if someone is working on something similar, or do you have
>> any suggestions for the right approach to this issue ?
>
> Have you thought of using FIT? It suppose multiple DTB files, multiple
> kernels, compression, etc. and is readily extensible.
It's an option I'm considering, but I think it will much more suitable
to keep the
android image format, this way I could support fastboot and also still
use qualcomm proprietary tools
for flashing the images in the right place.

I did notice also that building uImage in Linux kernel doesn't work on
arm64 targets, did I miss something ?
>
> Regards,
> Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2 0/5] sunxi: Add support for ALL-H3-CC H2+/H5 variants

2018-04-30 Thread Jagan Teki
On Sat, Apr 28, 2018 at 11:05 AM, Chen-Yu Tsai  wrote:
> Hi,
>
> This is v2 of the ALL-H3-CC H2+/H5 variants series.
>
> Changes since v1:
>
>   - Renamed common board .dtsi to follow what was merged in Linux
>   - Fixed error in Makefile
>   - Collected acks from Maxime
>
> Original cover letter:
>
>
> This series is adds support for the H2+ and H5 variants of the Libre
> Computer Project ALL-H3-CC board. The board uses the same board design
> with the H2+, H3, and H5 SoCs, with different memory capacities. The
> H3 version was supported in v2018.03.
>
> The Linux Kernel patch submissions for these two boards can be found
> here: https://lkml.org/lkml/2018/4/24/312
>
> The device tree changes are not synced from the kernel. Rather, the
> same changes are applied to U-boot's copy. First the ALL-H3-CC dts
> is split into a common board design dtsi, and a H3 specific dts.
> Then the H2+ and H5 versions are added, reusing the same dtsi file.
>
> Patch 1 disables R_I2C and SPL_I2C for the ALL-H3-CC. Turns out there
> is no use for it.
>
> Patch 2 splits the ALL-H3-CC dts file into a common board design dtsi,
> and a H3 specific dts.
>
> Patch 3 adds support for the H2+ variant of ALL-H3-CC.
>
> Patch 4 adds support for the H5 variant of ALL-H3-CC.
>
> Patch 5 is an unrelated cleanup patch for the dts Makefile. It might or
> might not conflict if sent separately, depending on how much diff context
> git uses, so I'm sending it together.
>
> Please have a look.
>
>
> Chen-Yu Tsai (5):
>   sunxi: Disable R_I2C for Libre Computer Board ALL-H3-CC H3 ver.
>   sunxi: Split out common board design for ALL-H3-CC device tree
>   sunxi: Add Libre Computer Board ALL-H3-CC H2+ ver.
>   sunxi: Add Libre Computer Board ALL-H3-CC H5 ver.
>   sunxi: Sort dts Makefile entries for H3

Reviewed-by: Jagan Teki 

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


Re: [U-Boot] Logo for U-Boot

2018-04-30 Thread Marek Vasut
On 04/30/2018 08:22 PM, Heinrich Schuchardt wrote:
> U-Boot has currently no logo that we can use in presentations.
> 
> On the U-Boot IRC channel the following propositions where made:
> 
> Source: https://commons.wikimedia.org/wiki/File:Circle-icons-submarine.svg
> License: GPL2+
> (Alex used this in some presentations.)

Yellow submarine, nice.

Maybe we should make it a bit more toward teal and orange to improve the
contrast ? Although, maybe just replacing the depressive gray background
with a light blue one would do.

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


Re: [U-Boot] [PATCH v10 3/3] Adding wget

2018-04-30 Thread Joe Hershberger
On Sat, Apr 14, 2018 at 6:43 PM,   wrote:
> From: Duncan Hare 
>
> Why http and wget:
>
> HTTP is the most efficient file retrieval protocol in common
> use. The client send a single request, after TCP connection,
> to receive a file of any length.
>
> WGET is the application which implements http file transfer
> outside browsers as a file transfer protocol. Versions of
> wget exists on many operating systems.
> END
>
> Signed-off-by: Duncan Hare 
> ---
>
> Changes in v10: None
>
>  cmd/Kconfig|   5 +
>  cmd/net.c  |  13 ++
>  include/net.h  |  16 +-
>  include/net/wget.h |  17 +++
>  net/Kconfig|   7 +-
>  net/Makefile   |   1 +
>  net/wget.c | 420 
> +
>  7 files changed, 470 insertions(+), 9 deletions(-)
>  create mode 100644 include/net/wget.h
>  create mode 100644 net/wget.c
>
> diff --git a/cmd/Kconfig b/cmd/Kconfig
> index 136836d146..1113d69950 100644
> --- a/cmd/Kconfig
> +++ b/cmd/Kconfig
> @@ -1094,6 +1094,11 @@ config CMD_ETHSW
>   operations such as enabling / disabling a port and
>   viewing/maintaining the filtering database (FDB)
>
> +config CMD_WGET
> +   bool "wget"
> +   select TCP
> +   help
> + Download a kernel, or other files, from a web server over TCP.
>  endif
>
>  endmenu
> diff --git a/cmd/net.c b/cmd/net.c
> index d7c776aacf..6a7a51f357 100644
> --- a/cmd/net.c
> +++ b/cmd/net.c
> @@ -110,6 +110,19 @@ U_BOOT_CMD(
>  );
>  #endif
>
> +#if defined(CONFIG_CMD_WGET)
> +static int do_wget(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
> +{
> +   return netboot_common(WGET, cmdtp, argc, argv);
> +}
> +
> +U_BOOT_CMD(
> +   wget,   3,  1,  do_wget,
> +   "boot image via network using HTTP protocol",
> +   "[loadAddress] [[hostIPaddr:]path and image name]"
> +);
> +#endif
> +
>  static void netboot_update_env(void)
>  {
> char tmp[22];
> diff --git a/include/net.h b/include/net.h
> index e29d804a23..ec44bf2bec 100644
> --- a/include/net.h
> +++ b/include/net.h
> @@ -15,10 +15,14 @@
>  #include 
>  #include  /* for nton* / ntoh* stuff */
>
> -#define DEBUG_LL_STATE  0  /* Link local state machine changes */
> -#define DEBUG_DEV_PKT   0  /* Packets or info directed to the device */
> +#define DEBUG_LL_STATE  0  /* Link local state machine changes*/
> +#define DEBUG_DEV_PKT   0  /* Packets or info directed to the device  */
>  #define DEBUG_NET_PKT   0  /* Packets on info on the network at large */
> -#define DEBUG_INT_STATE 0  /* Internal network state changes */
> +#define DEBUG_INT_STATE 0  /* Internal network state change   */

Random formatting change... also changed differently in a former patch
if I recall.

> +
> +#if defined(CONFIG_TCP)

Why would a #define need to be protected?

> +#define CONFIG_SYS_RX_ETH_BUFFER 12 /* For TCP */
> +#endif
>
>  /*
>   * The number of receive packet buffers, and the required packet buffer
> @@ -31,10 +35,6 @@
>   * data, the sending TCP will stop sending.
>   */
>
> -#if defined(CONFIG_TCP)
> -#define CONFIG_SYS_RX_ETH_BUFFER 12/* For TCP */
> -#endif

Why not just put it in the proper place in the TCP patch instead of
moving it later?

> -
>  #ifdef CONFIG_SYS_RX_ETH_BUFFER
>  # define PKTBUFSRX CONFIG_SYS_RX_ETH_BUFFER
>  #else
> @@ -362,8 +362,8 @@ struct vlan_ethernet_hdr {
>  #define PROT_PPP_SES   0x8864  /* PPPoE session messages   */
>
>  #define IPPROTO_ICMP1  /* Internet Control Message Protocol*/
> +#define IPPROTO_TCP  6  /* Transmission Control Protocol*/
>  #define IPPROTO_UDP17  /* User Datagram Protocol   */
> -#define IPPROTO_TCP 6  /* Transmission Control Protocol*/

Yeah... same thing... Looks like you didn't ignore me when I made this
in an earlier version, you just applied the change to the wrong patch.

>
>  /*
>   * Internet Protocol (IP) header.
> diff --git a/include/net/wget.h b/include/net/wget.h
> new file mode 100644
> index 00..dce16c573d
> --- /dev/null
> +++ b/include/net/wget.h
> @@ -0,0 +1,17 @@
> +/*
> + * Duncan Hare Copyright 2017
> + */
> +
> +void wget_start(void); /* Begin wget */
> +
> +enum WGET_STATE {
> +   WGET_CLOSED,
> +   WGET_CONNECTING,
> +   WGET_CONNECTED,
> +   WGET_TRANSFERRING,
> +   WGET_TRANSFERRED};

Closing brace on its own line.

> +
> +#defineDEBUG_WGET  0   /* Set to 1 for debug messges 
> */
> +#defineSERVER_PORT 80
> +#defineWGET_RETRY_COUNT30
> +#defineWGET_TIMEOUT2000UL
> diff --git a/net/Kconfig b/net/Kconfig
> index cc6dd83fc4..c973def3b8 100644
> --- a/net/Kconfig
> +++ b/net/Kconfig
> @@ -36,7 +36,12 @@ config NET_TFTP_VARS
>  config TCP
> bool "Include Subset TCP stack 

Re: [U-Boot] [PATCH v10 0/3] Why netboot:

2018-04-30 Thread Joe Hershberger
On Sat, Apr 14, 2018 at 6:43 PM,   wrote:
> From: Duncan Hare 
>
> Central management, including logs and change control,
> coupled with with enhanced security and unauthorized
> change detection and remediation by exposing a
> small attack surface.
>
> Why TCP:
>
> Currently file transfer are done using tftp or NFS both
> over udp. This requires a request to be sent from client
> (u-boot) to the boot server.
>
> For a 4 Mbyte kernel, with a 1k block size this requires
> 4,000 request for a block.
>
> Using a large block size, one greater than the Ethernet
> maximum frame size limitation, would require fragmentation,
> which u-boot supports. However missing fragment recovery
> requires timeout detection and re-transmission requests
> for missing fragments.
>
> UDP is ideally suited to fast single packet exchanges,
> inquiry/response, for example dns, becuse of the lack of
> connection overhead.
>
> UDP as a file transport mechanism is slow, even in low
> latency networks, because file transfer with udp requires
> poll/response mechanism to provide transfer integrity.
>
> In networks with large latency, for example: the internet,
> UDP is even slower. What is a 30 second transfer on a local
> boot server and LAN increase to over 3 minutes, because of
> all the requests/response traffic.
>
> This was anticipated in the evolution of the IP protocols
> and TCP was developed and then enhanced for high latency high
> bandwidth networks.
>
> The current standard is TCP with selective acknowledgment.
>
> In our testing we have reduce kernel transmission time to
> around 0.4 seconds for a 4Mbyte kernel, with a 100 Mbps
> downlink.
>
> Why http and wget:
>
> HTTP is the most efficient file retrieval protocol in common
> use. The client send a single request, after TCP connection,
> to receive a file of any length.
>
> WGET is the application which implements http file transfer
> outside browsers as a file transfer protocol. Versions of
> wget exists on many operating systems.
>
> Changes in v10:
> Initial changes for adding TCP
>
> Duncan Hare (3):
>   Adding TCP and wget into u-boot
>   Adding TCP
>   Adding wget

From https://www.denx.de/wiki/U-Boot/Patches
"""
Use the imperative tense in your summary line (e.g., "Add support for
X" rather than "Adds support for X"). In general, you can think of the
summary line as "this commit is meant to 'Add support for X'"
"""

These patch subjects don't comply.

>
>  cmd/Kconfig|   5 +
>  cmd/net.c  |  13 +
>  include/net.h  |  33 ++-
>  include/net/tcp.h  | 218 
>  include/net/wget.h |  17 ++
>  net/Kconfig|  10 +
>  net/Makefile   |   3 +-
>  net/net.c  |  89 +--
>  net/ping.c |   9 +-
>  net/tcp.c  | 749 
> +
>  net/wget.c | 420 ++
>  11 files changed, 1532 insertions(+), 34 deletions(-)
>  create mode 100644 include/net/tcp.h
>  create mode 100644 include/net/wget.h
>  create mode 100644 net/tcp.c
>  create mode 100644 net/wget.c
>
> --
> 2.11.0
>
> ___
> U-Boot mailing list
> U-Boot@lists.denx.de
> https://lists.denx.de/listinfo/u-boot
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v10 3/3] Adding wget

2018-04-30 Thread Joe Hershberger
On Wed, Apr 25, 2018 at 6:52 PM, Duncan Hare  wrote:
>
>
>From: Simon Glass 
>  To: Duncan Hare 
> Cc: Wolfgang Denk ; U-Boot Mailing List ; 
> Joe Hershberger 
>  Sent: Wednesday, April 25, 2018 4:44 PM
>  Subject: Re: [PATCH v10 3/3] Adding wget
>
> Hi Duncan,
>
> On 25 April 2018 at 08:33, Duncan Hare  wrote:
> 
>>> From: Simon Glass 
>>> To: Duncan Hare 
>>> Cc: U-Boot Mailing List ; Joe Hershberger
>>> 
>>> Sent: Tuesday, April 24, 2018 10:01 PM
>>> Subject: Re: [PATCH v10 3/3] Adding wget
>>>
>>> Hi Duncan,
>>>
 On 22 April 2018 at 21:22, Duncan Hare  wrote:

>The server can be tested with the wget command which
> can be installed on linux.
> I doubt that loop-back like this will produce the scrambling of packet
> order
> which is a feature of push down stacks for packet queues
> in the internet.
>
> Hence my comment in a different thread about buffering on the pi. Few of
> the
> socs appear to use net_pkt_buf  buffers for net traffic.
>
> If there are too many transmission errors the sending tcp drops the
> connection. My solution to this is to halve the size of
> CONFIG_SYS_RX_ETH_BUFFER until transmission works.
>
 >
> Possibly CONFIG_SYS_RX_ETH_BUFFER could come under Kconfig.

Just to be clear, I was wondering about having an automated test. Manual
> tests are not very useful since people won't do them. See 'make tests' for
> all the test that we >currently >run. I'm pretty sure you could standard 
> up
> a little server, run your wget, then shut it down, all within a pytest 
> test.
>>>
>>>
>Regards,
>Simon
>>>
>>> Hi Wolfgang. Simon
>>>
>>> Can we put a test 4 Mbyte kernel on the u-boot website for an automated test
>>> for other users of TCP & Wget in u-boot?
>>>
>>> Then I can produce a standard u-boot script for testing.
>
>>How about the test just creates a little (4KB) file. We don't want the
>>tests to access a real network, if possible, just use localhost.

This makes it portable to where ever the test is run.

>
>>Regards,
>>Simon
> 4k is 4 packets. I believe most kernels are larger.
> I was think of a static server set up with a known dns name.
> Thta's what I've got.
>
> Do the test setup once.

This assume accessibility to this Internet server and that this server
is up /still configured when the test runs.

Please setup a test that can run in an environment without the
Internet. That is critical for unit tests.

Hand tests for Internet usage and the environmental effects are great,
but that can't be what we include in the auto tests for repeat-ability
reasons. Simon is asking for a separate type of test.

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


Re: [U-Boot] [PATCH v10 3/3] Adding wget

2018-04-30 Thread Joe Hershberger
On Tue, Apr 17, 2018 at 10:10 AM, Simon Glass  wrote:
> Hi Duncan,
>
> On 14 April 2018 at 17:43,   wrote:
>> From: Duncan Hare 
>>
>> Why http and wget:
>>
>> HTTP is the most efficient file retrieval protocol in common
>> use. The client send a single request, after TCP connection,
>> to receive a file of any length.
>>
>> WGET is the application which implements http file transfer
>> outside browsers as a file transfer protocol. Versions of
>> wget exists on many operating systems.
>> END
>
> Why END?

I would assume that (from reading this blurb) this is really a series
cover letter and the END would terminate that... so the Cover-letter:
tag is probably malformed.

Which begs the question, where the actual log is for the wget patch?

>>
>> Signed-off-by: Duncan Hare 
>> ---
>>
>> Changes in v10: None
>
> There is no change log here. Has nothing changed since v1?

Duncan has been struggling to use patman effectively.

>
> This code looks OK to me, but please can you run it through patman? I
> see what look like some style errors.

This is after using patman since v2 or so.

>
> How can we create a test for this? Can we add something to test_net.py ?
>
> Regards,
> Simon
> ___
> U-Boot mailing list
> U-Boot@lists.denx.de
> https://lists.denx.de/listinfo/u-boot
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v10 2/3] Adding TCP

2018-04-30 Thread Joe Hershberger
Hi Duncan,

On Sat, Apr 14, 2018 at 6:43 PM,   wrote:
> From: Duncan Hare 
>
> All the code is new, and not copied from any source.
>
> Series-changes
> The previous patch was using an old version of net/Kconfig,
> which prevented requesting options for a bootp/dhcp request.
>
> A similar issue fixed with a cmd/Kconfig.
> Items in include/net.h fixed.

Please follow the format as listed in the patman README:
"""
Series-changes: n
- Guinea pig moved into its cage
- Other changes ending with a blank line

This can appear in any commit. It lists the changes for a
particular version n of that commit. The change list is
created based on this information. Each commit gets its own
change list and also the whole thing is repeated in the cover
letter (where duplicate change lines are merged).

By adding your change lists into your commits it is easier to
keep track of what happened. When you amend a commit, remember
to update the log there and then, knowing that the script will
do the rest.
"""

When you make changes to the patches based on my feedback, add to the
list of changes for version 11 as you make the changes so you won't
forget anything.

> Signed-off-by: Duncan Hare 
> Signed-off-by: Duncan Hare 
> ---
>
> Why TCP:
>
> Currently file transfer are done using tftp or NFS both
> over udp. This requires a request to be sent from client
> (u-boot) to the boot server.
>
> For a 4 Mbyte kernel, with a 1k block size this requires
> 4,000 request for a block.
>
> Using a large block size, one greater than the Ethernet
> maximum frame size limitation, would require fragmentation,
> which u-boot supports. However missing fragment recovery
> requires timeout detection and re-transmission requests
> for missing fragments.
>
> In networks with large latency, for example: the internet,
> UDP is vwey slow. What is a 30 second transfer on a local
> boot server and LAN increase to over 3 minutes, because of
> all the requests/response traffic.
>
> This was anticipated in the evolution of the IP protocols
> and TCP was developed and then enhanced for high latency high
> bandwidth networks.
>
> The current standard is TCP with selective acknowledgment.

You make no mention in the commit log of this patch supporting
selective ack or not. Honestly, all of this description (above this
line) seems like info that should actually stay in the patch's log,
not in a note.

> Routine tcp_print_buffer() is used to print portions of
> non zero terminated buffers. If there is an existing routine
> please let me know. I'm from the world of length fields
> not zero terminated strings (zOS).
>
>
> Changes in v10: None
>
>  include/net.h |   8 +-
>  include/net/tcp.h | 218 
>  net/Kconfig   |   5 +
>  net/Makefile  |   2 +-
>  net/net.c |  51 +++-
>  net/tcp.c | 749 
> ++
>  6 files changed, 1023 insertions(+), 10 deletions(-)
>  create mode 100644 include/net/tcp.h
>  create mode 100644 net/tcp.c
>
> diff --git a/include/net.h b/include/net.h
> index 7e5f5a6a5b..e29d804a23 100644
> --- a/include/net.h
> +++ b/include/net.h
> @@ -548,7 +548,7 @@ extern int  net_restart_wrap;   /* Tried all 
> network devices */
>
>  enum proto_t {
> BOOTP, RARP, ARP, TFTPGET, DHCP, PING, DNS, NFS, CDP, NETCONS, SNTP,
> -   TFTPSRV, TFTPPUT, LINKLOCAL
> +   TFTPSRV, TFTPPUT, LINKLOCAL, WGET

Seems like this should be in the WGET patch, right?

>  };
>
>  extern charnet_boot_file_name[1024];/* Boot File name */
> @@ -681,11 +681,15 @@ static inline void net_send_packet(uchar *pkt, int len)
>   * @param payload_len Length of data after the UDP header
>   */
>  int net_send_ip_packet(uchar *ether, struct in_addr dest, int dport, int 
> sport,
> -  int payload_len, int proto);
> +  int payload_len, int proto, u8 action, u32 tcp_seq_num,
> +  u32 tcp_ack_num);
>
>  int net_send_udp_packet(uchar *ether, struct in_addr dest, int dport,
> int sport, int payload_len);
>
> +int net_send_tcp_packet(int payload_len, int dport, int sport, u8 action,
> +   u32 tcp_seq_num, u32 tcp_ack_num);
> +
>  /* Processes a received packet */
>  void net_process_received_packet(uchar *in_packet, int len);
>
> diff --git a/include/net/tcp.h b/include/net/tcp.h
> new file mode 100644
> index 00..81f263351e
> --- /dev/null
> +++ b/include/net/tcp.h
> @@ -0,0 +1,218 @@
> +/*
> + * TCP Support for file transfer.
> + *
> + * Copyright 2017 Duncan Hare, All rights reserved.
> + *
> + *  SPDX-License-Identifier:GPL-2.0
> + */
> +
> +#define TCP_ACTIVITY 127   /* Activity on downloading  */

What is the meaning of this number? Number of packets before the
console adds a 

Re: [U-Boot] [PATCH v2 06/10] timer: Add MPC83xx timer driver

2018-04-30 Thread Simon Glass
Hi Mario,

On 27 April 2018 at 06:52, Mario Six  wrote:
> Add a timer driver for the MPC83xx architecture.
>
> Signed-off-by: Mario Six 
>
> ---
>
> v1 -> v2:
> * Removed now-superfluous comments
> * Removed usage of uclass_{first,next}_device_compat
> * Switched to usage of new board uclass (instead of devinfo)
>
> ---
>  arch/powerpc/cpu/mpc83xx/cpu.c |   4 +-
>  arch/powerpc/lib/Makefile  |   4 ++
>  arch/powerpc/lib/interrupts.c  |   5 +-
>  drivers/timer/Kconfig  |   7 ++
>  drivers/timer/Makefile |   1 +
>  drivers/timer/mpc83xx_timer.c  | 160 
> +
>  6 files changed, 178 insertions(+), 3 deletions(-)
>  create mode 100644 drivers/timer/mpc83xx_timer.c

Reviewed-by: Simon Glass 

Please see below.

>
> diff --git a/arch/powerpc/cpu/mpc83xx/cpu.c b/arch/powerpc/cpu/mpc83xx/cpu.c
> index 9a5c1b7d55..376483eda7 100644
> --- a/arch/powerpc/cpu/mpc83xx/cpu.c
> +++ b/arch/powerpc/cpu/mpc83xx/cpu.c
> @@ -176,12 +176,12 @@ do_reset (cmd_tbl_t * cmdtp, int flag, int argc, char * 
> const argv[])
>  /*
>   * Get timebase clock frequency (like cpu_clk in Hz)
>   */
> -
> +#ifndef CONFIG_TIMER
>  unsigned long get_tbclk(void)
>  {
> return (gd->bus_clk + 3L) / 4L;
>  }
> -
> +#endif
>
>  #if defined(CONFIG_WATCHDOG)
>  void watchdog_reset (void)
> diff --git a/arch/powerpc/lib/Makefile b/arch/powerpc/lib/Makefile
> index 9a3043abf8..537693e3bc 100644
> --- a/arch/powerpc/lib/Makefile
> +++ b/arch/powerpc/lib/Makefile
> @@ -19,13 +19,17 @@ endif
>
>  ifdef MINIMAL
>  obj-y += cache.o time.o
> +ifndef CONFIG_TIMER
>  obj-y += ticks.o
> +endif
>  else
>
>  obj-y  += ppcstring.o
>
>  obj-y  += ppccache.o
> +ifndef CONFIG_TIMER
>  obj-y  += ticks.o
> +endif
>  obj-y  += reloc.o
>
>  obj-$(CONFIG_BAT_RW) += bat_rw.o
> diff --git a/arch/powerpc/lib/interrupts.c b/arch/powerpc/lib/interrupts.c
> index e8784aa16e..56a697d28c 100644
> --- a/arch/powerpc/lib/interrupts.c
> +++ b/arch/powerpc/lib/interrupts.c
> @@ -15,6 +15,7 @@
>  #include 
>  #endif
>
> +#ifndef CONFIG_MPC83XX_TIMER
>  #ifdef CONFIG_SHOW_ACTIVITY
>  void board_show_activity (ulong) __attribute__((weak, 
> alias("__board_show_activity")));
>
> @@ -45,7 +46,7 @@ static __inline__ void set_dec (unsigned long val)
> if (val)
> asm volatile ("mtdec %0"::"r" (val));
>  }
> -
> +#endif /* !CONFIG_MPC83XX_TIMER */
>
>  void enable_interrupts (void)
>  {
> @@ -61,6 +62,7 @@ int disable_interrupts (void)
> return ((msr & MSR_EE) != 0);
>  }
>
> +#ifndef CONFIG_MPC83XX_TIMER
>  int interrupt_init (void)
>  {
> /* call cpu specific function from $(CPU)/interrupts.c */
> @@ -103,3 +105,4 @@ ulong get_timer (ulong base)
>  {
> return (timestamp - base);
>  }
> +#endif /* !CONFIG_MPC83XX_TIMER */
> diff --git a/drivers/timer/Kconfig b/drivers/timer/Kconfig
> index 2c96896726..1b78ce784a 100644
> --- a/drivers/timer/Kconfig
> +++ b/drivers/timer/Kconfig
> @@ -126,4 +126,11 @@ config STM32_TIMER
>   Select this to enable support for the timer found on
>   STM32 devices.
>
> +config MPC83XX_TIMER
> +bool "MPC83xx timer support"
> +   depends on TIMER
> +   help
> + Select this to enable support for the timer found on
> + devices based on the MPC83xx family of SoCs.
> +
>  endmenu
> diff --git a/drivers/timer/Makefile b/drivers/timer/Makefile
> index a6e7832154..d35d235195 100644
> --- a/drivers/timer/Makefile
> +++ b/drivers/timer/Makefile
> @@ -17,3 +17,4 @@ obj-$(CONFIG_ATCPIT100_TIMER) += atcpit100_timer.o
>  obj-$(CONFIG_ROCKCHIP_TIMER) += rockchip_timer.o
>  obj-$(CONFIG_ATMEL_PIT_TIMER) += atmel_pit_timer.o
>  obj-$(CONFIG_STM32_TIMER)  += stm32_timer.o
> +obj-$(CONFIG_MPC83XX_TIMER) += mpc83xx_timer.o
> diff --git a/drivers/timer/mpc83xx_timer.c b/drivers/timer/mpc83xx_timer.c
> new file mode 100644
> index 00..c3dd306c5b
> --- /dev/null
> +++ b/drivers/timer/mpc83xx_timer.c
> @@ -0,0 +1,160 @@
> +/*
> + * (C) Copyright 2018
> + * Mario Six, Guntermann & Drunck GmbH, mario@gdsys.cc
> + *
> + * SPDX-License-Identifier:GPL-2.0+
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +struct mpc83xx_timer_priv {
> +};
> +
> +static uint decrementer_count; /* count value for 1e6/HZ microseconds */

Have a static var in BSS means it cannot be used before relocation, or
in SPL, right?

> +
> +static inline unsigned long get_dec(void)
> +{
> +   unsigned long val;
> +
> +   asm volatile ("mfdec %0":"=r" (val):);
> +
> +   return val;
> +}
> +
> +static inline void set_dec(unsigned long val)
> +{
> +   if (val)
> +   asm volatile ("mtdec %0"::"r" (val));
> +}
> +
> +/* TODO(mario@gdsys.cc): This should really be done by timer_init, and 
> the
> + * interrupt init should go into a interrupt driver.
> + */
> +int interrupt_init(void)
> +{
> +   immap_t *immr = 

Re: [U-Boot] [PATCH v10 1/3] Adding TCP and wget into u-boot

2018-04-30 Thread Joe Hershberger
Hi Duncan,

Please change the subject of this patch to: "Prepare to add TCP and wget"

On Sat, Apr 14, 2018 at 6:43 PM,   wrote:
> From: Duncan Hare 

Include in the body of the log a high-level description, such as:
"Consolidating UDP header functions to make it easier to add TCP
versions of the same, while reusing the IP portions. This patch should
not change any behaviors."

>
> Signed-off-by: Duncan Hare 
> ---
>
> Added a protocol parameter to ip packet sending in net.c
> Added UDP protocol for current applications to minimize
> code changes to existing net apps.
>
> All the code is new, and not copied from any source.
>
>
> Changes in v10:
> Initial changes for adding TCP
>
>  include/net.h | 25 +++--
>  net/net.c | 52 ++--
>  net/ping.c|  9 ++---
>  3 files changed, 55 insertions(+), 31 deletions(-)
>
> diff --git a/include/net.h b/include/net.h
> index 455b48f6c7..7e5f5a6a5b 100644
> --- a/include/net.h
> +++ b/include/net.h
> @@ -15,17 +15,26 @@
>  #include 
>  #include  /* for nton* / ntoh* stuff */
>
> -#define DEBUG_LL_STATE 0   /* Link local state machine changes */
> -#define DEBUG_DEV_PKT 0/* Packets or info directed to the 
> device */
> -#define DEBUG_NET_PKT 0/* Packets on info on the network at 
> large */
> +#define DEBUG_LL_STATE  0  /* Link local state machine changes */
> +#define DEBUG_DEV_PKT   0  /* Packets or info directed to the device */
> +#define DEBUG_NET_PKT   0  /* Packets on info on the network at large */

If you want to do general formatting cleanup, please put it in a
separate patch (as patch 1).

>  #define DEBUG_INT_STATE 0  /* Internal network state changes */
>
>  /*
>   * The number of receive packet buffers, and the required packet buffer
>   * alignment in memory.
>   *
> + * The number of buffers for TCP is used to calculate a static TCP window
> + * size, becuse TCP window size is a promise to the sending TCP to be 
> able
> + * to buffer up to the window size of data.
> + * When the sending TCP has a window size of outstanding unacknowledged
> + * data, the sending TCP will stop sending.

Please add this in the TCP patch.

>   */
>
> +#if defined(CONFIG_TCP)
> +#define CONFIG_SYS_RX_ETH_BUFFER 12/* For TCP */

That comment is unnecessary... it is obvious from the ifdef
surrounding it. Remove the comment.

> +#endif
> +
>  #ifdef CONFIG_SYS_RX_ETH_BUFFER
>  # define PKTBUFSRX CONFIG_SYS_RX_ETH_BUFFER
>  #else
> @@ -354,6 +363,7 @@ struct vlan_ethernet_hdr {
>
>  #define IPPROTO_ICMP1  /* Internet Control Message Protocol*/
>  #define IPPROTO_UDP17  /* User Datagram Protocol   */
> +#define IPPROTO_TCP 6  /* Transmission Control Protocol*/

Don't add this define in this patch. Save it for the TCP patch. When
you do add it, do so in numerical order.

>
>  /*
>   * Internet Protocol (IP) header.
> @@ -596,10 +606,10 @@ int net_set_ether(uchar *xet, const uchar 
> *dest_ethaddr, uint prot);
>  int net_update_ether(struct ethernet_hdr *et, uchar *addr, uint prot);
>
>  /* Set IP header */
> -void net_set_ip_header(uchar *pkt, struct in_addr dest, struct in_addr 
> source);
> +void net_set_ip_header(uchar *pkt, struct in_addr dest, struct in_addr 
> source,
> +  u16  pkt_len, u8 prot);
>  void net_set_udp_header(uchar *pkt, struct in_addr dest, int dport,
> -   int sport, int len);
> -
> +   int sport, int len);

This is just a formatting change.

>  /**
>   * compute_ip_checksum() - Compute IP checksum
>   *
> @@ -670,6 +680,9 @@ static inline void net_send_packet(uchar *pkt, int len)
>   * @param sport Source UDP port
>   * @param payload_len Length of data after the UDP header
>   */
> +int net_send_ip_packet(uchar *ether, struct in_addr dest, int dport, int 
> sport,
> +  int payload_len, int proto);
> +

Separating with a blank line here and removing it above. Why the inconsistency?

>  int net_send_udp_packet(uchar *ether, struct in_addr dest, int dport,
> int sport, int payload_len);
>
> diff --git a/net/net.c b/net/net.c
> index 4259c9e321..df4e7317e7 100644
> --- a/net/net.c
> +++ b/net/net.c
> @@ -181,6 +181,7 @@ int net_ntp_time_offset;
>  static uchar net_pkt_buf[(PKTBUFSRX+1) * PKTSIZE_ALIGN + PKTALIGN];
>  /* Receive packets */
>  uchar *net_rx_packets[PKTBUFSRX];
> +

Random formatting change.

>  /* Current UDP RX packet handler */
>  static rxhand_f *udp_packet_handler;
>  /* Current ARP RX packet handler */
> @@ -777,11 +778,23 @@ void net_set_timeout_handler(ulong iv, thand_f *f)
>  }
>
>  int net_send_udp_packet(uchar *ether, struct in_addr dest, int dport, int 
> sport,
> -   int payload_len)
> +   int 

Re: [U-Boot] [PATCH] regmap: add regmap_update_bits() helper

2018-04-30 Thread Simon Glass
Hi Neil,

On 26 April 2018 at 09:23, Neil Armstrong  wrote:
> Hi,
>
> On 26/04/2018 16:40, Simon Glass wrote:
>> Hi Neil,
>>
>> On 23 April 2018 at 08:16, Neil Armstrong  wrote:
>>> Add the regmap_update_bits() to simply the read/modify/write of registers
>>> in a single command. The function is taken from Linux regmap
>>> implementation.
>>>
>>> Signed-off-by: Neil Armstrong 
>>> ---
>>>  include/regmap.h | 23 +++
>>>  1 file changed, 23 insertions(+)
>>>
>>> diff --git a/include/regmap.h b/include/regmap.h
>>> index 493a5d8..3c463e9 100644
>>> --- a/include/regmap.h
>>> +++ b/include/regmap.h
>>> @@ -47,6 +47,29 @@ int regmap_read(struct regmap *map, uint offset, uint 
>>> *valp);
>>> regmap_read(map, (uint32_t *)(ptr)->member - (uint32_t *)(ptr), 
>>> valp)
>>>
>>>  /**
>>> + * regmap_update_bits() - Perform a read/modify/write using a mask
>>> + *
>>> + * @map:   The map returned by regmap_init_mem*()
>>> + * @offset:Offset of the memory
>>> + * @mask:  Mask to apply to the read value
>>> + * @val:   Value to apply to the value to write
>>> + */
>>> +static inline int regmap_update_bits(struct regmap *map, uint offset,
>>> +uint mask, uint val)
>>
>> Why is this inline? I think it would save code size to make it a
>> normal function.
>
> Seemed a good idea, but I'll move it to the uclass.
>
>>
>> Also can you add a call to this function somewhere for sandbox, as a test?
>
> I did not find any test for regmap_read/write for sandbox, or maybe I missed 
> it.
>

No, that's why I'm asking :-)

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


Re: [U-Boot] [PATCH v2 2/2] test: regmap: add read/modify/write test

2018-04-30 Thread Simon Glass
On 27 April 2018 at 03:56, Neil Armstrong  wrote:
> Add calls to regmap_read/modify_bits/write even if the proper memory
> read/write calls are not executed in sandbox.
>
> Signed-off-by: Neil Armstrong 
> ---
>  test/dm/regmap.c | 24 
>  1 file changed, 24 insertions(+)

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


Re: [U-Boot] [PATCH v2 1/4] core: Add functions to set properties in live-tree

2018-04-30 Thread Simon Glass
Hi Mario,

On 27 April 2018 at 06:51, Mario Six  wrote:
>
> Implement a set of functions to manipulate properties in a live device
> tree:
>
> * ofnode_set_property() to set generic properties of a node
> * ofnode_write_string() to set string properties of a node
> * ofnode_set_enabled() to either enable or disable a node
>
> Signed-off-by: Mario Six 
>
> ---
>
> v1 -> v2:
> * Fix potential NULL pointer dereference in ofnode_write_property
>
> ---
>  drivers/core/ofnode.c | 58 
> +++
>  include/dm/ofnode.h   | 37 
>  2 files changed, 95 insertions(+)

Reviewed-by: Simon Glass 

But please see below.

>
> diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c
> index 5909a25f85..a55aa75e5b 100644
> --- a/drivers/core/ofnode.c
> +++ b/drivers/core/ofnode.c
> @@ -687,3 +687,61 @@ u64 ofnode_translate_address(ofnode node, const fdt32_t 
> *in_addr)
> else
> return fdt_translate_address(gd->fdt_blob, 
> ofnode_to_offset(node), in_addr);
>  }
> +
> +#ifdef CONFIG_OF_LIVE
> +int ofnode_write_property(ofnode node, const char *propname, int len,
> + const void *value)
> +{
> +   const struct device_node *np = ofnode_to_np(node);
> +   struct property *pp;
> +   struct property *pp_last = NULL;
> +   struct property *new;
> +
> +   if (!np)
> +   return -EINVAL;
> +
> +   for (pp = np->properties; pp; pp = pp->next) {
> +   if (strcmp(pp->name, propname) == 0) {
> +   /* Property exists -> change value */
> +   pp->value = (void *)value;
> +   pp->length = len;
> +   return 0;
> +   }
> +   pp_last = pp;
> +   }
> +
> +   if (!pp_last)
> +   return -ENOENT;
> +
> +   /* Property does not exist -> append new property */
> +   new = malloc(sizeof(struct property));
> +
> +   new->name = strdup(propname);
> +   new->value = malloc(len);
> +   memcpy(new->value, value, len);

To me it seems odd that you allocate space for the value here, but
above (in the loop) you just assign it.

> +   new->length = len;
> +   new->next = NULL;
> +
> +   pp_last->next = new;
> +
> +   return 0;
> +}
> +
> +int ofnode_write_string(ofnode node, const char *propname, const char *value)
> +{
> +   assert(ofnode_valid(node));
> +   debug("%s: %s = %s", __func__, propname, value);
> +
> +   return ofnode_write_property(node, propname, strlen(value) + 1, 
> value);
> +}
> +
> +int ofnode_set_enabled(ofnode node, bool value)
> +{
> +   assert(ofnode_valid(node));
> +
> +   if (value)
> +   return ofnode_write_string(node, "status", "okay");
> +   else
> +   return ofnode_write_string(node, "status", "disable");
> +}
> +#endif
> diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h
> index 0d008404f9..9224d583fc 100644
> --- a/include/dm/ofnode.h
> +++ b/include/dm/ofnode.h
> @@ -681,4 +681,41 @@ int ofnode_read_resource_byname(ofnode node, const char 
> *name,
>   * @return the translated address; OF_BAD_ADDR on error
>   */
>  u64 ofnode_translate_address(ofnode node, const fdt32_t *in_addr);
> +
> +/**
> + * ofnode_write_property() - Set a property of a ofnode
> + *
> + * @node:  The node for whose property should be set
> + * @propname:  The name of the property to set
> + * @len:   The length of the new value of the property
> + * @value: The new value of the property

Need to mention if this is copied or if the pointer needs to remain
valid forever.

> + * @return 0 if successful, -ve on error
> + */
> +int ofnode_write_property(ofnode node, const char *propname, int len,
> + const void *value);
> +
> +/**
> + * ofnode_write_string() - Set a string property of a ofnode
> + *
> + * @node:  The node for whose string property should be set
> + * @propname:  The name of the string property to set
> + * @value: The new value of the string property

Same here

> + * @return 0 if successful, -ve on error
> + */
> +int ofnode_write_string(ofnode node, const char *propname, const char 
> *value);
> +
> +/**
> + * ofnode_set_enabled() - Enable or disable a device tree node given by its 
> ofnode
> + *
> + * This function effectively sets the node's "status" property to either 
> "okay"
> + * or "disable", hence making it available for driver model initialization or
> + * not.
> + *
> + * @node:  The node to enable
> + * @value: Flag that tells the function to either disable or enable the
> + * node
> + * @return 0 if successful, -ve on error
> + */
> +int ofnode_set_enabled(ofnode node, bool value);
> +
>  #endif
> --
> 2.16.1
>

Regards,
Simon
___
U-Boot mailing list
U-Boot@lists.denx.de

Re: [U-Boot] [PATCH 4/5] pmic: dm: Rewrite pmic_reg_{read|write} and pmic_clrsetbits to support transmissions larger than 1 byte

2018-04-30 Thread Simon Glass
Hi Lukasz,

On 26 April 2018 at 06:19, Lukasz Majewski  wrote:
> This commit provides support for transmissions larger than 1 byte for
> PMIC devices used with DM (e.g. MC34708 from NXP).
>
> Signed-off-by: Lukasz Majewski 
> ---
>
>  drivers/power/pmic/pmic-uclass.c | 38 ++
>  1 file changed, 26 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/power/pmic/pmic-uclass.c 
> b/drivers/power/pmic/pmic-uclass.c
> index 0148e5c883..9004911daa 100644
> --- a/drivers/power/pmic/pmic-uclass.c
> +++ b/drivers/power/pmic/pmic-uclass.c
> @@ -143,23 +143,32 @@ int pmic_write(struct udevice *dev, uint reg, const 
> uint8_t *buffer, int len)
>
>  int pmic_reg_read(struct udevice *dev, uint reg)
>  {
> -   u8 byte;
> +   int tx_num = 1;
> +   u32 val = 0;
> int ret;
>
> -   debug("%s: reg=%x", __func__, reg);
> -   ret = pmic_read(dev, reg, , 1);
> -   debug(", value=%x, ret=%d\n", byte, ret);
> +   ret = pmic_trans_len(dev);

As with the previous patch, I think it is better to put this in the
uclass's device-private data. It can be set to 1 by default, and the
device can updated it to 2, etc, as needed.

Then we avoid making this extra call for every operation.

Also please don't forget to add a sandbox test for it.

> +   if (ret > 1 && ret <= sizeof(val))
> +   tx_num = ret;
>
> -   return ret ? ret : byte;
> +   debug("%s: reg=%x tx_num:%d", __func__, reg, tx_num);
> +   ret = pmic_read(dev, reg, (uint8_t *), tx_num);
> +   debug(", value=%x, ret=%d\n", val, ret);
> +
> +   return ret ? ret : val;
>  }
>
>  int pmic_reg_write(struct udevice *dev, uint reg, uint value)
>  {
> -   u8 byte = value;
> +   int tx_num = 1;
> int ret;
>
> -   debug("%s: reg=%x, value=%x", __func__, reg, value);
> -   ret = pmic_write(dev, reg, , 1);
> +   ret = pmic_trans_len(dev);
> +   if (ret > 1 && ret <= sizeof(value))
> +   tx_num = ret;
> +
> +   debug("%s: reg=%x, value=%x tx_num:%d", __func__, reg, value, tx_num);
> +   ret = pmic_write(dev, reg, (uint8_t *), tx_num);
> debug(", ret=%d\n", ret);
>
> return ret;
> @@ -167,15 +176,20 @@ int pmic_reg_write(struct udevice *dev, uint reg, uint 
> value)
>
>  int pmic_clrsetbits(struct udevice *dev, uint reg, uint clr, uint set)
>  {
> -   u8 byte;
> +   int tx_num = 1;
> +   u32 val = 0;
> int ret;
>
> -   ret = pmic_reg_read(dev, reg);
> +   ret = pmic_trans_len(dev);
> +   if (ret > 1 && ret <= sizeof(val))
> +   tx_num = ret;
> +
> +   ret = pmic_read(dev, reg, (uint8_t *), tx_num);
> if (ret < 0)
> return ret;
> -   byte = (ret & ~clr) | set;
>
> -   return pmic_reg_write(dev, reg, byte);
> +   val = (val & ~clr) | set;
> +   return pmic_write(dev, reg, (uint8_t *), tx_num);
>  }
>
>  UCLASS_DRIVER(pmic) = {
> --
> 2.11.0
>

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


Re: [U-Boot] [PATCH v2 1/2] regmap: add regmap_update_bits() helper

2018-04-30 Thread Simon Glass
Hi Neil,

On 27 April 2018 at 03:56, Neil Armstrong  wrote:
>
> Add the regmap_update_bits() to simply the read/modify/write of registers
> in a single command. The function is taken from Linux regmap
> implementation.
>
> Signed-off-by: Neil Armstrong 
> ---
>  drivers/core/regmap.c | 14 ++
>  include/regmap.h  | 10 ++
>  2 files changed, 24 insertions(+)

Reviewed-by: Simon Glass 

nit below:

>
> diff --git a/drivers/core/regmap.c b/drivers/core/regmap.c
> index 8a0e00f..9fae252 100644
> --- a/drivers/core/regmap.c
> +++ b/drivers/core/regmap.c
> @@ -147,3 +147,17 @@ int regmap_write(struct regmap *map, uint offset, uint 
> val)
>
> return 0;
>  }
> +
> +int regmap_update_bits(struct regmap *map, uint offset, uint mask, uint val)
> +{
> +   uint reg;
> +   int ret;
> +
> +   ret = regmap_read(map, offset, );
> +   if (ret)
> +   return ret;
> +
> +   reg &= ~mask;
> +
> +   return regmap_write(map, offset, reg | val);
> +}
> diff --git a/include/regmap.h b/include/regmap.h
> index 493a5d8..1349d40 100644
> --- a/include/regmap.h
> +++ b/include/regmap.h
> @@ -47,6 +47,16 @@ int regmap_read(struct regmap *map, uint offset, uint 
> *valp);
> regmap_read(map, (uint32_t *)(ptr)->member - (uint32_t *)(ptr), valp)
>
>  /**
> + * regmap_update_bits() - Perform a read/modify/write using a mask
> + *
> + * @map:   The map returned by regmap_init_mem*()
> + * @offset:Offset of the memory
> + * @mask:  Mask to apply to the read value
> + * @val:   Value to apply to the value to write

How about 'Value to OR to the value to write"

> + */
> +int regmap_update_bits(struct regmap *map, uint offset, uint mask, uint val);
> +
> +/**
>   * regmap_init_mem() - Set up a new register map that uses memory access
>   *
>   * Use regmap_uninit() to free it.
> --
> 2.7.4
>

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


Re: [U-Boot] [PATCH v3] dm: core: add functions to get memory-mapped I/O addresses

2018-04-30 Thread Simon Glass
On 29 April 2018 at 13:56, Daniel Schwierzeck
 wrote:
> From: Álvaro Fernández Rojas 
>
> Signed-off-by: Álvaro Fernández Rojas 
> Reviewed-by: Daniel Schwierzeck 
> Signed-off-by: Daniel Schwierzeck 
>
> ---
> This replaces/updates patch 01/17 from patch series
> https://patchwork.ozlabs.org/cover/889542/. The update fixes
> some issues with Sandbox and adds unit-tests. The remaining patches
> from the patch series can be applied as-is when this patch has been
> committed.
>
> Changes in v3:
> - replace ioremap() with map_physmem()
> - add unit tests
> - fix checkpatch.pl warnings
>
> Changes in v2:
> - new patch
>
>  drivers/core/fdtaddr.c | 15 +++
>  drivers/core/read.c| 15 +++
>  include/dm/fdtaddr.h   | 22 ++
>  include/dm/read.h  | 32 
>  test/dm/test-fdt.c | 42 ++
>  5 files changed, 126 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 v6 1/2] x86: Add TSC-specific timer functions

2018-04-30 Thread Simon Glass
Hi Bin,

On 25 April 2018 at 21:42, Bin Meng  wrote:
> Hi Ivan,
>
> On Tue, Apr 24, 2018 at 4:41 PM, Bin Meng  wrote:
>> Hi Ivan,
>>
>> On Tue, Apr 24, 2018 at 7:56 AM, Ivan Gorinov  wrote:
>>> Hi Bin,
>>>
>>> On Mon, Apr 23, 2018 at 01:38:05AM -0600, Bin Meng wrote:
 > Coreboot timestamp functions and Quark memory reference code use
 > get_tbclk() to get TSC frequency. This will not work if another
 > early timer is selected.

 Thanks for working on this. But get_tbclk() is one API provided by the
 timer library. The get_tbclk_mhz() is something that is implemented by
 the TSC timer driver, so can we get rid of the get_tbclk_mhz() and use
 the get_tbclk() instead in coreboot/timestamp.c and quark/mrc_util.c?
>>>
>>> The Coreboot timestamp code and Quark MRC specifically use rdtsc().
>>> We can replace it with timer_early_get_count() or provide a function
>>> to get the TSC frequency even when another early timer is selected.
>>>
>>
>> Good catch. Yes, we should fix coreboot timestamp code and Quark MRC
>> codes to not explicitly call rdtsc.
>>
>
> Further checking the coreboot timestamp codes, I think we may have to
> leave the coreboot timestamp codes as it is now.
>
> We have the codes blow:
> void timestamp_add_now(enum timestamp_id id)
> {
> timestamp_add(id, rdtsc());
> }
>
> We cannot replace rdtsc() with timer_early_get_count(), because this
> timestamp_add_now() is called both before and after DM initialization.
> If the HPET is selected as the early timer and TSC is selected as the
> normal timer, the timestamp numbers are meaningless to compare against
> each other.
>
>> Another driver that explicitly calls rdtsc() is hw_watchdog_reset() in
>> watchdog/tangier_wdt.c driver. We need fix that too.
>>
>
> Simon, another issue is the bootstage support. So far the
> timer_get_boot_us() is not implemented by DM timer APIs.
> timer_get_boot_us() is implemented per timer driver if
> CONFIG_SYS_TIMER_COUNTER is not defined. Note CONFIG_SYS_TIMER_COUNTER
> is non-DM stuff. That means the bootstage support is bounded by a
> specific timer driver, instead of a generic library. To me this
> overall timer support is somehow fragmentary.

Yes I agree. I'm open to ideas and patches :-)

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


Re: [U-Boot] [PATCH] cmd: add ADC cli commands

2018-04-30 Thread Simon Glass
Hi Neil,

On 27 April 2018 at 04:07, Neil Armstrong  wrote:
> Hi,
>
> On 26/04/2018 16:40, Simon Glass wrote:
>> Hi Neil,
>>
>> On 23 April 2018 at 08:18, Neil Armstrong  wrote:
>>> Add an 'adc' cli command to get adc devices informations and read single
>>> shots datas.
>>>
>>> Signed-off-by: Neil Armstrong 
>>> ---
>>>  cmd/Kconfig  |   7 
>>>  cmd/Makefile |   1 +
>>>  cmd/adc.c| 126 
>>> +++
>>>  3 files changed, 134 insertions(+)
>>>  create mode 100644 cmd/adc.c
>>
>> Reviewed-by: Simon Glass 
>>
>> Nits below
>>
>>>
>>> diff --git a/cmd/Kconfig b/cmd/Kconfig
>>> index bc1d2f3..631daee 100644
>>> --- a/cmd/Kconfig
>>> +++ b/cmd/Kconfig
>>> @@ -601,6 +601,13 @@ config CMD_ARMFLASH
>>> help
>>>   ARM Ltd reference designs flash partition access
>>>
>>> +config CMD_ADC
>>> +   bool "adc - Access ADC info and data"
>>> +   select ADC
>>> +   select DM_REGULATOR
>>> +   help
>>> + Shows ADC device info and get single shot data;
>>
>> Please spell out ADC in the help. Also, what is single-shot data?
>
> I'll add more text.
>
>>
>>> +
>>>  config CMD_CLK
>>> bool "clk - Show clock frequencies"
>>> help
>>> diff --git a/cmd/Makefile b/cmd/Makefile
>>> index c4269ac..4c66353 100644
>>> --- a/cmd/Makefile
>>> +++ b/cmd/Makefile
>>> @@ -14,6 +14,7 @@ obj-y += version.o
>>>
>>>  # command
>>>  obj-$(CONFIG_CMD_AES) += aes.o
>>> +obj-$(CONFIG_CMD_ADC) += adc.o
>>>  obj-$(CONFIG_CMD_ARMFLASH) += armflash.o
>>>  obj-y += blk_common.o
>>>  obj-$(CONFIG_SOURCE) += source.o
>>> diff --git a/cmd/adc.c b/cmd/adc.c
>>> new file mode 100644
>>> index 000..f82305c
>>> --- /dev/null
>>> +++ b/cmd/adc.c
>>> @@ -0,0 +1,126 @@
>>> +/*
>>> + * Copyright (C) 2018 BayLibre, SAS
>>> + *  Author: Neil Armstrong 
>>> + *
>>> + * SPDX-License-Identifier:GPL-2.0+
>>> + */
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +
>>> +static int do_adc_list(cmd_tbl_t *cmdtp, int flag, int argc,
>>> +  char *const argv[])
>>> +{
>>> +   struct udevice *dev;
>>> +   int ret;
>>> +
>>> +   ret = uclass_first_device_err(UCLASS_ADC, );
>>
>> This will probe the device. Is that what you want?
>
> Is there another way ?
> I mean you need to probe to know if the device is actually usable, no ?

You can use something like uclass_find_first_device() which doesn't probe.

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


Re: [U-Boot] [PATCH 3/5] pmic: dm: Provide *trans_len() callback for pmic-uclass

2018-04-30 Thread Simon Glass
Hi Lucasz,

On 26 April 2018 at 06:19, Lukasz Majewski  wrote:
> This callback provides information of number of bytes to be sent/read
> during single transfer, as some PMICs transfer more bytes at once (e.g.
> MC34708 from NXP/Freescale).
>
> At present the PMIC DM supports only transfers with one byte. The old PMIC
> framework was able to transfer up till 3 bytes at once.
>
> Let's provide the same capability to new PMIC framework.

Can we instead make this a property of uclass-private data for each device?

I don't see a lot of point in adding a new method, since the value is
presumably set once and does not change through the life of the
device.

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


Re: [U-Boot] [RFC PATCH v2 01/20] fastboot: Move fastboot to drivers/fastboot

2018-04-30 Thread Simon Glass
On 30 April 2018 at 02:32, Alex Kiernan  wrote:
> Separate CMD_FASTBOOT from FASTBOOT and move code and configuration to
> drivers/fastboot.
>
> Signed-off-by: Alex Kiernan 
> ---
>
> Changes in v2: None
>
>  cmd/Kconfig | 14 --
>  common/Makefile | 13 -
>  drivers/Kconfig |  2 ++
>  drivers/Makefile|  1 +
>  {cmd => drivers}/fastboot/Kconfig   | 12 
>  drivers/fastboot/Makefile   | 10 ++
>  {common => drivers/fastboot}/fb_mmc.c   |  0
>  {common => drivers/fastboot}/fb_nand.c  |  0
>  {common => drivers/fastboot}/image-sparse.c |  0
>  9 files changed, 25 insertions(+), 27 deletions(-)
>  rename {cmd => drivers}/fastboot/Kconfig (91%)
>  create mode 100644 drivers/fastboot/Makefile
>  rename {common => drivers/fastboot}/fb_mmc.c (100%)
>  rename {common => drivers/fastboot}/fb_nand.c (100%)
>  rename {common => drivers/fastboot}/image-sparse.c (100%)
>

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


Re: [U-Boot] [PATCH v2 3/3] test: Add tests for board uclass

2018-04-30 Thread Simon Glass
On 27 April 2018 at 06:51, Mario Six  wrote:
> Add tests for the new board uclass.
>
> Signed-off-by: Mario Six 
> ---
>
> v1 -> v2:
> New in v2
>
> ---
>  arch/sandbox/dts/test.dts  |   4 ++
>  configs/sandbox64_defconfig|   2 +
>  configs/sandbox_defconfig  |   2 +
>  configs/sandbox_flattree_defconfig |   2 +
>  configs/sandbox_noblk_defconfig|   2 +
>  configs/sandbox_spl_defconfig  |   2 +
>  drivers/board/Kconfig  |   7 ++-
>  drivers/board/Makefile |   1 +
>  drivers/board/sandbox.c| 108 
> +
>  drivers/board/sandbox.h|  13 +
>  test/dm/Makefile   |   1 +
>  test/dm/board.c|  57 
>  12 files changed, 200 insertions(+), 1 deletion(-)
>  create mode 100644 drivers/board/sandbox.c
>  create mode 100644 drivers/board/sandbox.h
>  create mode 100644 test/dm/board.c

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


[U-Boot] [PATCH] README.sandbox: small typos

2018-04-30 Thread Trevor Woerner
Signed-off-by: Trevor Woerner 
---
 board/sandbox/README.sandbox | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/board/sandbox/README.sandbox b/board/sandbox/README.sandbox
index 760866f1c3..8250073c38 100644
--- a/board/sandbox/README.sandbox
+++ b/board/sandbox/README.sandbox
@@ -106,8 +106,8 @@ recreate the binary file.
 
 To execute commands directly, use the -c option. You can specify a single
 command, or multiple commands separated by a semicolon, as is normal in
-U-Boot. Be careful with quoting as the shall will normally process and
-swallow quotes. When -c is used, U-Boot exists after the command is complete,
+U-Boot. Be careful with quoting as the shell will normally process and
+swallow quotes. When -c is used, U-Boot exits after the command is complete,
 but you can force it to go to interactive mode instead with -i.
 
 
@@ -188,7 +188,7 @@ U-Boot sandbox supports these emulations:
 - SPI flash
 - TPM (Trusted Platform Module)
 
-A wide range of commands is implemented. Filesystems which use a block
+A wide range of commands are implemented. Filesystems which use a block
 device are supported.
 
 Also sandbox supports driver model (CONFIG_DM) and associated commands.
@@ -245,7 +245,7 @@ dhcp
 set serverip WWW.XXX.YYY.ZZZ
 tftpboot u-boot.bin
 
-The bridge also support (to a lesser extent) the localhost inderface, 'lo'.
+The bridge also supports (to a lesser extent) the localhost interface, 'lo'.
 
 The 'lo' interface cannot use the RAW AF_PACKET API because the lo interface
 doesn't support Ethernet-level traffic. It is a higher-level interface that is
-- 
2.17.0.rc2.3.gc2a499e6c

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


Re: [U-Boot] [PATCH v2 1/3] drivers: Add board uclass

2018-04-30 Thread Simon Glass
Hi,

On 27 April 2018 at 07:02, Dr. Philipp Tomsich
 wrote:
>
>> On 27 Apr 2018, at 14:51, Mario Six  wrote:
>>
>> Since there is no canonical "board device" that can be used in board
>> files, it is difficult to use DM function for board initialization in
>> these cases.
>>
>> Hence, add a uclass that implements a simple "board device", which can
>> hold devices not suitable anywhere else in the device tree, and is also
>> able to read encoded information, e.g. hard-wired GPIOs on a GPIO
>> expander, read-only memory ICs, etc. that carry information about the
>> hardware.

With comments below:

Reviewed-by: Simon Glass 

>
> A board-uclass should model a board (i.e. provide implementations for
> the same key abstractions that we have in place today: e.g., board_init).
>
> This seems more like a specialised form of a misc-device.
>
>> The devices of this uclass expose methods to read generic data types
>> (integers, strings, booleans) to encode the information provided by the
>> hardware.
>
> Again, this is what a misc-device is intended for… and extending the
> misc-device APIs (or having a convenience layer on top of its ioctl
> interface?) might be more appropriate.
>
> After reviewing the below, the similarities to the misc-device are even
> more apparent: if you need typed access to a key-value pair, this can
> be easily implemented through a common ioctl with semantic sugar
> at the misc-uclass level.

A misc device might be similar in action but it is not the same in
terms of concept. For example it would be very strange to have a misc
device which points to lots of other devices that are on the board.
For example, consider this hypothetical case:

board {
   identity-eeprom = <>;
   id-gpios = < 2>, < 4>;
   ec = <_ec>;
};

Here we point to a few devices which may otherwise require specific
device-tree references to locate. Already we are seeing this sort of
code in U-Boot:

/* find the grf node */
node = fdt_node_offset_by_compatible(blob, -1,
"rockchip,rk3288-grf");

ret = regulator_get_by_platname("vdd_arm", );
if (ret) {
debug("Cannot set regulator name\n");
return ret;
}

These are the sorts of things which suggest that some sort of 'board
directory', pointing to the things that the board needs to init, would
be useful.

>
>> Signed-off-by: Mario Six 
>> ---
>>
>> v1 -> v2:
>> * Corrected description of dev parameter of devinfo_detect
>> * Added size parameter to devinfo_get_str
>> * Expanded uclass documentation
>> * Added function to get devinfo instance
>> * Renamed the uclass from devinfo to board
>>
>> ---
>> drivers/Kconfig  |   2 +
>> drivers/Makefile |   1 +
>> drivers/board/Kconfig|  17 +++
>> drivers/board/Makefile   |   9 
>> drivers/board/board-uclass.c |  61 +++
>> include/board.h  | 115 
>> +++
>> include/dm/uclass-id.h   |   1 +
>> 7 files changed, 206 insertions(+)
>> create mode 100644 drivers/board/Kconfig
>> create mode 100644 drivers/board/Makefile
>> create mode 100644 drivers/board/board-uclass.c
>> create mode 100644 include/board.h
>>
>> diff --git a/drivers/Kconfig b/drivers/Kconfig
>> index c2e813f5ad..19c7c448c0 100644
>> --- a/drivers/Kconfig
>> +++ b/drivers/Kconfig
>> @@ -22,6 +22,8 @@ source "drivers/ddr/Kconfig"
>>
>> source "drivers/demo/Kconfig"
>>
>> +source "drivers/board/Kconfig"
>> +
>> source "drivers/ddr/fsl/Kconfig"
>>
>> source "drivers/dfu/Kconfig"
>> diff --git a/drivers/Makefile b/drivers/Makefile
>> index 6846d181aa..fecf64021c 100644
>> --- a/drivers/Makefile
>> +++ b/drivers/Makefile
>> @@ -72,6 +72,7 @@ obj-y += block/
>> obj-$(CONFIG_BOOTCOUNT_LIMIT) += bootcount/
>> obj-$(CONFIG_CPU) += cpu/
>> obj-y += crypto/
>> +obj-y += board/
>> obj-y += firmware/
>> obj-$(CONFIG_FPGA) += fpga/
>> obj-y += misc/
>> diff --git a/drivers/board/Kconfig b/drivers/board/Kconfig
>> new file mode 100644
>> index 00..cc1cf27205
>> --- /dev/null
>> +++ b/drivers/board/Kconfig
>> @@ -0,0 +1,17 @@
>> +menuconfig BOARD
>> + bool "Device Information"
>> + help
>> +   Support methods to query hardware configurations from internal
>> +   mechanisms (e.g. reading GPIO values, determining the presence of
>> +   devices on busses, etc.). This enables the usage of U-Boot with
>> +   modular board architectures.
>> +
>> +if BOARD
>> +
>> +
>> +config BOARD_GAZERBEAM
>> + bool "Enable device information for the Gazerbeam board"
>> + help
>> +   Support querying device information for the gdsys Gazerbeam board.
>> +
>> +endif
>> diff --git a/drivers/board/Makefile b/drivers/board/Makefile
>> new file mode 100644
>> index 00..397706245a
>> --- /dev/null
>> +++ b/drivers/board/Makefile
>> @@ -0,0 +1,9 @@
>> +#
>> +# (C) Copyright 2017
>> +# Mario Six,  Guntermann & Drunck GmbH, mario@gdsys.cc
>> +#
>> +# 

Re: [U-Boot] Appended DTB Android boot image support

2018-04-30 Thread Simon Glass
Hi Ramon,

On 30 April 2018 at 07:04, Ramon Fried  wrote:
> Hi all.
> I'm currently adding support for Qualcomm Dragonboards  to U-boot as a
> primary bootloader without chain-loading using LK which is currently
> already supported in mainline U-boot.
>
> Qualcomm Android images are regular android images where the DTB's are
> appended to the image. Qualcomm used the "unused" field in the image
> header to populate the size of the DTB *.
>
> I'm looking for a more standard version for supporting these kind of images.
> Currently, to boot these images, you must provide DTB somewhere in mem
> and provide it as argument to bootm for instance.
>
> My goal is to add support that U-boot will parse the image, see that
> the DTB is included and use that as the FDT automatically.
>
> I'm looking at the "secondary" fields which are currently not used as
> a valid option to point to the DTB and it's size.
>
> Do you know if someone is working on something similar, or do you have
> any suggestions for the right approach to this issue ?

Have you thought of using FIT? It suppose multiple DTB files, multiple
kernels, compression, etc. and is readily extensible.

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


Re: [U-Boot] [PATCH 1/2] [RFC]new command: wol - Wake on LAN

2018-04-30 Thread Simon Glass
Hi Lothar,

On 23 April 2018 at 11:47, Lothar Felten  wrote:
> This patch adds a new command 'wol': It waits for an incoming
> Wake-on-LAN
> packet or times out if no WoL packed is received.
> If the WoL packet contains a password, it is saved in the environment
> variable 'wolpassword' using the etherwake format (dot separated
> decimals).
>
> Intended use case: a networked device should boot an alternate image.
> It's attached to a network on a client site, modifying the DHCP server
> configuration or setup of a tftp server is not allowed.
> After power on the device waits a few seconds for a WoL packet. If a
> packet is received, the device boots the alternate image. Otherwise
> it boots the default image.
>
> This method is a simple way to interact with a system via network even
> if only the MAC address is known. Tools to send WoL packets are
> available on all common platforms.
>
> Signed-off-by: Lothar Felten 
> ---
>  net/wol.c | 54 ++
>  net/wol.h | 40 
>  2 files changed, 94 insertions(+)
>  create mode 100644 net/wol.c
>  create mode 100644 net/wol.h
>
> diff --git a/net/wol.c b/net/wol.c
> new file mode 100644
> index 00..0cedbaed85
> --- /dev/null
> +++ b/net/wol.c
> @@ -0,0 +1,54 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Copyright 2018 Lothar Felten, lothar.fel...@gmail.com
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include "wol.h"
> +
> +/*
> + * Handle a received wake-on-lan packet.
> + */
> +void wol_receive(struct ip_udp_hdr *ip, unsigned int len)
> +{
> +   char buf[4];
> +   int i;
> +   struct wol_hdr *wol;
> +
> +   wol = (struct wol_hdr *)ip;
> +
> +   if (len < 102)
> +   return;
> +
> +   for (i = 0; i < 6; i++)
> +   if (wol->wol_sync[i] != 0xff)
> +   return;
> +
> +   for (i = 0; i < 16; i++)
> +   if (memcmp(>wol_dest[i * 6], net_ethaddr, 6) != 0)
> +   return;
> +
> +   /* save the optional password using the etherwake format */
> +   if (len >= 106) {

Is it possible to remove these four open-coded values and use values
from the header file instead?

> +   sprintf(buf, "%i.%i.%i.%i",
> +   wol->wol_passwd[0], wol->wol_passwd[1],
> +   wol->wol_passwd[2], wol->wol_passwd[3]);
> +   env_set("wolpassword", buf);
> +   }
> +   net_set_state(NETLOOP_SUCCESS);
> +}
> +
> +static void wol_timeout_handler(void)
> +{
> +   eth_halt();
> +   net_set_state(NETLOOP_FAIL);
> +}
> +
> +void wol_start(void)
> +{
> +   ulong timeout = env_get_ulong("woltimeout", 10, 5);
> +
> +   net_set_timeout_handler(timeout * 1000, wol_timeout_handler);
> +}
> diff --git a/net/wol.h b/net/wol.h
> new file mode 100644
> index 00..e34767c733
> --- /dev/null
> +++ b/net/wol.h
> @@ -0,0 +1,40 @@
> +/* SPDX-License-Identifier: GPL-2.0+ */
> +/*
> + * Copyright 2018 Lothar Felten, lothar.fel...@gmail.com
> + */
> +
> +#if defined(CONFIG_CMD_WOL)
> +
> +#ifndef __WOL_H__
> +#define __WOL_H__
> +
> +#include 
> +
> +/**/
> +
> +/*
> + * Wake-on-LAN header.
> + */
> +struct wol_hdr {
> +   u8  wol_sync[6];/* sync bytes   */
> +   u8  wol_dest[16 * 6];   /* 16x destination MAC address  */
> +   u8  wol_passwd[4];  /* optional password*/
> +};
> +
> +/*
> + * Initialize wol (beginning of netloop)
> + */
> +void wol_start(void);
> +
> +/*
> + * Deal with the receipt of a wol packet
> + *
> + * @param ip IP header in the packet
> + * @param len Packet length
> + */
> +void wol_receive(struct ip_udp_hdr *ip, unsigned int len);

It seems like this should return an error code if the packet does not
match as expected (the 'return' in your impl)

Also you could expand a bit on what 'deal with' means. What exactly happens?

Seems like there should be a README addition somewhere too.

> +
> +/**/
> +
> +#endif /* __WOL_H__ */
> +#endif
> --
> 2.14.1
>

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


Re: [U-Boot] [PATCH] test: dm: regmap: fix license header

2018-04-30 Thread Simon Glass
On 26 April 2018 at 10:07, Masahiro Yamada
 wrote:
> Signed-off-by: Masahiro Yamada 
> ---
>
>  test/dm/regmap.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

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


Re: [U-Boot] [PATCH 2/2] [RFC]new command: wol - enable command

2018-04-30 Thread Simon Glass
Hi Lothar,

On 23 April 2018 at 11:47, Lothar Felten  wrote:
> This patch enables the WoL command
>
> Signed-off-by: Lothar Felten 
> ---
>  cmd/Kconfig   |  5 +
>  cmd/net.c | 14 ++
>  include/net.h |  3 ++-
>  net/Makefile  |  1 +
>  net/net.c | 19 +++
>  5 files changed, 41 insertions(+), 1 deletion(-)
>
> diff --git a/cmd/Kconfig b/cmd/Kconfig
> index bc1d2f31c0..ed9d82fe71 100644
> --- a/cmd/Kconfig
> +++ b/cmd/Kconfig
> @@ -1142,6 +1142,11 @@ config CMD_RARP
> help
>   Boot image via network using RARP/TFTP protocol
>
> +config CMD_WOL
> +   bool "wol"
> +   help
> + Wait for wake-on-lan packages

Can you expand this a bit, perhaps explaining what it is for?

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


Re: [U-Boot] [PATCH v2 2/4] dm: ofnode: add ofnode_device_is_compatible() helper

2018-04-30 Thread Simon Glass
On 26 April 2018 at 10:03, Masahiro Yamada
 wrote:
> Hi Simon,
>
>
> 2018-04-26 23:40 GMT+09:00 Simon Glass :
>> Hi Masahiro,
>>
>> On 18 April 2018 at 21:14, Masahiro Yamada
>>  wrote:
>>> device_is_compatible() takes udevice, but there is no such a helper
>>> that takes ofnode.
>>>
>>> Signed-off-by: Masahiro Yamada 
>>> ---
>>>
>>> Changes in v2: None
>>>
>>>  drivers/core/device.c |  8 +---
>>>  drivers/core/ofnode.c | 11 +++
>>>  include/dm/ofnode.h   | 11 +++
>>>  3 files changed, 23 insertions(+), 7 deletions(-)
>>>
>>
>> Please can you add a simple test for this?
>
> I wrote a simple test:
>
> http://patchwork.ozlabs.org/patch/905181/

Thanks!

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


Re: [U-Boot] [PATCH] test: ofnode: test ofnode_device_is_compatible()

2018-04-30 Thread Simon Glass
On 26 April 2018 at 10:02, Masahiro Yamada
 wrote:
>
> Test ofnode_device_is_compatible(), and also ofnode_path().
>
> Requested-by: Simon Glass 
> Signed-off-by: Masahiro Yamada 
> ---
>
>  test/dm/Makefile |  1 +
>  test/dm/ofnode.c | 19 +++
>  2 files changed, 20 insertions(+)
>  create mode 100644 test/dm/ofnode.c

Thanks Masahiro, much appreciated.

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


[U-Boot] Logo for U-Boot

2018-04-30 Thread Heinrich Schuchardt
U-Boot has currently no logo that we can use in presentations.

On the U-Boot IRC channel the following propositions where made:

Source: https://commons.wikimedia.org/wiki/File:Circle-icons-submarine.svg
License: GPL2+
(Alex used this in some presentations.)

Source: https://gist.github.com/xypron/a923ad8cca83e648fc91716f2f29beed
License: GPL2+
(The image is already used in U-Boot:
setenv efi_selftest block image transfer
bootefi selftest
)

Looking forward to your further suggestions.

Best regards

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


[U-Boot] [PATCH] net: Express LINK_LOCAL dependency on LIB_RAND

2018-04-30 Thread Joe Hershberger
Signed-off-by: Joe Hershberger 
---

 cmd/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/cmd/Kconfig b/cmd/Kconfig
index 225bb00..3aa87c8 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -1175,6 +1175,7 @@ config CMD_DNS
 
 config CMD_LINK_LOCAL
bool "linklocal"
+   select LIB_RAND
help
  Acquire a network IP address using the link-local protocol
 
-- 
1.7.11.5

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


Re: [U-Boot] [GIT] Pull request: u-boot-dfu (30.04.2018)

2018-04-30 Thread Marek Vasut
On 04/30/2018 02:48 PM, Lukasz Majewski wrote:
> Dear Marek,
> 
> Travis CI:
> https://travis-ci.org/lmajewski/u-boot-dfu/builds/372935934
> 
> Test HW: Beagle Bone Black
> 
> 
> The following changes since commit
> d57ed4d9f2cb6abc9438104f321b4fe3bc829d57:
> 
>   usb: gadget: composite: fix NULL pointer when a non standard request
>   is received (2018-04-26 15:15:07 +0200)
> 
> are available in the git repository at:
> 
>   git://git.denx.de/u-boot-dfu.git 
> 
> for you to fetch changes up to c85f73adb296ca734dffbe10e0a5190aa6c747c7:
> 
>   usb: f_mass_storage: simplify logical expression (2018-04-30 10:41:01
>   +0200)

Applied, thanks

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


Re: [U-Boot] [RFH] Das U-Boot logo help

2018-04-30 Thread Måns Rullgård
Tom Rini  writes:

> Hey all,
>
> So, as far as I can tell, U-Boot hasn't ever had an official logo.  This
> lead a while back to Alex using the following logo in a presentation
> that I attended:
> https://commons.wikimedia.org/wiki/File:Circle-icons-submarine.svg
>
> And I thought it was a pretty good fit too, and as a bonus it's already
> GPLv2 or later licensed.  The only thing missing is that it should
> probably say U-Boot on it somewhere.  Does anyone out there want to take
> a pass at something like that?  Thanks!

I'm picturing something looking a bit ambiguously like either a
submarine or a boot, but I don't have the artistic skills to draw it.

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


[U-Boot] [PATCH v3 4/9] nios2: Define PLATFORM__SET_BIT for generic_set_bit()

2018-04-30 Thread Bryan O'Donoghue
nios2 bitops.h provides a __set_bit() but does not define PLATFORM__SET_BIT
as a result generic_set_bit() is used instead of the architecturally
provided __set_bit().

This patch defines PLATFORM__SET_BIT which means that __set_bit() in nios2
bitops.h will be called whenever generic_set_bit() is called - as opposed
to the default cross-platform generic_set_bit().

Signed-off-by: Bryan O'Donoghue 
Cc: Thomas Chou 
---
 arch/nios2/include/asm/bitops/non-atomic.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/nios2/include/asm/bitops/non-atomic.h 
b/arch/nios2/include/asm/bitops/non-atomic.h
index 697cc2b7e0..9dd9d923e1 100644
--- a/arch/nios2/include/asm/bitops/non-atomic.h
+++ b/arch/nios2/include/asm/bitops/non-atomic.h
@@ -20,6 +20,8 @@ static inline void __set_bit(int nr, volatile unsigned long 
*addr)
*p  |= mask;
 }
 
+#define PLATFORM__SET_BIT
+
 static inline void __clear_bit(int nr, volatile unsigned long *addr)
 {
unsigned long mask = BIT_MASK(nr);
-- 
2.17.0

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


[U-Boot] [PATCH v3 9/9] usb: composite convert __set_bit to generic_set_bit

2018-04-30 Thread Bryan O'Donoghue
Compiling the f_mass_storage driver for an x86 target results in a
compilation error as set_bit and clear_bit are provided by bitops.h

To address that situation we discussed on the list moving to
genetic_set_bit() instead.

Doing a quick grep for similar situations in drivers/usb shows that the
composite device is using __set_bit().

This patch switches over to generic_set_bit to maintain consistency between
the two gadget drivers.

Signed-off-by: Bryan O'Donoghue 
Cc: Lukasz Majewski 
Cc: Marek Vasut 
---
 drivers/usb/gadget/composite.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index a87639def9..9229d9ee30 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -379,7 +379,7 @@ static int set_config(struct usb_composite_dev *cdev,
ep = (struct usb_endpoint_descriptor *)*descriptors;
addr = ((ep->bEndpointAddress & 0x80) >> 3)
 |  (ep->bEndpointAddress & 0x0f);
-   __set_bit(addr, f->endpoints);
+   generic_set_bit(addr, f->endpoints);
}
 
result = f->set_alt(f, tmp, 0);
-- 
2.17.0

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


[U-Boot] [PATCH v3 3/9] riscv: Define PLATFORM__CLEAR_BIT for generic_clear_bit()

2018-04-30 Thread Bryan O'Donoghue
riscv bitops.h provides a __clear_bit() but does not define
PLATFORM__CLEAR_BIT as a result generic_clear_bit() is used instead of the
architecturally provided __clear_bit().

This patch defines PLATFORM__CLEAR_BIT which means that __clear_bit() in
riscv bitops.h will be called whenever generic_clear_bit() is called - as
opposed to the default cross-platform generic_clear_bit().

Signed-off-by: Bryan O'Donoghue 
Cc: Rick Chen 
Cc: Greentime Hu 
---
 arch/riscv/include/asm/bitops.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/riscv/include/asm/bitops.h b/arch/riscv/include/asm/bitops.h
index 0149e5c696..536629bbec 100644
--- a/arch/riscv/include/asm/bitops.h
+++ b/arch/riscv/include/asm/bitops.h
@@ -54,6 +54,8 @@ static inline void __clear_bit(int nr, void *addr)
*a &= ~mask;
 }
 
+#define PLATFORM__CLEAR_BIT
+
 static inline void __change_bit(int nr, void *addr)
 {
int mask;
-- 
2.17.0

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


[U-Boot] [PATCH v3 6/9] nds32: Define PLATFORM__SET_BIT for generic_set_bit()

2018-04-30 Thread Bryan O'Donoghue
nds32 bitops.h provides a __set_bit() but does not define PLATFORM__SET_BIT
as a result generic_set_bit() is used instead of the architecturally
provided __set_bit().

This patch defines PLATFORM__SET_BIT which means that __set_bit() in nds32
bitops.h will be called whenever generic_set_bit() is called - as opposed
to the default cross-platform generic_set_bit().

Signed-off-by: Bryan O'Donoghue 
Cc: Macpaul Lin 
---
 arch/nds32/include/asm/bitops.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/nds32/include/asm/bitops.h b/arch/nds32/include/asm/bitops.h
index 7ee37c37bc..ecd0032664 100644
--- a/arch/nds32/include/asm/bitops.h
+++ b/arch/nds32/include/asm/bitops.h
@@ -44,6 +44,8 @@ static inline void __set_bit(int nr, void *addr)
*a |= mask;
 }
 
+#define PLATFORM__SET_BIT
+
 extern void clear_bit(int nr, void *addr);
 
 static inline void __clear_bit(int nr, void *addr)
-- 
2.17.0

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


[U-Boot] [PATCH v3 8/9] usb: f_mass_storage: Fix set_bit and clear_bit usage

2018-04-30 Thread Bryan O'Donoghue
Compiling the f_mass_storage driver for an x86 target results in a
compilation error as set_bit and clear_bit are provided by bitops.h

Looking at the provenance of the current u-boot code and the git change
history in the kernel, it looks like we have a local copy of set_bit and
clear_bit as a hold-over from porting the Linux driver into u-boot.

These days __set_bit and __clear_bit are optionally provided by an arch and
can be used as inputs to generic_bit_set and generic_bit_clear.

This patch switches over to generic_set_bit and generic_clear_bit to
accommodate.

Tested on i.MX WaRP7 and Intel Edison

Signed-off-by: Bryan O'Donoghue 
Cc: Lukasz Majewski 
Cc: Marek Vasut 
---
 drivers/usb/gadget/f_mass_storage.c | 25 +++--
 1 file changed, 3 insertions(+), 22 deletions(-)

diff --git a/drivers/usb/gadget/f_mass_storage.c 
b/drivers/usb/gadget/f_mass_storage.c
index 1ecb92ac6b..209932df45 100644
--- a/drivers/usb/gadget/f_mass_storage.c
+++ b/drivers/usb/gadget/f_mass_storage.c
@@ -252,6 +252,7 @@
 #include 
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -283,26 +284,6 @@ static const char fsg_string_interface[] = "Mass Storage";
 struct kref {int x; };
 struct completion {int x; };
 
-inline void set_bit(int nr, volatile void *addr)
-{
-   int mask;
-   unsigned int *a = (unsigned int *) addr;
-
-   a += nr >> 5;
-   mask = 1 << (nr & 0x1f);
-   *a |= mask;
-}
-
-inline void clear_bit(int nr, volatile void *addr)
-{
-   int mask;
-   unsigned int *a = (unsigned int *) addr;
-
-   a += nr >> 5;
-   mask = 1 << (nr & 0x1f);
-   *a &= ~mask;
-}
-
 struct fsg_dev;
 struct fsg_common;
 
@@ -2086,7 +2067,7 @@ static int received_cbw(struct fsg_dev *fsg, struct 
fsg_buffhd *bh)
 * we can simply accept and discard any data received
 * until the next reset. */
wedge_bulk_in_endpoint(fsg);
-   set_bit(IGNORE_BULK_OUT, >atomic_bitflags);
+   generic_set_bit(IGNORE_BULK_OUT, >atomic_bitflags);
return -EINVAL;
}
 
@@ -2250,7 +2231,7 @@ reset:
fsg->bulk_out_enabled = 1;
common->bulk_out_maxpacket =
le16_to_cpu(get_unaligned(>wMaxPacketSize));
-   clear_bit(IGNORE_BULK_OUT, >atomic_bitflags);
+   generic_clear_bit(IGNORE_BULK_OUT, >atomic_bitflags);
 
/* Allocate the requests */
for (i = 0; i < FSG_NUM_BUFFERS; ++i) {
-- 
2.17.0

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


[U-Boot] [PATCH v3 7/9] nds32: Define PLATFORM__CLEAR_BIT for generic_clear_bit()

2018-04-30 Thread Bryan O'Donoghue
nds2 bitops.h provides a __clear_bit() but does not define
PLATFORM__CLEAR_BIT as a result generic_clear_bit() is used instead of the
architecturally provided __clear_bit().

This patch defines PLATFORM__CLEAR_BIT which means that __clear_bit() in
nds32 bitops.h will be called whenever generic_clear_bit() is called - as
opposed to the default cross-platform generic_clear_bit().

Signed-off-by: Bryan O'Donoghue 
Cc: Macpaul Lin 
---
 arch/nds32/include/asm/bitops.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/nds32/include/asm/bitops.h b/arch/nds32/include/asm/bitops.h
index ecd0032664..f1cdcf3e65 100644
--- a/arch/nds32/include/asm/bitops.h
+++ b/arch/nds32/include/asm/bitops.h
@@ -61,6 +61,8 @@ static inline void __clear_bit(int nr, void *addr)
local_irq_restore(flags);
 }
 
+#define PLATFORM__CLEAR_BIT
+
 extern void change_bit(int nr, void *addr);
 
 static inline void __change_bit(int nr, void *addr)
-- 
2.17.0

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


[U-Boot] [PATCH v3 1/9] x86: Define PLATFORM__SET_BIT for generic_set_bit()

2018-04-30 Thread Bryan O'Donoghue
x86 bitops.h provides a __set_bit() but does not define PLATFORM__SET_BIT
as a result generic_set_bit() is used instead of the architecturally
provided __set_bit().

This patch defines PLATFORM__SET_BIT which means that __set_bit() in x86
bitops.h will be called whenever generic_set_bit() is called - as opposed
to the default cross-platform generic_set_bit().

Signed-off-by: Bryan O'Donoghue 
Cc: Simon Glass 
Cc: Bin Meng 
---
 arch/x86/include/asm/bitops.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
index f97dc66439..196fcf9d3f 100644
--- a/arch/x86/include/asm/bitops.h
+++ b/arch/x86/include/asm/bitops.h
@@ -61,6 +61,8 @@ static __inline__ void __set_bit(int nr, volatile void * addr)
:"Ir" (nr));
 }
 
+#define PLATFORM__SET_BIT
+
 /**
  * clear_bit - Clears a bit in memory
  * @nr: Bit to clear
-- 
2.17.0

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


[U-Boot] [PATCH v3 2/9] riscv: Define PLATFORM__SET_BIT for generic_set_bit()

2018-04-30 Thread Bryan O'Donoghue
riscv bitops.h provides a __set_bit() but does not define PLATFORM__SET_BIT
as a result generic_set_bit() is used instead of the architecturally
provided __set_bit().

This patch defines PLATFORM__SET_BIT which means that __set_bit() in x86
bitops.h will be called whenever generic_set_bit() is called - as opposed
to the default cross-platform generic_set_bit().

Signed-off-by: Bryan O'Donoghue 
Cc: Rick Chen 
Cc: Greentime Hu 
---
 arch/riscv/include/asm/bitops.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/riscv/include/asm/bitops.h b/arch/riscv/include/asm/bitops.h
index 55d420fdfb..0149e5c696 100644
--- a/arch/riscv/include/asm/bitops.h
+++ b/arch/riscv/include/asm/bitops.h
@@ -42,6 +42,8 @@ static inline void __set_bit(int nr, void *addr)
*a |= mask;
 }
 
+#define PLATFORM__SET_BIT
+
 static inline void __clear_bit(int nr, void *addr)
 {
int *a = (int *)addr;
-- 
2.17.0

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


[U-Boot] [PATCH v3 0/9] Fixup set_bit/clear_bit definition and usage

2018-04-30 Thread Bryan O'Donoghue
v3:
- Use linux/bitops.h instead of asm/bitops.h
  - checkpatch.pl

- Updated commit logs to make intended usage of __set_bit() and __clear_bit()
  clearer with respect to generic_set_bit() - Bin Meng

- Added Patch #8 changelong to cover-letter - Lukasz Majewski
  Initial patch fixes compile error for x86 by ifdeffing the local
  set_bit() clear_bit()

  Second patch renames to _set_bit() and _clear_bit() respectively

  Third patch - on further discussion we agree to use generic_set_bit()
  and generic_clear_bit().

  Using generic_set_bit() and generic_clear_bit() prompts me to do a
  general tidy-up of set_bit() and clear_bit() for USB gadget and to
  ensure where architectures provide __set_bit() and/or __clear_bit() that
  said functions are appropriately stitched into generic_set_bit() and
  generic_clear_bit() respectively.

V2:
- Fix commit log nds2 -> nds32
- Fix copy/paste error resulting in double colon "arch : : text"

V1:
Following on from a discussion with Marek and Lukasz re: a namespace
collision with set_bit and clear_bit in f_mass_storage, I noticed some
inconsistencies in the definition and usage of PLATFORM__SET_BIT and
PLATFORM__CLEAR_BIT as well as a similar use of __set_bit in the composite
USB gadget driver.

__set_bit is lock-prefixed on x86 whereas set_bit is not and the analog
driver in upstream Linux does set_bit() not __set_bit().

This series addresses all of those inconsistencies.

There are some usages of __set_bit() but those are in SoC specific GPIO
code-paths and therefore don't really need to change IMO.


Bryan O'Donoghue (9):
  x86: Define PLATFORM__SET_BIT for generic_set_bit()
  riscv: Define PLATFORM__SET_BIT for generic_set_bit()
  riscv: Define PLATFORM__CLEAR_BIT for generic_clear_bit()
  nios2: Define PLATFORM__SET_BIT for generic_set_bit()
  nios2: Define PLATFORM__CLEAR_BIT for generic_clear_bit()
  nds32: Define PLATFORM__SET_BIT for generic_set_bit()
  nds32: Define PLATFORM__CLEAR_BIT for generic_clear_bit()
  usb: f_mass_storage: Fix set_bit and clear_bit usage
  usb: composite convert __set_bit to generic_set_bit

 arch/nds32/include/asm/bitops.h|  4 
 arch/nios2/include/asm/bitops/non-atomic.h |  4 
 arch/riscv/include/asm/bitops.h|  4 
 arch/x86/include/asm/bitops.h  |  2 ++
 drivers/usb/gadget/composite.c |  2 +-
 drivers/usb/gadget/f_mass_storage.c| 25 +++---
 6 files changed, 18 insertions(+), 23 deletions(-)

-- 
2.17.0

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


[U-Boot] [RFH] Das U-Boot logo help

2018-04-30 Thread Tom Rini
Hey all,

So, as far as I can tell, U-Boot hasn't ever had an official logo.  This
lead a while back to Alex using the following logo in a presentation
that I attended:
https://commons.wikimedia.org/wiki/File:Circle-icons-submarine.svg

And I thought it was a pretty good fit too, and as a bonus it's already
GPLv2 or later licensed.  The only thing missing is that it should
probably say U-Boot on it somewhere.  Does anyone out there want to take
a pass at something like that?  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 v3 5/7] bootcount: spl: Extend SPL to support bootcount incrementation

2018-04-30 Thread Tom Rini
On Sun, Apr 29, 2018 at 03:36:31PM +0200, Lukasz Majewski wrote:

> This patch adds support for incrementation of the bootcount in SPL.
> Such feature is necessary when we do want to use this feature with
> 'falcon' boot mode (which loads OS directly in SPL).
> 
> Signed-off-by: Lukasz Majewski 
> 

Reviewed-by: Tom Rini 

-- 
Tom


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


Re: [U-Boot] [PATCH v3 2/7] bootcount: Add include guards into bootcount.h file

2018-04-30 Thread Tom Rini
On Sun, Apr 29, 2018 at 03:36:28PM +0200, Lukasz Majewski wrote:

> This patch adds missing include guards for bootcount.h file.
> 
> Signed-off-by: Lukasz Majewski 
> Reviewed-by: Stefan Roese 
> 

Reviewed-by: Tom Rini 

-- 
Tom


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


Re: [U-Boot] [UBOOT PATCH v3 0/7] Add support of SD3.0 UHS modes for ZynqMP

2018-04-30 Thread Tom Rini
On Mon, Apr 30, 2018 at 11:02:24AM +0200, Michal Simek wrote:
> Hi Tom,
> 
> On 19.4.2018 09:07, Siva Durga Prasad Paladugu wrote:
> > This patch series is meant to add SD3.0 support for ZynqMP
> > platform.
> > The first five patches in the series mostly setting up
> > things in sdhci layer to support SD3.0 , the sixth patch
> > is to add SD3.0 support for ZynqMP platform and the last
> > patch is to enable this support for ZynqMP zcu102 rev1.0
> > eval board.
> > 
> > Siva Durga Prasad Paladugu (7):
> >   mmc: sdhci: Add support for disabling clock
> >   mmc: sdhci: Handle execute tuning command in sdhci_send_command
> >   sdhci: Add new sdhci ops for platform specific tuning and delays
> >   mmc: sdhci: Invoke platform specific tuning and delay routines
> >   mmc : sdhci: Read capabilities register1 and update host caps
> >   mmc: zynq_sdhci: Add support for SD3.0
> >   zynqmp: zcu102: Enable UHS support for ZCU102 Rev1.0 board
> > 
> >  board/xilinx/zynqmp/Makefile  |   2 +
> >  board/xilinx/zynqmp/tap_delays.c  | 229 
> > +
> >  configs/xilinx_zynqmp_zcu102_rev1_0_defconfig |   2 +
> >  drivers/mmc/sdhci.c   |  63 ++-
> >  drivers/mmc/zynq_sdhci.c  | 231 
> > +-
> >  include/sdhci.h   |   8 +
> >  include/zynqmp_tap_delay.h|  20 +++
> >  7 files changed, 547 insertions(+), 8 deletions(-)
> >  create mode 100644 board/xilinx/zynqmp/tap_delays.c
> >  create mode 100644 include/zynqmp_tap_delay.h
> > 
> 
> It looks like that Jaehoon is out or busy with something else. Can you
> please recommend someone to take a look at these patches? Definitely
> feel free to look at it self.

Are these things that need to come in for v2018.05 to fix regressions or
new support?  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 v3 4/7] bootcount: Rewrite autoboot to use wrapper functions from bootcount.h

2018-04-30 Thread Tom Rini
On Sun, Apr 29, 2018 at 03:36:30PM +0200, Lukasz Majewski wrote:

> The code has been refactored to use common wrappers from bootcount.h
> header.
> 
> Signed-off-by: Lukasz Majewski 
> 

Reviewed-by: Tom Rini 

-- 
Tom


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


[U-Boot] [PATCH] arm: Add support for Trenz TE0820 (zynqmp)

2018-04-30 Thread Vladimir Svoboda
Add support for Trenz TE0820 revision 2 MPSoC module.

Signed-off-by: Vladimir Svoboda 
---

 arch/arm/dts/Makefile |   1 +
 arch/arm/dts/zynqmp-te0820-rev2.dts   | 669 ++
 .../zynqmp/zynqmp-te0820-rev2/psu_init_gpl.c  | 624 
 configs/xilinx_zynqmp_te0820_rev2_defconfig   | 105 +++
 include/configs/xilinx_zynqmp_te0820.h|  49 ++
 5 files changed, 1448 insertions(+)
 create mode 100644 arch/arm/dts/zynqmp-te0820-rev2.dts
 create mode 100644 board/xilinx/zynqmp/zynqmp-te0820-rev2/psu_init_gpl.c
 create mode 100644 configs/xilinx_zynqmp_te0820_rev2_defconfig
 create mode 100644 include/configs/xilinx_zynqmp_te0820.h

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index ac7667b1e8..ec4e7cc206 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -148,6 +148,7 @@ dtb-$(CONFIG_ARCH_ZYNQ) += \
 dtb-$(CONFIG_ARCH_ZYNQMP) += \
zynqmp-mini-emmc.dtb\
zynqmp-mini-nand.dtb\
+   zynqmp-te0820-rev2.dtb  \
zynqmp-zcu100-revC.dtb  \
zynqmp-zcu102-revA.dtb  \
zynqmp-zcu102-revB.dtb  \
diff --git a/arch/arm/dts/zynqmp-te0820-rev2.dts 
b/arch/arm/dts/zynqmp-te0820-rev2.dts
new file mode 100644
index 00..db23dfe45c
--- /dev/null
+++ b/arch/arm/dts/zynqmp-te0820-rev2.dts
@@ -0,0 +1,669 @@
+/*
+ * dts file for Xilinx ZynqMP TE0820 Rev2
+ *
+ * (C) Copyright 2018, HIPPEROS.
+ *
+ * Vladimir Svoboda 
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+/dts-v1/;
+
+#include "zynqmp.dtsi"
+#include "zynqmp-clk-ccf.dtsi"
+#include 
+#include 
+#include 
+
+/ {
+   model = "ZynqMP TE0820 Rev2";
+   compatible = "xlnx,zynqmp-te0820-rev2", "xlnx,zynqmp-te0820", 
"xlnx,zynqmp";
+
+   aliases {
+   ethernet0 = 
+   gpio0 = 
+   i2c0 = 
+   i2c1 = 
+   mmc0 = 
+   rtc0 = 
+   serial0 = 
+   serial1 = 
+   serial2 = 
+   spi0 = 
+   usb0 = 
+   };
+
+   chosen {
+   bootargs = "earlycon";
+   stdout-path = "serial0:115200n8";
+   };
+
+   memory@0 {
+   device_type = "memory";
+   reg = <0x0 0x0 0x0 0x4000>;
+   };
+
+   gpio-keys {
+   compatible = "gpio-keys";
+   #address-cells = <1>;
+   #size-cells = <0>;
+   autorepeat;
+   sw19 {
+   label = "sw19";
+   gpios = < 22 GPIO_ACTIVE_HIGH>;
+   linux,code = ;
+   gpio-key,wakeup;
+   autorepeat;
+   };
+   };
+
+   leds {
+   compatible = "gpio-leds";
+   heartbeat_led {
+   label = "heartbeat";
+   gpios = < 23 GPIO_ACTIVE_HIGH>;
+   linux,default-trigger = "heartbeat";
+   };
+   };
+};
+
+ {
+   status = "okay";
+};
+
+ {
+   status = "okay";
+};
+
+_dma_chan1 {
+   status = "okay";
+};
+
+_dma_chan2 {
+   status = "okay";
+};
+
+_dma_chan3 {
+   status = "okay";
+};
+
+_dma_chan4 {
+   status = "okay";
+};
+
+_dma_chan5 {
+   status = "okay";
+};
+
+_dma_chan6 {
+   status = "okay";
+};
+
+_dma_chan7 {
+   status = "okay";
+};
+
+_dma_chan8 {
+   status = "okay";
+};
+
+ {
+   status = "okay";
+   phy-handle = <>;
+   phy-mode = "rgmii-id";
+   phy0: phy@21 {
+   reg = <21>;
+   ti,rx-internal-delay = <0x8>;
+   ti,tx-internal-delay = <0xa>;
+   ti,fifo-depth = <0x1>;
+   };
+   ethernet_phy0: ethernet-phy@0 {
+   compatible = "marvell,88e1510";
+   device_type = "ethernet-phy";
+   reg = <1>;
+   };
+};
+
+ {
+   status = "okay";
+};
+
+ {
+   status = "okay";
+};
+
+ {
+   status = "okay";
+   clock-frequency = <40>;
+
+   tca6416_u97: gpio@20 {
+   compatible = "ti,tca6416";
+   reg = <0x20>;
+   gpio-controller;
+   #gpio-cells = <2>;
+   /*
+* IRQ not connected
+* Lines:
+* 0 - PS_GTR_LAN_SEL0
+* 1 - PS_GTR_LAN_SEL1
+* 2 - PS_GTR_LAN_SEL2
+* 3 - PS_GTR_LAN_SEL3
+* 4 - PCI_CLK_DIR_SEL
+* 5 - IIC_MUX_RESET_B
+* 6 - GEM3_EXP_RESET_B
+* 7, 10 - 17 - not connected
+*/
+
+   gtr_sel0 {
+   gpio-hog;
+   gpios = <0 0>;
+   output-low; /* PCIE = 0, DP = 1 */
+   line-name = "sel0";
+   

[U-Boot] Uboot Hangs when Initrd size increased in FIT image

2018-04-30 Thread gnix
Im booting Linux on arm64 using FIT multi image (image + initrd + DTB). So if
I increase the initrd size (from 16 MB -> 20MB) board hangs at "starting
kernel"). However if I change the load address of bootm (from 0x200 to
0x100) it boots successfully. Any pointers on why this is booting at
lower load address? What is the relationship between bootm multi image load
address and final jump addresses of Image, initrd and FDT? thanks in
advance.

Board config : 2 GB ram (0x - 0x800)
Init high enabled (so initrd is relocated to high mem)
FDT_high=0x so DTB is used in place. 
FDT load adress is (0x900)

Console output:
## Current stack ends at 0x7f6cc6c0 *  kernel: cmdline image address =
0x0200
## Loading kernel from FIT Image at 0200 ...
Using 'config@1' configuration
Verifying Hash Integrity ... OK
Trying 'kernel@0' kernel subimage
 Description:  linux-mvl-4.4
 Type: Kernel Image
 Compression:  uncompressed
 Data Start:   0x02bc
 Data Size:12473856 Bytes = 11.9 MiB
 Architecture: AArch64
 OS:   Linux
 Load Address: 0x0008
 Entry Point:  0x0008
Verifying Hash Integrity ... OK
kernel data at 0x02bc, len = 0x00be5600 (12473856)
*  ramdisk: using config 'config@1' from image at 0x0200
## Loading ramdisk from FIT Image at 0200 ...
Using 'config@1' configuration
Trying 'ramdisk@0' ramdisk subimage
 Description:  initramfs
 Type: RAMDisk Image
 Compression:  lzma compressed
 Data Start:   0x02be5764
 Data Size:22356891 Bytes = 21.3 MiB
 Architecture: AArch64
 OS:   Linux
Can't get 'load' property from FIT 0x0200, node: offset 12474104,   
name ramdisk@0 (FDT_ERR_NOTFOUND)
 Load Address: unavailable
Can't get 'entry' property from FIT 0x0200, node: offset 12474104, name
ramdisk@0 (FDT_ERR_NOTFOUND)
 Entry Point:  unavailable
Verifying Hash Integrity ... OK
Can't get 'load' property from FIT 0x0200, node: offset 12474104, name
ramdisk@0 (FDT_ERR_NOTFOUND)
ramdisk start = 0x02be5764, ramdisk end = 0x04137aff
*  fdt: using config 'config@1' from image at 0x0200
## Checking for 'FDT'/'FDT Image' at 0200
## Loading fdt from FIT Image at 0200 ...
Using 'config@1' configuration
Trying 'fdt@1' fdt subimage
  Description:  P1 fdt
  Type: Flat Device Tree
  Compression:  uncompressed
  Data Start:   0x0413eadc
  Data Size:28899 Bytes = 28.2 KiB
  Architecture: AArch64
 Verifying Hash Integrity ... OK
 Loading fdt from 0x0413eadc to 0x0900
 Booting using the fdt blob at 0x900
 of_flat_tree at 0x0900 size 0x70e3
 Loading Kernel Image ... OK
 kernel loaded at 0x0008, end = 0x00c65600
 ## initrd_high = 0x8000, copy_to_ram = 1
 Loading Ramdisk to 7e179000, end 7f6cb39b ... OK
ramdisk load start = 0x7e179000, ramdisk load end = 0x7f6cb39b
using: FDT
## DT length 41187
Using Device Tree in place at 0900, end 0900a0e2
mci_find_sb_node.no Device found
DevID=11f found on MCi bus 0
DevID=121 found on MCi bus 1
## Transferring control to Linux (at address 8)...

 Starting kernel ...



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


[U-Boot] [RFC PATCH v2 00/20] Add fastboot UDP support

2018-04-30 Thread Alex Kiernan

This series merges the fastboot UDP support from AOSP into mainline
U-Boot.

The underlying implementations of most commands are now merged between
both code paths ('oem format' from the USB side is the only one remaining).

Other changes to command handling so that UDP follows the existing USB
behaviour:

- 'boot' now follows the USB code and does 'fastboot CONFIG_FASTBOOT_BUF_ADDR'.
  I've added 'fastbootcmd' which if set overrides the boot command and
  allows the existing UDP behaviour to be preserved.
- 'continue' in UDP now exits the fastboot server rather than executing
  'run bootcmd'
- 'reboot-bootloader' no longer writes 'reboot-bootloader' to
  CONFIG_FASTBOOT_BUF_ADDR as its marker for the subsequent boot. The code
  which is in AOSP common/android_bootloader.c expects this marker, but
  we have prior art in the USB code using the weak function
  fb_set_reboot_flag
- 'getvar' in the UDP path now supports fetching 'fastboot.' prefixed
  variables (inherited from the USB path)
- 'getvar' in the USB path inherits all the variables from the UDP path

Remaining issues:

- whilst I've merged NAND support into the UDP code path, I've no way
  of testing it. My expectation is it'll work, but will need timed_send_info
  working into the NAND path to avoid timeouts on the network side.
- I still need to fix timed_send_info handling when going through the USB
  path.
- the protocol part of the fastboot UDP implementation is separated out
  and would I expect form the basis of a consolidated implementation, but
  I'm inclined to address that as a clearly separate patch so it can be
  tested in isolation (I have no USB hardware I can try this on).

Changes in v2:
- ensure fastboot syntax is backward compatible - 'fastboot 0' means
  'fastboot usb 0'

Alex Kiernan (20):
  fastboot: Move fastboot to drivers/fastboot
  fastboot: Switch dependencies on FASTBOOT to USB_FUNCTION_FASTBOOT
  fastboot: Refactor fastboot_okay/fail to take response
  fastboot: Extract fastboot_okay/fail to fb_common.c
  fastboot: Introduce fastboot_response and refactor fastboot_okay/fail
  fastboot: Correct dependencies in FASTBOOT_FLASH
  net: fastboot: Merge AOSP UDP fastboot
  net: fastboot: Support building without MMC
  fastboot: Refactor write_fb_response into fastboot_okay/fail/response
  fastboot: Merge USB and UDP getvar implementation
  fastboot: net: Change 'continue' so it matches USB fastboot
  fastboot: net: Convert command lookup to a table
  fastboot: Merge reboot-bootloader handling
  fastboot: Avoid re-parsing cmd_string for boot/reboot
  fastboot: Merge boot common across USB and UDP
  fastboot: net: Add NAND support
  fastboot: Guard getvar:partition-type/size with MMC
  fastboot: Check if part_name is NULL before using it
  fastboot: Add missing newlines
  fastboot: net: Split fastboot protocol out from net

 arch/arm/Kconfig |   2 -
 arch/arm/mach-omap2/boot-common.c|   2 +-
 arch/arm/mach-omap2/utils.c  |   4 +-
 arch/arm/mach-rockchip/rk3128-board.c|   2 +-
 arch/arm/mach-rockchip/rk322x-board.c|   2 +-
 board/ti/common/Kconfig  |   1 -
 cmd/Kconfig  |  14 +-
 cmd/fastboot.c   |  35 ++-
 cmd/net.c|   6 +
 common/Makefile  |  13 --
 configs/am335x_boneblack_defconfig   |   2 +-
 configs/am335x_boneblack_vboot_defconfig |   2 +-
 configs/am335x_evm_defconfig |   2 +-
 configs/am335x_evm_nor_defconfig |   2 +-
 configs/am335x_evm_norboot_defconfig |   2 +-
 configs/am335x_evm_spiboot_defconfig |   2 +-
 configs/am335x_evm_usbspl_defconfig  |   2 +-
 configs/am57xx_evm_defconfig |   2 +-
 configs/am57xx_hs_evm_defconfig  |   2 +-
 configs/bcm23550_w1d_defconfig   |   2 +-
 configs/bcm28155_ap_defconfig|   2 +-
 configs/birdland_bav335a_defconfig   |   2 +-
 configs/birdland_bav335b_defconfig   |   2 +-
 configs/cgtqmx6eval_defconfig|   2 +-
 configs/dra7xx_evm_defconfig |   2 +-
 configs/dra7xx_hs_evm_defconfig  |   2 +-
 configs/kc1_defconfig|   2 +-
 configs/mx6qsabrelite_defconfig  |   2 +-
 configs/mx6sabresd_defconfig |   2 +-
 configs/nitrogen6dl2g_defconfig  |   2 +-
 configs/nitrogen6dl_defconfig|   2 +-
 configs/nitrogen6q2g_defconfig   |   2 +-
 configs/nitrogen6q_defconfig |   2 +-
 configs/nitrogen6s1g_defconfig   |   2 +-
 configs/nitrogen6s_defconfig |   2 +-
 configs/omap3_beagle_defconfig   |   2 +-
 

[U-Boot] Appended DTB Android boot image support

2018-04-30 Thread Ramon Fried
Hi all.
I'm currently adding support for Qualcomm Dragonboards  to U-boot as a
primary bootloader without chain-loading using LK which is currently
already supported in mainline U-boot.

Qualcomm Android images are regular android images where the DTB's are
appended to the image. Qualcomm used the "unused" field in the image
header to populate the size of the DTB *.

I'm looking for a more standard version for supporting these kind of images.
Currently, to boot these images, you must provide DTB somewhere in mem
and provide it as argument to bootm for instance.

My goal is to add support that U-boot will parse the image, see that
the DTB is included and use that as the FDT automatically.

I'm looking at the "secondary" fields which are currently not used as
a valid option to point to the DTB and it's size.

Do you know if someone is working on something similar, or do you have
any suggestions for the right approach to this issue ?

Thanks,
Ramon

* - Actually, Qualcomm appends a pack of DTBs with offset table and
chooses the right DTB in runtime.
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] boot Hangs when Initrd size increases in FIT image

2018-04-30 Thread gnix
Hello All,

Im booting Linux on arm64 using FIT multi image (image + initrd + DTB). So
if I increase the initrd size (from 16 MB -> 20MB) board hangs at "starting
kernel"). However if I change the load address of bootm (from 0x200 to
0x100) it boots successfully.  Any pointers on why this is booting at
lower load address? thanks in advance.

Board config : 2 GB ram (0x - 0x800)
Init high enabled (so initrd is relocated to high mem)
FDT_high=0x so DTB is used in place. 
FDT load adress is (0x900)

Following is the console o/p:

## Current stack ends at 0x7f6cc6c0 *  kernel: cmdline image address =
0x0200
## Loading kernel from FIT Image at 0200 ...
   Using 'config@1' configuration
   Verifying Hash Integrity ... OK
   Trying 'kernel@0' kernel subimage
 Description:  linux-mvl-4.4
 Type: Kernel Image
 Compression:  uncompressed
 Data Start:   0x02bc
 Data Size:12473856 Bytes = 11.9 MiB
 Architecture: AArch64
 OS:   Linux
 Load Address: 0x0008
 Entry Point:  0x0008
   Verifying Hash Integrity ... OK
   kernel data at 0x02bc, len = 0x00be5600 (12473856)
*  ramdisk: using config 'config@1' from image at 0x0200
## Loading ramdisk from FIT Image at 0200 ...
   Using 'config@1' configuration
   Trying 'ramdisk@0' ramdisk subimage
 Description:  initramfs
 Type: RAMDisk Image
 Compression:  lzma compressed
 Data Start:   0x02be5764
 Data Size:22356891 Bytes = 21.3 MiB
 Architecture: AArch64
 OS:   Linux
Can't get 'load' property from FIT 0x0200, node: offset 12474104, name
ramdisk@0 (FDT_ERR_NOTFOUND)
 Load Address: unavailable
Can't get 'entry' property from FIT 0x0200, node: offset 12474104, name
ramdisk@0 (FDT_ERR_NOTFOUND)
 Entry Point:  unavailable
   Verifying Hash Integrity ... OK
Can't get 'load' property from FIT 0x0200, node: offset 12474104, name
ramdisk@0 (FDT_ERR_NOTFOUND)
   ramdisk start = 0x02be5764, ramdisk end = 0x04137aff
*  fdt: using config 'config@1' from image at 0x0200
## Checking for 'FDT'/'FDT Image' at 0200
## Loading fdt from FIT Image at 0200 ...
   Using 'config@1' configuration
   Trying 'fdt@1' fdt subimage
 Description:  P1 fdt
 Type: Flat Device Tree
 Compression:  uncompressed
 Data Start:   0x0413eadc
 Data Size:28899 Bytes = 28.2 KiB
 Architecture: AArch64
   Verifying Hash Integrity ... OK
   Loading fdt from 0x0413eadc to 0x0900
   Booting using the fdt blob at 0x900
   of_flat_tree at 0x0900 size 0x70e3
   Loading Kernel Image ... OK
   kernel loaded at 0x0008, end = 0x00c65600
## initrd_high = 0x8000, copy_to_ram = 1
   Loading Ramdisk to 7e179000, end 7f6cb39b ... OK
   ramdisk load start = 0x7e179000, ramdisk load end = 0x7f6cb39b
using: FDT
## DT length 41187
   Using Device Tree in place at 0900, end 0900a0e2
mci_find_sb_node.no Device found
DevID=11f found on MCi bus 0
DevID=121 found on MCi bus 1
## Transferring control to Linux (at address 8)...

 Starting kernel ...



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


[U-Boot] [GIT] Pull request: u-boot-dfu (30.04.2018)

2018-04-30 Thread Lukasz Majewski
Dear Marek,

Travis CI:
https://travis-ci.org/lmajewski/u-boot-dfu/builds/372935934

Test HW: Beagle Bone Black


The following changes since commit
d57ed4d9f2cb6abc9438104f321b4fe3bc829d57:

  usb: gadget: composite: fix NULL pointer when a non standard request
  is received (2018-04-26 15:15:07 +0200)

are available in the git repository at:

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

for you to fetch changes up to c85f73adb296ca734dffbe10e0a5190aa6c747c7:

  usb: f_mass_storage: simplify logical expression (2018-04-30 10:41:01
  +0200)


Heinrich Schuchardt (2):
  usb: gadget: remove duplicate assignment.
  usb: f_mass_storage: simplify logical expression

 drivers/usb/gadget/composite.c  | 2 +-
 drivers/usb/gadget/f_mass_storage.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

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


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


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

2018-04-30 Thread Stefano Babic
Hi Tom,

please pull from u-.boot-imx, thanks !

The following changes since commit 5512f5ccf1dc5cec068f8efa1d8ce81f51a988d3:

  Merge git://git.denx.de/u-boot-video (2018-04-24 20:27:43 -0400)

are available in the git repository at:

  git://www.denx.de/git/u-boot-imx.git master

for you to fetch changes up to 07a8f79ee850b1e59371519f179d32fea171bbec:

  ARM: mxs: support full SPL framework (2018-04-27 09:32:54 +0200)


Bryan O'Donoghue (20):
  tools/imximage: Fix fruity lack of 0x prefix in DCD Blocks
  imximage: Specify default IVT offset in IMX image
  warp7: hab: Add a CSF location definition
  warp7: hab: Set environment variable indicating HAB enable
  warp7: defconfig: Enable OPTEE for WaRP7
  warp7: Allocate specific region of memory to OPTEE
  warp7: Print out the OPTEE DRAM region
  warp7: Specify CONFIG_OPTEE_LOAD_ADDR
  warp7: defconfig: Enable CONFIG_SECURE_BOOT
  warp7: defconfig: Enable CONFIG_BOOTM_TEE
  warp7: Make CONFIG_SYS_FDT_ADDR a define
  warp7: Add Kconfig WARP7_ROOT_PART
  warp7: select uuid partition based on rootpart
  warp7: Define the name of a signed boot-script file
  warp7: add warp7_auth_or_fail
  warp7: hab: Set environment variable indicating IVT offset
  warp7: defconfig: Enable CMD_SETEXPR
  warp7: Add support for automated secure boot.scr verification
  warp7: secure_defconfig: Remove secure_defconfig
  warp7: defconfig: Fix CAAM on boot with tip-of-tree

Fabio Estevam (2):
  mx7dsabresd: Remove the mx7dsabresd_secure_defconfig target
  Revert "imximage: Remove failure when no IVT offset is found"

Lukasz Majewski (2):
  eth: dm: fec: Change FEC PHY mask setting from CONFIG_PHYLIB to
CONFIG_FEC_MXC_PHYADDR
  dts: dm: fec: imx53: Provide proper compatible string for imx53
fec driver

Mans Rullgard (5):
  ARM: mxs: make lowlevel_init() weak
  ARM: arm926ejs: fix lowlevel_init call
  ARM: spl: include arm/thumb glue sections
  ARM: mxs: move spl data
  ARM: mxs: support full SPL framework

Mark Jonas (1):
  arm,imx6: fix PAD_CTL_SPEED_LOW constant

Pierre-Jean TEXIER (2):
  warp7: include/configs: use generic fs commands in
CONFIG_EXTRA_ENV_SETTINGS
  warp7: configs: enable CONFIG_CMD_FS_GENERIC

Sébastien Szymanski (2):
  imx6ul: opos6ul: add SPL_DM support
  imx6ul: opos6ul: in Serial Downloader boot mode use ymodem

 arch/arm/Kconfig |  2 +-
 arch/arm/cpu/arm926ejs/mxs/Makefile  |  4 ++--
 arch/arm/cpu/arm926ejs/mxs/mxs.c |  8 +++-
 arch/arm/cpu/arm926ejs/mxs/mxsimage-spl.mx23.cfg |  5 +
 arch/arm/cpu/arm926ejs/mxs/mxsimage-spl.mx28.cfg |  6 ++
 arch/arm/cpu/arm926ejs/mxs/spl_boot.c|  5 +++--
 arch/arm/cpu/arm926ejs/start.S   |  4 ++--
 arch/arm/cpu/u-boot-spl.lds  |  1 +
 arch/arm/dts/imx6ul-opos6ul.dtsi |  4 +++-
 arch/arm/dts/imx6ul-opos6uldev.dts   |  2 ++
 arch/arm/dts/imx6ul.dtsi |  1 +
 arch/arm/include/asm/arch-mx6/opos6ul.h  |  4 
 arch/arm/include/asm/arch-mxs/sys_proto.h|  2 ++
 arch/arm/include/asm/mach-imx/iomux-v3.h |  6 +++---
 arch/arm/mach-imx/mx6/Kconfig|  4 
 arch/arm/mach-imx/mx6/opos6ul.c  | 54
+-
 board/armadeus/opos6uldev/board.c| 20 +---
 board/freescale/mx7dsabresd/MAINTAINERS  |  1 -
 board/warp7/Kconfig  | 14 ++
 board/warp7/MAINTAINERS  |  1 -
 board/warp7/imximage.cfg |  4 
 board/warp7/warp7.c  | 23
+++
 configs/mx7dsabresd_defconfig|  1 +
 configs/mx7dsabresd_secure_defconfig | 78
--
 configs/opos6uldev_defconfig |  5 +
 configs/warp7_defconfig  |  8 +++-
 configs/warp7_secure_defconfig   | 43
---
 drivers/net/fec_mxc.c|  3 ++-
 include/configs/mxs.h|  2 ++
 include/configs/opos6uldev.h |  9 +++--
 include/configs/warp7.h  | 28
+++-
 include/imximage.h   |  3 +++
 tools/imximage.c |  7 ++-
 33 files changed, 145 insertions(+), 217 deletions(-)
 create mode 100644 arch/arm/cpu/arm926ejs/mxs/mxsimage-spl.mx23.cfg
 create mode 100644 arch/arm/cpu/arm926ejs/mxs/mxsimage-spl.mx28.cfg
 delete mode 100644 configs/mx7dsabresd_secure_defconfig
 delete mode 100644 

Re: [U-Boot] Pull request: u-boot-sunxi/master

2018-04-30 Thread Jagan Teki
On Mon, Apr 30, 2018 at 2:35 AM, Tom Rini  wrote:
> On Fri, Apr 27, 2018 at 06:32:53PM +0530, Jagan Teki wrote:
>
>> Hi Tom,
>>
>> Please pull this PR.
>>
>> thanks,
>> Jagan.
>>
>> The following changes since commit 275d80a4c2fb63890f3f4c16b7ad481064e650a0:
>>
>>   Merge git://git.denx.de/u-boot-usb (2018-04-22 09:30:36 -0400)
>>
>> are available in the Git repository at:
>>
>>   git://git.denx.de/u-boot-sunxi.git master
>>
>> for you to fetch changes up to 5ff8e54888e4d26a352453564f7f599d29696dc9:
>>
>>   sunxi: improve throughput in the sunxi_mmc driver (2018-04-25 10:29:38 
>> +0530)
>>
>> 
>> Philipp Tomsich (1):
>>   sunxi: improve throughput in the sunxi_mmc driver
>>
>> Stefan Mavrodiev (1):
>>   sunxi: mmc: Fix phase delays
>>
>>  drivers/mmc/sunxi_mmc.c | 35 ---
>>  1 file changed, 20 insertions(+), 15 deletions(-)
>
> Please re-push on your side, git is unhappy:

done, please try again.

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


Re: [U-Boot] [PATCH v3 8/9] usb: f_mass_storage: Fix set_bit and clear_bit usage

2018-04-30 Thread Bryan O'Donoghue

On 27/04/18 17:20, Lukasz Majewski wrote:

Hi Bryan,


Compiling the f_mass_storage driver for an x86 target results in a
compilation error as set_bit and clear_bit are provided by bitops.h

Looking at the provenance of the current u-boot code and the git
change history in the kernel, it looks like we have a local copy of
set_bit and clear_bit as a hold-over from porting the Linux driver
into u-boot.

These days __set_bit and __clear_bit are optionally provided by an
arch and can be used as inputs to generic_bit_set and
generic_bit_clear.

This patch switches over to generic_set_bit and generic_clear_bit to
accommodate.

Tested on i.MX WaRP7 and Intel Edison


Just I'm a bit puzzled:

This is v3 8/9, followed by 9/9 (v1)?


I sent out two previous versions of this patch as a standalone, if you 
recall.



And after some time you sent v2 8/9 and v2 9/9.

I suppose that the latter ones are correct?

Also it is very handy to have some kind of change log in patches - i.e.:


Cover letter contains, and I believe best practice is to keep the 
changelog in the cover-letter - not the patch itself.


##
V2:
- Fix commit log nds2 -> nds32
- Fix copy/paste error resulting in double colon "arch : : text"

V1:
Following on from a discussion with Marek and Lukasz re: a namespace
collision with set_bit and clear_bit in f_mass_storage, I noticed some
inconsistencies in the definition and usage of PLATFORM__SET_BIT and
PLATFORM__CLEAR_BIT as well as a similar use of __set_bit in the composite
USB gadget driver.

__set_bit is lock-prefixed on x86 whereas set_bit is not and the analog
driver in upstream Linux does set_bit() not __set_bit().

This series addresses all of those inconsistencies.

There are some usages of __set_bit() but those are in SoC specific GPIO
code-paths and therefore don't really need to change IMO.
##

Anyway I'll resend this set as a v3 since Bin Meng needs a change to the 
log text anyway.


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


Re: [U-Boot] [PATCH 6/6] cmd: Add "boot_android" command.

2018-04-30 Thread Alex Deymo
Regarding the boot_android command, U-Boot supports loading Android-format
kernel images to memory and booting them. That's not the main purpose of
boot_android, it actually does that by just calling bootm.

The part that U-Boot doesn't support is all the flows around booting an
Android device that are expected in AOSP. A big one is reading and honoring
the Boot Control Block (BCB), normally the first 4KiB of the "misc"
partition. See
https://android.googlesource.com/platform/bootable/recovery/+/master/bootloader_message/include/bootloader_message/bootloader_message.h
for a definition.

BCB is used for factory reset (from the Settings UI in Android), which will
write a message in the BCB saying "boot-recovery":
https://android.googlesource.com/platform/bootable/recovery/+/master/recovery.cpp#135

On boot, the bootloader must read the BCB and decide whether to boot the
normal kernel or instead boot to "recovery" mode. During the Factory Reset,
it is important that this is stored somewhere on the emmc, otherwise if you
just rely on a memory flag to tell the bootloader to boot to "recovery"
mode and complete the factory reset; a cold start boot might forget that
value. There are other cases where the bootloader should enter recovery,
for example when you run "boot recovery" from adb, or whit a multi-stage
non-A/B update (needs to reboot multiple times to recovery).

There's the "bootonce-bootloader" message too, in bootloader_message.cpp in
AOSP as well which tells to boot in bootloader mode (essentially, fastboot
mode), which can be triggered by "reboot bootloader" from userspace.
Deciding this means changing the kernel command line in the bootloader, so
that also must be done somewhere.

On top of that there's all the A/B logic flow, to decide which slot to boot
from; which is also defined in the bootloader_message.h, explained here:
https://source.android.com/devices/tech/ota/ab/ (See "Implementing A/B
Updates" too).

All this is what the boot_android command is taking care of. I'm sorry that
I don't have a better self-contained documentation link about this flow.

I should note that these flows are not *required* for all Android devices.
Android partners are free to use their own format for A/B metadata, not use
the AOSP "recovery" program/updates at all, and I think that even
"fastboot" is not mandatory for some devices (but I really don't know). Of
course, if you don't use this, you have to implement your own (updates, A/B
flow, factory reset...). That said, in my opinion if you take the latest
AOSP, U-Boot and kernel and put them together in a reasonable unlocked
device they should all work with these features and flows. You shouldn't
need to write code to make that work, just enable them, so that's why I
think U-Boot should have these Android-specific flows in it, given that it
already supports loading Android-format kernels.

Best regards,
Alex

2018-04-27 0:41 GMT+02:00 Stanislas BERTRAND :

> Hi Sam,
>
> > Can I ask you some questions about this code?
> >  1. Do I understand correctly that this is just some old patch hanging
> > in mailing list [1]?
>
> Yes, it is from an old post to the mailing list.
>
> >  2. What is the motivation of adding this command? We already have
> > Android boot image support in bootm command, which we successfully use
> > in TI just by loading needed images to RAM and then passing them to
> > bootm, like this: [2].
>
> I am working to get a Android A/B System implementation on my board.
> I was looking to reuse existing implementation. Aiming to stay close to
> the mainline.
>
> The command boot_android performs the different loading and checks
> required before calling bootm.
>
> Like Alex mentioned [4], those patch series are not recent but it was good
> starting point of implementation.
> I had to perform some customization to have a functional boot flow adapted
> to my system ( Android 7.1.1, Linux 4.4.45, U-Boot 2017.0 ).
>
> I am not pushing to have this particular implementation mainline.
> However having a mainline implementation for Android A/B system,
> would be nice. I was giving feedback from my particular system usage.
>
> >  3. Can you provide more information about how this code works? And
> > probably show some relevant link from Android documentation where it
> > says about boot flow implemented here?
>
> >  [1] https://lists.denx.de/pipermail/u-boot/2017-April/285847.html
> > [2] http://git.denx.de/?p=u-boot.git;a=blob;f=include/
> environment/ti/boot.h;h=24b7783f88947db07480d814c798e5
> 1197c07ce2;hb=HEAD#l38
> 
> More information was posted by Alex in his original patch series [3].
>
> Alex, I did add loading of the FDT in the boot_android command. How did
> you load your at 'fdt_addr' ?
>

This was done for the raspberry pi and I was using the FDT that the
bootloader code in the Pi loads and assembles. This is so all the boot.txt
configs and overlays that people expect to work on the pi 

[U-Boot] Fwd: [PATCH 1/1] include: update log2 header from the Linux kernel

2018-04-30 Thread Heinrich Schuchardt
Cc: Fabio Estevam 
(Fabio Estevam  is not valid anymore)

On 04/30/2018 09:09 AM, Heinrich Schuchardt wrote:
> Without the patch gcc 8 produces:
> warning: ignoring attribute ‘noreturn’ because it conflicts with
> attribute ‘const’ [-Wattributes]
>  int ilog2_NaN(void);
> 
> So let's update the include from Linux kernel v4.16.
> 
> This removes static checks of ilog2() arguments.
> 
> Signed-off-by: Heinrich Schuchardt 
> ---
>  include/linux/log2.h | 63 +---
>  1 file changed, 36 insertions(+), 27 deletions(-)
> 
> diff --git a/include/linux/log2.h b/include/linux/log2.h
> index aa1de63090..41a1ae0109 100644
> --- a/include/linux/log2.h
> +++ b/include/linux/log2.h
> @@ -3,7 +3,10 @@
>   * Copyright (C) 2006 Red Hat, Inc. All Rights Reserved.
>   * Written by David Howells (dhowe...@redhat.com)
>   *
> - * SPDX-License-Identifier:  GPL-2.0+
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * as published by the Free Software Foundation; either version
> + * 2 of the License, or (at your option) any later version.
>   */
>  
>  #ifndef _LINUX_LOG2_H
> @@ -12,12 +15,6 @@
>  #include 
>  #include 
>  
> -/*
> - * deal with unrepresentable constant logarithms
> - */
> -extern __attribute__((const, noreturn))
> -int ilog2_NaN(void);
> -
>  /*
>   * non-constant log of base 2 calculators
>   * - the arch may override these in asm/bitops.h if they can be implemented
> @@ -40,19 +37,23 @@ int __ilog2_u64(u64 n)
>  }
>  #endif
>  
> -/*
> - *  Determine whether some value is a power of two, where zero is
> +/**
> + * is_power_of_2() - check if a value is a power of two
> + * @n: the value to check
> + *
> + * Determine whether some value is a power of two, where zero is
>   * *not* considered a power of two.
> + * Return: true if @n is a power of 2, otherwise false.
>   */
> -
>  static inline __attribute__((const))
>  bool is_power_of_2(unsigned long n)
>  {
>   return (n != 0 && ((n & (n - 1)) == 0));
>  }
>  
> -/*
> - * round up to nearest power of two
> +/**
> + * __roundup_pow_of_two() - round up to nearest power of two
> + * @n: value to round up
>   */
>  static inline __attribute__((const))
>  unsigned long __roundup_pow_of_two(unsigned long n)
> @@ -60,8 +61,9 @@ unsigned long __roundup_pow_of_two(unsigned long n)
>   return 1UL << fls_long(n - 1);
>  }
>  
> -/*
> - * round down to nearest power of two
> +/**
> + * __rounddown_pow_of_two() - round down to nearest power of two
> + * @n: value to round down
>   */
>  static inline __attribute__((const))
>  unsigned long __rounddown_pow_of_two(unsigned long n)
> @@ -70,19 +72,19 @@ unsigned long __rounddown_pow_of_two(unsigned long n)
>  }
>  
>  /**
> - * ilog2 - log of base 2 of 32-bit or a 64-bit unsigned value
> - * @n - parameter
> + * ilog2 - log base 2 of 32-bit or a 64-bit unsigned value
> + * @n: parameter
>   *
>   * constant-capable log of base 2 calculation
>   * - this can be used to initialise global variables from constant data, 
> hence
> - *   the massive ternary operator construction
> + * the massive ternary operator construction
>   *
>   * selects the appropriately-sized optimised version depending on sizeof(n)
>   */
>  #define ilog2(n) \
>  (\
>   __builtin_constant_p(n) ? ( \
> - (n) < 1 ? ilog2_NaN() : \
> + (n) < 2 ? 0 :   \
>   (n) & (1ULL << 63) ? 63 :   \
>   (n) & (1ULL << 62) ? 62 :   \
>   (n) & (1ULL << 61) ? 61 :   \
> @@ -145,10 +147,7 @@ unsigned long __rounddown_pow_of_two(unsigned long n)
>   (n) & (1ULL <<  4) ?  4 :   \
>   (n) & (1ULL <<  3) ?  3 :   \
>   (n) & (1ULL <<  2) ?  2 :   \
> - (n) & (1ULL <<  1) ?  1 :   \
> - (n) & (1ULL <<  0) ?  0 :   \
> - ilog2_NaN() \
> -) :  \
> + 1) :\
>   (sizeof(n) <= 4) ?  \
>   __ilog2_u32(n) :\
>   __ilog2_u64(n)  \
> @@ -156,7 +155,7 @@ unsigned long __rounddown_pow_of_two(unsigned long n)
>  
>  /**
>   * roundup_pow_of_two - round the given value up to nearest power of two
> - * @n - parameter
> + * @n: parameter
>   *
>   * round the given value up to the nearest power of two
>   * - the result is undefined when n == 0
> @@ -173,7 +172,7 @@ unsigned long __rounddown_pow_of_two(unsigned long n)
>  
>  /**
>   * rounddown_pow_of_two - round the given value down to nearest power of two
> - * @n - parameter
> + * @n: parameter
>   *
>   * round the given value down to the nearest power of two
>   * - the result is 

Re: [U-Boot] [PATCH v2] arm: zynqmp: Add ZynqMP minimal R5 support

2018-04-30 Thread Michal Simek
On 30.4.2018 11:07, Alexander Graf wrote:
> 
> 
> On 30.04.18 10:43, Michal Simek wrote:
>> On 30.4.2018 09:53, Alexander Graf wrote:
>>>
>>>
>>> On 30.04.18 09:37, Michal Simek wrote:
 Xilinx ZynqMP also contains dual Cortex R5 which can run U-Boot.
 This patch is adding minimal support to get U-Boot boot.
 U-Boot on R5 runs out of DDR with default configuration that's why
 DDR needs to be partitioned if there is something else running on arm64.
 Console is done via Cadence uart driver and the first Cadence Triple
 Timer Counter is used for time.

 This configuration with uart1 was tested on zcu100-revC.

 U-Boot 2018.05-rc2-00021-gd058a08d907d (Apr 18 2018 - 14:11:27 +0200)

 Model: Xilinx ZynqMP R5
 DRAM:  512 MiB
 WARNING: Caches not enabled
 MMC:
 In:serial@ff01
 Out:   serial@ff01
 Err:   serial@ff01
 Net:   Net Initialization Skipped
 No ethernet found.
 ZynqMP r5>

 There are two ways how to run this on ZynqMP.
 1. Run from ZynqMP arm64
 tftpb 2000 u-boot-r5.elf
 setenv autostart no && bootelf -p 2000
 cpu 4 disable && cpu 4 release 1000 lockstep
 or
 cpu 4 disable && cpu 4 release 1000 split

 2. Load via jtag when directly to R5

 Signed-off-by: Michal Simek 
 ---

 Changes in v2:
 - Make this a single patch because core support was handled by Lokesh
   Vulta R5 series. Rebase on the top of this series
 - Add reset_cpu which is not handle by core
 - Add MPU support to enable only 0-512MB and RO for 512MB-2GB
 - Enable cache support
 - Wire MTEST macros but not enable mtest command

 Changes compare to RFC
 - Use 500MHz instead of 600MHz
 - Remove fpu compilation flags
 - Split arm-r5 code and platform

> 
> 
> [...]
> 
 +/* Serial drivers */
 +/* The following table includes the supported baudrates */
 +#define CONFIG_SYS_BAUDRATE_TABLE  \
 +  {300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400}
 +
 +# define CONFIG_ENV_SIZE  (128 << 10)
 +
 +/* Allow to overwrite serial and ethaddr */
 +#define CONFIG_ENV_OVERWRITE
 +
 +/* Boot configuration */
 +#define CONFIG_SYS_LOAD_ADDR  0 /* default? */
 +
 +#define CONFIG_SYS_MAXARGS32 /* max number of command 
 args */
 +
 +#define CONFIG_NR_DRAM_BANKS  1
>>>
>>> Is this enough? I would assume people will want to at least cover TCM
>>> and DDR from within U-Boot.
>>
>> Initial expectation is that R5 will run just from DDR because exception
>> vectors are placed at 0x0. It means it is about how big memory you want
>> to assign to R5. I hardcoded it to 0-512MB which should be enough for start.
>>
>> I didn't test TCM that's why it is not there and can be added later when
>> it is tested properly like with others drivers which are not enabled now.
> 
> Works for me, it just means more places people could trip over when
> adding additional regions.
> 
> Also keep in mind that while U-Boot may run from DDR, it doesn't mean
> whatever it's booting can't use TCM. And if that something happens to be
> a UEFI binary, that would share its address space with U-Boot.

It is not only about TCM. Also OCM can be used for that purpose or
whatever memory in PL.

Thanks,
Michal


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


Re: [U-Boot] [PATCH v2] arm: zynqmp: Add ZynqMP minimal R5 support

2018-04-30 Thread Alexander Graf


On 30.04.18 10:43, Michal Simek wrote:
> On 30.4.2018 09:53, Alexander Graf wrote:
>>
>>
>> On 30.04.18 09:37, Michal Simek wrote:
>>> Xilinx ZynqMP also contains dual Cortex R5 which can run U-Boot.
>>> This patch is adding minimal support to get U-Boot boot.
>>> U-Boot on R5 runs out of DDR with default configuration that's why
>>> DDR needs to be partitioned if there is something else running on arm64.
>>> Console is done via Cadence uart driver and the first Cadence Triple
>>> Timer Counter is used for time.
>>>
>>> This configuration with uart1 was tested on zcu100-revC.
>>>
>>> U-Boot 2018.05-rc2-00021-gd058a08d907d (Apr 18 2018 - 14:11:27 +0200)
>>>
>>> Model: Xilinx ZynqMP R5
>>> DRAM:  512 MiB
>>> WARNING: Caches not enabled
>>> MMC:
>>> In:serial@ff01
>>> Out:   serial@ff01
>>> Err:   serial@ff01
>>> Net:   Net Initialization Skipped
>>> No ethernet found.
>>> ZynqMP r5>
>>>
>>> There are two ways how to run this on ZynqMP.
>>> 1. Run from ZynqMP arm64
>>> tftpb 2000 u-boot-r5.elf
>>> setenv autostart no && bootelf -p 2000
>>> cpu 4 disable && cpu 4 release 1000 lockstep
>>> or
>>> cpu 4 disable && cpu 4 release 1000 split
>>>
>>> 2. Load via jtag when directly to R5
>>>
>>> Signed-off-by: Michal Simek 
>>> ---
>>>
>>> Changes in v2:
>>> - Make this a single patch because core support was handled by Lokesh
>>>   Vulta R5 series. Rebase on the top of this series
>>> - Add reset_cpu which is not handle by core
>>> - Add MPU support to enable only 0-512MB and RO for 512MB-2GB
>>> - Enable cache support
>>> - Wire MTEST macros but not enable mtest command
>>>
>>> Changes compare to RFC
>>> - Use 500MHz instead of 600MHz
>>> - Remove fpu compilation flags
>>> - Split arm-r5 code and platform
>>>


[...]

>>> +/* Serial drivers */
>>> +/* The following table includes the supported baudrates */
>>> +#define CONFIG_SYS_BAUDRATE_TABLE  \
>>> +   {300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400}
>>> +
>>> +# define CONFIG_ENV_SIZE   (128 << 10)
>>> +
>>> +/* Allow to overwrite serial and ethaddr */
>>> +#define CONFIG_ENV_OVERWRITE
>>> +
>>> +/* Boot configuration */
>>> +#define CONFIG_SYS_LOAD_ADDR   0 /* default? */
>>> +
>>> +#define CONFIG_SYS_MAXARGS 32 /* max number of command args */
>>> +
>>> +#define CONFIG_NR_DRAM_BANKS   1
>>
>> Is this enough? I would assume people will want to at least cover TCM
>> and DDR from within U-Boot.
> 
> Initial expectation is that R5 will run just from DDR because exception
> vectors are placed at 0x0. It means it is about how big memory you want
> to assign to R5. I hardcoded it to 0-512MB which should be enough for start.
> 
> I didn't test TCM that's why it is not there and can be added later when
> it is tested properly like with others drivers which are not enabled now.

Works for me, it just means more places people could trip over when
adding additional regions.

Also keep in mind that while U-Boot may run from DDR, it doesn't mean
whatever it's booting can't use TCM. And if that something happens to be
a UEFI binary, that would share its address space with U-Boot.


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


Re: [U-Boot] [UBOOT PATCH v3 0/7] Add support of SD3.0 UHS modes for ZynqMP

2018-04-30 Thread Michal Simek
Hi Tom,

On 19.4.2018 09:07, Siva Durga Prasad Paladugu wrote:
> This patch series is meant to add SD3.0 support for ZynqMP
> platform.
> The first five patches in the series mostly setting up
> things in sdhci layer to support SD3.0 , the sixth patch
> is to add SD3.0 support for ZynqMP platform and the last
> patch is to enable this support for ZynqMP zcu102 rev1.0
> eval board.
> 
> Siva Durga Prasad Paladugu (7):
>   mmc: sdhci: Add support for disabling clock
>   mmc: sdhci: Handle execute tuning command in sdhci_send_command
>   sdhci: Add new sdhci ops for platform specific tuning and delays
>   mmc: sdhci: Invoke platform specific tuning and delay routines
>   mmc : sdhci: Read capabilities register1 and update host caps
>   mmc: zynq_sdhci: Add support for SD3.0
>   zynqmp: zcu102: Enable UHS support for ZCU102 Rev1.0 board
> 
>  board/xilinx/zynqmp/Makefile  |   2 +
>  board/xilinx/zynqmp/tap_delays.c  | 229 +
>  configs/xilinx_zynqmp_zcu102_rev1_0_defconfig |   2 +
>  drivers/mmc/sdhci.c   |  63 ++-
>  drivers/mmc/zynq_sdhci.c  | 231 
> +-
>  include/sdhci.h   |   8 +
>  include/zynqmp_tap_delay.h|  20 +++
>  7 files changed, 547 insertions(+), 8 deletions(-)
>  create mode 100644 board/xilinx/zynqmp/tap_delays.c
>  create mode 100644 include/zynqmp_tap_delay.h
> 

It looks like that Jaehoon is out or busy with something else. Can you
please recommend someone to take a look at these patches? Definitely
feel free to look at it self.

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


Re: [U-Boot] [PATCH v2] arm64: zynqmp: Setup MMU map for DDR at run time

2018-04-30 Thread Michal Simek
On 30.4.2018 09:46, Alexander Graf wrote:
> 
> 
> On 30.04.18 09:23, Michal Simek wrote:
>> From: Nitin Jain 
>>
>> This patch fills the MMU map for DDR at run time based information read
> 
> based on

will fix.


>> +void mem_map_fill(void)
>> +{
>> +int banks = ZYNQMP_MEM_MAP_USED;
>> +
>> +#if defined(CONFIG_DEFINE_TCM_OCM_MMAP)
>> +zynqmp_mem_map[banks].virt = 0xffe0UL;
>> +zynqmp_mem_map[banks].phys = 0xffe0UL;
>> +zynqmp_mem_map[banks].size = 0x0020UL;
>> +zynqmp_mem_map[banks].attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
>> +  PTE_BLOCK_INNER_SHARE;
>> +banks = banks + 1;
>> +#endif
>> +
>> +#if !defined(CONFIG_ZYNQMP_NO_DDR)
>> +for (int i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
>> +/* Skip empty banks */
>> +if (!gd->bd->bi_dram[i].size)
>> +break;
> 
> This doesn't skip, it takes empty as abort condition. That is probably
> correct, but please update the comment above to reflect reality.

Will fix comment.

> 
>> +
>> +zynqmp_mem_map[banks].virt = gd->bd->bi_dram[i].start;
>> +zynqmp_mem_map[banks].phys = gd->bd->bi_dram[i].start;
>> +zynqmp_mem_map[banks].size = gd->bd->bi_dram[i].size;
>> +zynqmp_mem_map[banks].attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
>> +  PTE_BLOCK_INNER_SHARE;
>> +banks = banks + 1;
>> +}
>> +#endif
>> +}
>> +
>>  struct mm_region *mem_map = zynqmp_mem_map;
>>  
>>  u64 get_page_table_size(void)
>> diff --git a/arch/arm/include/asm/arch-zynqmp/sys_proto.h 
>> b/arch/arm/include/asm/arch-zynqmp/sys_proto.h
>> index 3daf0e81d80c..d11c0782b8dd 100644
>> --- a/arch/arm/include/asm/arch-zynqmp/sys_proto.h
>> +++ b/arch/arm/include/asm/arch-zynqmp/sys_proto.h
>> @@ -46,7 +46,7 @@ int invoke_smc(u32 pm_api_id, u32 arg0, u32 arg1, u32 
>> arg2, u32 arg3,
>> u32 *ret_payload);
>>  
>>  void initialize_tcm(bool mode);
>> -
>> +void mem_map_fill(void);
>>  int chip_id(unsigned char id);
>>  
>>  #endif /* _ASM_ARCH_SYS_PROTO_H */
>> diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c
>> index aeef0b4cdd7e..6d09a4c73139 100644
>> --- a/board/xilinx/zynqmp/zynqmp.c
>> +++ b/board/xilinx/zynqmp/zynqmp.c
>> @@ -406,7 +406,15 @@ unsigned long do_go_exec(ulong (*entry)(int, char * 
>> const []), int argc,
>>  #if !defined(CONFIG_SYS_SDRAM_BASE) && !defined(CONFIG_SYS_SDRAM_SIZE)
>>  int dram_init_banksize(void)
>>  {
>> -return fdtdec_setup_memory_banksize();
>> +int ret;
>> +
>> +ret = fdtdec_setup_memory_banksize();
>> +if (ret)
>> +return ret;
>> +
>> +mem_map_fill();
>> +
>> +return 0;
>>  }
>>  
>>  int dram_init(void)
>> @@ -417,6 +425,18 @@ int dram_init(void)
>>  return 0;
>>  }
>>  #else
>> +int dram_init_banksize(void)
>> +{
>> +#if defined(CONFIG_NR_DRAM_BANKS)
>> +gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
>> +gd->bd->bi_dram[0].size = get_effective_memsize();
>> +#endif
> 
> Didn't zynqmp have a split ddr window with one starting from 0 and one
> from 0x8? How can this span all available memory then?

There are even 3 locations above 0 (+2GB size), 32GB (+32GB size) and
768G (+256GB) but I have never seen zynqmp with more then 32GB memory.

This is for !DT case where it is expectation that you work with memory
below 4GB which is all the time just one BANK used by mini u-boot
configurations.

> Doesn't that mean your OS would not see all memory because U-Boot
> doesn't tell it about all? Both booti (via dtb patching) and bootefi
> (via efi memory tables) pass memory information to the OS from bi_dram
> fields.

These mini configurations are not used for boot OS. But if you want to
do that CONFIG_ARCH_FIXUP_FDT_MEMORY is your friend and memory map
doesn't need to be passed to OS at all.

For OF case which are standard configuration there are 2 banks wired.

Thanks,
Michal

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


Re: [U-Boot] [PATCH v2] arm: zynqmp: Add ZynqMP minimal R5 support

2018-04-30 Thread Michal Simek
On 30.4.2018 09:53, Alexander Graf wrote:
> 
> 
> On 30.04.18 09:37, Michal Simek wrote:
>> Xilinx ZynqMP also contains dual Cortex R5 which can run U-Boot.
>> This patch is adding minimal support to get U-Boot boot.
>> U-Boot on R5 runs out of DDR with default configuration that's why
>> DDR needs to be partitioned if there is something else running on arm64.
>> Console is done via Cadence uart driver and the first Cadence Triple
>> Timer Counter is used for time.
>>
>> This configuration with uart1 was tested on zcu100-revC.
>>
>> U-Boot 2018.05-rc2-00021-gd058a08d907d (Apr 18 2018 - 14:11:27 +0200)
>>
>> Model: Xilinx ZynqMP R5
>> DRAM:  512 MiB
>> WARNING: Caches not enabled
>> MMC:
>> In:serial@ff01
>> Out:   serial@ff01
>> Err:   serial@ff01
>> Net:   Net Initialization Skipped
>> No ethernet found.
>> ZynqMP r5>
>>
>> There are two ways how to run this on ZynqMP.
>> 1. Run from ZynqMP arm64
>> tftpb 2000 u-boot-r5.elf
>> setenv autostart no && bootelf -p 2000
>> cpu 4 disable && cpu 4 release 1000 lockstep
>> or
>> cpu 4 disable && cpu 4 release 1000 split
>>
>> 2. Load via jtag when directly to R5
>>
>> Signed-off-by: Michal Simek 
>> ---
>>
>> Changes in v2:
>> - Make this a single patch because core support was handled by Lokesh
>>   Vulta R5 series. Rebase on the top of this series
>> - Add reset_cpu which is not handle by core
>> - Add MPU support to enable only 0-512MB and RO for 512MB-2GB
>> - Enable cache support
>> - Wire MTEST macros but not enable mtest command
>>
>> Changes compare to RFC
>> - Use 500MHz instead of 600MHz
>> - Remove fpu compilation flags
>> - Split arm-r5 code and platform
>>
>> ---
>>  MAINTAINERS|  6 +++
>>  arch/arm/Kconfig   | 10 
>>  arch/arm/Makefile  |  1 +
>>  arch/arm/dts/Makefile  |  2 +
>>  arch/arm/dts/zynqmp-r5.dts | 73 ++
>>  arch/arm/mach-zynqmp-r5/Kconfig| 27 +++
>>  arch/arm/mach-zynqmp-r5/Makefile   |  3 ++
>>  arch/arm/mach-zynqmp-r5/cpu.c  | 37 +++
>>  board/xilinx/zynqmp_r5/MAINTAINERS |  7 +++
>>  board/xilinx/zynqmp_r5/Makefile|  6 +++
>>  board/xilinx/zynqmp_r5/board.c | 25 ++
>>  configs/xilinx_zynqmp_r5_defconfig | 16 +++
>>  drivers/serial/Kconfig |  2 +-
>>  include/configs/xilinx_zynqmp_r5.h | 51 +
>>  14 files changed, 265 insertions(+), 1 deletion(-)
>>  create mode 100644 arch/arm/dts/zynqmp-r5.dts
>>  create mode 100644 arch/arm/mach-zynqmp-r5/Kconfig
>>  create mode 100644 arch/arm/mach-zynqmp-r5/Makefile
>>  create mode 100644 arch/arm/mach-zynqmp-r5/cpu.c
>>  create mode 100644 board/xilinx/zynqmp_r5/MAINTAINERS
>>  create mode 100644 board/xilinx/zynqmp_r5/Makefile
>>  create mode 100644 board/xilinx/zynqmp_r5/board.c
>>  create mode 100644 configs/xilinx_zynqmp_r5_defconfig
>>  create mode 100644 include/configs/xilinx_zynqmp_r5.h
>>
>> diff --git a/MAINTAINERS b/MAINTAINERS
>> index 147551f66fd3..e60d76dbad8a 100644
>> --- a/MAINTAINERS
>> +++ b/MAINTAINERS
>> @@ -295,6 +295,12 @@ F:  include/zynqmppl.h
>>  F:  tools/zynqimage.c
>>  N:  zynqmp
>>  
>> +ARM ZYNQMP R5
>> +M:  Michal Simek 
>> +S:  Maintained
>> +T:  git git://git.denx.de/u-boot-microblaze.git
>> +F:  arch/arm/mach-zynqmp-r5/
>> +
>>  BUILDMAN
>>  M:  Simon Glass 
>>  S:  Maintained
>> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
>> index f07f17f053ff..13e06ff763d0 100644
>> --- a/arch/arm/Kconfig
>> +++ b/arch/arm/Kconfig
>> @@ -823,6 +823,14 @@ config ARCH_ZYNQ
>>  imply CMD_SPL
>>  imply ARCH_EARLY_INIT_R
>>  
>> +config ARCH_ZYNQMP_R5
>> +bool "Xilinx ZynqMP R5 based platform"
>> +select CPU_V7R
>> +select OF_CONTROL
>> +select DM
>> +select DM_SERIAL
>> +select CLK
>> +
>>  config ARCH_ZYNQMP
>>  bool "Xilinx ZynqMP based platform"
>>  select ARM64
>> @@ -1345,6 +1353,8 @@ source "arch/arm/cpu/armv7/vf610/Kconfig"
>>  
>>  source "arch/arm/mach-zynq/Kconfig"
>>  
>> +source "arch/arm/mach-zynqmp-r5/Kconfig"
>> +
>>  source "arch/arm/cpu/armv7/Kconfig"
>>  
>>  source "arch/arm/cpu/armv8/zynqmp/Kconfig"
>> diff --git a/arch/arm/Makefile b/arch/arm/Makefile
>> index 3f5343bc017b..63e2b89ee7ef 100644
>> --- a/arch/arm/Makefile
>> +++ b/arch/arm/Makefile
>> @@ -78,6 +78,7 @@ machine-$(CONFIG_ARCH_STM32MP) += stm32mp
>>  machine-$(CONFIG_TEGRA) += tegra
>>  machine-$(CONFIG_ARCH_UNIPHIER) += uniphier
>>  machine-$(CONFIG_ARCH_ZYNQ) += zynq
>> +machine-$(CONFIG_ARCH_ZYNQMP_R5)+= zynqmp-r5
>>  
>>  machdirs := $(patsubst %,arch/arm/mach-%/,$(machine-y))
>>  
>> diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
>> index 1fb36b3ecdb3..d44a4310081e 100644
>> --- a/arch/arm/dts/Makefile
>> +++ b/arch/arm/dts/Makefile
>> @@ -165,6 +165,8 @@ dtb-$(CONFIG_ARCH_ZYNQMP) += \
>>  

Re: [U-Boot] [PATCH v3 3/7] bootcount: Add function wrappers to handle bootcount increment and error checking

2018-04-30 Thread Lukasz Majewski
Hi Stefan,

> Hi Lukasz,
> 
> sorry, I still have some comments to (hopefully) make this
> implementation a bit more "elegant". Please see below.
> 
> On 29.04.2018 15:36, Lukasz Majewski wrote:
> > Those two functions can be used to provide easy bootcount
> > management.
> > 
> > Signed-off-by: Lukasz Majewski 
> > 
> > ---
> > 
> > Changes in v3:
> > - Unify those functions to also work with common/autoboot.c code
> > - Add enum bootcount_context to distinguish between u-boot proper
> > and SPL
> > 
> > Changes in v2:
> > - None
> > 
> >   include/bootcount.h | 50
> > ++ 1 file changed,
> > 50 insertions(+)
> > 
> > diff --git a/include/bootcount.h b/include/bootcount.h
> > index e3b3f7028e..16fc657b2a 100644
> > --- a/include/bootcount.h
> > +++ b/include/bootcount.h
> > @@ -11,6 +11,13 @@
> >   #include 
> >   #include 
> >   
> > +enum bootcount_context {
> > +   SPL = 1,
> > +   UBOOT,
> > +};  
> 
> Perhaps better some bootcount specific values / enums, like:
> 
> enum bootcount_context {
>   BOOTCOUNT_STATE_SPL = 1,
>   BOOTCOUNT_STATE_UBOOT,
> };
> 
> Or even more generic, as this "boot-state" does not have to be
> bootcount specific:
> 
> enum u_boot_context {
>   U_BOOT_STATE_SPL = 1,
>   U_BOOT_STATE_U_BOOT,
> };
> 
> Or do we already have something like this, perhaps in "gd", where
> its marked, in which state we are currently running? If not, it
> could be added there and could be used from the bootcounter code
> and other interfaces / drivers as well. The parts pre-relocation and
> post-relocation fall also into this area (for the pre- / post-reloc
> we definitely have a variable / flag in gd somewhere). So perhaps:
> 
> enum u_boot_context {
>   U_BOOT_STATE_SPL = 1,
>   U_BOOT_STATE_U_BOOT_PRE_RELOC,
>   U_BOOT_STATE_U_BOOT_POST_RELOC,
> };

I will check if we do have such flags already defined. "gd" approach
looks better (more generic for sure) than the one from v3.

> 
> > +#if defined CONFIG_SPL_BOOTCOUNT_LIMIT || defined
> > CONFIG_BOOTCOUNT_LIMIT +
> >   #if !defined(CONFIG_SYS_BOOTCOUNT_LE)
> > && !defined(CONFIG_SYS_BOOTCOUNT_BE) # if __BYTE_ORDER ==
> > __LITTLE_ENDIAN #  define CONFIG_SYS_BOOTCOUNT_LE
> > @@ -40,4 +47,47 @@ static inline u32 raw_bootcount_load(volatile
> > u32 *addr) return in_be32(addr);
> >   }
> >   #endif
> > +
> > +static inline int bootcount_error(enum bootcount_context bc)
> > +{
> > +   unsigned long bootcount = bootcount_load();
> > +   unsigned long bootlimit = env_get_ulong("bootlimit", 10,
> > 0); +
> > +   if (bootlimit && bootcount > bootlimit) {
> > +   printf("Warning: Bootlimit (%lu) exceeded.",
> > bootlimit);
> > +   if (bc == UBOOT)
> > +   printf(" Using altbootcmd.");
> > +   printf("\n");
> > +
> > +   return 1;
> > +   }
> > +
> > +   return 0;
> > +}
> > +
> > +static inline void bootcount_inc(enum bootcount_context bc)
> > +{
> > +   unsigned long bootcount = bootcount_load();
> > +
> > +   if (bc == SPL) {
> > +   bootcount_store(++bootcount);
> > +   return;
> > +   }
> > +
> > +   /* Only increment bootcount when no bootcount support in
> > SPL */ +#ifndef CONFIG_SPL_BOOTCOUNT_LIMIT
> > +   bootcount++;
> > +#endif
> > +   bootcount_store(bootcount);
> > +   env_set_ulong("bootcount", bootcount);
> > +}  
> 
> Why not use the same logic / code as above (the store does not need
> to happen twice):
> 
>   /* Only increment bootcount when no bootcount support in SPL
> */ #ifndef CONFIG_SPL_BOOTCOUNT_LIMIT
>   bootcount_store(++bootcount);
> #endif
> 
>   env_set_ulong("bootcount", bootcount);
> 
> ?
> 
> What do you think?

Good point - I will add it in v4.

Thanks for input.

> 
> Thanks,
> Stefan


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


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


[U-Boot] [RFC PATCH v2 15/20] fastboot: Merge boot common across USB and UDP

2018-04-30 Thread Alex Kiernan
Merge USB and UDP boot code. The USB implementation stays the same, but
UDP no longer passes an fdt. We introduce a new environment variable
'fastbootcmd' which if set overrides the hardcoded boot command, setting
this then allows the UDP implementation to remain the same. If after
running 'fastbootcmd' the board has not booted, control is returned
to U-Boot and the fastboot process ends.

Signed-off-by: Alex Kiernan 
---

Changes in v2: None

 drivers/fastboot/fb_common.c| 27 +++
 drivers/usb/gadget/f_fastboot.c | 22 +++---
 include/fastboot.h  |  1 +
 net/fastboot.c  | 16 ++--
 4 files changed, 37 insertions(+), 29 deletions(-)

diff --git a/drivers/fastboot/fb_common.c b/drivers/fastboot/fb_common.c
index 36ef669..73d8f94 100644
--- a/drivers/fastboot/fb_common.c
+++ b/drivers/fastboot/fb_common.c
@@ -107,3 +107,30 @@ int __weak fb_set_reboot_flag(void)
 {
return -1;
 }
+
+void fastboot_boot(void *addr)
+{
+   char *s;
+
+   s = env_get("fastbootcmd");
+   if (s) {
+   run_command(s, CMD_FLAG_ENV);
+   } else {
+   static char boot_addr_start[12];
+   static char *const bootm_args[] = {
+   "bootm", boot_addr_start, NULL
+   };
+
+   snprintf(boot_addr_start, sizeof(boot_addr_start) - 1,
+"0x%lx", (long)addr);
+   printf("Booting kernel at %s...\n\n\n", boot_addr_start);
+
+   do_bootm(NULL, 0, 2, bootm_args);
+
+   /* This only happens if image is somehow faulty so we start
+* over. We deliberately leave this policy to the invocation
+* of fastbootcmd if that's what's being run
+*/
+   do_reset(NULL, 0, 0, NULL);
+   }
+}
diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index 84515da..1dca4dd 100644
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -480,18 +480,15 @@ static void cb_download(struct usb_ep *ep, struct 
usb_request *req)
fastboot_tx_write_str(response);
 }
 
-static void do_bootm_on_complete(struct usb_ep *ep, struct usb_request *req)
+static void do_exit_on_complete(struct usb_ep *ep, struct usb_request *req)
 {
-   char boot_addr_start[12];
-   char *bootm_args[] = { "bootm", boot_addr_start, NULL };
-
-   puts("Booting kernel..\n");
-
-   sprintf(boot_addr_start, "0x%lx", (long)CONFIG_FASTBOOT_BUF_ADDR);
-   do_bootm(NULL, 0, 2, bootm_args);
+   g_dnl_trigger_detach();
+}
 
-   /* This only happens if image is somehow faulty so we start over */
-   do_reset(NULL, 0, 0, NULL);
+static void do_bootm_on_complete(struct usb_ep *ep, struct usb_request *req)
+{
+   fastboot_boot((void *)CONFIG_FASTBOOT_BUF_ADDR);
+   do_exit_on_complete(ep, req);
 }
 
 static void cb_boot(struct usb_ep *ep, struct usb_request *req)
@@ -500,11 +497,6 @@ static void cb_boot(struct usb_ep *ep, struct usb_request 
*req)
fastboot_tx_write_str("OKAY");
 }
 
-static void do_exit_on_complete(struct usb_ep *ep, struct usb_request *req)
-{
-   g_dnl_trigger_detach();
-}
-
 static void cb_continue(struct usb_ep *ep, struct usb_request *req)
 {
fastboot_func->in_req->complete = do_exit_on_complete;
diff --git a/include/fastboot.h b/include/fastboot.h
index 9767065..64f9939 100644
--- a/include/fastboot.h
+++ b/include/fastboot.h
@@ -76,4 +76,5 @@ int strcmp_l1(const char *s1, const char *s2);
 
 int fastboot_lookup_command(const char *cmd_string);
 int fb_set_reboot_flag(void);
+void fastboot_boot(void *addr);
 #endif /* _FASTBOOT_H_ */
diff --git a/net/fastboot.c b/net/fastboot.c
index ad8c101..119011c 100644
--- a/net/fastboot.c
+++ b/net/fastboot.c
@@ -383,20 +383,8 @@ static void cb_reboot_bootloader(char *cmd_parameter, char 
*fastboot_data,
  */
 static void boot_downloaded_image(void)
 {
-   char kernel_addr[12];
-   char *fdt_addr = env_get("fdt_addr_r");
-   char *const bootm_args[] = {
-   "bootm", kernel_addr, "-", fdt_addr, NULL
-   };
-
-   sprintf(kernel_addr, "0x%lx", (long)CONFIG_FASTBOOT_BUF_ADDR);
-
-   printf("\nBooting kernel at %s with fdt at %s...\n\n\n",
-  kernel_addr, fdt_addr);
-   do_bootm(NULL, 0, 4, bootm_args);
-
-   /* This only happens if image is faulty so we start over. */
-   do_reset(NULL, 0, 0, NULL);
+   fastboot_boot((void *)CONFIG_FASTBOOT_BUF_ADDR);
+   net_set_state(NETLOOP_SUCCESS);
 }
 
 /**
-- 
2.7.4

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


[U-Boot] [RFC PATCH v2 19/20] fastboot: Add missing newlines

2018-04-30 Thread Alex Kiernan
Add newlines so we format our output correctly.

Signed-off-by: Alex Kiernan 
---

Changes in v2: None

 drivers/fastboot/fb_mmc.c | 28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/fastboot/fb_mmc.c b/drivers/fastboot/fb_mmc.c
index 416f309..2f67965 100644
--- a/drivers/fastboot/fb_mmc.c
+++ b/drivers/fastboot/fb_mmc.c
@@ -154,7 +154,7 @@ static lbaint_t fb_mmc_get_boot_header(struct blk_desc 
*dev_desc,
sector_size = info->blksz;
hdr_sectors = DIV_ROUND_UP(sizeof(struct andr_img_hdr), sector_size);
if (hdr_sectors == 0) {
-   pr_err("invalid number of boot sectors: 0");
+   pr_err("invalid number of boot sectors: 0\n");
fastboot_fail("invalid number of boot sectors: 0", response);
return 0;
}
@@ -162,7 +162,7 @@ static lbaint_t fb_mmc_get_boot_header(struct blk_desc 
*dev_desc,
/* Read the boot image header */
res = blk_dread(dev_desc, info->start, hdr_sectors, (void *)hdr);
if (res != hdr_sectors) {
-   pr_err("cannot read header from boot partition");
+   pr_err("cannot read header from boot partition\n");
fastboot_fail("cannot read header from boot partition",
  response);
return 0;
@@ -171,7 +171,7 @@ static lbaint_t fb_mmc_get_boot_header(struct blk_desc 
*dev_desc,
/* Check boot header magic string */
res = android_image_check_header(hdr);
if (res != 0) {
-   pr_err("bad boot image magic");
+   pr_err("bad boot image magic\n");
fastboot_fail("boot partition not initialized", response);
return 0;
}
@@ -210,7 +210,7 @@ static int fb_mmc_update_zimage(struct blk_desc *dev_desc,
/* Get boot partition info */
res = part_get_info_by_name(dev_desc, BOOT_PARTITION_NAME, );
if (res < 0) {
-   pr_err("cannot find boot partition");
+   pr_err("cannot find boot partition\n");
fastboot_fail("cannot find boot partition", response);
return -1;
}
@@ -222,14 +222,14 @@ static int fb_mmc_update_zimage(struct blk_desc *dev_desc,
/* Read boot image header */
hdr_sectors = fb_mmc_get_boot_header(dev_desc, , hdr, response);
if (hdr_sectors == 0) {
-   pr_err("unable to read boot image header");
+   pr_err("unable to read boot image header\n");
fastboot_fail("unable to read boot image header", response);
return -1;
}
 
/* Check if boot image has second stage in it (we don't support it) */
if (hdr->second_size > 0) {
-   pr_err("moving second stage is not supported yet");
+   pr_err("moving second stage is not supported yet\n");
fastboot_fail("moving second stage is not supported yet",
  response);
return -1;
@@ -248,7 +248,7 @@ static int fb_mmc_update_zimage(struct blk_desc *dev_desc,
res = blk_dread(dev_desc, ramdisk_sector_start, ramdisk_sectors,
ramdisk_buffer);
if (res != ramdisk_sectors) {
-   pr_err("cannot read ramdisk from boot partition");
+   pr_err("cannot read ramdisk from boot partition\n");
fastboot_fail("cannot read ramdisk from boot partition",
  response);
return -1;
@@ -258,7 +258,7 @@ static int fb_mmc_update_zimage(struct blk_desc *dev_desc,
hdr->kernel_size = download_bytes;
res = blk_dwrite(dev_desc, info.start, hdr_sectors, (void *)hdr);
if (res == 0) {
-   pr_err("cannot writeback boot image header");
+   pr_err("cannot writeback boot image header\n");
fastboot_fail("cannot write back boot image header", response);
return -1;
}
@@ -270,7 +270,7 @@ static int fb_mmc_update_zimage(struct blk_desc *dev_desc,
res = blk_dwrite(dev_desc, kernel_sector_start, kernel_sectors,
 download_buffer);
if (res == 0) {
-   pr_err("cannot write new kernel");
+   pr_err("cannot write new kernel\n");
fastboot_fail("cannot write new kernel", response);
return -1;
}
@@ -282,7 +282,7 @@ static int fb_mmc_update_zimage(struct blk_desc *dev_desc,
res = blk_dwrite(dev_desc, ramdisk_sector_start, ramdisk_sectors,
 ramdisk_buffer);
if (res == 0) {
-   pr_err("cannot write back original ramdisk");
+   pr_err("cannot write back original ramdisk\n");
fastboot_fail("cannot write back original ramdisk", response);
return -1;
}
@@ -396,21 +396,21 @@ void fb_mmc_erase(const char *cmd, char 

Re: [U-Boot] [RFC PATCH v1 0/5] Add fastboot UDP support

2018-04-30 Thread Alex Kiernan
On Fri, Apr 27, 2018 at 1:20 PM, Alex Kiernan  wrote:
> On Fri, Apr 27, 2018 at 9:04 AM, Lukasz Majewski  wrote:
>> Hi Kever,
>>
>>> Hi Jocelyn and Alex,
>>>
>>>
>>> It's great to see you are getting this feature from google code
>>> to be mainline code.
>>>
>>> My opinion is that we should have the same fastboot cmd handling
>>> in both UDP and USB in a common file, but not have separate code in
>>> net/fastboot.c and drivers/usb/gadget/f_fastboot.c, could you try to
>>> merge these two in one?
>>
>> I've already proposed to put common code (the protocol handling)
>> into /drivers/fastboot and have only small glue code for USB and NET.
>>
>
> I'm working towards that. I'm starting with the command
> implementations, then I'll look at the protocol.
>
> Hopefully I'll get an RFCv2 out sometime over the weekend with the
> first bits done.
>

Just posted a v2, still needs more work, but getting feedback on the
direction would be useful.

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


Re: [U-Boot] [PATCH 3/5] api: Flush cache when closing api

2018-04-30 Thread Dr. Philipp Tomsich

> On 30 Apr 2018, at 10:34, Emmanuel Vadot  wrote:
> 
> Signed-off-by: Emmanuel Vadot 
> ---
> api/api.c | 11 +++
> 1 file changed, 11 insertions(+)
> 
> diff --git a/api/api.c b/api/api.c
> index 7eee2fc083..7d1608b520 100644
> --- a/api/api.c
> +++ b/api/api.c
> @@ -290,6 +290,17 @@ static int API_dev_close(va_list ap)
>   if (!err)
>   di->state = DEV_STA_CLOSED;
> 
> +#if defined(CONFIG_SYS_HAVE_DCACHE_MAINTENANCE) && \
> + !defined(CONFIG_SYS_DCACHE_OFF)
> + if (dcache_status())
> + flush_dcache_all();
> +#endif
> +#if defined(CONFIG_SYS_HAVE_ICACHE_MAINTENANCE) && \
> + !defined(CONFIG_SYS_ICACHE_OFF)
> + if (icache_status())
> + invalidate_icache_all();
> +#endif

Wouldn’t it be a cleaner option to make flush_dcache_all and 
invalidate_icache_all
weak-functions and provide a default implementation that does nothing. Those
architectures that then need to implement specific cache maintenance, could
override these as required.

>   return err;
> }
> 
> -- 
> 2.16.3
> 

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


[U-Boot] [RFC PATCH v2 13/20] fastboot: Merge reboot-bootloader handling

2018-04-30 Thread Alex Kiernan
Extract fb_set_reboot_flag() from USB code and ensure all the overides
are included, then make the UDP fastboot code go through this same
path.

Note this changes the behaviour of the fastboot net code such that
"reboot-bootloader" is no longer written to CONFIG_FASTBOOT_BUF_ADDR for
use as a marker on reboot (the AOSP code in common/android-bootloader.c
uses this marker - this code could be reinstated there if that gets
merged).

Signed-off-by: Alex Kiernan 
---

Changes in v2: None

 arch/arm/mach-omap2/boot-common.c |  2 +-
 arch/arm/mach-rockchip/rk3128-board.c |  2 +-
 arch/arm/mach-rockchip/rk322x-board.c |  2 +-
 drivers/fastboot/fb_common.c  |  5 +
 drivers/usb/gadget/f_fastboot.c   |  5 -
 include/fastboot.h|  1 +
 net/fastboot.c| 17 +
 7 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/arch/arm/mach-omap2/boot-common.c 
b/arch/arm/mach-omap2/boot-common.c
index f9ab5da..2be5c11 100644
--- a/arch/arm/mach-omap2/boot-common.c
+++ b/arch/arm/mach-omap2/boot-common.c
@@ -238,7 +238,7 @@ void arch_preboot_os(void)
 }
 #endif
 
-#if defined(CONFIG_USB_FUNCTION_FASTBOOT) && !defined(CONFIG_ENV_IS_NOWHERE)
+#if CONFIG_IS_ENABLED(FASTBOOT) && !CONFIG_IS_ENABLED(ENV_IS_NOWHERE)
 int fb_set_reboot_flag(void)
 {
printf("Setting reboot to fastboot flag ...\n");
diff --git a/arch/arm/mach-rockchip/rk3128-board.c 
b/arch/arm/mach-rockchip/rk3128-board.c
index 2e8393d..00ad563 100644
--- a/arch/arm/mach-rockchip/rk3128-board.c
+++ b/arch/arm/mach-rockchip/rk3128-board.c
@@ -112,7 +112,7 @@ int board_usb_cleanup(int index, enum usb_init_type init)
 }
 #endif
 
-#if defined(CONFIG_USB_FUNCTION_FASTBOOT)
+#if CONFIG_IS_ENABLED(FASTBOOT)
 int fb_set_reboot_flag(void)
 {
struct rk3128_grf *grf;
diff --git a/arch/arm/mach-rockchip/rk322x-board.c 
b/arch/arm/mach-rockchip/rk322x-board.c
index 8642a90..0ddfac8 100644
--- a/arch/arm/mach-rockchip/rk322x-board.c
+++ b/arch/arm/mach-rockchip/rk322x-board.c
@@ -140,7 +140,7 @@ int board_usb_cleanup(int index, enum usb_init_type init)
 }
 #endif
 
-#if defined(CONFIG_USB_FUNCTION_FASTBOOT)
+#if CONFIG_IS_ENABLED(FASTBOOT)
 int fb_set_reboot_flag(void)
 {
struct rk322x_grf *grf;
diff --git a/drivers/fastboot/fb_common.c b/drivers/fastboot/fb_common.c
index 8b3627b..36ef669 100644
--- a/drivers/fastboot/fb_common.c
+++ b/drivers/fastboot/fb_common.c
@@ -102,3 +102,8 @@ int fastboot_lookup_command(const char *cmd_string)
 
return -1;
 }
+
+int __weak fb_set_reboot_flag(void)
+{
+   return -1;
+}
diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index a493c75..84515da 100644
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -357,11 +357,6 @@ static void compl_do_reset(struct usb_ep *ep, struct 
usb_request *req)
do_reset(NULL, 0, 0, NULL);
 }
 
-int __weak fb_set_reboot_flag(void)
-{
-   return -ENOSYS;
-}
-
 static void cb_reboot(struct usb_ep *ep, struct usb_request *req)
 {
char *cmd = req->buf;
diff --git a/include/fastboot.h b/include/fastboot.h
index de07220..9767065 100644
--- a/include/fastboot.h
+++ b/include/fastboot.h
@@ -75,4 +75,5 @@ void timed_send_info(ulong *start, const char *msg);
 int strcmp_l1(const char *s1, const char *s2);
 
 int fastboot_lookup_command(const char *cmd_string);
+int fb_set_reboot_flag(void);
 #endif /* _FASTBOOT_H_ */
diff --git a/net/fastboot.c b/net/fastboot.c
index 155049a..edf78df 100644
--- a/net/fastboot.c
+++ b/net/fastboot.c
@@ -65,7 +65,7 @@ static void cb_flash(char *, char *, unsigned int, char *);
 static void cb_erase(char *, char *, unsigned int, char *);
 #endif
 static void cb_continue(char *, char *, unsigned int, char *);
-static void cb_reboot(char *, char *, unsigned int, char *);
+static void cb_reboot_bootloader(char *, char *, unsigned int, char *);
 
 static void (*fb_net_dispatch[])(char *cmd_parameter,
 char *fastboot_data,
@@ -83,8 +83,8 @@ static void (*fb_net_dispatch[])(char *cmd_parameter,
 #endif
[FB_CMD_BOOT] = cb_okay,
[FB_CMD_CONTINUE] = cb_continue,
-   [FB_CMD_REBOOT] = cb_reboot,
-   [FB_CMD_REBOOT_BOOTLOADER] = cb_reboot,
+   [FB_CMD_REBOOT] = cb_okay,
+   [FB_CMD_REBOOT_BOOTLOADER] = cb_reboot_bootloader,
[FB_CMD_POWERDOWN] = NULL,
[FB_CMD_SET_ACTIVE] = cb_okay,
[FB_CMD_UPLOAD] = NULL,
@@ -370,12 +370,13 @@ static void cb_continue(char *cmd_parameter, char 
*fastboot_data,
  *
  * @param repsonsePointer to fastboot response buffer
  */
-static void cb_reboot(char *cmd_parameter, char *fastboot_data,
- unsigned int fastboot_data_len, char *response)
+static void cb_reboot_bootloader(char *cmd_parameter, char *fastboot_data,
+unsigned int fastboot_data_len, char *response)
 {
-   fastboot_okay(NULL, response);
-   if 

Re: [U-Boot] [PATCH v4 3/4] MAINTAINERS: Declare tools/zynq*.{c, h} as Xilinx maintained

2018-04-30 Thread Michal Simek
On 13.4.2018 14:18, Alexander Graf wrote:
> The zynqimage.c, zynqmpimage.c and the new zynqmpbif.c files are all
> maintained by Xilinx for the Zynq platforms. Let's match them accordingly
> in the MAINTAINERS file.
> 
> Signed-off-by: Alexander Graf 
> ---
>  MAINTAINERS | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 44eeefa635..bf7f7bf23c 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -289,7 +289,8 @@ F:drivers/spi/zynq_spi.c
>  F:   drivers/usb/host/ehci-zynq.c
>  F:   drivers/watchdog/cdns_wdt.c
>  F:   include/zynqmppl.h
> -F:   tools/zynqimage.c
> +F:   tools/zynq*.c
> +F:   tools/zynq*.h

zynqmp* - should be enough
zynq*.c is also covering zynqimage.c which is taken by previous fragment.

I have fixed it myself.

Thanks
Michal

-- 
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Xilinx Microblaze
Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP ARM64 SoCs
U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP SoCs

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


[U-Boot] [RFC PATCH v2 09/20] fastboot: Refactor write_fb_response into fastboot_okay/fail/response

2018-04-30 Thread Alex Kiernan
Replace write_fb_response with fastboot_okay/fail/response. Also allow
fastboot_okay to take NULL when we have no message to send.

Signed-off-by: Alex Kiernan 
---

Changes in v2: None

 drivers/fastboot/fb_common.c|  5 ++-
 drivers/fastboot/fb_mmc.c   | 10 ++---
 drivers/fastboot/fb_nand.c  |  4 +-
 drivers/fastboot/image-sparse.c |  2 +-
 net/fastboot.c  | 95 +++--
 5 files changed, 47 insertions(+), 69 deletions(-)

diff --git a/drivers/fastboot/fb_common.c b/drivers/fastboot/fb_common.c
index 7367fbb..f0bf53d 100644
--- a/drivers/fastboot/fb_common.c
+++ b/drivers/fastboot/fb_common.c
@@ -45,7 +45,10 @@ void fastboot_fail(const char *reason, char *response)
 
 void fastboot_okay(const char *reason, char *response)
 {
-   fastboot_response("OKAY", response, "%s", reason);
+   if (reason)
+   fastboot_response("OKAY", response, "%s", reason);
+   else
+   fastboot_response("OKAY", response, NULL);
 }
 
 void timed_send_info(ulong *start, const char *msg)
diff --git a/drivers/fastboot/fb_mmc.c b/drivers/fastboot/fb_mmc.c
index 304bda1..416f309 100644
--- a/drivers/fastboot/fb_mmc.c
+++ b/drivers/fastboot/fb_mmc.c
@@ -128,7 +128,7 @@ static void write_raw_image(struct blk_desc *dev_desc, 
disk_partition_t *info,
 
printf(" wrote " LBAFU " bytes to '%s'\n", blkcnt * info->blksz,
   part_name);
-   fastboot_okay("", response);
+   fastboot_okay(NULL, response);
 }
 
 #ifdef CONFIG_ANDROID_BOOT_IMAGE
@@ -288,7 +288,7 @@ static int fb_mmc_update_zimage(struct blk_desc *dev_desc,
}
 
puts(" zImage was updated in boot partition\n");
-   fastboot_okay("", response);
+   fastboot_okay(NULL, response);
return 0;
 }
 #endif
@@ -323,7 +323,7 @@ void fb_mmc_flash_write(const char *cmd, void 
*download_buffer,
return;
}
printf(" success\n");
-   fastboot_okay("", response);
+   fastboot_okay(NULL, response);
return;
}
 #endif
@@ -344,7 +344,7 @@ void fb_mmc_flash_write(const char *cmd, void 
*download_buffer,
return;
}
printf(" success\n");
-   fastboot_okay("", response);
+   fastboot_okay(NULL, response);
return;
}
 #endif
@@ -436,5 +436,5 @@ void fb_mmc_erase(const char *cmd, char *response)
 
printf(" erased " LBAFU " bytes from '%s'\n",
   blks_size * info.blksz, cmd);
-   fastboot_okay("", response);
+   fastboot_okay(NULL, response);
 }
diff --git a/drivers/fastboot/fb_nand.c b/drivers/fastboot/fb_nand.c
index 3a0b101..de869a0 100644
--- a/drivers/fastboot/fb_nand.c
+++ b/drivers/fastboot/fb_nand.c
@@ -199,7 +199,7 @@ void fb_nand_flash_write(const char *cmd, void 
*download_buffer,
return;
}
 
-   fastboot_okay("", response);
+   fastboot_okay(NULL, response);
 }
 
 void fb_nand_erase(const char *cmd, char *response)
@@ -226,5 +226,5 @@ void fb_nand_erase(const char *cmd, char *response)
return;
}
 
-   fastboot_okay("", response);
+   fastboot_okay(NULL, response);
 }
diff --git a/drivers/fastboot/image-sparse.c b/drivers/fastboot/image-sparse.c
index 616c2bd..ecdb3d3 100644
--- a/drivers/fastboot/image-sparse.c
+++ b/drivers/fastboot/image-sparse.c
@@ -257,7 +257,7 @@ void write_sparse_image(
if (total_blocks != sparse_header->total_blks)
fastboot_fail("sparse image write failure", response);
else
-   fastboot_okay("", response);
+   fastboot_okay(NULL, response);
 
return;
 }
diff --git a/net/fastboot.c b/net/fastboot.c
index 87c12e5..960e7f1 100644
--- a/net/fastboot.c
+++ b/net/fastboot.c
@@ -67,7 +67,6 @@ static void fb_continue(char *);
 static void fb_reboot(char *);
 static void boot_downloaded_image(void);
 static void cleanup_command_data(void);
-static void write_fb_response(const char *, const char *, char *);
 
 void fastboot_send_info(const char *msg)
 {
@@ -89,7 +88,7 @@ void fastboot_send_info(const char *msg)
memcpy(packet, _response_header, sizeof(fb_response_header));
packet += sizeof(fb_response_header);
/* Write response */
-   write_fb_response("INFO", msg, response);
+   fastboot_response("INFO", response, "%s", msg);
memcpy(packet, response, strlen(response));
packet += strlen(response);
 
@@ -178,18 +177,17 @@ static void fastboot_send(struct fastboot_header 
fb_header, char *fastboot_data,
fb_erase(response);
 #endif
} else if (!strcmp("boot", cmd_string)) {
-   write_fb_response("OKAY", "", response);
+   fastboot_okay(NULL, response);
} else if 

[U-Boot] [RFC PATCH v2 12/20] fastboot: net: Convert command lookup to a table

2018-04-30 Thread Alex Kiernan
Change command lookup to use a lookup table so it matches the existing
USB fastboot code.

Signed-off-by: Alex Kiernan 
---

Changes in v2: None

 drivers/fastboot/fb_common.c |  30 
 include/fastboot.h   |  21 +
 net/fastboot.c   | 108 ++-
 3 files changed, 127 insertions(+), 32 deletions(-)

diff --git a/drivers/fastboot/fb_common.c b/drivers/fastboot/fb_common.c
index 3b68f25..8b3627b 100644
--- a/drivers/fastboot/fb_common.c
+++ b/drivers/fastboot/fb_common.c
@@ -72,3 +72,33 @@ int strcmp_l1(const char *s1, const char *s2)
return -1;
return strncmp(s1, s2, strlen(s1));
 }
+
+static const char *const fb_commands[] = {
+   [FB_CMD_GETVAR] = "getvar",
+   [FB_CMD_DOWNLOAD] = "download",
+   [FB_CMD_VERIFY] = "verify",
+   [FB_CMD_FLASH] = "flash",
+   [FB_CMD_ERASE] = "erase",
+   [FB_CMD_BOOT] = "boot",
+   [FB_CMD_CONTINUE] = "continue",
+   [FB_CMD_REBOOT] = "reboot",
+   [FB_CMD_REBOOT_BOOTLOADER] = "reboot-bootloader",
+   [FB_CMD_POWERDOWN] = "powerdown",
+   [FB_CMD_SET_ACTIVE] = "set_active",
+   [FB_CMD_UPLOAD] = "upload",
+};
+
+int fastboot_lookup_command(const char *cmd_string)
+{
+   int i;
+
+   for (i = 0; i < FB_CMD_COUNT; i++) {
+   int len = strlen(fb_commands[i]);
+
+   if (!strncmp(fb_commands[i], cmd_string, len) &&
+   (cmd_string[len] == '\0' || cmd_string[len] == ':'))
+   return i;
+   }
+
+   return -1;
+}
diff --git a/include/fastboot.h b/include/fastboot.h
index fb58358..de07220 100644
--- a/include/fastboot.h
+++ b/include/fastboot.h
@@ -18,6 +18,26 @@
 /* The 64 defined bytes plus \0 */
 #define FASTBOOT_RESPONSE_LEN  (64 + 1)
 
+/**
+ * All known commands to fastboot
+ */
+enum {
+   FB_CMD_GETVAR = 0,
+   FB_CMD_DOWNLOAD,
+   FB_CMD_VERIFY,
+   FB_CMD_FLASH,
+   FB_CMD_ERASE,
+   FB_CMD_BOOT,
+   FB_CMD_CONTINUE,
+   FB_CMD_REBOOT,
+   FB_CMD_REBOOT_BOOTLOADER,
+   FB_CMD_POWERDOWN,
+   FB_CMD_SET_ACTIVE,
+   FB_CMD_UPLOAD,
+
+   FB_CMD_COUNT
+};
+
 void fastboot_response(const char *tag, char *response,
   const char *format, ...)
__attribute__ ((format (__printf__, 3, 4)));
@@ -54,4 +74,5 @@ void timed_send_info(ulong *start, const char *msg);
  */
 int strcmp_l1(const char *s1, const char *s2);
 
+int fastboot_lookup_command(const char *cmd_string);
 #endif /* _FASTBOOT_H_ */
diff --git a/net/fastboot.c b/net/fastboot.c
index ed13890..155049a 100644
--- a/net/fastboot.c
+++ b/net/fastboot.c
@@ -57,13 +57,39 @@ static int fastboot_remote_port;
 /* The UDP port at our end */
 static int fastboot_our_port;
 
-static void fb_download(char *, unsigned int, char *);
+static void cb_okay(char *, char *, unsigned int, char *);
+static void cb_getvar(char *, char *, unsigned int, char *);
+static void cb_download(char *, char *, unsigned int, char *);
 #if CONFIG_IS_ENABLED(FASTBOOT_FLASH_MMC)
-static void fb_flash(char *);
-static void fb_erase(char *);
+static void cb_flash(char *, char *, unsigned int, char *);
+static void cb_erase(char *, char *, unsigned int, char *);
 #endif
-static void fb_continue(char *);
-static void fb_reboot(char *);
+static void cb_continue(char *, char *, unsigned int, char *);
+static void cb_reboot(char *, char *, unsigned int, char *);
+
+static void (*fb_net_dispatch[])(char *cmd_parameter,
+char *fastboot_data,
+unsigned int fastboot_data_len,
+char *response) = {
+   [FB_CMD_GETVAR] = cb_getvar,
+   [FB_CMD_DOWNLOAD] = cb_download,
+   [FB_CMD_VERIFY] = NULL,
+#if CONFIG_IS_ENABLED(FASTBOOT_FLASH_MMC)
+   [FB_CMD_FLASH] = cb_flash,
+   [FB_CMD_ERASE] = cb_erase,
+#else
+   [FB_CMD_FLASH] = NULL,
+   [FB_CMD_ERASE] = NULL,
+#endif
+   [FB_CMD_BOOT] = cb_okay,
+   [FB_CMD_CONTINUE] = cb_continue,
+   [FB_CMD_REBOOT] = cb_reboot,
+   [FB_CMD_REBOOT_BOOTLOADER] = cb_reboot,
+   [FB_CMD_POWERDOWN] = NULL,
+   [FB_CMD_SET_ACTIVE] = cb_okay,
+   [FB_CMD_UPLOAD] = NULL,
+};
+
 static void boot_downloaded_image(void);
 static void cleanup_command_data(void);
 
@@ -165,28 +191,30 @@ static void fastboot_send(struct fastboot_header 
fb_header, char *fastboot_data,
cmd_string = strdup(cmd_string);
if (cmd_parameter)
cmd_parameter = strdup(cmd_parameter);
-   } else if (!strcmp("getvar", cmd_string)) {
-   fb_getvar(cmd_parameter, response);
-   } else if (!strcmp("download", cmd_string)) {
-   fb_download(fastboot_data, fastboot_data_len, response);
-#if CONFIG_IS_ENABLED(FASTBOOT_FLASH_MMC)
-   } else if (!strcmp("flash", 

[U-Boot] [RFC PATCH v2 20/20] fastboot: net: Split fastboot protocol out from net

2018-04-30 Thread Alex Kiernan
Separate the fastboot protocol handling from the fastboot UDP code in
preparation for reusing it in the USB code.

Signed-off-by: Alex Kiernan 
---

Changes in v2: None

 drivers/fastboot/Makefile|   1 +
 drivers/fastboot/fb_packet.c | 249 +++
 include/fastboot.h   |   3 +
 net/fastboot.c   | 234 +---
 4 files changed, 258 insertions(+), 229 deletions(-)
 create mode 100644 drivers/fastboot/fb_packet.c

diff --git a/drivers/fastboot/Makefile b/drivers/fastboot/Makefile
index 9af4073..c0106a7 100644
--- a/drivers/fastboot/Makefile
+++ b/drivers/fastboot/Makefile
@@ -2,6 +2,7 @@
 
 obj-y += fb_common.o
 obj-y += fb_getvar.o
+obj-y += fb_packet.o
 obj-$(CONFIG_FASTBOOT_FLASH) += image-sparse.o
 
 obj-$(CONFIG_FASTBOOT_FLASH_MMC) += fb_mmc.o
diff --git a/drivers/fastboot/fb_packet.c b/drivers/fastboot/fb_packet.c
new file mode 100644
index 000..fbe5668
--- /dev/null
+++ b/drivers/fastboot/fb_packet.c
@@ -0,0 +1,249 @@
+// SPDX-License-Identifier: BSD-2-Clause
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Parsed from first fastboot command packet */
+static char *cmd_string;
+static char *cmd_parameter;
+static int cmd = -1;
+
+/* Fastboot download parameters */
+static unsigned int bytes_received;
+static unsigned int bytes_expected;
+static unsigned int image_size;
+
+static void cb_okay(char *, char *, unsigned int, char *);
+static void cb_getvar(char *, char *, unsigned int, char *);
+static void cb_download(char *, char *, unsigned int, char *);
+#if CONFIG_IS_ENABLED(FASTBOOT_FLASH)
+static void cb_flash(char *, char *, unsigned int, char *);
+static void cb_erase(char *, char *, unsigned int, char *);
+#endif
+static void cb_continue(char *, char *, unsigned int, char *);
+static void cb_reboot_bootloader(char *, char *, unsigned int, char *);
+
+static void (*fb_net_dispatch[])(char *cmd_parameter,
+char *fastboot_data,
+unsigned int fastboot_data_len,
+char *response) = {
+   [FB_CMD_GETVAR] = cb_getvar,
+   [FB_CMD_DOWNLOAD] = cb_download,
+   [FB_CMD_VERIFY] = NULL,
+#if CONFIG_IS_ENABLED(FASTBOOT_FLASH)
+   [FB_CMD_FLASH] = cb_flash,
+   [FB_CMD_ERASE] = cb_erase,
+#else
+   [FB_CMD_FLASH] = NULL,
+   [FB_CMD_ERASE] = NULL,
+#endif
+   [FB_CMD_BOOT] = cb_okay,
+   [FB_CMD_CONTINUE] = cb_continue,
+   [FB_CMD_REBOOT] = cb_okay,
+   [FB_CMD_REBOOT_BOOTLOADER] = cb_reboot_bootloader,
+   [FB_CMD_POWERDOWN] = NULL,
+   [FB_CMD_SET_ACTIVE] = cb_okay,
+   [FB_CMD_UPLOAD] = NULL,
+};
+
+static void cleanup_command_data(void);
+
+int fastboot_packet_handle(char *fastboot_data,
+  unsigned int fastboot_data_len, char *response)
+{
+   if (!cmd_string) {
+   /* Parse command and send ack */
+   cmd_parameter = fastboot_data;
+   cmd_string = strsep(_parameter, ":");
+   cmd_string = strdup(cmd_string);
+   cmd = fastboot_lookup_command(cmd_string);
+   if (cmd_parameter)
+   cmd_parameter = strdup(cmd_parameter);
+   } else {
+   if (cmd >= 0) {
+   void (*fb_call)(char *cmd_parameter,
+   char *fastboot_data,
+   unsigned int fastboot_data_len,
+   char *response);
+   fb_call = fb_net_dispatch[cmd];
+   if (fb_call) {
+   fb_call(cmd_parameter, fastboot_data,
+   fastboot_data_len, response);
+   } else {
+   pr_err("command %s not implemented.\n",
+  cmd_string);
+   fastboot_fail("unrecognized command",
+ response);
+   }
+   } else {
+   pr_err("command %s not recognized.\n",
+  cmd_string);
+   fastboot_fail("unrecognized command", response);
+   }
+   }
+   return cmd;
+}
+
+void fastboot_after_response(char *response)
+{
+   /* OKAY and FAIL indicate command is complete */
+   if (!strncmp("OKAY", response, 4) || !strncmp("FAIL", response, 4))
+   cleanup_command_data();
+}
+
+static void cb_okay(char *cmd_parameter, char *fastboot_data,
+   unsigned int fastboot_data_len, char *response)
+{
+   fastboot_okay(NULL, response);
+}
+
+static void cb_getvar(char *cmd_parameter, char *fastboot_data,
+ unsigned int fastboot_data_len, char *response)

[U-Boot] [RFC PATCH v2 07/20] net: fastboot: Merge AOSP UDP fastboot

2018-04-30 Thread Alex Kiernan
Merge UDP fastboot support from AOSP:

https://android.googlesource.com/platform/external/u-boot/+/android-o-mr1-iot-preview-8

Signed-off-by: Alex Kiernan 
Signed-off-by: Alex Deymo 
---

Changes in v2:
- ensure fastboot syntax is backward compatible - 'fastboot 0' means
  'fastboot usb 0'

 cmd/fastboot.c   |  35 ++-
 cmd/net.c|   6 +
 drivers/fastboot/Kconfig |  16 +-
 drivers/fastboot/fb_common.c |  18 ++
 drivers/fastboot/fb_mmc.c|  34 ++-
 include/fastboot.h   |  13 ++
 include/net.h|   6 +-
 include/net/fastboot.h   |  27 +++
 net/Makefile |   1 +
 net/fastboot.c   | 542 +++
 net/net.c|   9 +
 11 files changed, 695 insertions(+), 12 deletions(-)
 create mode 100644 include/net/fastboot.h
 create mode 100644 net/fastboot.c

diff --git a/cmd/fastboot.c b/cmd/fastboot.c
index 8adcca5..68a41de 100644
--- a/cmd/fastboot.c
+++ b/cmd/fastboot.c
@@ -11,17 +11,41 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 static int do_fastboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const 
argv[])
 {
+#ifdef CONFIG_USB_FUNCTION_FASTBOOT
int controller_index;
char *usb_controller;
int ret;
+#endif
 
if (argc < 2)
return CMD_RET_USAGE;
 
+   if (!strcmp(argv[1], "udp")) {
+#ifndef CONFIG_UDP_FUNCTION_FASTBOOT
+   pr_err("Fastboot UDP not enabled\n");
+   return -1;
+#else
+   return do_fastboot_udp(cmdtp, flag, argc, argv);
+#endif
+   }
+
+   if (!strcmp(argv[1], "usb")) {
+   argv++;
+   argc--;
+   }
+
+   if (argc < 2)
+   return CMD_RET_USAGE;
+
+#ifndef CONFIG_USB_FUNCTION_FASTBOOT
+   pr_err("Fastboot USB not enabled\n");
+   return -1;
+#else
usb_controller = argv[1];
controller_index = simple_strtoul(usb_controller, NULL, 0);
 
@@ -59,11 +83,14 @@ exit:
board_usb_cleanup(controller_index, USB_INIT_DEVICE);
 
return ret;
+#endif
 }
 
 U_BOOT_CMD(
-   fastboot, 2, 1, do_fastboot,
-   "use USB Fastboot protocol",
-   "\n"
-   "- run as a fastboot usb device"
+   fastboot, 3, 1, do_fastboot,
+   "use USB or UDP Fastboot protocol",
+   "[usb,udp] \n"
+   " - run as a fastboot usb or udp device\n"
+   "   usb: specify \n"
+   "   udp: requires ip_addr set and ethernet initialized\n"
 );
diff --git a/cmd/net.c b/cmd/net.c
index 67888d4..668f344 100644
--- a/cmd/net.c
+++ b/cmd/net.c
@@ -74,6 +74,12 @@ U_BOOT_CMD(
 );
 #endif
 
+#ifdef CONFIG_UDP_FUNCTION_FASTBOOT
+int do_fastboot_udp(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
+{
+   return netboot_common(FASTBOOT, cmdtp, argc, argv);
+}
+#endif
 
 #ifdef CONFIG_CMD_RARP
 int do_rarpb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
diff --git a/drivers/fastboot/Kconfig b/drivers/fastboot/Kconfig
index 64b94f0..53c337f 100644
--- a/drivers/fastboot/Kconfig
+++ b/drivers/fastboot/Kconfig
@@ -2,6 +2,8 @@ menu "Fastboot support"
 
 config FASTBOOT
bool
+   imply ANDROID_BOOT_IMAGE
+   imply CMD_FASTBOOT
 
 config USB_FUNCTION_FASTBOOT
bool "Enable USB fastboot gadget"
@@ -9,12 +11,17 @@ config USB_FUNCTION_FASTBOOT
default y if ARCH_SUNXI && USB_MUSB_GADGET
select FASTBOOT
select USB_GADGET_DOWNLOAD
-   imply ANDROID_BOOT_IMAGE
-   imply CMD_FASTBOOT
help
  This enables the USB part of the fastboot gadget.
 
-if USB_FUNCTION_FASTBOOT
+config UDP_FUNCTION_FASTBOOT
+   depends on NET
+   select FASTBOOT
+   bool "Enable fastboot protocol over UDP"
+   help
+ This enables the fastboot protocol over UDP.
+
+if USB_FUNCTION_FASTBOOT || UDP_FUNCTION_FASTBOOT
 
 config FASTBOOT_BUF_ADDR
hex "Define FASTBOOT buffer address"
@@ -46,6 +53,7 @@ config FASTBOOT_BUF_SIZE
 
 config FASTBOOT_USB_DEV
int "USB controller number"
+   depends on USB_FUNCTION_FASTBOOT
default 0
help
  Some boards have USB OTG controller other than 0. Define this
@@ -117,6 +125,6 @@ config FASTBOOT_MBR_NAME
  specified on the "fastboot flash" command line matches the value
  defined here. The default target name for updating MBR is "mbr".
 
-endif # USB_FUNCTION_FASTBOOT
+endif # USB_FUNCTION_FASTBOOT || UDP_FUNCTION_FASTBOOT
 
 endmenu
diff --git a/drivers/fastboot/fb_common.c b/drivers/fastboot/fb_common.c
index fe58803..7367fbb 100644
--- a/drivers/fastboot/fb_common.c
+++ b/drivers/fastboot/fb_common.c
@@ -12,6 +12,9 @@
 
 #include 
 #include 
+#ifdef CONFIG_UDP_FUNCTION_FASTBOOT
+#include 
+#endif
 
 /**
  * Writes a response to response buffer of the form "$tag$reason".
@@ -44,3 +47,18 @@ void fastboot_okay(const char *reason, char *response)
 {
fastboot_response("OKAY", response, 

[U-Boot] [RFC PATCH v2 17/20] fastboot: Guard getvar:partition-type/size with MMC

2018-04-30 Thread Alex Kiernan
Add guard for partition-type/size against MMC as we need that in order
to lookup partitions.

Signed-off-by: Alex Kiernan 
---

Changes in v2: None

 drivers/fastboot/fb_getvar.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/fastboot/fb_getvar.c b/drivers/fastboot/fb_getvar.c
index aa68371..7989a19 100644
--- a/drivers/fastboot/fb_getvar.c
+++ b/drivers/fastboot/fb_getvar.c
@@ -55,6 +55,7 @@ void fb_getvar(char *cmd_parameter, char *response)
fastboot_okay("yes", response);
else
fastboot_okay("no", response);
+#if CONFIG_IS_ENABLED(FASTBOOT_FLASH_MMC)
} else if (!strcmp_l1("partition-type", cmd_parameter) ||
   !strcmp_l1("partition-size", cmd_parameter)) {
disk_partition_t part_info;
@@ -74,6 +75,7 @@ void fb_getvar(char *cmd_parameter, char *response)
fastboot_response("OKAY", response,
  "0x%016x", (int)part_info.size);
}
+#endif
} else {
 #define FASTBOOT_ENV_PREFIX"fastboot."
char envstr[FASTBOOT_RESPONSE_LEN];
-- 
2.7.4

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


[U-Boot] [RFC PATCH v2 14/20] fastboot: Avoid re-parsing cmd_string for boot/reboot

2018-04-30 Thread Alex Kiernan
When picking up boot/reboot after we've sent our result packet, use
the previously parsed command rather than redoing the strcmp.

Signed-off-by: Alex Kiernan 
---

Changes in v2: None

 net/fastboot.c | 15 +++
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/net/fastboot.c b/net/fastboot.c
index edf78df..ad8c101 100644
--- a/net/fastboot.c
+++ b/net/fastboot.c
@@ -141,6 +141,7 @@ static void fastboot_send(struct fastboot_header fb_header, 
char *fastboot_data,
uchar *packet;
uchar *packet_base;
int len = 0;
+   int cmd = -1;
const char *error_msg = "An error occurred.";
short tmp;
struct fastboot_header fb_response_header = fb_header;
@@ -192,15 +193,13 @@ static void fastboot_send(struct fastboot_header 
fb_header, char *fastboot_data,
if (cmd_parameter)
cmd_parameter = strdup(cmd_parameter);
} else {
-   int i;
-
-   i = fastboot_lookup_command(cmd_string);
-   if (i >= 0) {
+   cmd = fastboot_lookup_command(cmd_string);
+   if (cmd >= 0) {
void (*fb_call)(char *cmd_parameter,
char *fastboot_data,
unsigned int fastboot_data_len,
char *response);
-   fb_call = fb_net_dispatch[i];
+   fb_call = fb_net_dispatch[cmd];
if (fb_call) {
fb_call(cmd_parameter, fastboot_data,
fastboot_data_len, response);
@@ -244,10 +243,10 @@ static void fastboot_send(struct fastboot_header 
fb_header, char *fastboot_data,
 
/* Continue boot process after sending response */
if (!strncmp("OKAY", response, 4)) {
-   if (!strcmp("boot", cmd_string)) {
+   if (cmd == FB_CMD_BOOT) {
boot_downloaded_image();
-   } else if (!strncmp("reboot", cmd_string, 6)) {
-   /* Matches reboot or reboot-bootloader */
+   } else if (cmd == FB_CMD_REBOOT ||
+  cmd == FB_CMD_REBOOT_BOOTLOADER) {
do_reset(NULL, 0, 0, NULL);
}
}
-- 
2.7.4

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


[U-Boot] [RFC PATCH v2 08/20] net: fastboot: Support building without MMC

2018-04-30 Thread Alex Kiernan
If the fastboot flash/erase commands are disabled, remove that support
so we still build correctly.

Signed-off-by: Alex Kiernan 
---

Changes in v2: None

 net/fastboot.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/net/fastboot.c b/net/fastboot.c
index 32cb581..87c12e5 100644
--- a/net/fastboot.c
+++ b/net/fastboot.c
@@ -59,8 +59,10 @@ static int fastboot_our_port;
 
 static void fb_getvar(char *);
 static void fb_download(char *, unsigned int, char *);
+#if CONFIG_IS_ENABLED(FASTBOOT_FLASH_MMC)
 static void fb_flash(char *);
 static void fb_erase(char *);
+#endif
 static void fb_continue(char *);
 static void fb_reboot(char *);
 static void boot_downloaded_image(void);
@@ -169,10 +171,12 @@ static void fastboot_send(struct fastboot_header 
fb_header, char *fastboot_data,
fb_getvar(response);
} else if (!strcmp("download", cmd_string)) {
fb_download(fastboot_data, fastboot_data_len, response);
+#if CONFIG_IS_ENABLED(FASTBOOT_FLASH_MMC)
} else if (!strcmp("flash", cmd_string)) {
fb_flash(response);
} else if (!strcmp("erase", cmd_string)) {
fb_erase(response);
+#endif
} else if (!strcmp("boot", cmd_string)) {
write_fb_response("OKAY", "", response);
} else if (!strcmp("continue", cmd_string)) {
@@ -367,6 +371,7 @@ static void fb_download(char *fastboot_data, unsigned int 
fastboot_data_len,
}
 }
 
+#if CONFIG_IS_ENABLED(FASTBOOT_FLASH_MMC)
 /**
  * Writes the previously downloaded image to the partition indicated by
  * cmd_parameter. Writes to response.
@@ -389,6 +394,7 @@ static void fb_erase(char *response)
 {
fb_mmc_erase(cmd_parameter, response);
 }
+#endif
 
 /**
  * Continues normal boot process by running "bootcmd". Writes
-- 
2.7.4

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


[U-Boot] [RFC PATCH v2 11/20] fastboot: net: Change 'continue' so it matches USB fastboot

2018-04-30 Thread Alex Kiernan
Change the behaviour of 'continue' so that we simply exit the fastboot
server and leave the caller to decide what to do next. This matches
the USB fastboot behaviour.

Signed-off-by: Alex Kiernan 
---

Changes in v2: None

 net/fastboot.c | 13 +++--
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/net/fastboot.c b/net/fastboot.c
index cd09ada..ed13890 100644
--- a/net/fastboot.c
+++ b/net/fastboot.c
@@ -218,8 +218,6 @@ static void fastboot_send(struct fastboot_header fb_header, 
char *fastboot_data,
if (!strncmp("OKAY", response, 4)) {
if (!strcmp("boot", cmd_string)) {
boot_downloaded_image();
-   } else if (!strcmp("continue", cmd_string)) {
-   run_command(env_get("bootcmd"), CMD_FLAG_ENV);
} else if (!strncmp("reboot", cmd_string, 6)) {
/* Matches reboot or reboot-bootloader */
do_reset(NULL, 0, 0, NULL);
@@ -313,20 +311,15 @@ static void fb_erase(char *response)
 #endif
 
 /**
- * Continues normal boot process by running "bootcmd". Writes
+ * Continues normal boot process by exiting fastboot server. Writes
  * to response.
  *
  * @param repsonsePointer to fastboot response buffer
  */
 static void fb_continue(char *response)
 {
-   char *bootcmd;
-
-   bootcmd = env_get("bootcmd");
-   if (bootcmd)
-   fastboot_okay(NULL, response);
-   else
-   fastboot_fail("bootcmd not set", response);
+   net_set_state(NETLOOP_SUCCESS);
+   fastboot_okay(NULL, response);
 }
 
 /**
-- 
2.7.4

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


[U-Boot] [RFC PATCH v2 16/20] fastboot: net: Add NAND support

2018-04-30 Thread Alex Kiernan
Add NAND support to fastboot UDP flash/erase commands

Signed-off-by: Alex Kiernan 
---

Changes in v2: None

 net/fastboot.c | 17 ++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/net/fastboot.c b/net/fastboot.c
index 119011c..a07b1ad 100644
--- a/net/fastboot.c
+++ b/net/fastboot.c
@@ -60,7 +60,7 @@ static int fastboot_our_port;
 static void cb_okay(char *, char *, unsigned int, char *);
 static void cb_getvar(char *, char *, unsigned int, char *);
 static void cb_download(char *, char *, unsigned int, char *);
-#if CONFIG_IS_ENABLED(FASTBOOT_FLASH_MMC)
+#if CONFIG_IS_ENABLED(FASTBOOT_FLASH)
 static void cb_flash(char *, char *, unsigned int, char *);
 static void cb_erase(char *, char *, unsigned int, char *);
 #endif
@@ -74,7 +74,7 @@ static void (*fb_net_dispatch[])(char *cmd_parameter,
[FB_CMD_GETVAR] = cb_getvar,
[FB_CMD_DOWNLOAD] = cb_download,
[FB_CMD_VERIFY] = NULL,
-#if CONFIG_IS_ENABLED(FASTBOOT_FLASH_MMC)
+#if CONFIG_IS_ENABLED(FASTBOOT_FLASH)
[FB_CMD_FLASH] = cb_flash,
[FB_CMD_ERASE] = cb_erase,
 #else
@@ -324,7 +324,7 @@ static void cb_download(char *cmd_parameter, char 
*fastboot_data,
}
 }
 
-#if CONFIG_IS_ENABLED(FASTBOOT_FLASH_MMC)
+#if CONFIG_IS_ENABLED(FASTBOOT_FLASH)
 /**
  * Writes the previously downloaded image to the partition indicated by
  * cmd_parameter. Writes to response.
@@ -334,8 +334,14 @@ static void cb_download(char *cmd_parameter, char 
*fastboot_data,
 static void cb_flash(char *cmd_parameter, char *fastboot_data,
 unsigned int fastboot_data_len, char *response)
 {
+#if CONFIG_IS_ENABLED(FASTBOOT_FLASH_MMC)
fb_mmc_flash_write(cmd_parameter, (void *)CONFIG_FASTBOOT_BUF_ADDR,
   image_size, response);
+#endif
+#if CONFIG_IS_ENABLED(FASTBOOT_FLASH_NAND)
+   fb_nand_flash_write(cmd_parameter, (void *)CONFIG_FASTBOOT_BUF_ADDR,
+   image_size, response);
+#endif
 }
 
 /**
@@ -347,7 +353,12 @@ static void cb_flash(char *cmd_parameter, char 
*fastboot_data,
 static void cb_erase(char *cmd_parameter, char *fastboot_data,
 unsigned int fastboot_data_len, char *response)
 {
+#if CONFIG_IS_ENABLED(FASTBOOT_FLASH_MMC)
fb_mmc_erase(cmd_parameter, response);
+#endif
+#if CONFIG_IS_ENABLED(FASTBOOT_FLASH_NAND)
+   fb_nand_erase(cmd_parameter, response);
+#endif
 }
 #endif
 
-- 
2.7.4

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


[U-Boot] [RFC PATCH v2 18/20] fastboot: Check if part_name is NULL before using it

2018-04-30 Thread Alex Kiernan
If we don't have a partition name passed, report it as not found.

Signed-off-by: Alex Kiernan 
---

Changes in v2: None

 drivers/fastboot/fb_getvar.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/fastboot/fb_getvar.c b/drivers/fastboot/fb_getvar.c
index 7989a19..cc74bab 100644
--- a/drivers/fastboot/fb_getvar.c
+++ b/drivers/fastboot/fb_getvar.c
@@ -66,7 +66,8 @@ void fb_getvar(char *cmd_parameter, char *response)
dev_desc = blk_get_dev("mmc", 0);
if (!dev_desc) {
fastboot_fail("block device not found", response);
-   } else if (part_get_info_by_name(dev_desc, part_name,
+   } else if (!part_name ||
+  part_get_info_by_name(dev_desc, part_name,
 _info) < 0) {
fastboot_fail("partition not found", response);
} else if (!strcmp_l1("partition-type", cmd_parameter)) {
-- 
2.7.4

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


[U-Boot] [RFC PATCH v2 04/20] fastboot: Extract fastboot_okay/fail to fb_common.c

2018-04-30 Thread Alex Kiernan
Add drivers/fastboot/fb_common.c, where fastboot_okay/fail are implemented
so we can call them from a non-USB implementation.

Signed-off-by: Alex Kiernan 
---

Changes in v2: None

 drivers/fastboot/Makefile   |  1 +
 drivers/fastboot/fb_common.c| 26 ++
 drivers/usb/gadget/f_fastboot.c | 13 -
 3 files changed, 27 insertions(+), 13 deletions(-)
 create mode 100644 drivers/fastboot/fb_common.c

diff --git a/drivers/fastboot/Makefile b/drivers/fastboot/Makefile
index 63a67c1..5b8337f 100644
--- a/drivers/fastboot/Makefile
+++ b/drivers/fastboot/Makefile
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier:  GPL-2.0+
 
+obj-y += fb_common.o
 obj-$(CONFIG_FASTBOOT_FLASH) += image-sparse.o
 
 ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV
diff --git a/drivers/fastboot/fb_common.c b/drivers/fastboot/fb_common.c
new file mode 100644
index 000..53cffe3
--- /dev/null
+++ b/drivers/fastboot/fb_common.c
@@ -0,0 +1,26 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2008 - 2009
+ * Windriver, 
+ * Tom Rix 
+ *
+ * Copyright 2011 Sebastian Andrzej Siewior 
+ *
+ * Copyright 2014 Linaro, Ltd.
+ * Rob Herring 
+ */
+
+#include 
+#include 
+
+void fastboot_fail(const char *reason, char *response)
+{
+   strncpy(response, "FAIL\0", 5);
+   strncat(response, reason, FASTBOOT_RESPONSE_LEN - 4 - 1);
+}
+
+void fastboot_okay(const char *reason, char *response)
+{
+   strncpy(response, "OKAY\0", 5);
+   strncat(response, reason, FASTBOOT_RESPONSE_LEN - 4 - 1);
+}
diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index 6ae1d97..fda4505 100644
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -150,19 +150,6 @@ static struct usb_gadget_strings *fastboot_strings[] = {
 static void rx_handler_command(struct usb_ep *ep, struct usb_request *req);
 static int strcmp_l1(const char *s1, const char *s2);
 
-
-void fastboot_fail(const char *reason, char *response)
-{
-   strncpy(response, "FAIL\0", 5);
-   strncat(response, reason, FASTBOOT_RESPONSE_LEN - 4 - 1);
-}
-
-void fastboot_okay(const char *reason, char *response)
-{
-   strncpy(response, "OKAY\0", 5);
-   strncat(response, reason, FASTBOOT_RESPONSE_LEN - 4 - 1);
-}
-
 static void fastboot_complete(struct usb_ep *ep, struct usb_request *req)
 {
int status = req->status;
-- 
2.7.4

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


[U-Boot] [RFC PATCH v2 10/20] fastboot: Merge USB and UDP getvar implementation

2018-04-30 Thread Alex Kiernan
Merge the USB and UDP getvar implementations into one. The USB side
gains new variables previously defined in the network side and the
network side now supports fetching of arbitrary variables prefixed with
'fastboot.'

Signed-off-by: Alex Kiernan 
---

Changes in v2: None

 drivers/fastboot/Makefile   |  1 +
 drivers/fastboot/fb_common.c|  7 
 drivers/fastboot/fb_getvar.c| 93 +
 drivers/usb/gadget/f_fastboot.c | 56 +
 include/fastboot.h  | 18 
 net/fastboot.c  | 75 +
 6 files changed, 121 insertions(+), 129 deletions(-)
 create mode 100644 drivers/fastboot/fb_getvar.c

diff --git a/drivers/fastboot/Makefile b/drivers/fastboot/Makefile
index c12dfa8..9af4073 100644
--- a/drivers/fastboot/Makefile
+++ b/drivers/fastboot/Makefile
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier:  GPL-2.0+
 
 obj-y += fb_common.o
+obj-y += fb_getvar.o
 obj-$(CONFIG_FASTBOOT_FLASH) += image-sparse.o
 
 obj-$(CONFIG_FASTBOOT_FLASH_MMC) += fb_mmc.o
diff --git a/drivers/fastboot/fb_common.c b/drivers/fastboot/fb_common.c
index f0bf53d..3b68f25 100644
--- a/drivers/fastboot/fb_common.c
+++ b/drivers/fastboot/fb_common.c
@@ -65,3 +65,10 @@ void timed_send_info(ulong *start, const char *msg)
}
 #endif
 }
+
+int strcmp_l1(const char *s1, const char *s2)
+{
+   if (!s1 || !s2)
+   return -1;
+   return strncmp(s1, s2, strlen(s1));
+}
diff --git a/drivers/fastboot/fb_getvar.c b/drivers/fastboot/fb_getvar.c
new file mode 100644
index 000..aa68371
--- /dev/null
+++ b/drivers/fastboot/fb_getvar.c
@@ -0,0 +1,93 @@
+// SPDX-License-Identifier: BSD-2-Clause
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ */
+
+#include 
+#include 
+#include 
+
+/**
+ * Writes ascii string specified by cmd_parameter to response.
+ *
+ * @param cmd_parameterPoint to command parameter
+ * @param response Pointer to fastboot response buffer
+ */
+void fb_getvar(char *cmd_parameter, char *response)
+{
+   if (!cmd_parameter) {
+   fastboot_fail("missing var", response);
+   } else if (!strcmp("version", cmd_parameter)) {
+   fastboot_okay(FASTBOOT_VERSION, response);
+   } else if (!strcmp("bootloader-version", cmd_parameter) ||
+  !strcmp("version-bootloader", cmd_parameter)) {
+   fastboot_okay(U_BOOT_VERSION, response);
+   } else if (!strcmp("downloadsize", cmd_parameter) ||
+  !strcmp("max-download-size", cmd_parameter)) {
+   fastboot_response("OKAY", response,
+ "0x%08x", CONFIG_FASTBOOT_BUF_SIZE);
+   } else if (!strcmp("serialno", cmd_parameter)) {
+   const char *tmp = env_get("serial#");
+
+   if (tmp)
+   fastboot_okay(tmp, response);
+   else
+   fastboot_fail("Value not set", response);
+   } else if (!strcmp("version-baseband", cmd_parameter)) {
+   fastboot_okay("N/A", response);
+   } else if (!strcmp("product", cmd_parameter)) {
+   const char *board = env_get("board");
+
+   if (board)
+   fastboot_okay(board, response);
+   else
+   fastboot_fail("Board not set", response);
+   } else if (!strcmp("current-slot", cmd_parameter)) {
+   /* A/B not implemented, for now always return _a */
+   fastboot_okay("_a", response);
+   } else if (!strcmp("slot-suffixes", cmd_parameter)) {
+   fastboot_okay("_a,_b", response);
+   } else if (!strcmp_l1("has-slot", cmd_parameter)) {
+   char *part_name = cmd_parameter;
+
+   cmd_parameter = strsep(_name, ":");
+   if (!strcmp(part_name, "boot") || !strcmp(part_name, "system"))
+   fastboot_okay("yes", response);
+   else
+   fastboot_okay("no", response);
+   } else if (!strcmp_l1("partition-type", cmd_parameter) ||
+  !strcmp_l1("partition-size", cmd_parameter)) {
+   disk_partition_t part_info;
+   struct blk_desc *dev_desc;
+   char *part_name = cmd_parameter;
+
+   cmd_parameter = strsep(_name, ":");
+   dev_desc = blk_get_dev("mmc", 0);
+   if (!dev_desc) {
+   fastboot_fail("block device not found", response);
+   } else if (part_get_info_by_name(dev_desc, part_name,
+_info) < 0) {
+   fastboot_fail("partition not found", response);
+   } else if (!strcmp_l1("partition-type", cmd_parameter)) {
+   fastboot_okay((char *)part_info.type, response);
+   } else if (!strcmp_l1("partition-size", cmd_parameter)) {
+ 

[U-Boot] [RFC PATCH v2 06/20] fastboot: Correct dependencies in FASTBOOT_FLASH

2018-04-30 Thread Alex Kiernan
Ensure that when selecting FASTBOOT_FLASH you end up with a buildable
configuration. Prior to this you could select NAND without MTDPARTS
and end up with an image which (surprisingly) excluded NAND.

Signed-off-by: Alex Kiernan 
---

Changes in v2: None

 arch/arm/mach-omap2/utils.c |  4 ++--
 drivers/fastboot/Kconfig|  8 
 drivers/fastboot/Makefile   |  8 ++--
 drivers/usb/gadget/f_fastboot.c | 14 +++---
 4 files changed, 15 insertions(+), 19 deletions(-)

diff --git a/arch/arm/mach-omap2/utils.c b/arch/arm/mach-omap2/utils.c
index 1d39625..28ca0e8 100644
--- a/arch/arm/mach-omap2/utils.c
+++ b/arch/arm/mach-omap2/utils.c
@@ -84,7 +84,7 @@ static void omap_set_fastboot_board_rev(void)
env_set("fastboot.board_rev", board_rev);
 }
 
-#ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV
+#ifdef CONFIG_FASTBOOT_FLASH_MMC
 static u32 omap_mmc_get_part_size(const char *part)
 {
int res;
@@ -127,7 +127,7 @@ static void omap_set_fastboot_userdata_size(void)
 static inline void omap_set_fastboot_userdata_size(void)
 {
 }
-#endif /* CONFIG_FASTBOOT_FLASH_MMC_DEV */
+#endif /* CONFIG_FASTBOOT_FLASH_MMC */
 void omap_set_fastboot_vars(void)
 {
omap_set_fastboot_cpu();
diff --git a/drivers/fastboot/Kconfig b/drivers/fastboot/Kconfig
index eee866a..64b94f0 100644
--- a/drivers/fastboot/Kconfig
+++ b/drivers/fastboot/Kconfig
@@ -55,6 +55,7 @@ config FASTBOOT_USB_DEV
 config FASTBOOT_FLASH
bool "Enable FASTBOOT FLASH command"
default y if ARCH_SUNXI
+   depends on MMC || (NAND && CMD_MTDPARTS)
help
  The fastboot protocol includes a "flash" command for writing
  the downloaded image to a non-volatile storage device. Define
@@ -70,7 +71,7 @@ config FASTBOOT_FLASH_MMC
 
 config FASTBOOT_FLASH_NAND
bool "FASTBOOT on NAND"
-   depends on NAND
+   depends on NAND && CMD_MTDPARTS
 
 endchoice
 
@@ -87,7 +88,6 @@ config FASTBOOT_FLASH_MMC_DEV
 config FASTBOOT_FLASH_NAND_DEV
int "Define FASTBOOT NAND FLASH default device"
depends on FASTBOOT_FLASH_NAND
-   depends on CMD_MTDPARTS
default 0 if ARCH_SUNXI && NAND_SUNXI
help
  The fastboot "flash" command requires additional information
@@ -96,7 +96,7 @@ config FASTBOOT_FLASH_NAND_DEV
 
 config FASTBOOT_GPT_NAME
string "Target name for updating GPT"
-   depends on FASTBOOT_FLASH
+   depends on FASTBOOT_FLASH_MMC
default "gpt"
help
  The fastboot "flash" command supports writing the downloaded
@@ -109,7 +109,7 @@ config FASTBOOT_GPT_NAME
 
 config FASTBOOT_MBR_NAME
string "Target name for updating MBR"
-   depends on FASTBOOT_FLASH
+   depends on FASTBOOT_FLASH_MMC
default "mbr"
help
  The fastboot "flash" command allows to write the downloaded image
diff --git a/drivers/fastboot/Makefile b/drivers/fastboot/Makefile
index 5b8337f..c12dfa8 100644
--- a/drivers/fastboot/Makefile
+++ b/drivers/fastboot/Makefile
@@ -3,9 +3,5 @@
 obj-y += fb_common.o
 obj-$(CONFIG_FASTBOOT_FLASH) += image-sparse.o
 
-ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV
-obj-y += fb_mmc.o
-endif
-ifdef CONFIG_FASTBOOT_FLASH_NAND_DEV
-obj-y += fb_nand.o
-endif
+obj-$(CONFIG_FASTBOOT_FLASH_MMC) += fb_mmc.o
+obj-$(CONFIG_FASTBOOT_FLASH_NAND) += fb_nand.o
diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index fda4505..e757c3e 100644
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -21,10 +21,10 @@
 #include 
 #include 
 #include 
-#ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV
+#ifdef CONFIG_FASTBOOT_FLASH_MMC
 #include 
 #endif
-#ifdef CONFIG_FASTBOOT_FLASH_NAND_DEV
+#ifdef CONFIG_FASTBOOT_FLASH_NAND
 #include 
 #endif
 
@@ -584,11 +584,11 @@ static void cb_flash(struct usb_ep *ep, struct 
usb_request *req)
}
 
fastboot_fail("no flash device defined", response);
-#ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV
+#ifdef CONFIG_FASTBOOT_FLASH_MMC
fb_mmc_flash_write(cmd, (void *)CONFIG_FASTBOOT_BUF_ADDR,
   download_bytes, response);
 #endif
-#ifdef CONFIG_FASTBOOT_FLASH_NAND_DEV
+#ifdef CONFIG_FASTBOOT_FLASH_NAND
fb_nand_flash_write(cmd, (void *)CONFIG_FASTBOOT_BUF_ADDR,
download_bytes, response);
 #endif
@@ -599,7 +599,7 @@ static void cb_flash(struct usb_ep *ep, struct usb_request 
*req)
 static void cb_oem(struct usb_ep *ep, struct usb_request *req)
 {
char *cmd = req->buf;
-#ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV
+#ifdef CONFIG_FASTBOOT_FLASH_MMC
if (strncmp("format", cmd + 4, 6) == 0) {
char cmdbuf[32];
 sprintf(cmdbuf, "gpt write mmc %x $partitions",
@@ -632,10 +632,10 @@ static void cb_erase(struct usb_ep *ep, struct 
usb_request *req)
}
 
fastboot_fail("no flash device defined", response);
-#ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV
+#ifdef CONFIG_FASTBOOT_FLASH_MMC
fb_mmc_erase(cmd, 

[U-Boot] [RFC PATCH v2 03/20] fastboot: Refactor fastboot_okay/fail to take response

2018-04-30 Thread Alex Kiernan
Add the response string as a parameter to fastboot_okay/fail, instead
of modifying a global, to match the contract expected by the AOSP
U-Boot code.

Signed-off-by: Alex Kiernan 
---

Changes in v2: None

 drivers/fastboot/fb_mmc.c   | 80 ++---
 drivers/fastboot/fb_nand.c  | 31 
 drivers/fastboot/image-sparse.c | 41 +++--
 drivers/usb/gadget/f_fastboot.c | 35 +++---
 include/fastboot.h  |  4 +--
 include/fb_mmc.h|  4 +--
 include/fb_nand.h   |  4 +--
 include/image-sparse.h  |  2 +-
 8 files changed, 100 insertions(+), 101 deletions(-)

diff --git a/drivers/fastboot/fb_mmc.c b/drivers/fastboot/fb_mmc.c
index cf5b77c..02864aa 100644
--- a/drivers/fastboot/fb_mmc.c
+++ b/drivers/fastboot/fb_mmc.c
@@ -74,7 +74,7 @@ static lbaint_t fb_mmc_sparse_reserve(struct sparse_storage 
*info,
 
 static void write_raw_image(struct blk_desc *dev_desc, disk_partition_t *info,
const char *part_name, void *buffer,
-   unsigned int download_bytes)
+   unsigned int download_bytes, char *response)
 {
lbaint_t blkcnt;
lbaint_t blks;
@@ -85,7 +85,7 @@ static void write_raw_image(struct blk_desc *dev_desc, 
disk_partition_t *info,
 
if (blkcnt > info->size) {
pr_err("too large for partition: '%s'\n", part_name);
-   fastboot_fail("too large for partition");
+   fastboot_fail("too large for partition", response);
return;
}
 
@@ -94,13 +94,13 @@ static void write_raw_image(struct blk_desc *dev_desc, 
disk_partition_t *info,
blks = blk_dwrite(dev_desc, info->start, blkcnt, buffer);
if (blks != blkcnt) {
pr_err("failed writing to device %d\n", dev_desc->devnum);
-   fastboot_fail("failed writing to device");
+   fastboot_fail("failed writing to device", response);
return;
}
 
printf(" wrote " LBAFU " bytes to '%s'\n", blkcnt * info->blksz,
   part_name);
-   fastboot_okay("");
+   fastboot_okay("", response);
 }
 
 #ifdef CONFIG_ANDROID_BOOT_IMAGE
@@ -115,7 +115,8 @@ static void write_raw_image(struct blk_desc *dev_desc, 
disk_partition_t *info,
  */
 static lbaint_t fb_mmc_get_boot_header(struct blk_desc *dev_desc,
   disk_partition_t *info,
-  struct andr_img_hdr *hdr)
+  struct andr_img_hdr *hdr,
+  char *response)
 {
ulong sector_size;  /* boot partition sector size */
lbaint_t hdr_sectors;   /* boot image header sectors count */
@@ -126,7 +127,7 @@ static lbaint_t fb_mmc_get_boot_header(struct blk_desc 
*dev_desc,
hdr_sectors = DIV_ROUND_UP(sizeof(struct andr_img_hdr), sector_size);
if (hdr_sectors == 0) {
pr_err("invalid number of boot sectors: 0");
-   fastboot_fail("invalid number of boot sectors: 0");
+   fastboot_fail("invalid number of boot sectors: 0", response);
return 0;
}
 
@@ -134,7 +135,8 @@ static lbaint_t fb_mmc_get_boot_header(struct blk_desc 
*dev_desc,
res = blk_dread(dev_desc, info->start, hdr_sectors, (void *)hdr);
if (res != hdr_sectors) {
pr_err("cannot read header from boot partition");
-   fastboot_fail("cannot read header from boot partition");
+   fastboot_fail("cannot read header from boot partition",
+ response);
return 0;
}
 
@@ -142,7 +144,7 @@ static lbaint_t fb_mmc_get_boot_header(struct blk_desc 
*dev_desc,
res = android_image_check_header(hdr);
if (res != 0) {
pr_err("bad boot image magic");
-   fastboot_fail("boot partition not initialized");
+   fastboot_fail("boot partition not initialized", response);
return 0;
}
 
@@ -160,7 +162,8 @@ static lbaint_t fb_mmc_get_boot_header(struct blk_desc 
*dev_desc,
  */
 static int fb_mmc_update_zimage(struct blk_desc *dev_desc,
void *download_buffer,
-   unsigned int download_bytes)
+   unsigned int download_bytes,
+   char *response)
 {
uintptr_t hdr_addr; /* boot image header address */
struct andr_img_hdr *hdr;   /* boot image header */
@@ -180,7 +183,7 @@ static int fb_mmc_update_zimage(struct blk_desc *dev_desc,
res = part_get_info_by_name(dev_desc, BOOT_PARTITION_NAME, );
if (res < 0) {
pr_err("cannot find boot partition");
-   fastboot_fail("cannot find boot partition");
+   fastboot_fail("cannot 

[U-Boot] [RFC PATCH v2 05/20] fastboot: Introduce fastboot_response and refactor fastboot_okay/fail

2018-04-30 Thread Alex Kiernan
Introduce fastboot_response which takes varargs parameters so we can
use it to generate formatted response strings. Refactor fastboot_okay/fail
to use it.

Signed-off-by: Alex Kiernan 
---

Changes in v2: None

 drivers/fastboot/fb_common.c | 28 
 include/fastboot.h   |  4 
 2 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/drivers/fastboot/fb_common.c b/drivers/fastboot/fb_common.c
index 53cffe3..fe58803 100644
--- a/drivers/fastboot/fb_common.c
+++ b/drivers/fastboot/fb_common.c
@@ -13,14 +13,34 @@
 #include 
 #include 
 
+/**
+ * Writes a response to response buffer of the form "$tag$reason".
+ *
+ * @param tag  The first part of the response
+ * @param response Pointer to fastboot response buffer
+ * @param format   printf style format string
+ */
+void fastboot_response(const char *tag, char *response,
+  const char *format, ...)
+{
+   va_list args;
+
+   strlcpy(response, tag, FASTBOOT_RESPONSE_LEN);
+   if (format) {
+   va_start(args, format);
+   vsnprintf(response + strlen(response),
+ FASTBOOT_RESPONSE_LEN - strlen(response) - 1,
+ format, args);
+   va_end(args);
+   }
+}
+
 void fastboot_fail(const char *reason, char *response)
 {
-   strncpy(response, "FAIL\0", 5);
-   strncat(response, reason, FASTBOOT_RESPONSE_LEN - 4 - 1);
+   fastboot_response("FAIL", response, "%s", reason);
 }
 
 void fastboot_okay(const char *reason, char *response)
 {
-   strncpy(response, "OKAY\0", 5);
-   strncat(response, reason, FASTBOOT_RESPONSE_LEN - 4 - 1);
+   fastboot_response("OKAY", response, "%s", reason);
 }
diff --git a/include/fastboot.h b/include/fastboot.h
index f22080a..2140c94 100644
--- a/include/fastboot.h
+++ b/include/fastboot.h
@@ -16,6 +16,10 @@
 /* The 64 defined bytes plus \0 */
 #define FASTBOOT_RESPONSE_LEN  (64 + 1)
 
+void fastboot_response(const char *tag, char *response,
+  const char *format, ...)
+   __attribute__ ((format (__printf__, 3, 4)));
+
 void fastboot_fail(const char *reason, char *response);
 void fastboot_okay(const char *reason, char *response);
 
-- 
2.7.4

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


[U-Boot] [RFC PATCH v2 02/20] fastboot: Switch dependencies on FASTBOOT to USB_FUNCTION_FASTBOOT

2018-04-30 Thread Alex Kiernan
Anyone who wants FASTBOOT before this series wants USB_FUNCTION_FASTBOOT.
Split USB_FUNCTION_FASTBOOT from FASTBOOT so they retain their existing
behaviour.

Signed-off-by: Alex Kiernan 
---

Changes in v2: None

 arch/arm/Kconfig |  2 --
 board/ti/common/Kconfig  |  1 -
 configs/am335x_boneblack_defconfig   |  2 +-
 configs/am335x_boneblack_vboot_defconfig |  2 +-
 configs/am335x_evm_defconfig |  2 +-
 configs/am335x_evm_nor_defconfig |  2 +-
 configs/am335x_evm_norboot_defconfig |  2 +-
 configs/am335x_evm_spiboot_defconfig |  2 +-
 configs/am335x_evm_usbspl_defconfig  |  2 +-
 configs/am57xx_evm_defconfig |  2 +-
 configs/am57xx_hs_evm_defconfig  |  2 +-
 configs/bcm23550_w1d_defconfig   |  2 +-
 configs/bcm28155_ap_defconfig|  2 +-
 configs/birdland_bav335a_defconfig   |  2 +-
 configs/birdland_bav335b_defconfig   |  2 +-
 configs/cgtqmx6eval_defconfig|  2 +-
 configs/dra7xx_evm_defconfig |  2 +-
 configs/dra7xx_hs_evm_defconfig  |  2 +-
 configs/kc1_defconfig|  2 +-
 configs/mx6qsabrelite_defconfig  |  2 +-
 configs/mx6sabresd_defconfig |  2 +-
 configs/nitrogen6dl2g_defconfig  |  2 +-
 configs/nitrogen6dl_defconfig|  2 +-
 configs/nitrogen6q2g_defconfig   |  2 +-
 configs/nitrogen6q_defconfig |  2 +-
 configs/nitrogen6s1g_defconfig   |  2 +-
 configs/nitrogen6s_defconfig |  2 +-
 configs/omap3_beagle_defconfig   |  2 +-
 configs/omap3_evm_defconfig  |  2 +-
 configs/omap3_logic_defconfig|  2 +-
 configs/sniper_defconfig |  2 +-
 configs/stih410-b2260_defconfig  |  2 +-
 configs/xilinx_zynqmp_zc1751_xm015_dc1_defconfig |  2 +-
 configs/xilinx_zynqmp_zc1751_xm016_dc2_defconfig |  2 +-
 configs/xilinx_zynqmp_zcu102_rev1_0_defconfig|  2 +-
 configs/xilinx_zynqmp_zcu102_revA_defconfig  |  2 +-
 configs/xilinx_zynqmp_zcu102_revB_defconfig  |  2 +-
 configs/xilinx_zynqmp_zcu106_revA_defconfig  |  2 +-
 drivers/fastboot/Kconfig | 14 +++---
 39 files changed, 43 insertions(+), 46 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 35fcd24..9bf05d8 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1196,9 +1196,7 @@ config ARCH_ROCKCHIP
select DM_REGULATOR
select ENABLE_ARM_SOC_BOOT0_HOOK
select SPI
-   imply CMD_FASTBOOT
imply DISTRO_DEFAULTS
-   imply FASTBOOT
imply FAT_WRITE
imply USB_FUNCTION_FASTBOOT
imply SPL_SYSRESET
diff --git a/board/ti/common/Kconfig b/board/ti/common/Kconfig
index c21eb8c..b1956b8 100644
--- a/board/ti/common/Kconfig
+++ b/board/ti/common/Kconfig
@@ -25,7 +25,6 @@ config TI_COMMON_CMD_OPTIONS
imply CMD_EXT2
imply CMD_EXT4
imply CMD_EXT4_WRITE
-   imply CMD_FASTBOOT if FASTBOOT
imply CMD_FAT
imply FAT_WRITE if CMD_FAT
imply CMD_FS_GENERIC
diff --git a/configs/am335x_boneblack_defconfig 
b/configs/am335x_boneblack_defconfig
index 5c01b20..bd3a374 100644
--- a/configs/am335x_boneblack_defconfig
+++ b/configs/am335x_boneblack_defconfig
@@ -16,7 +16,7 @@ CONFIG_AUTOBOOT_KEYED=y
 CONFIG_AUTOBOOT_PROMPT="Press SPACE to abort autoboot in %d seconds\n"
 CONFIG_AUTOBOOT_DELAY_STR="d"
 CONFIG_AUTOBOOT_STOP_STR=" "
-CONFIG_FASTBOOT=y
+CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_FASTBOOT_FLASH=y
 CONFIG_FASTBOOT_FLASH_MMC_DEV=1
 CONFIG_CMD_SPL=y
diff --git a/configs/am335x_boneblack_vboot_defconfig 
b/configs/am335x_boneblack_vboot_defconfig
index abbacdc..baaae36 100644
--- a/configs/am335x_boneblack_vboot_defconfig
+++ b/configs/am335x_boneblack_vboot_defconfig
@@ -19,7 +19,7 @@ CONFIG_AUTOBOOT_KEYED=y
 CONFIG_AUTOBOOT_PROMPT="Press SPACE to abort autoboot in %d seconds\n"
 CONFIG_AUTOBOOT_DELAY_STR="d"
 CONFIG_AUTOBOOT_STOP_STR=" "
-CONFIG_FASTBOOT=y
+CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_CMD_SPL=y
 # CONFIG_CMD_FLASH is not set
 # CONFIG_CMD_SETEXPR is not set
diff --git a/configs/am335x_evm_defconfig b/configs/am335x_evm_defconfig
index 6732013..cc556d1 100644
--- a/configs/am335x_evm_defconfig
+++ b/configs/am335x_evm_defconfig
@@ -13,7 +13,7 @@ CONFIG_ARCH_MISC_INIT=y
 CONFIG_SPL_MTD_SUPPORT=y
 CONFIG_SPL_MUSB_NEW_SUPPORT=y
 CONFIG_SPL_OS_BOOT=y
-CONFIG_FASTBOOT=y
+CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_CMD_SPL=y
 CONFIG_CMD_SPL_NAND_OFS=0x0008
 # CONFIG_CMD_FLASH is not set
diff --git a/configs/am335x_evm_nor_defconfig b/configs/am335x_evm_nor_defconfig
index bbde07f..41a5c79 100644
--- a/configs/am335x_evm_nor_defconfig

[U-Boot] [RFC PATCH v2 01/20] fastboot: Move fastboot to drivers/fastboot

2018-04-30 Thread Alex Kiernan
Separate CMD_FASTBOOT from FASTBOOT and move code and configuration to
drivers/fastboot.

Signed-off-by: Alex Kiernan 
---

Changes in v2: None

 cmd/Kconfig | 14 --
 common/Makefile | 13 -
 drivers/Kconfig |  2 ++
 drivers/Makefile|  1 +
 {cmd => drivers}/fastboot/Kconfig   | 12 
 drivers/fastboot/Makefile   | 10 ++
 {common => drivers/fastboot}/fb_mmc.c   |  0
 {common => drivers/fastboot}/fb_nand.c  |  0
 {common => drivers/fastboot}/image-sparse.c |  0
 9 files changed, 25 insertions(+), 27 deletions(-)
 rename {cmd => drivers}/fastboot/Kconfig (91%)
 create mode 100644 drivers/fastboot/Makefile
 rename {common => drivers/fastboot}/fb_mmc.c (100%)
 rename {common => drivers/fastboot}/fb_nand.c (100%)
 rename {common => drivers/fastboot}/image-sparse.c (100%)

diff --git a/cmd/Kconfig b/cmd/Kconfig
index 225bb00..15361ff 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -137,8 +137,6 @@ config AUTOBOOT_STOP_STR_SHA256
 
 endmenu
 
-source "cmd/fastboot/Kconfig"
-
 config BUILD_BIN2C
bool
 
@@ -642,6 +640,18 @@ config CMD_DM
  can be useful to see the state of driver model for debugging or
  interest.
 
+config CMD_FASTBOOT
+   bool "fastboot - Android fastboot support"
+   depends on USB_FUNCTION_FASTBOOT || UDP_FUNCTION_FASTBOOT
+   help
+ This enables the command "fastboot" which enables the Android
+ fastboot mode for the platform. Fastboot is a protocol for
+ downloading images, flashing and device control used on
+ Android devices. Fastboot requires either network stack
+ enabled or support for acting as a USB device.
+
+ See doc/README.android-fastboot for more information.
+
 config CMD_FDC
bool "fdcboot - Boot from floppy device"
help
diff --git a/common/Makefile b/common/Makefile
index 7011dad..26f7fb1 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -111,19 +111,6 @@ obj-$(CONFIG_IO_TRACE) += iotrace.o
 obj-y += memsize.o
 obj-y += stdio.o
 
-ifndef CONFIG_SPL_BUILD
-# This option is not just y/n - it can have a numeric value
-ifdef CONFIG_FASTBOOT_FLASH
-obj-y += image-sparse.o
-ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV
-obj-y += fb_mmc.o
-endif
-ifdef CONFIG_FASTBOOT_FLASH_NAND_DEV
-obj-y += fb_nand.o
-endif
-endif
-endif
-
 ifdef CONFIG_CMD_EEPROM_LAYOUT
 obj-y += eeprom/eeprom_field.o eeprom/eeprom_layout.o
 endif
diff --git a/drivers/Kconfig b/drivers/Kconfig
index c2e813f..8424898 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -28,6 +28,8 @@ source "drivers/dfu/Kconfig"
 
 source "drivers/dma/Kconfig"
 
+source "drivers/fastboot/Kconfig"
+
 source "drivers/firmware/Kconfig"
 
 source "drivers/fpga/Kconfig"
diff --git a/drivers/Makefile b/drivers/Makefile
index 6846d18..78ec2f2 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -72,6 +72,7 @@ obj-y += block/
 obj-$(CONFIG_BOOTCOUNT_LIMIT) += bootcount/
 obj-$(CONFIG_CPU) += cpu/
 obj-y += crypto/
+obj-$(CONFIG_FASTBOOT) += fastboot/
 obj-y += firmware/
 obj-$(CONFIG_FPGA) += fpga/
 obj-y += misc/
diff --git a/cmd/fastboot/Kconfig b/drivers/fastboot/Kconfig
similarity index 91%
rename from cmd/fastboot/Kconfig
rename to drivers/fastboot/Kconfig
index 0d2c2f1..45600d2 100644
--- a/cmd/fastboot/Kconfig
+++ b/drivers/fastboot/Kconfig
@@ -1,5 +1,3 @@
-comment "FASTBOOT"
-
 menuconfig FASTBOOT
bool "Fastboot support"
depends on USB_GADGET
@@ -16,16 +14,6 @@ config USB_FUNCTION_FASTBOOT
help
  This enables the USB part of the fastboot gadget.
 
-config CMD_FASTBOOT
-   bool "Enable FASTBOOT command"
-   help
- This enables the command "fastboot" which enables the Android
- fastboot mode for the platform's USB device. Fastboot is a USB
- protocol for downloading images, flashing and device control
- used on Android devices.
-
- See doc/README.android-fastboot for more information.
-
 if USB_FUNCTION_FASTBOOT
 
 config FASTBOOT_BUF_ADDR
diff --git a/drivers/fastboot/Makefile b/drivers/fastboot/Makefile
new file mode 100644
index 000..63a67c1
--- /dev/null
+++ b/drivers/fastboot/Makefile
@@ -0,0 +1,10 @@
+# SPDX-License-Identifier:  GPL-2.0+
+
+obj-$(CONFIG_FASTBOOT_FLASH) += image-sparse.o
+
+ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV
+obj-y += fb_mmc.o
+endif
+ifdef CONFIG_FASTBOOT_FLASH_NAND_DEV
+obj-y += fb_nand.o
+endif
diff --git a/common/fb_mmc.c b/drivers/fastboot/fb_mmc.c
similarity index 100%
rename from common/fb_mmc.c
rename to drivers/fastboot/fb_mmc.c
diff --git a/common/fb_nand.c b/drivers/fastboot/fb_nand.c
similarity index 100%
rename from common/fb_nand.c
rename to drivers/fastboot/fb_nand.c
diff --git a/common/image-sparse.c b/drivers/fastboot/image-sparse.c
similarity index 100%
rename from common/image-sparse.c
rename to 

Re: [U-Boot] [PATCH v3 5/7] bootcount: spl: Extend SPL to support bootcount incrementation

2018-04-30 Thread Stefan Roese

Hi Lukasz,

On 29.04.2018 15:36, Lukasz Majewski wrote:

This patch adds support for incrementation of the bootcount in SPL.
Such feature is necessary when we do want to use this feature with
'falcon' boot mode (which loads OS directly in SPL).

Signed-off-by: Lukasz Majewski 

---

Changes in v3:
- Remove not needed #ifdefs
- Add enum bootcount_context parameter to bootcount_inc() function

Changes in v2:
- New patch - as suggested by Stefan Roese - bootcount_inc() is called
   in common SPL code (./common/spl/spl.c), so other boards can also
   reuse it without modification

  common/spl/spl.c | 3 +++
  1 file changed, 3 insertions(+)

diff --git a/common/spl/spl.c b/common/spl/spl.c
index 61d3071324..2d10c84296 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -20,6 +20,7 @@
  #include 
  #include 
  #include 
+#include 
  
  DECLARE_GLOBAL_DATA_PTR;
  
@@ -417,6 +418,8 @@ void board_init_r(gd_t *dummy1, ulong dummy2)

spl_board_init();
  #endif
  
+	bootcount_inc(SPL);

+


Thanks. With the suggested addition of automatic runtime detection
of the boot-stage (SPL vs U-Boot etc), this SPL parameter can be
dropped.

Other that this:

Reviewed-by: Stefan Roese 

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


Re: [U-Boot] [PATCH v3 4/7] bootcount: Rewrite autoboot to use wrapper functions from bootcount.h

2018-04-30 Thread Stefan Roese

Hi Lukasz,

On 29.04.2018 15:36, Lukasz Majewski wrote:

The code has been refactored to use common wrappers from bootcount.h
header.

Signed-off-by: Lukasz Majewski 

---

Changes in v3:
- New patch

Changes in v2:
- None

  common/autoboot.c | 23 +--
  1 file changed, 5 insertions(+), 18 deletions(-)

diff --git a/common/autoboot.c b/common/autoboot.c
index 2eef7a04cc..bfe4bdcf50 100644
--- a/common/autoboot.c
+++ b/common/autoboot.c
@@ -14,6 +14,7 @@
  #include 
  #include 
  #include 
+#include 
  
  DECLARE_GLOBAL_DATA_PTR;
  
@@ -291,18 +292,8 @@ const char *bootdelay_process(void)

  {
char *s;
int bootdelay;
-#ifdef CONFIG_BOOTCOUNT_LIMIT
-   unsigned long bootcount = 0;
-   unsigned long bootlimit = 0;
-#endif /* CONFIG_BOOTCOUNT_LIMIT */
-
-#ifdef CONFIG_BOOTCOUNT_LIMIT
-   bootcount = bootcount_load();
-   bootcount++;
-   bootcount_store(bootcount);
-   env_set_ulong("bootcount", bootcount);
-   bootlimit = env_get_ulong("bootlimit", 10, 0);
-#endif /* CONFIG_BOOTCOUNT_LIMIT */
+
+   bootcount_inc(UBOOT);
  
  	s = env_get("bootdelay");

bootdelay = s ? (int)simple_strtol(s, NULL, 10) : CONFIG_BOOTDELAY;
@@ -324,13 +315,9 @@ const char *bootdelay_process(void)
s = env_get("failbootcmd");
} else
  #endif /* CONFIG_POST */
-#ifdef CONFIG_BOOTCOUNT_LIMIT
-   if (bootlimit && (bootcount > bootlimit)) {
-   printf("Warning: Bootlimit (%u) exceeded. Using altbootcmd.\n",
-  (unsigned)bootlimit);
+   if (bootcount_error(UBOOT))
s = env_get("altbootcmd");
-   } else
-#endif /* CONFIG_BOOTCOUNT_LIMIT */
+   else
s = env_get("bootcmd");
  
  	process_fdt_options(gd->fdt_blob);


Now that look much simpler / cleaner. Thanks for working on this.

Reviewed-by: Stefan Roese 

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


Re: [U-Boot] [PATCH v3 5/5] mtd: nand: mxs_nand: add minimal ECC support

2018-04-30 Thread Stefan Agner
On 27.04.2018 09:31, Stefano Babic wrote:
> Hi Stefan,
> 
> On 11/04/2018 18:04, Stefan Agner wrote:
>> From: Stefan Agner 
>>
>> Add support for minimum ECC strength supported by the NAND chip.
>> This aligns with the behavior when using the fsl,use-minimum-ecc
>> device tree property in Linux.
>>
>> Signed-off-by: Stefan Agner 
>> ---
>>
>> Changes in v3: None
>> Changes in v2: None
>>
>>  drivers/mtd/nand/Kconfig|  8 +
>>  drivers/mtd/nand/mxs_nand.c | 71 +
>>  2 files changed, 65 insertions(+), 14 deletions(-)
>>
>> diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
>> index 4db259fcb2..c039b9cc60 100644
>> --- a/drivers/mtd/nand/Kconfig
>> +++ b/drivers/mtd/nand/Kconfig
>> @@ -152,6 +152,14 @@ config NAND_MXS
>>This enables NAND driver for the NAND flash controller on the
>>MXS processors.
>>
>> +if NAND_MXS
>> +
>> +config NAND_MXS_USE_MINIMUM_ECC
>> +bool "Use minimum ECC strength supported by the controller"
>> +default false
>> +
>> +endif
>> +
>>  config NAND_ZYNQ
>>  bool "Support for Zynq Nand controller"
>>  select SYS_NAND_SELF_INIT
>> diff --git a/drivers/mtd/nand/mxs_nand.c b/drivers/mtd/nand/mxs_nand.c
>> index 2696b543ef..8305bf2302 100644
>> --- a/drivers/mtd/nand/mxs_nand.c
>> +++ b/drivers/mtd/nand/mxs_nand.c
>> @@ -211,11 +211,52 @@ static inline int mxs_nand_calc_mark_offset(struct 
>> bch_geometry *geo,
>>  return 0;
>>  }
>>
>> +static inline unsigned int mxs_nand_max_ecc_strength_supported(void)
>> +{
>> +/* Refer to Chapter 17 for i.MX6DQ, Chapter 18 for i.MX6SX */
>> +if (is_mx6sx() || is_mx7())
>> +return 62;
>> +else
>> +return 40;
>> +}
>> +
>> +static inline int mxs_nand_calc_ecc_layout_by_info(struct bch_geometry *geo,
>> +   struct mtd_info *mtd)
>> +{
>> +struct nand_chip *chip = mtd_to_nand(mtd);
>> +
>> +if (!(chip->ecc_strength_ds > 0 && chip->ecc_step_ds > 0))
>> +return -ENOTSUPP;
>> +
>> +switch (chip->ecc_step_ds) {
>> +case SZ_512:
>> +geo->gf_len = 13;
>> +break;
>> +case SZ_1K:
>> +geo->gf_len = 14;
>> +break;
>> +default:
>> +return -EINVAL;
>> +}
>> +
>> +geo->ecc_chunk_size = chip->ecc_step_ds;
>> +geo->ecc_strength = round_up(chip->ecc_strength_ds, 2);
>> +
>> +/* Keep the C >= O */
>> +if (geo->ecc_chunk_size < mtd->oobsize)
>> +return -EINVAL;
>> +
>> +if (geo->ecc_strength > mxs_nand_max_ecc_strength_supported())
>> +return -EINVAL;
>> +
>> +geo->ecc_chunk_count = mtd->writesize / geo->ecc_chunk_size;
>> +
>> +return 0;
>> +}
>> +
>>  static inline int mxs_nand_calc_ecc_layout(struct bch_geometry *geo,
>> struct mtd_info *mtd)
>>  {
>> -unsigned int max_ecc_strength_supported;
>> -
>>  /* The default for the length of Galois Field. */
>>  geo->gf_len = 13;
>>
>> @@ -235,12 +276,6 @@ static inline int mxs_nand_calc_ecc_layout(struct 
>> bch_geometry *geo,
>>
>>  geo->ecc_chunk_count = mtd->writesize / geo->ecc_chunk_size;
>>
>> -/* Refer to Chapter 17 for i.MX6DQ, Chapter 18 for i.MX6SX */
>> -if (is_mx6sx() || is_mx7())
>> -max_ecc_strength_supported = 62;
>> -else
>> -max_ecc_strength_supported = 40;
>> -
>>  /*
>>   * Determine the ECC layout with the formula:
>>   *  ECC bits per chunk = (total page spare data bits) /
>> @@ -252,10 +287,8 @@ static inline int mxs_nand_calc_ecc_layout(struct 
>> bch_geometry *geo,
>>  geo->ecc_strength = ((mtd->oobsize - MXS_NAND_METADATA_SIZE) * 8)
>>  / (geo->gf_len * geo->ecc_chunk_count);
>>
>> -geo->ecc_strength = min(round_down(geo->ecc_strength, 2), 
>> max_ecc_strength_supported);
>> -
>> -if (mxs_nand_calc_mark_offset(geo, mtd->writesize) < 0)
>> -return -EINVAL;
>> +geo->ecc_strength = min(round_down(geo->ecc_strength, 2),
>> +mxs_nand_max_ecc_strength_supported());
>>
>>  return 0;
>>  }
>> @@ -1006,9 +1039,19 @@ static int mxs_nand_setup_ecc(struct mtd_info *mtd)
>>  struct bch_geometry *geo = _info->bch_geometry;
>>  struct mxs_bch_regs *bch_regs = (struct mxs_bch_regs *)MXS_BCH_BASE;
>>  uint32_t tmp;
>> +int ret = -ENOTSUPP;
>>
>> -if (mxs_nand_calc_ecc_layout(geo, mtd))
>> -return -EINVAL;
>> +#ifdef CONFIG_NAND_MXS_USE_MINIMUM_ECC
>> +ret = mxs_nand_calc_ecc_layout_by_info(geo, mtd);
>> +#endif
>> +
>> +if (ret == -ENOTSUPP)
>> +ret = mxs_nand_calc_ecc_layout(geo, mtd);
>> +
>> +if (ret)
>> +return ret;
>> +
>> +mxs_nand_calc_mark_offset(geo, mtd->writesize);
>>
>>  /* Configure BCH and set NFC geometry */
>>  mxs_reset_block(_regs->hw_bch_ctrl_reg);
>>
> 
> This is 

Re: [U-Boot] [PATCH v3 3/7] bootcount: Add function wrappers to handle bootcount increment and error checking

2018-04-30 Thread Stefan Roese

Hi Lukasz,

sorry, I still have some comments to (hopefully) make this
implementation a bit more "elegant". Please see below.

On 29.04.2018 15:36, Lukasz Majewski wrote:

Those two functions can be used to provide easy bootcount management.

Signed-off-by: Lukasz Majewski 

---

Changes in v3:
- Unify those functions to also work with common/autoboot.c code
- Add enum bootcount_context to distinguish between u-boot proper and SPL

Changes in v2:
- None

  include/bootcount.h | 50 ++
  1 file changed, 50 insertions(+)

diff --git a/include/bootcount.h b/include/bootcount.h
index e3b3f7028e..16fc657b2a 100644
--- a/include/bootcount.h
+++ b/include/bootcount.h
@@ -11,6 +11,13 @@
  #include 
  #include 
  
+enum bootcount_context {

+   SPL = 1,
+   UBOOT,
+};


Perhaps better some bootcount specific values / enums, like:

enum bootcount_context {
BOOTCOUNT_STATE_SPL = 1,
BOOTCOUNT_STATE_UBOOT,
};

Or even more generic, as this "boot-state" does not have to be bootcount
specific:

enum u_boot_context {
U_BOOT_STATE_SPL = 1,
U_BOOT_STATE_U_BOOT,
};

Or do we already have something like this, perhaps in "gd", where
its marked, in which state we are currently running? If not, it
could be added there and could be used from the bootcounter code
and other interfaces / drivers as well. The parts pre-relocation and
post-relocation fall also into this area (for the pre- / post-reloc
we definitely have a variable / flag in gd somewhere). So perhaps:

enum u_boot_context {
U_BOOT_STATE_SPL = 1,
U_BOOT_STATE_U_BOOT_PRE_RELOC,
U_BOOT_STATE_U_BOOT_POST_RELOC,
};


+#if defined CONFIG_SPL_BOOTCOUNT_LIMIT || defined CONFIG_BOOTCOUNT_LIMIT
+
  #if !defined(CONFIG_SYS_BOOTCOUNT_LE) && !defined(CONFIG_SYS_BOOTCOUNT_BE)
  # if __BYTE_ORDER == __LITTLE_ENDIAN
  #  define CONFIG_SYS_BOOTCOUNT_LE
@@ -40,4 +47,47 @@ static inline u32 raw_bootcount_load(volatile u32 *addr)
return in_be32(addr);
  }
  #endif
+
+static inline int bootcount_error(enum bootcount_context bc)
+{
+   unsigned long bootcount = bootcount_load();
+   unsigned long bootlimit = env_get_ulong("bootlimit", 10, 0);
+
+   if (bootlimit && bootcount > bootlimit) {
+   printf("Warning: Bootlimit (%lu) exceeded.", bootlimit);
+   if (bc == UBOOT)
+   printf(" Using altbootcmd.");
+   printf("\n");
+
+   return 1;
+   }
+
+   return 0;
+}
+
+static inline void bootcount_inc(enum bootcount_context bc)
+{
+   unsigned long bootcount = bootcount_load();
+
+   if (bc == SPL) {
+   bootcount_store(++bootcount);
+   return;
+   }
+
+   /* Only increment bootcount when no bootcount support in SPL */
+#ifndef CONFIG_SPL_BOOTCOUNT_LIMIT
+   bootcount++;
+#endif
+   bootcount_store(bootcount);
+   env_set_ulong("bootcount", bootcount);
+}


Why not use the same logic / code as above (the store does not need
to happen twice):

/* Only increment bootcount when no bootcount support in SPL */
#ifndef CONFIG_SPL_BOOTCOUNT_LIMIT
bootcount_store(++bootcount);
#endif

env_set_ulong("bootcount", bootcount);

?

What do you think?

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


Re: [U-Boot] [PATCH v2] arm: zynqmp: Add ZynqMP minimal R5 support

2018-04-30 Thread Alexander Graf


On 30.04.18 09:37, Michal Simek wrote:
> Xilinx ZynqMP also contains dual Cortex R5 which can run U-Boot.
> This patch is adding minimal support to get U-Boot boot.
> U-Boot on R5 runs out of DDR with default configuration that's why
> DDR needs to be partitioned if there is something else running on arm64.
> Console is done via Cadence uart driver and the first Cadence Triple
> Timer Counter is used for time.
> 
> This configuration with uart1 was tested on zcu100-revC.
> 
> U-Boot 2018.05-rc2-00021-gd058a08d907d (Apr 18 2018 - 14:11:27 +0200)
> 
> Model: Xilinx ZynqMP R5
> DRAM:  512 MiB
> WARNING: Caches not enabled
> MMC:
> In:serial@ff01
> Out:   serial@ff01
> Err:   serial@ff01
> Net:   Net Initialization Skipped
> No ethernet found.
> ZynqMP r5>
> 
> There are two ways how to run this on ZynqMP.
> 1. Run from ZynqMP arm64
> tftpb 2000 u-boot-r5.elf
> setenv autostart no && bootelf -p 2000
> cpu 4 disable && cpu 4 release 1000 lockstep
> or
> cpu 4 disable && cpu 4 release 1000 split
> 
> 2. Load via jtag when directly to R5
> 
> Signed-off-by: Michal Simek 
> ---
> 
> Changes in v2:
> - Make this a single patch because core support was handled by Lokesh
>   Vulta R5 series. Rebase on the top of this series
> - Add reset_cpu which is not handle by core
> - Add MPU support to enable only 0-512MB and RO for 512MB-2GB
> - Enable cache support
> - Wire MTEST macros but not enable mtest command
> 
> Changes compare to RFC
> - Use 500MHz instead of 600MHz
> - Remove fpu compilation flags
> - Split arm-r5 code and platform
> 
> ---
>  MAINTAINERS|  6 +++
>  arch/arm/Kconfig   | 10 
>  arch/arm/Makefile  |  1 +
>  arch/arm/dts/Makefile  |  2 +
>  arch/arm/dts/zynqmp-r5.dts | 73 ++
>  arch/arm/mach-zynqmp-r5/Kconfig| 27 +++
>  arch/arm/mach-zynqmp-r5/Makefile   |  3 ++
>  arch/arm/mach-zynqmp-r5/cpu.c  | 37 +++
>  board/xilinx/zynqmp_r5/MAINTAINERS |  7 +++
>  board/xilinx/zynqmp_r5/Makefile|  6 +++
>  board/xilinx/zynqmp_r5/board.c | 25 ++
>  configs/xilinx_zynqmp_r5_defconfig | 16 +++
>  drivers/serial/Kconfig |  2 +-
>  include/configs/xilinx_zynqmp_r5.h | 51 +
>  14 files changed, 265 insertions(+), 1 deletion(-)
>  create mode 100644 arch/arm/dts/zynqmp-r5.dts
>  create mode 100644 arch/arm/mach-zynqmp-r5/Kconfig
>  create mode 100644 arch/arm/mach-zynqmp-r5/Makefile
>  create mode 100644 arch/arm/mach-zynqmp-r5/cpu.c
>  create mode 100644 board/xilinx/zynqmp_r5/MAINTAINERS
>  create mode 100644 board/xilinx/zynqmp_r5/Makefile
>  create mode 100644 board/xilinx/zynqmp_r5/board.c
>  create mode 100644 configs/xilinx_zynqmp_r5_defconfig
>  create mode 100644 include/configs/xilinx_zynqmp_r5.h
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 147551f66fd3..e60d76dbad8a 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -295,6 +295,12 @@ F:   include/zynqmppl.h
>  F:   tools/zynqimage.c
>  N:   zynqmp
>  
> +ARM ZYNQMP R5
> +M:   Michal Simek 
> +S:   Maintained
> +T:   git git://git.denx.de/u-boot-microblaze.git
> +F:   arch/arm/mach-zynqmp-r5/
> +
>  BUILDMAN
>  M:   Simon Glass 
>  S:   Maintained
> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index f07f17f053ff..13e06ff763d0 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -823,6 +823,14 @@ config ARCH_ZYNQ
>   imply CMD_SPL
>   imply ARCH_EARLY_INIT_R
>  
> +config ARCH_ZYNQMP_R5
> + bool "Xilinx ZynqMP R5 based platform"
> + select CPU_V7R
> + select OF_CONTROL
> + select DM
> + select DM_SERIAL
> + select CLK
> +
>  config ARCH_ZYNQMP
>   bool "Xilinx ZynqMP based platform"
>   select ARM64
> @@ -1345,6 +1353,8 @@ source "arch/arm/cpu/armv7/vf610/Kconfig"
>  
>  source "arch/arm/mach-zynq/Kconfig"
>  
> +source "arch/arm/mach-zynqmp-r5/Kconfig"
> +
>  source "arch/arm/cpu/armv7/Kconfig"
>  
>  source "arch/arm/cpu/armv8/zynqmp/Kconfig"
> diff --git a/arch/arm/Makefile b/arch/arm/Makefile
> index 3f5343bc017b..63e2b89ee7ef 100644
> --- a/arch/arm/Makefile
> +++ b/arch/arm/Makefile
> @@ -78,6 +78,7 @@ machine-$(CONFIG_ARCH_STM32MP)  += stm32mp
>  machine-$(CONFIG_TEGRA)  += tegra
>  machine-$(CONFIG_ARCH_UNIPHIER)  += uniphier
>  machine-$(CONFIG_ARCH_ZYNQ)  += zynq
> +machine-$(CONFIG_ARCH_ZYNQMP_R5) += zynqmp-r5
>  
>  machdirs := $(patsubst %,arch/arm/mach-%/,$(machine-y))
>  
> diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
> index 1fb36b3ecdb3..d44a4310081e 100644
> --- a/arch/arm/dts/Makefile
> +++ b/arch/arm/dts/Makefile
> @@ -165,6 +165,8 @@ dtb-$(CONFIG_ARCH_ZYNQMP) += \
>   zynqmp-zc1751-xm017-dc3.dtb \
>   zynqmp-zc1751-xm018-dc4.dtb \
>   zynqmp-zc1751-xm019-dc5.dtb
> 

Re: [U-Boot] [PATCH v2] arm64: zynqmp: Setup MMU map for DDR at run time

2018-04-30 Thread Alexander Graf


On 30.04.18 09:23, Michal Simek wrote:
> From: Nitin Jain 
> 
> This patch fills the MMU map for DDR at run time based information read

based on

> from Device Tree or automatically detected from static configuration.
> 
> The patch is needed because for systems which has for example 1GB of memory
> but MMU map is 2GB there could be spurious accesses which was seen in past
> when mapping is not fitting with actual memory installed.
> 
> Signed-off-by: Nitin Jain 
> Signed-off-by: Siva Durga Prasad Paladugu 
> Signed-off-by: Michal Simek 
> ---
> 
> Changes in v2:
> - Fix and extended commit description (asked-by: agraf)
> 
>  arch/arm/cpu/armv8/zynqmp/cpu.c  | 84 
>  arch/arm/include/asm/arch-zynqmp/sys_proto.h |  2 +-
>  board/xilinx/zynqmp/zynqmp.c | 22 -
>  3 files changed, 74 insertions(+), 34 deletions(-)
> 
> diff --git a/arch/arm/cpu/armv8/zynqmp/cpu.c b/arch/arm/cpu/armv8/zynqmp/cpu.c
> index 14e7d4006494..5db5fafc6f65 100644
> --- a/arch/arm/cpu/armv8/zynqmp/cpu.c
> +++ b/arch/arm/cpu/armv8/zynqmp/cpu.c
> @@ -16,16 +16,28 @@
>  
>  DECLARE_GLOBAL_DATA_PTR;
>  
> -static struct mm_region zynqmp_mem_map[] = {
> +/*
> + * Number of filled static entries and also the first empty
> + * slot in zynqmp_mem_map.
> + */
> +#define ZYNQMP_MEM_MAP_USED  4
> +
>  #if !defined(CONFIG_ZYNQMP_NO_DDR)
> - {
> - .virt = 0x0UL,
> - .phys = 0x0UL,
> - .size = 0x8000UL,
> - .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
> -  PTE_BLOCK_INNER_SHARE
> - },
> +#define DRAM_BANKS CONFIG_NR_DRAM_BANKS
> +#else
> +#define DRAM_BANKS 0
>  #endif
> +
> +#if defined(CONFIG_DEFINE_TCM_OCM_MMAP)
> +#define TCM_MAP 1
> +#else
> +#define TCM_MAP 0
> +#endif
> +
> +/* +1 is end of list which needs to be empty */
> +#define ZYNQMP_MEM_MAP_MAX (ZYNQMP_MEM_MAP_USED + DRAM_BANKS + TCM_MAP + 1)
> +
> +static struct mm_region zynqmp_mem_map[ZYNQMP_MEM_MAP_MAX] = {
>   {
>   .virt = 0x8000UL,
>   .phys = 0x8000UL,
> @@ -33,8 +45,7 @@ static struct mm_region zynqmp_mem_map[] = {
>   .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
>PTE_BLOCK_NON_SHARE |
>PTE_BLOCK_PXN | PTE_BLOCK_UXN
> - },
> - {
> + }, {
>   .virt = 0xf800UL,
>   .phys = 0xf800UL,
>   .size = 0x07e0UL,
> @@ -42,42 +53,51 @@ static struct mm_region zynqmp_mem_map[] = {
>PTE_BLOCK_NON_SHARE |
>PTE_BLOCK_PXN | PTE_BLOCK_UXN
>   }, {
> -#if defined(CONFIG_DEFINE_TCM_OCM_MMAP)
> - .virt = 0xffe0UL,
> - .phys = 0xffe0UL,
> - .size = 0x0020UL,
> - .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
> -  PTE_BLOCK_INNER_SHARE
> - }, {
> -#endif
>   .virt = 0x4UL,
>   .phys = 0x4UL,
>   .size = 0x4UL,
>   .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
>PTE_BLOCK_NON_SHARE |
>PTE_BLOCK_PXN | PTE_BLOCK_UXN
> - },
> -#if !defined(CONFIG_ZYNQMP_NO_DDR)
> - {
> - .virt = 0x8UL,
> - .phys = 0x8UL,
> - .size = 0x8UL,
> - .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
> -  PTE_BLOCK_INNER_SHARE
> - },
> -#endif
> - {
> + }, {
>   .virt = 0x10UL,
>   .phys = 0x10UL,
>   .size = 0xf0UL,
>   .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
>PTE_BLOCK_NON_SHARE |
>PTE_BLOCK_PXN | PTE_BLOCK_UXN
> - }, {
> - /* List terminator */
> - 0,
>   }
>  };
> +
> +void mem_map_fill(void)
> +{
> + int banks = ZYNQMP_MEM_MAP_USED;
> +
> +#if defined(CONFIG_DEFINE_TCM_OCM_MMAP)
> + zynqmp_mem_map[banks].virt = 0xffe0UL;
> + zynqmp_mem_map[banks].phys = 0xffe0UL;
> + zynqmp_mem_map[banks].size = 0x0020UL;
> + zynqmp_mem_map[banks].attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
> +   PTE_BLOCK_INNER_SHARE;
> + banks = banks + 1;
> +#endif
> +
> +#if !defined(CONFIG_ZYNQMP_NO_DDR)
> + for (int i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
> + /* Skip empty banks */
> + if (!gd->bd->bi_dram[i].size)
> + break;

This doesn't skip, it takes empty as abort condition. That is probably
correct, but please update the comment above to reflect reality.

> +
> + zynqmp_mem_map[banks].virt = gd->bd->bi_dram[i].start;
> + zynqmp_mem_map[banks].phys = gd->bd->bi_dram[i].start;
> + zynqmp_mem_map[banks].size = 

[U-Boot] [PATCH v2] arm: zynqmp: Add ZynqMP minimal R5 support

2018-04-30 Thread Michal Simek
Xilinx ZynqMP also contains dual Cortex R5 which can run U-Boot.
This patch is adding minimal support to get U-Boot boot.
U-Boot on R5 runs out of DDR with default configuration that's why
DDR needs to be partitioned if there is something else running on arm64.
Console is done via Cadence uart driver and the first Cadence Triple
Timer Counter is used for time.

This configuration with uart1 was tested on zcu100-revC.

U-Boot 2018.05-rc2-00021-gd058a08d907d (Apr 18 2018 - 14:11:27 +0200)

Model: Xilinx ZynqMP R5
DRAM:  512 MiB
WARNING: Caches not enabled
MMC:
In:serial@ff01
Out:   serial@ff01
Err:   serial@ff01
Net:   Net Initialization Skipped
No ethernet found.
ZynqMP r5>

There are two ways how to run this on ZynqMP.
1. Run from ZynqMP arm64
tftpb 2000 u-boot-r5.elf
setenv autostart no && bootelf -p 2000
cpu 4 disable && cpu 4 release 1000 lockstep
or
cpu 4 disable && cpu 4 release 1000 split

2. Load via jtag when directly to R5

Signed-off-by: Michal Simek 
---

Changes in v2:
- Make this a single patch because core support was handled by Lokesh
  Vulta R5 series. Rebase on the top of this series
- Add reset_cpu which is not handle by core
- Add MPU support to enable only 0-512MB and RO for 512MB-2GB
- Enable cache support
- Wire MTEST macros but not enable mtest command

Changes compare to RFC
- Use 500MHz instead of 600MHz
- Remove fpu compilation flags
- Split arm-r5 code and platform

---
 MAINTAINERS|  6 +++
 arch/arm/Kconfig   | 10 
 arch/arm/Makefile  |  1 +
 arch/arm/dts/Makefile  |  2 +
 arch/arm/dts/zynqmp-r5.dts | 73 ++
 arch/arm/mach-zynqmp-r5/Kconfig| 27 +++
 arch/arm/mach-zynqmp-r5/Makefile   |  3 ++
 arch/arm/mach-zynqmp-r5/cpu.c  | 37 +++
 board/xilinx/zynqmp_r5/MAINTAINERS |  7 +++
 board/xilinx/zynqmp_r5/Makefile|  6 +++
 board/xilinx/zynqmp_r5/board.c | 25 ++
 configs/xilinx_zynqmp_r5_defconfig | 16 +++
 drivers/serial/Kconfig |  2 +-
 include/configs/xilinx_zynqmp_r5.h | 51 +
 14 files changed, 265 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/dts/zynqmp-r5.dts
 create mode 100644 arch/arm/mach-zynqmp-r5/Kconfig
 create mode 100644 arch/arm/mach-zynqmp-r5/Makefile
 create mode 100644 arch/arm/mach-zynqmp-r5/cpu.c
 create mode 100644 board/xilinx/zynqmp_r5/MAINTAINERS
 create mode 100644 board/xilinx/zynqmp_r5/Makefile
 create mode 100644 board/xilinx/zynqmp_r5/board.c
 create mode 100644 configs/xilinx_zynqmp_r5_defconfig
 create mode 100644 include/configs/xilinx_zynqmp_r5.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 147551f66fd3..e60d76dbad8a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -295,6 +295,12 @@ F: include/zynqmppl.h
 F: tools/zynqimage.c
 N: zynqmp
 
+ARM ZYNQMP R5
+M: Michal Simek 
+S: Maintained
+T: git git://git.denx.de/u-boot-microblaze.git
+F: arch/arm/mach-zynqmp-r5/
+
 BUILDMAN
 M: Simon Glass 
 S: Maintained
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index f07f17f053ff..13e06ff763d0 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -823,6 +823,14 @@ config ARCH_ZYNQ
imply CMD_SPL
imply ARCH_EARLY_INIT_R
 
+config ARCH_ZYNQMP_R5
+   bool "Xilinx ZynqMP R5 based platform"
+   select CPU_V7R
+   select OF_CONTROL
+   select DM
+   select DM_SERIAL
+   select CLK
+
 config ARCH_ZYNQMP
bool "Xilinx ZynqMP based platform"
select ARM64
@@ -1345,6 +1353,8 @@ source "arch/arm/cpu/armv7/vf610/Kconfig"
 
 source "arch/arm/mach-zynq/Kconfig"
 
+source "arch/arm/mach-zynqmp-r5/Kconfig"
+
 source "arch/arm/cpu/armv7/Kconfig"
 
 source "arch/arm/cpu/armv8/zynqmp/Kconfig"
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 3f5343bc017b..63e2b89ee7ef 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -78,6 +78,7 @@ machine-$(CONFIG_ARCH_STM32MP)+= stm32mp
 machine-$(CONFIG_TEGRA)+= tegra
 machine-$(CONFIG_ARCH_UNIPHIER)+= uniphier
 machine-$(CONFIG_ARCH_ZYNQ)+= zynq
+machine-$(CONFIG_ARCH_ZYNQMP_R5)   += zynqmp-r5
 
 machdirs := $(patsubst %,arch/arm/mach-%/,$(machine-y))
 
diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 1fb36b3ecdb3..d44a4310081e 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -165,6 +165,8 @@ dtb-$(CONFIG_ARCH_ZYNQMP) += \
zynqmp-zc1751-xm017-dc3.dtb \
zynqmp-zc1751-xm018-dc4.dtb \
zynqmp-zc1751-xm019-dc5.dtb
+dtb-$(CONFIG_ARCH_ZYNQMP_R5) += \
+   zynqmp-r5.dtb
 dtb-$(CONFIG_AM33XX) += am335x-boneblack.dtb am335x-bone.dtb \
am335x-draco.dtb \
am335x-evm.dtb \
diff --git a/arch/arm/dts/zynqmp-r5.dts b/arch/arm/dts/zynqmp-r5.dts
new file mode 100644
index ..a72172ef2ea4

[U-Boot] [PATCH v2] arm64: zynqmp: Setup MMU map for DDR at run time

2018-04-30 Thread Michal Simek
From: Nitin Jain 

This patch fills the MMU map for DDR at run time based information read
from Device Tree or automatically detected from static configuration.

The patch is needed because for systems which has for example 1GB of memory
but MMU map is 2GB there could be spurious accesses which was seen in past
when mapping is not fitting with actual memory installed.

Signed-off-by: Nitin Jain 
Signed-off-by: Siva Durga Prasad Paladugu 
Signed-off-by: Michal Simek 
---

Changes in v2:
- Fix and extended commit description (asked-by: agraf)

 arch/arm/cpu/armv8/zynqmp/cpu.c  | 84 
 arch/arm/include/asm/arch-zynqmp/sys_proto.h |  2 +-
 board/xilinx/zynqmp/zynqmp.c | 22 -
 3 files changed, 74 insertions(+), 34 deletions(-)

diff --git a/arch/arm/cpu/armv8/zynqmp/cpu.c b/arch/arm/cpu/armv8/zynqmp/cpu.c
index 14e7d4006494..5db5fafc6f65 100644
--- a/arch/arm/cpu/armv8/zynqmp/cpu.c
+++ b/arch/arm/cpu/armv8/zynqmp/cpu.c
@@ -16,16 +16,28 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-static struct mm_region zynqmp_mem_map[] = {
+/*
+ * Number of filled static entries and also the first empty
+ * slot in zynqmp_mem_map.
+ */
+#define ZYNQMP_MEM_MAP_USED4
+
 #if !defined(CONFIG_ZYNQMP_NO_DDR)
-   {
-   .virt = 0x0UL,
-   .phys = 0x0UL,
-   .size = 0x8000UL,
-   .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
-PTE_BLOCK_INNER_SHARE
-   },
+#define DRAM_BANKS CONFIG_NR_DRAM_BANKS
+#else
+#define DRAM_BANKS 0
 #endif
+
+#if defined(CONFIG_DEFINE_TCM_OCM_MMAP)
+#define TCM_MAP 1
+#else
+#define TCM_MAP 0
+#endif
+
+/* +1 is end of list which needs to be empty */
+#define ZYNQMP_MEM_MAP_MAX (ZYNQMP_MEM_MAP_USED + DRAM_BANKS + TCM_MAP + 1)
+
+static struct mm_region zynqmp_mem_map[ZYNQMP_MEM_MAP_MAX] = {
{
.virt = 0x8000UL,
.phys = 0x8000UL,
@@ -33,8 +45,7 @@ static struct mm_region zynqmp_mem_map[] = {
.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
 PTE_BLOCK_NON_SHARE |
 PTE_BLOCK_PXN | PTE_BLOCK_UXN
-   },
-   {
+   }, {
.virt = 0xf800UL,
.phys = 0xf800UL,
.size = 0x07e0UL,
@@ -42,42 +53,51 @@ static struct mm_region zynqmp_mem_map[] = {
 PTE_BLOCK_NON_SHARE |
 PTE_BLOCK_PXN | PTE_BLOCK_UXN
}, {
-#if defined(CONFIG_DEFINE_TCM_OCM_MMAP)
-   .virt = 0xffe0UL,
-   .phys = 0xffe0UL,
-   .size = 0x0020UL,
-   .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
-PTE_BLOCK_INNER_SHARE
-   }, {
-#endif
.virt = 0x4UL,
.phys = 0x4UL,
.size = 0x4UL,
.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
 PTE_BLOCK_NON_SHARE |
 PTE_BLOCK_PXN | PTE_BLOCK_UXN
-   },
-#if !defined(CONFIG_ZYNQMP_NO_DDR)
-   {
-   .virt = 0x8UL,
-   .phys = 0x8UL,
-   .size = 0x8UL,
-   .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
-PTE_BLOCK_INNER_SHARE
-   },
-#endif
-   {
+   }, {
.virt = 0x10UL,
.phys = 0x10UL,
.size = 0xf0UL,
.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
 PTE_BLOCK_NON_SHARE |
 PTE_BLOCK_PXN | PTE_BLOCK_UXN
-   }, {
-   /* List terminator */
-   0,
}
 };
+
+void mem_map_fill(void)
+{
+   int banks = ZYNQMP_MEM_MAP_USED;
+
+#if defined(CONFIG_DEFINE_TCM_OCM_MMAP)
+   zynqmp_mem_map[banks].virt = 0xffe0UL;
+   zynqmp_mem_map[banks].phys = 0xffe0UL;
+   zynqmp_mem_map[banks].size = 0x0020UL;
+   zynqmp_mem_map[banks].attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
+ PTE_BLOCK_INNER_SHARE;
+   banks = banks + 1;
+#endif
+
+#if !defined(CONFIG_ZYNQMP_NO_DDR)
+   for (int i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
+   /* Skip empty banks */
+   if (!gd->bd->bi_dram[i].size)
+   break;
+
+   zynqmp_mem_map[banks].virt = gd->bd->bi_dram[i].start;
+   zynqmp_mem_map[banks].phys = gd->bd->bi_dram[i].start;
+   zynqmp_mem_map[banks].size = gd->bd->bi_dram[i].size;
+   zynqmp_mem_map[banks].attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
+ PTE_BLOCK_INNER_SHARE;
+   banks = banks + 1;
+   }
+#endif
+}
+
 struct mm_region *mem_map = zynqmp_mem_map;
 
 u64 get_page_table_size(void)
diff --git 

[U-Boot] [PATCH 1/1] include: update log2 header from the Linux kernel

2018-04-30 Thread Heinrich Schuchardt
Without the patch gcc 8 produces:
warning: ignoring attribute ‘noreturn’ because it conflicts with
attribute ‘const’ [-Wattributes]
 int ilog2_NaN(void);

So let's update the include from Linux kernel v4.16.

This removes static checks of ilog2() arguments.

Signed-off-by: Heinrich Schuchardt 
---
 include/linux/log2.h | 63 +---
 1 file changed, 36 insertions(+), 27 deletions(-)

diff --git a/include/linux/log2.h b/include/linux/log2.h
index aa1de63090..41a1ae0109 100644
--- a/include/linux/log2.h
+++ b/include/linux/log2.h
@@ -3,7 +3,10 @@
  * Copyright (C) 2006 Red Hat, Inc. All Rights Reserved.
  * Written by David Howells (dhowe...@redhat.com)
  *
- * SPDX-License-Identifier:GPL-2.0+
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
  */
 
 #ifndef _LINUX_LOG2_H
@@ -12,12 +15,6 @@
 #include 
 #include 
 
-/*
- * deal with unrepresentable constant logarithms
- */
-extern __attribute__((const, noreturn))
-int ilog2_NaN(void);
-
 /*
  * non-constant log of base 2 calculators
  * - the arch may override these in asm/bitops.h if they can be implemented
@@ -40,19 +37,23 @@ int __ilog2_u64(u64 n)
 }
 #endif
 
-/*
- *  Determine whether some value is a power of two, where zero is
+/**
+ * is_power_of_2() - check if a value is a power of two
+ * @n: the value to check
+ *
+ * Determine whether some value is a power of two, where zero is
  * *not* considered a power of two.
+ * Return: true if @n is a power of 2, otherwise false.
  */
-
 static inline __attribute__((const))
 bool is_power_of_2(unsigned long n)
 {
return (n != 0 && ((n & (n - 1)) == 0));
 }
 
-/*
- * round up to nearest power of two
+/**
+ * __roundup_pow_of_two() - round up to nearest power of two
+ * @n: value to round up
  */
 static inline __attribute__((const))
 unsigned long __roundup_pow_of_two(unsigned long n)
@@ -60,8 +61,9 @@ unsigned long __roundup_pow_of_two(unsigned long n)
return 1UL << fls_long(n - 1);
 }
 
-/*
- * round down to nearest power of two
+/**
+ * __rounddown_pow_of_two() - round down to nearest power of two
+ * @n: value to round down
  */
 static inline __attribute__((const))
 unsigned long __rounddown_pow_of_two(unsigned long n)
@@ -70,19 +72,19 @@ unsigned long __rounddown_pow_of_two(unsigned long n)
 }
 
 /**
- * ilog2 - log of base 2 of 32-bit or a 64-bit unsigned value
- * @n - parameter
+ * ilog2 - log base 2 of 32-bit or a 64-bit unsigned value
+ * @n: parameter
  *
  * constant-capable log of base 2 calculation
  * - this can be used to initialise global variables from constant data, hence
- *   the massive ternary operator construction
+ * the massive ternary operator construction
  *
  * selects the appropriately-sized optimised version depending on sizeof(n)
  */
 #define ilog2(n)   \
 (  \
__builtin_constant_p(n) ? ( \
-   (n) < 1 ? ilog2_NaN() : \
+   (n) < 2 ? 0 :   \
(n) & (1ULL << 63) ? 63 :   \
(n) & (1ULL << 62) ? 62 :   \
(n) & (1ULL << 61) ? 61 :   \
@@ -145,10 +147,7 @@ unsigned long __rounddown_pow_of_two(unsigned long n)
(n) & (1ULL <<  4) ?  4 :   \
(n) & (1ULL <<  3) ?  3 :   \
(n) & (1ULL <<  2) ?  2 :   \
-   (n) & (1ULL <<  1) ?  1 :   \
-   (n) & (1ULL <<  0) ?  0 :   \
-   ilog2_NaN() \
-  ) :  \
+   1) :\
(sizeof(n) <= 4) ?  \
__ilog2_u32(n) :\
__ilog2_u64(n)  \
@@ -156,7 +155,7 @@ unsigned long __rounddown_pow_of_two(unsigned long n)
 
 /**
  * roundup_pow_of_two - round the given value up to nearest power of two
- * @n - parameter
+ * @n: parameter
  *
  * round the given value up to the nearest power of two
  * - the result is undefined when n == 0
@@ -173,7 +172,7 @@ unsigned long __rounddown_pow_of_two(unsigned long n)
 
 /**
  * rounddown_pow_of_two - round the given value down to nearest power of two
- * @n - parameter
+ * @n: parameter
  *
  * round the given value down to the nearest power of two
  * - the result is undefined when n == 0
@@ -186,6 +185,12 @@ unsigned long __rounddown_pow_of_two(unsigned long n)
__rounddown_pow_of_two(n)   \
  )
 
+static inline __attribute_const__
+int __order_base_2(unsigned long n)
+{
+   return n > 1 ? ilog2(n - 1) + 1 : 0;
+}
+
 /**
  * order_base_2 - calculate the (rounded up) base 2 order of the argument
  * @n: parameter
@@ -199,7 +204,11 

Re: [U-Boot] [RESEND][PATCH v1 0/3] Add STM32MP157 regulator driver

2018-04-30 Thread Jaehoon Chung
Hi,

On 04/27/2018 12:11 AM, Patrice CHOTARD wrote:
> it misses one patch, sorry
> i ressend it right now

"[RESEND][PATCH v1 0/4]  " are right?

Best Regards,
Jaehoon Chung

> 
> Patrice
> 
> On 04/26/2018 04:42 PM, Patrice Chotard wrote:
>>
>> This series :
>>_ adds stpmu1 regulator driver
>>_ enables regulator relative flags in stm32mp15_basic_defconfig
>>_ updates pmic driver to bind regulator child nodes
>>_ adds regulator nodes entry in DT
>>
>>
>> Patrice Chotard (3):
>>power: pmic: stpmu1: Add regulator bindings
>>ARM: dts: stm32mp157c-ed1: Add regulator node
>>configs: stm32mp15_basic: Set regulator relative flags
>>
>>   arch/arm/dts/stm32mp157c-ed1.dts| 272 
>> 
>>   configs/stm32mp15_basic_defconfig   |   5 +
>>   drivers/power/pmic/stpmu1.c |  34 +
>>   include/dt-bindings/mfd/st,stpmu1.h |  60 
>>   4 files changed, 371 insertions(+)
>>   create mode 100644 include/dt-bindings/mfd/st,stpmu1.h

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


Re: [U-Boot] dm: mmc: socfpga: call dwmci_probe()

2018-04-30 Thread Jaehoon Chung
On 04/27/2018 05:48 PM, Marek Vasut wrote:
> On 04/27/2018 10:35 AM, Jaehoon Chung wrote:
>> Dear Marek,
>>
>> On 04/26/2018 09:01 PM, Marek Vasut wrote:
>>> On 04/26/2018 12:30 PM, Jaehoon Chung wrote:
 Hi,

 On 03/06/2018 05:07 PM, linux-kernel-...@beckhoff.com wrote:
> From: Patrick Bruenn 
>
> On a socfpga_cyclone5 based board the SD card, was never powered up. For
> other dw_mmc based SoCs dwmci_probe() is called in the platform specific
> probe(). It seems this call is missing for socfpga_dw_mmc.
>
> With this change DWMCI_PWREN is set by dmwci_init().

 Sorry for late. Applied to u-boot-mmc. Thanks!
>>>
>>> This is for next, right ?
>>
>> If possible, i want to apply this for v2018.05.
>> I know it's too late. It's my fault.
> 
> Yes it is, and if it breaks something, there's very little time to find
> out or test it.
> 
>> If not possible, i will rebase mmc repository with fixing patches.
>> And other patches will move to next branch.
> 
> Yes

Will do. This patch will move to next branch.

> 
>> Will make a decision until today. And Will send the PR for v2081.05.
> 
> I am happy to take this via socfpga-next if you cannot submit a PR right
> after the release for some reason.

I will do.

Best Regards,
Jaehoon Chung

> 

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


Re: [U-Boot] u-boot 2018 SPI SPL

2018-04-30 Thread Mehmet Ali İPİN
Dear Fabio,

Windows 10 tried but could not load the device driver of our eMMC (micron tech 
MTFC4GLDDQ). Then

I programmed SPL and u-boot.img into eMMC with u-boot commands; even SPI flash 
based SPL see the MMC1(eMMC), u-boot did not run correctly.

As shown below, I put printf/puts messages in function entry and exit to debug 
SPL:

U-Boot SPL 2018.05-rc1 (Apr 27 2018 - 04:15:59 -0700)
SPL set_bd()
SPL Malloc; gd flags
SPL init_i
SPL init_exit
boot mode bmode =3201
boot mode reg =18080030
SPI serial mode return
board boot order boot list
spl_boot_list:8
spl_boot_list:8
SPL image loader boot device 8
boot device name:MMC1
boot device name:MMC1
boot device name:MMC1
boot device name:MMC1
SPL image loader Not Found
Trying to boot from -442503140
SPL: Unsupported Boot Device!
spl_boot_list:1
SPL image loader boot device 1
boot device name:MMC1
Trying to boot from 1
Trying to boot from MMC1
SPL load image


I disabled #CONFIG_SPL_OS_BOOT=y flag, to disable direct boot linux kernel 
code, changed boot from SD directives to spi, tested many other serial SPI boot 
config definitions, included all congatec cgtqmx_defconfig definitions;

İn my SPI SPL, SRC_SBMR1 read returns 0x18080030 which is exactly my spi nor 
flash register boot setting,  and spl_boot _list:8 (SPI NOR Boot setting, 
(which is verified by my "SPI serial mode return" printf message), boot device 
name is always MMC1. Its always trying to boot from -442503140, and can not 
find SPL image loader finally.. 

Since they did not give all of their u-boot source and config files, It is 
impossible for me to know how congatec succeded from SPI boot of 
SPL+u-boot.img,  

But my test of u-boot 2018.01/05 shows, even my DCD header in SPI is correct, 
even I proceeded congatech's SPI  SPL u-boot.img flash loading sequences, after 
testing many configurations in 2/3 weeks I am sure there is a problem with SPL 
u-boot.img for SPI boot such that:

Even on chip ROM code detects correct boot register settings,  jumps to spi 
flash, starts executing SPL codes, it always search MMC/SD card.

Since it is very important for us to bring this i.mx6 board, which several 
projects depend on it;

And since I did not see your name in SPL files, May I request your kind helps, 
if you can direct me to whom developing SPL codes for u-boot 2018 in  
list.denx.de group?

Thanks and best regards.

Mehmet Ali Ipin.


-Original Message-
From: Fabio Estevam [mailto:feste...@gmail.com] 
Sent: Saturday, April 21, 2018 2:40 AM
To: Mehmet Ali İPİN 
Cc: u-boot@lists.denx.de; Kutsal ANIL 
Subject: Re: [U-Boot] u-boot 2018 SPI SPL

On Fri, Apr 20, 2018 at 3:43 AM, Mehmet Ali İPİN  
wrote:
> Dear Fabio
>
> Thank you very much for your directives and helps.
>
> I applied the steps in WARP board readme file, for the command
>
> => ums 0 mmc 2
>
> I received Unknown command 'ums' - try 'help'
>
> I compared with  WARP7 defconfig and mx6sabresd_defconfig files added some 
> definitions in WARP, but got error messages in make file.
> Therefore I would appreciate your helps/commends if you write me the 
> definitions in config/defconfig files to enable u-boot to run this command?

You can take a look at this commit for reference:

commit 506abdb4ee9664cc0d6d1321e96f7fb8dae72eb9
Author: Marek Vasut 
Date:   Sun Oct 22 10:22:40 2017 +0200

ARM: imx6: Enable UMS and DFU on DHCOM i.MX6 PDK

Enable UMS and DFU, so that the eMMC can be accessed via the
USB gadget port on the board.

Signed-off-by: Marek Vasut 
Cc: Stefano Babic 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


  1   2   >