Re: [U-Boot] [PATCH v4 6/6] common: Generic loader for file system

2018-09-25 Thread Chee, Tien Fong
On Thu, 2018-09-20 at 21:42 -0700, Chee, Tien Fong wrote:
> > 
If everybody agree with current framework, then the next version i will
include the fixes:
1. Adding DM_FLAG_PRE_RELOC, this would allow runtime to choose the
right fs_loader if the chosen node u-boot, fs-loader is not defined.

2. Let driver model handles all memory allocation

3. Using local variable instead of messy casts.

Thanks.
> On Tue, 2018-07-31 at 08:22 +0200, Michal Simek wrote:
> > 
> > On 30.7.2018 18:05, Simon Glass wrote:
> > > 
> > > 
> > > Hi Michal,
> > > 
> > > On 30 July 2018 at 07:30, Michal Simek 
> > > wrote:
> > > > 
> > > > 
> > > > On 30.7.2018 15:26, Simon Glass wrote:
> > > > > 
> > > > > 
> > > > > Hi,
> > > > > 
> > > > > On 27 July 2018 at 02:40, Chee, Tien Fong  > > > > el
> > > > > .com> wrote:
> > > > > > 
> > > > > > 
> > > > > > 
> > > > > > On Thu, 2018-07-26 at 11:03 +0200, Michal Simek wrote:
> > > > > > > 
> > > > > > > 
> > > > > > > On 25.7.2018 18:03, Tom Rini wrote:
> > > > > > > > 
> > > > > > > > 
> > > > > > > > 
> > > > > > > > On Wed, Jul 25, 2018 at 09:47:17AM -0600, Simon Glass
> > > > > > > > wrote:
> > > > > > > > > 
> > > > > > > > > 
> > > > > > > > > 
> > > > > > > > > Hi,
> > > > > > > > > 
> > > > > > > > > On 25 July 2018 at 03:48, Michal Simek  > > > > > > > > xi
> > > > > > > > > linx.com>
> > > > > > > > > wrote:
> > > > > > > > > > 
> > > > > > > > > > 
> > > > > > > > > > 
> > > > > > > > > > 
> > > > > > > > > > On 25.7.2018 08:31, Chee, Tien Fong wrote:
> > > > > > > > > > > 
> > > > > > > > > > > 
> > > > > > > > > > > 
> > > > > > > > > > > On Wed, 2018-07-18 at 16:48 +0200, Michal Simek
> > > > > > > > > > > wrote:
> > > > > > > > > > > > 
> > > > > > > > > > > > 
> > > > > > > > > > > > 
> > > > > > > > > > > > On 6.7.2018 10:28, tien.fong.c...@intel.com
> > > > > > > > > > > > wrote:
> > > > > > > > > > > > > 
> > > > > > > > > > > > > 
> > > > > > > > > > > > > 
> > > > > > > > > > > > > 
> > > > > > > > > > > > > From: Tien Fong Chee  > > > > > > > > > > > > m>
> > > > > > > > > > > > > 
> > > > > > > > > [...]
> > > > > > > > > 
> > > > > > > > > > 
> > > > > > > > > > 
> > > > > > > > > > 
> > > > > > > > > > > 
> > > > > > > > > > > 
> > > > > > > > > > > 
> > > > > > > > > > > > 
> > > > > > > > > > > > 
> > > > > > > > > > > > 
> > > > > > > > > > > > 
> > > > > > > > > > > > Also that DT binding is quite weird and I don't
> > > > > > > > > > > > think you
> > > > > > > > > > > > will get
> > > > > > > > > > > > ACK
> > > > > > > > > > > > for this from device tree community at all. I
> > > > > > > > > > > > think that
> > > > > > > > > > > > calling via
> > > > > > > > > > > > platdata and avoid DT nodes would be better way
> > > > > > > > > > > > to go.
> > > > > > > > > > > Why do you think DT binding is weird? The DT is
> > > > > > > > > > > designed
> > > > > > > > > > > based on Simon
> > > > > > > > > > > proposal, and i believe following the rules in
> > > > > > > > > > > DTS
> > > > > > > > > > > spec.
> > > > > > > > > > > There are some DT benefits with current design, i
> > > > > > > > > > > think
> > > > > > > > > > > someone may be
> > > > > > > > > > > maintainer need to made the final decision on the
> > > > > > > > > > > design.
> > > > > > > > > > It is software configuration in file which should
> > > > > > > > > > mostly
> > > > > > > > > > describe
> > > > > > > > > > hardware and state for hardware configuration.
> > > > > > > > > > 
> > > > > > > > > > Your fs_loader node is purely describe sw
> > > > > > > > > > configuration which
> > > > > > > > > > shouldn't
> > > > > > > > > > be here.
> > > > > > > > > > You have there run time configuration via
> > > > > > > > > > variables.
> > > > > > > > > > I think
> > > > > > > > > > using only
> > > > > > > > > > this way is enough. Default variables will match
> > > > > > > > > > what
> > > > > > > > > > you would
> > > > > > > > > > want to
> > > > > > > > > > add to DT.
> > > > > > > > > I think DT makes sense in the U-Boot context.
> > > > > > > > > 
> > > > > > > > > We don't have a user space to handle policy
> > > > > > > > > decisions,
> > > > > > > > > and the
> > > > > > > > > 'chosen' node is a good place to configure these
> > > > > > > > > common
> > > > > > > > > features.
> > > > > > > > > 
> > > > > > > > > While you can argue that the partition or filesystem
> > > > > > > > > where an
> > > > > > > > > image
> > > > > > > > > comes from is a software config, it is something that
> > > > > > > > > has to be
> > > > > > > > > configured. It has impact on hardware too, since the
> > > > > > > > > FPGA has to
> > > > > > > > > get
> > > > > > > > > its firmware from somewhere. We use the chosen node
> > > > > > > > > to
> > > > > > > > > specify
> > > > > > > > > the
> > > > > > > > > UART to use, and this is no different. Again, we
> > > > > > > > > don't
> > > > > > > > > have user-
> > > > > > > > > space
> > > > > > > > > config files in U-Boot.
> > > > > > > > > 
> > > > > > > > >

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

2018-09-25 Thread Jens Wiklander
Hi Simon,

I have one question inline below.

On Fri, Sep 14, 2018 at 12:53 PM, Simon Glass  wrote:
> Hi Jens,
>
> On 3 September 2018 at 16:47, Jens Wiklander  
> wrote:
>> Adds a sandboxtee driver which emulates a generic TEE with the OP-TEE
>
> sandbox tee
>
>> AVB TA.
>>
>> Signed-off-by: Jens Wiklander 
>> ---
>>  drivers/tee/Kconfig   |  12 +-
>>  drivers/tee/Makefile  |   1 +
>>  drivers/tee/optee/Kconfig |   2 +-
>>  drivers/tee/sandbox.c | 299 ++
>>  include/sandboxtee.h  |  15 ++
>>  5 files changed, 326 insertions(+), 3 deletions(-)
>>  create mode 100644 drivers/tee/sandbox.c
>>  create mode 100644 include/sandboxtee.h
>
> Reviewed-by: Simon Glass 
>
> nits below.
>
>>
>> diff --git a/drivers/tee/Kconfig b/drivers/tee/Kconfig
>> index 835c256e9239..4697b80913d6 100644
>> --- a/drivers/tee/Kconfig
>> +++ b/drivers/tee/Kconfig
>> @@ -1,8 +1,8 @@
>>  # Generic Trusted Execution Environment Configuration
>>  config TEE
>> bool "Trusted Execution Environment support"
>> -   depends on ARM && (ARM64 || CPU_V7A)
>> -   select ARM_SMCCC
>> +   depends on (ARM && (ARM64 || CPU_V7A)) || SANDBOX
>> +   select ARM_SMCCC if ARM
>> help
>>   This implements a generic interface towards a Trusted Execution
>>   Environment (TEE). A TEE is a trusted OS running in some secure
>> @@ -14,6 +14,14 @@ if TEE
>>
>>  menu "TEE drivers"
>>
>> +config SANDBOX_TEE
>> +   bool "Sandbox TEE emulator"
>> +   depends on SANDBOX
>> +   default y
>> +   help
>> + This emulates a generic TEE needed for testing including the AVB
>> + TA.
>
> Can you please expand this? What features does it implement? How do
> you access it from the U-Boot command line?

I'll expand it.

>
>> +
>>  source "drivers/tee/optee/Kconfig"
>>
>>  endmenu
>> diff --git a/drivers/tee/Makefile b/drivers/tee/Makefile
>> index 19633b60f235..f72c68c09f33 100644
>> --- a/drivers/tee/Makefile
>> +++ b/drivers/tee/Makefile
>> @@ -1,4 +1,5 @@
>>  # SPDX-License-Identifier: GPL-2.0+
>>
>>  obj-y += tee-uclass.o
>> +obj-$(CONFIG_SANDBOX) += sandbox.o
>>  obj-$(CONFIG_OPTEE) += optee/
>> diff --git a/drivers/tee/optee/Kconfig b/drivers/tee/optee/Kconfig
>> index dbfa7846a30f..d489834df926 100644
>> --- a/drivers/tee/optee/Kconfig
>> +++ b/drivers/tee/optee/Kconfig
>> @@ -10,7 +10,7 @@ config OPTEE
>>   handle Remote Procedure Calls (RPC) from OP-TEE needed to
>>   execute a service. For more information see: https://www.op-tee.org
>>
>> -if OPTEE
>> +if OPTEE || SANDBOX
>>
>>  menu "OP-TEE options"
>>
>> diff --git a/drivers/tee/sandbox.c b/drivers/tee/sandbox.c
>> new file mode 100644
>> index ..cd073497615f
>> --- /dev/null
>> +++ b/drivers/tee/sandbox.c
>> @@ -0,0 +1,299 @@
>> +// SPDX-License-Identifier: GPL-2.0+
>> +/*
>> + * Copyright (C) 2018 Linaro Limited
>> + */
>> +#include 
>> +#include 
>> +#include 
>
> Could this go in asm/ ?

I don't understand. What should go into asm/ and which directory is that?

>
>> +#include 
>> +#include 
>> +
>> +/*
>> + * The sandbox tee driver tries to emulate a generic TEE with the TA
>> + * OPTEE_TA_AVB available.
>
> What is TEE?
>
> What is TA?
>
> Please expand out the names once in this comment so people can see
> immediately what you are referring to.
>
>> + */
>> +
>
>
>
>> +struct ta_entry {
>
> What is this struct for? Please add a comment

OK

>
>> +   struct tee_optee_ta_uuid uuid;
>> +   u32 (*open_session)(uint num_params, struct tee_param *params);
>> +   u32 (*invoke_func)(u32 func, uint num_params, struct tee_param 
>> *params);
>> +};
>> +
>> +#ifdef CONFIG_OPTEE_TA_AVB
>> +static u32 get_attr(uint n, uint num_params, struct tee_param *params)
>> +{
>> +   if (n >= num_params)
>> +   return TEE_PARAM_ATTR_TYPE_NONE;
>> +
>> +   return params[n].attr;
>> +}
>> +
>> +static u32 check_params(u8 p0, u8 p1, u8 p2, u8 p3, uint num_params,
>> +   struct tee_param *params)
>> +{
>> +   u8 p[] = { p0, p1, p2, p3};
>> +   uint n;
>> +
>> +   for (n = 0; n < ARRAY_SIZE(p); n++)
>> +   if (p[n] != get_attr(n, num_params, params))
>> +   goto bad_params;
>> +
>> +   for (; n < num_params; n++)
>> +   if (get_attr(n, num_params, params))
>> +   goto bad_params;
>> +
>> +   return TEE_SUCCESS;
>> +
>> +bad_params:
>> +   printf("Bad param attrs\n");
>> +
>> +   return TEE_ERROR_BAD_PARAMETERS;
>> +}
>> +
>> +static u64 ta_avb_rollback_indexes[TA_AVB_MAX_ROLLBACK_LOCATIONS];
>> +static u32 ta_avb_lock_state;
>> +
>> +static u32 ta_avb_open_session(uint num_params, struct tee_param *params)
>> +{
>> +   /*
>> +* We don't expect additional parameters when opening a session to
>> +* this TA.
>> +*/
>> +   return check_params(TEE_PARAM_ATTR_TYPE_NONE, 
>> TEE_PARAM_ATTR_TYPE_NONE,
>> +  

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

2018-09-25 Thread Jens Wiklander
On Fri, Sep 14, 2018 at 12:54 PM, Simon Glass  wrote:
> On 3 September 2018 at 16:47, Jens Wiklander  
> wrote:
>> With CONFIG_OPTEE_TA_AVB use the trusted application AVB provided by
>> OP-TEE to manage rollback indexes and device lock status.
>
> Should this be device-lock status?

Yes, I'll fix.

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

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


Re: [U-Boot] [PATCH v2 0/7] [RESEND] Improvements for the dwc3_generic driver

2018-09-25 Thread Lukasz Majewski
Hi Jean-Jacques,

> On 21/09/2018 15:02, Jean-Jacques Hiblot wrote:
> >
> >
> > On 21/09/2018 12:43, Lukasz Majewski wrote:  
> >> Hi Jean-Jacques,
> >>  
> >>> On 21/09/2018 11:24, Lukasz Majewski wrote:  
>  Hi Jean-Jacques,  
> > On 21/09/2018 10:50, Lukasz Majewski wrote:  
> >> Hi Jean-Jacques,  
> >>> Hi Marek,
> >>>
> >>> I haven't heard of you on this series.
> >>>
> >>> It is already a resend and has been tested on 2 platforms
> >>> (zcu100 and dra7/am57).
> >>>
> >>> Can you please consider it for inclusion?  
> >> This is not Marek to blame for the delay - I had some non open
> >> source tasks to finish (and I do apologise for this
> >> situation).  
> > Thanks. I am not blaming anyone.  
>  :-)
> 
>  Could you check the build result?
>  https://travis-ci.org/lmajewski/u-boot-dfu/builds/431388980
>  I do see some issues with "Freescale ARM32/ARM64".  
> >>> I can reproduce the problem.
> >>> The root cause is that I moved the phy handling operation from the
> >>> host (xhci-dwc3.c) to the core dwc3/core.c thinking that all
> >>> users of the dwc3 would have the core code. Well that is not the
> >>> case.  
> >> Maybe a silly question - how those boards work as they do not
> >> use/include the DWC3 core?  
> > It looks like the host side of the dwc3 is  mostly self-contained
> > and that the code in dwc3/core.c is mostly used by the gadget side.
> >  
> It seems that the PHY code is not used by the platforms that failed
> to build, so it can be compiled out.
> I'll send a v3 shortly.

Thanks :-).

> JJ
> 
> >>
> >> They use xhci PHY handling code and what code on top?
> >>  
> >>> I see 2 solutions:
> >>> * move the phy code back to xhci-dwc3
> >>> * enable the core code for dwc3 (CONFIG_USB_DWC3) for the failing
> >>> platforms
> >>>
> >>> Any preference ?
> >>>
> >>>  
> > I just wanted to make sure that this
> > wasn't lost in limbo.  
> >> Your patches are now under build testing on travis-CI:
> >> https://travis-ci.org/lmajewski/u-boot-dfu/builds/431388980
> >>
> >> I will send the PR after CI finish.  
> >>> Thanks,
> >>>
> >>> JJ
> >>>
> >>>
> >>>
> >>> On 04/09/2018 15:42, Jean-Jacques Hiblot wrote:  
>  Resending this series after rebasing on top of latest u-boot.
> 
>  This series aims at bringing improvements to the dwc3_generic
>  driver so that it can be used by most of the platforms using
>  the dwc3 controller.
> 
>  I tested this on with DRA7 and AM57x platforms for both
>  Peripheral and Host operations. The code to enable DM USB
>  host & dev support for those platforms will be submitted in a
>  separate series.
> 
>  Michal Simek has tested this series:
>  " I have tested it on zcu100 with usb stick, usb to ethernet
>  converter and also dfu.
>  Tested-by: Michal Simek "
> 
>  Enhancements:
>  - use separate Kconfig option for DM USB Periphal and DM USB
>  Host. This allow platforms to keep their non-DM USB
>  peripheral code and use the DM USB host.
>  - fixes the bind/probe confusion in dwc3_generic. The probe
>  is done when the USB device is first needed.
>  - handles PHYs when in the peripheral mode. The code to
>  handle the PHYs is shared with the host side
>  - handles clock and reset
>  - bind host controller to the more generic driver 'xhci-dwc3'
> 
> 
>  Changes in v2:
>  - Updated commit log
>  - Fixed typo in thordown.c
>  - select DM_USB_DEV by default for zynqmp platforms
> 
>  Jean-Jacques Hiblot (7):
>    usb: gadget: Do not call board_usb_xxx() directly in
>  USB gadget drivers
>    usb: introduce a separate config option for DM USB
>  device usb: udc: implement DM versions of
>  usb_gadget_initialize()/_release()/_handle_interrupt()
>    dwc3_generic: do not probe the USB device driver when
>  it's bound dwc3: move phy operation to core.c
>    dwc3-generic: Handle the PHYs, the clocks and the reset
>  lines dwc3-generic: Add select_dr_mode operation
> 
>   arch/arm/Kconfig  |   2 +
>   cmd/fastboot.c    |   4 +-
>   cmd/rockusb.c |   4 +-
>   cmd/thordown.c    |   4 +-
>   cmd/usb_gadget_sdp.c  |   4 +-
>   cmd/usb_mass_storage.c    |   4 +-
>   common/dfu.c  |   6 +-
>   drivers/usb/Kconfig   |   6 ++
>   drivers/usb/dwc3/Kconfig  |   7 +-
>   drivers/usb/dwc3/core.c   |  86 +++-
>   drivers/u

Re: [U-Boot] [PATCH 01/10] net: sandbox: Move disabled flag into priv struct

2018-09-25 Thread Bin Meng
On Wed, Jul 25, 2018 at 5:40 AM Joe Hershberger  wrote:
>
> Store the per-device data with the device.
>
> Signed-off-by: Joe Hershberger 
> ---
>
>  drivers/net/sandbox.c | 18 ++
>  1 file changed, 14 insertions(+), 4 deletions(-)
>

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


Re: [U-Boot] [PATCH 02/10] net: sandbox: Refactor sandbox send function

2018-09-25 Thread Bin Meng
Hi Joe,

On Wed, Jul 25, 2018 at 5:46 AM Joe Hershberger  wrote:
>
> Make the behavior of the send function reusable.
>
> Signed-off-by: Joe Hershberger 
> ---
>
>  arch/sandbox/include/asm/eth.h |  20 +
>  drivers/net/sandbox.c  | 176 
> -
>  2 files changed, 124 insertions(+), 72 deletions(-)
>
> diff --git a/arch/sandbox/include/asm/eth.h b/arch/sandbox/include/asm/eth.h
> index bfcd11b593..00062616a4 100644
> --- a/arch/sandbox/include/asm/eth.h
> +++ b/arch/sandbox/include/asm/eth.h
> @@ -13,4 +13,24 @@ void sandbox_eth_disable_response(int index, bool disable);
>
>  void sandbox_eth_skip_timeout(void);
>
> +/*
> + * sandbox_eth_arp_req_to_reply()
> + *
> + * Check for an arp request to be sent. If so, inject a reply
> + *
> + * returns 1 if injected, 0 if not

The meaning of return code 1/0 seems odd. Normally 0 means OK. Can we
use -Exxx for the error condition?

> + */
> +int sandbox_eth_arp_req_to_reply(struct udevice *dev, void *packet,
> +unsigned int len);
> +
> +/*
> + * sandbox_eth_ping_req_to_reply()
> + *
> + * Check for a ping request to be sent. If so, inject a reply
> + *
> + * returns 1 if injected, 0 if not
> + */
> +int sandbox_eth_ping_req_to_reply(struct udevice *dev, void *packet,
> + unsigned int len);
> +
>  #endif /* __ETH_H */

[snip]

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


Re: [U-Boot] [PATCH 03/10] net: sandbox: Make the fake eth driver response configurable

2018-09-25 Thread Bin Meng
On Wed, Jul 25, 2018 at 5:47 AM Joe Hershberger  wrote:
>
> Make the send handler registerable so tests can check for different
> things.
>
> Signed-off-by: Joe Hershberger 
> ---
>
>  arch/sandbox/include/asm/eth.h | 17 ++
>  drivers/net/sandbox.c  | 53 
> ++
>  2 files changed, 66 insertions(+), 4 deletions(-)
>

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


Re: [U-Boot] [PATCH 09/10] test: eth: Add a test for the target being pinged

2018-09-25 Thread Bin Meng
Hi Joe,

On Wed, Jul 25, 2018 at 5:42 AM Joe Hershberger  wrote:
>
> The target will respond to pings while doing other network handling.
> Make sure that the response happens and is correct.
>
> This currently corrupts the ongoing operation of the device if it
> happens to be awaiting an ARP reply of its own to whatever serverip it
> is attempting to communicate with. In the test, add an expectation that
> the user operation (ping, in this case) will fail. A later patch will
> address this problem.
>
> Signed-off-by: Joe Hershberger 
> ---
>
>  arch/sandbox/include/asm/eth.h |  9 +
>  drivers/net/sandbox.c  | 51 ++
>  test/dm/eth.c  | 81 
> ++
>  3 files changed, 141 insertions(+)
>

Reviewed-by: Bin Meng 

But please see comments below.

> diff --git a/arch/sandbox/include/asm/eth.h b/arch/sandbox/include/asm/eth.h
> index 7cd5b551d9..66f6b4078b 100644
> --- a/arch/sandbox/include/asm/eth.h
> +++ b/arch/sandbox/include/asm/eth.h
> @@ -42,6 +42,15 @@ int sandbox_eth_ping_req_to_reply(struct udevice *dev, 
> void *packet,
>   */
>  int sandbox_eth_recv_arp_req(struct udevice *dev);
>
> +/*
> + * sandbox_eth_recv_ping_req()
> + *
> + * Inject a ping request for this target
> + *
> + * returns 1 if injected, 0 if not

again the return code issue

> + */
> +int sandbox_eth_recv_ping_req(struct udevice *dev);
> +
>  /**
>   * A packet handler
>   *
> diff --git a/drivers/net/sandbox.c b/drivers/net/sandbox.c
> index 2c2a2c6311..039c1e3222 100644
> --- a/drivers/net/sandbox.c
> +++ b/drivers/net/sandbox.c
> @@ -202,6 +202,57 @@ int sandbox_eth_recv_arp_req(struct udevice *dev)
>  }
>
>  /*
> + * sandbox_eth_recv_ping_req()
> + *
> + * Inject a ping request for this target
> + *
> + * returns 1 if injected, 0 if not
> + */
> +int sandbox_eth_recv_ping_req(struct udevice *dev)
> +{
> +   struct eth_sandbox_priv *priv = dev_get_priv(dev);
> +   struct ethernet_hdr *eth_recv;
> +   struct ip_udp_hdr *ipr;
> +   struct icmp_hdr *icmpr;
> +
> +   /* Don't allow the buffer to overrun */
> +   if (priv->recv_packets >= PKTBUFSRX)
> +   return 0;
> +
> +   /* Formulate a fake ping */
> +   eth_recv = (void *)priv->recv_packet_buffer[priv->recv_packets];
> +
> +   memcpy(eth_recv->et_dest, net_ethaddr, ARP_HLEN);
> +   memcpy(eth_recv->et_src, priv->fake_host_hwaddr, ARP_HLEN);
> +   eth_recv->et_protlen = htons(PROT_IP);
> +
> +   ipr = (void *)eth_recv + ETHER_HDR_SIZE;
> +   ipr->ip_hl_v = 0x45;
> +   ipr->ip_len = htons(IP_ICMP_HDR_SIZE);
> +   ipr->ip_off = htons(IP_FLAGS_DFRAG);
> +   ipr->ip_p = IPPROTO_ICMP;
> +   ipr->ip_sum = 0;
> +   net_write_ip(&ipr->ip_src, priv->fake_host_ipaddr);
> +   net_write_ip(&ipr->ip_dst, net_ip);
> +   ipr->ip_sum = compute_ip_checksum(ipr, IP_HDR_SIZE);
> +
> +   icmpr = (struct icmp_hdr *)&ipr->udp_src;
> +
> +   icmpr->type = ICMP_ECHO_REQUEST;
> +   icmpr->code = 0;
> +   icmpr->checksum = 0;
> +   icmpr->un.echo.id = 0;
> +   icmpr->un.echo.sequence = htons(1);
> +   icmpr->checksum = compute_ip_checksum(icmpr, ICMP_HDR_SIZE);
> +
> +   priv->recv_packet_length[priv->recv_packets] =
> +   ETHER_HDR_SIZE + IP_ICMP_HDR_SIZE;
> +   ++priv->recv_packets;
> +
> +   return 1;
> +}
> +
> +/*
>   * sb_default_handler()
>   *
>   * perform typical responses to simple ping
> diff --git a/test/dm/eth.c b/test/dm/eth.c
> index 9b5f53e819..77c602beaf 100644
> --- a/test/dm/eth.c
> +++ b/test/dm/eth.c
> @@ -339,3 +339,84 @@ static int dm_test_eth_async_arp_reply(struct 
> unit_test_state *uts)
>  }
>
>  DM_TEST(dm_test_eth_async_arp_reply, DM_TESTF_SCAN_FDT);
> +
> +static int sb_check_ping_reply(struct udevice *dev, void *packet,
> +  unsigned int len)
> +{
> +   struct eth_sandbox_priv *priv = dev_get_priv(dev);
> +   struct ethernet_hdr *eth = packet;
> +   struct ip_udp_hdr *ip;
> +   struct icmp_hdr *icmp;
> +   struct unit_test_state *uts = priv->priv;

This is not used anywhere.

> +
> +   if (ntohs(eth->et_protlen) != PROT_IP)
> +   return 0;
> +
> +   ip = packet + ETHER_HDR_SIZE;
> +
> +   if (ip->ip_p != IPPROTO_ICMP)
> +   return 0;
> +
> +   icmp = (struct icmp_hdr *)&ip->udp_src;
> +
> +   if (icmp->type != ICMP_ECHO_REPLY)
> +   return 0;
> +
> +   /* This test would be worthless if we are not waiting */
> +   ut_assert(arp_is_waiting());
> +
> +   /* Validate response */
> +   ut_assert(memcmp(eth->et_src, net_ethaddr, ARP_HLEN) == 0);
> +   ut_assert(memcmp(eth->et_dest, priv->fake_host_hwaddr, ARP_HLEN) == 
> 0);
> +   ut_assert(eth->et_protlen == htons(PROT_IP));
> +
> +   ut_assert(net_read_ip(&ip->ip_src).s_addr == net_ip.s_addr);
> +   ut_assert(net_read_ip(&ip->ip_dst).s_addr ==
> + str

Re: [U-Boot] [PATCH 04/10] net: sandbox: Share the priv structure with tests

2018-09-25 Thread Bin Meng
On Wed, Jul 25, 2018 at 5:42 AM Joe Hershberger  wrote:
>
> If tests want to implement tx handlers, they will likely need access to
> the details in the priv structure.
>
> Signed-off-by: Joe Hershberger 
> ---
>
>  arch/sandbox/include/asm/eth.h | 19 +++
>  drivers/net/sandbox.c  | 19 ---
>  2 files changed, 19 insertions(+), 19 deletions(-)
>

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


Re: [U-Boot] [PATCH 05/10] net: sandbox: Allow fake eth to handle more than 1 packet response

2018-09-25 Thread Bin Meng
On Wed, Jul 25, 2018 at 5:41 AM Joe Hershberger  wrote:
>
> Use up to the max allocated receive buffers so be able to test more
> complex situations.
>
> Signed-off-by: Joe Hershberger 
> ---
>
>  arch/sandbox/include/asm/eth.h | 10 +---
>  drivers/net/sandbox.c  | 57 
> ++
>  2 files changed, 52 insertions(+), 15 deletions(-)
>

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


Re: [U-Boot] [PATCH 07/10] net: sandbox: Add a priv ptr for tests to use

2018-09-25 Thread Bin Meng
Hi Joe,

On Wed, Jul 25, 2018 at 5:45 AM Joe Hershberger  wrote:
>
> Signed-off-by: Joe Hershberger 
> ---
>
>  arch/sandbox/include/asm/eth.h |  9 +
>  drivers/net/sandbox.c  | 20 
>  2 files changed, 29 insertions(+)
>
> diff --git a/arch/sandbox/include/asm/eth.h b/arch/sandbox/include/asm/eth.h
> index 6dabbf00ab..6bb3f1bbfd 100644
> --- a/arch/sandbox/include/asm/eth.h
> +++ b/arch/sandbox/include/asm/eth.h
> @@ -53,6 +53,7 @@ typedef int sandbox_eth_tx_hand_f(struct udevice *dev, void 
> *pkt,
>   * recv_packet_length - lengths of the packet returned as received
>   * recv_packets - number of packets returned
>   * tx_handler - function to generate responses to sent packets
> + * priv - a pointer to some structure a test may want to keep track of
>   */
>  struct eth_sandbox_priv {
> uchar fake_host_hwaddr[ARP_HLEN];
> @@ -62,6 +63,7 @@ struct eth_sandbox_priv {
> int recv_packet_length[PKTBUFSRX];
> int recv_packets;
> sandbox_eth_tx_hand_f *tx_handler;
> +   void *priv;
>  };
>
>  /*
> @@ -71,4 +73,11 @@ struct eth_sandbox_priv {
>   */
>  void sandbox_eth_set_tx_handler(int index, sandbox_eth_tx_hand_f *handler);
>
> +/*
> + * Set priv ptr
> + *
> + * priv - priv void ptr to store in the device
> + */
> +void sandbox_eth_set_priv(int index, void *priv);
> +
>  #endif /* __ETH_H */
> diff --git a/drivers/net/sandbox.c b/drivers/net/sandbox.c
> index 5117af8a82..29767ef291 100644
> --- a/drivers/net/sandbox.c
> +++ b/drivers/net/sandbox.c
> @@ -204,6 +204,26 @@ void sandbox_eth_set_tx_handler(int index, 
> sandbox_eth_tx_hand_f *handler)
> priv->tx_handler = sb_default_handler;
>  }
>
> +/*
> + * Set priv ptr
> + *
> + * priv - priv void ptr to store in the device
> + */
> +void sandbox_eth_set_priv(int index, void *priv)
> +{
> +   struct udevice *dev;
> +   struct eth_sandbox_priv *uc_priv;

Can we use 'priv' instead? As the name uc_prive seems to mean uclass's
prive, which isn't the truth.

> +   int ret;
> +
> +   ret = uclass_get_device(UCLASS_ETH, index, &dev);
> +   if (ret)
> +   return;
> +
> +   uc_priv = dev_get_priv(dev);
> +
> +   uc_priv->priv = priv;
> +}
> +
>  static int sb_eth_start(struct udevice *dev)
>  {
> struct eth_sandbox_priv *priv = dev_get_priv(dev);
> --

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


Re: [U-Boot] [PATCH 10/10] net: Don't overwrite waiting packets with asynchronous replies

2018-09-25 Thread Bin Meng
On Wed, Jul 25, 2018 at 5:44 AM Joe Hershberger  wrote:
>
> Peter originally sent a fix, but it breaks a number of other things.
> This addresses the original reported issue in a different way.
>
> That report was:
>
> > U-Boot has 1 common buffer to send Ethernet frames, pointed to by
> > net_tx_packet.  When sending to an IP address without knowing the MAC
> > address, U-Boot makes an ARP request (using the arp_tx_packet buffer)
> > to find out the MAC address of the IP addressr. When a matching ARP
> > reply is received, U-Boot continues sending the frame stored in the
> > net_tx_packet buffer.
> >
> > However, in the mean time, if U-Boot needs to send out any network
> > packets (e.g. replying ping packets or ARP requests for its own IP
> > address etc.), it will use the net_tx_packet buffer to prepare the
> > new packet. Thus this buffer is no longer the original packet meant
> > to be transmitted after the ARP reply. The original packet will be
> > lost.
>
> This instead uses the ARP tx buffer to send async replies in the case
> where we are actively waiting for an ARP reply.
>
> Signed-off-by: Joe Hershberger 
>
> Reported-by: Tran Tien Dat 
> ---
>
>  include/net.h | 8 
>  net/arp.c | 9 +
>  net/arp.h | 1 +
>  net/net.c | 8 
>  net/ping.c| 7 +--
>  test/dm/eth.c | 6 ++
>  6 files changed, 29 insertions(+), 10 deletions(-)
>

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


Re: [U-Boot] [PATCH 08/10] test: eth: Add a test for ARP requests

2018-09-25 Thread Bin Meng
Hi Joe,

On Wed, Jul 25, 2018 at 5:43 AM Joe Hershberger  wrote:
>
> This tests that ARP requests made to this target's IP address are
> responded-to by the target when it is doing other networking operations.
>
> This currently corrupts the ongoing operation of the device if it
> happens to be awaiting an ARP reply of its own to whatever serverip it
> is attempting to communicate with. In the test, add an expectation that
> the user operation (ping, in this case) will fail. A later patch will
> address this problem.
>
> Signed-off-by: Joe Hershberger 
> ---
>
>  arch/sandbox/include/asm/eth.h |  9 +
>  drivers/net/sandbox.c  | 41 +
>  test/dm/eth.c  | 81 
> ++
>  3 files changed, 131 insertions(+)
>

Reviewed-by: Bin Meng 

But please see comments below:

> diff --git a/arch/sandbox/include/asm/eth.h b/arch/sandbox/include/asm/eth.h
> index 6bb3f1bbfd..7cd5b551d9 100644
> --- a/arch/sandbox/include/asm/eth.h
> +++ b/arch/sandbox/include/asm/eth.h
> @@ -33,6 +33,15 @@ int sandbox_eth_arp_req_to_reply(struct udevice *dev, void 
> *packet,
>  int sandbox_eth_ping_req_to_reply(struct udevice *dev, void *packet,
>   unsigned int len);
>
> +/*
> + * sandbox_eth_recv_arp_req()
> + *
> + * Inject an ARP request for this target
> + *
> + * returns 1 if injected, 0 if not

again the return codes, can we use -Exxx instead? I see the return
error is not checked anywhere, maybe we should just make it return
void?

> + */
> +int sandbox_eth_recv_arp_req(struct udevice *dev);
> +
>  /**
>   * A packet handler
>   *
> diff --git a/drivers/net/sandbox.c b/drivers/net/sandbox.c
> index 29767ef291..2c2a2c6311 100644
> --- a/drivers/net/sandbox.c
> +++ b/drivers/net/sandbox.c
> @@ -161,6 +161,47 @@ int sandbox_eth_ping_req_to_reply(struct udevice *dev, 
> void *packet,
>  }
>
>  /*
> + * sandbox_eth_recv_arp_req()
> + *
> + * Inject an ARP request for this target
> + *
> + * returns 1 if injected, 0 if not
> + */
> +int sandbox_eth_recv_arp_req(struct udevice *dev)
> +{
> +   struct eth_sandbox_priv *priv = dev_get_priv(dev);
> +   struct ethernet_hdr *eth_recv;
> +   struct arp_hdr *arp_recv;
> +
> +   /* Don't allow the buffer to overrun */
> +   if (priv->recv_packets >= PKTBUFSRX)
> +   return 0;
> +
> +   /* Formulate a fake request */
> +   eth_recv = (void *)priv->recv_packet_buffer[priv->recv_packets];
> +   memcpy(eth_recv->et_dest, net_bcast_ethaddr, ARP_HLEN);
> +   memcpy(eth_recv->et_src, priv->fake_host_hwaddr, ARP_HLEN);
> +   eth_recv->et_protlen = htons(PROT_ARP);
> +
> +   arp_recv = (void *)eth_recv + ETHER_HDR_SIZE;
> +   arp_recv->ar_hrd = htons(ARP_ETHER);
> +   arp_recv->ar_pro = htons(PROT_IP);
> +   arp_recv->ar_hln = ARP_HLEN;
> +   arp_recv->ar_pln = ARP_PLEN;
> +   arp_recv->ar_op = htons(ARPOP_REQUEST);
> +   memcpy(&arp_recv->ar_sha, priv->fake_host_hwaddr, ARP_HLEN);
> +   net_write_ip(&arp_recv->ar_spa, priv->fake_host_ipaddr);
> +   memcpy(&arp_recv->ar_tha, net_null_ethaddr, ARP_HLEN);
> +   net_write_ip(&arp_recv->ar_tpa, net_ip);
> +
> +   priv->recv_packet_length[priv->recv_packets] =
> +   ETHER_HDR_SIZE + ARP_HDR_SIZE;
> +   ++priv->recv_packets;
> +
> +   return 1;
> +}
> +
> +/*
>   * sb_default_handler()
>   *
>   * perform typical responses to simple ping
> diff --git a/test/dm/eth.c b/test/dm/eth.c
> index 1a7684a887..9b5f53e819 100644
> --- a/test/dm/eth.c
> +++ b/test/dm/eth.c
> @@ -258,3 +258,84 @@ static int dm_test_net_retry(struct unit_test_state *uts)
> return retval;
>  }
>  DM_TEST(dm_test_net_retry, DM_TESTF_SCAN_FDT);
> +
> +static int sb_check_arp_reply(struct udevice *dev, void *packet,
> + unsigned int len)
> +{
> +   struct eth_sandbox_priv *priv = dev_get_priv(dev);
> +   struct ethernet_hdr *eth = packet;
> +   struct arp_hdr *arp;
> +   struct unit_test_state *uts = priv->priv;

This is not used anywhere. What is this for?

> +
> +   if (ntohs(eth->et_protlen) != PROT_ARP)
> +   return 0;
> +
> +   arp = packet + ETHER_HDR_SIZE;
> +
> +   if (ntohs(arp->ar_op) != ARPOP_REPLY)
> +   return 0;
> +
> +   /* This test would be worthless if we are not waiting */
> +   ut_assert(arp_is_waiting());
> +
> +   /* Validate response */
> +   ut_assert(memcmp(eth->et_src, net_ethaddr, ARP_HLEN) == 0);
> +   ut_assert(memcmp(eth->et_dest, priv->fake_host_hwaddr, ARP_HLEN) == 
> 0);
> +   ut_assert(eth->et_protlen == htons(PROT_ARP));
> +
> +   ut_assert(arp->ar_hrd == htons(ARP_ETHER));
> +   ut_assert(arp->ar_pro == htons(PROT_IP));
> +   ut_assert(arp->ar_hln == ARP_HLEN);
> +   ut_assert(arp->ar_pln == ARP_PLEN);
> +   ut_assert(memcmp(&arp->ar_sha, net_ethaddr, ARP_HLEN) == 0);
> +   ut_assert(net_read_ip(&a

Re: [U-Boot] [PATCH 06/10] net: Add an accessor to know if waiting for ARP

2018-09-25 Thread Bin Meng
Hi Joe,

On Wed, Jul 25, 2018 at 5:45 AM Joe Hershberger  wrote:
>
> This single-sources the state of the ARP.
>
> Signed-off-by: Joe Hershberger 
> ---
>
>  include/net.h |  1 +
>  net/arp.c | 11 ---
>  2 files changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/include/net.h b/include/net.h
> index f9984ae86c..63718a47f2 100644
> --- a/include/net.h
> +++ b/include/net.h
> @@ -635,6 +635,7 @@ rxhand_f *net_get_udp_handler(void);/* Get UDP RX 
> packet handler */
>  void net_set_udp_handler(rxhand_f *);  /* Set UDP RX packet handler */
>  rxhand_f *net_get_arp_handler(void);   /* Get ARP RX packet handler */
>  void net_set_arp_handler(rxhand_f *);  /* Set ARP RX packet handler */
> +int arp_is_waiting(void);  /* Waiting for ARP reply? */

Can we use 'bool' instead of 'int'?

>  void net_set_icmp_handler(rxhand_icmp_f *f); /* Set ICMP RX handler */
>  void net_set_timeout_handler(ulong, thand_f *);/* Set timeout handler */
>
> diff --git a/net/arp.c b/net/arp.c
> index b8a71684cd..524361cf1b 100644
> --- a/net/arp.c
> +++ b/net/arp.c
> @@ -100,7 +100,7 @@ int arp_timeout_check(void)
>  {
> ulong t;
>
> -   if (!net_arp_wait_packet_ip.s_addr)
> +   if (!arp_is_waiting())
> return 0;
>
> t = get_timer(0);
> @@ -187,8 +187,8 @@ void arp_receive(struct ethernet_hdr *et, struct 
> ip_udp_hdr *ip, int len)
> return;
>
> case ARPOP_REPLY:   /* arp reply */
> -   /* are we waiting for a reply */
> -   if (!net_arp_wait_packet_ip.s_addr)
> +   /* are we waiting for a reply? */
> +   if (!arp_is_waiting())
> break;
>
>  #ifdef CONFIG_KEEP_SERVERADDR
> @@ -233,3 +233,8 @@ void arp_receive(struct ethernet_hdr *et, struct 
> ip_udp_hdr *ip, int len)
> return;
> }
>  }
> +
> +int arp_is_waiting(void)
> +{
> +   return !!net_arp_wait_packet_ip.s_addr;
> +}
> --

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


[U-Boot] [PATCH] driver/mtd: Add MICRON manufacturer id in spi framework

2018-09-25 Thread Ashish Kumar
Signed-off-by: Suresh Gupta 
Signed-off-by: Yogesh Gaur 
Signed-off-by: Ashish Kumar 
---
 drivers/mtd/spi/sf_internal.h | 1 +
 drivers/mtd/spi/spi_flash.c   | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/drivers/mtd/spi/sf_internal.h b/drivers/mtd/spi/sf_internal.h
index 4f63cacc64..26f5c7c995 100644
--- a/drivers/mtd/spi/sf_internal.h
+++ b/drivers/mtd/spi/sf_internal.h
@@ -32,6 +32,7 @@ enum spi_nor_option_flags {
 /* CFI Manufacture ID's */
 #define SPI_FLASH_CFI_MFR_SPANSION 0x01
 #define SPI_FLASH_CFI_MFR_STMICRO  0x20
+#define SPI_FLASH_CFI_MFR_MICRON   0x2C
 #define SPI_FLASH_CFI_MFR_MACRONIX 0xc2
 #define SPI_FLASH_CFI_MFR_SST  0xbf
 #define SPI_FLASH_CFI_MFR_WINBOND  0xef
diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c
index c159124259..c73011748e 100644
--- a/drivers/mtd/spi/spi_flash.c
+++ b/drivers/mtd/spi/spi_flash.c
@@ -1096,6 +1096,7 @@ static int set_quad_mode(struct spi_flash *flash,
 #endif
 #ifdef CONFIG_SPI_FLASH_STMICRO
case SPI_FLASH_CFI_MFR_STMICRO:
+   case SPI_FLASH_CFI_MFR_MICRON:
debug("SF: QEB is volatile for %02x flash\n", JEDEC_MFR(info));
return 0;
 #endif
@@ -1183,6 +1184,7 @@ int spi_flash_scan(struct spi_flash *flash)
 #if defined(CONFIG_SPI_FLASH_STMICRO) || defined(CONFIG_SPI_FLASH_SST)
/* NOR protection support for STmicro/Micron chips and similar */
if (JEDEC_MFR(info) == SPI_FLASH_CFI_MFR_STMICRO ||
+   JEDEC_MFR(info) == SPI_FLASH_CFI_MFR_MICRON ||
JEDEC_MFR(info) == SPI_FLASH_CFI_MFR_SST) {
flash->flash_lock = stm_lock;
flash->flash_unlock = stm_unlock;
-- 
2.17.1

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


[U-Boot] [PATCH] driver/spi: Add FSPI driver for NXP FlexSPI controller

2018-09-25 Thread Ashish Kumar
Add nxp_fspi driver for NXP FlexSPI controller.
This driver supports both IP Mode read/write and
AHB mode READ.

It supports Single Bit mode read along with Fast Read cmd support.
Octal bit mode is supported for read.
Multi CS are supported tested until 4.

Signed-off-by: Suresh Gupta 
Signed-off-by: Yogesh Gaur 
Signed-off-by: Rajat Srivastava 
Signed-off-by: Ashish Kumar 
---
 arch/arm/cpu/armv8/fsl-layerscape/Kconfig |   10 +
 drivers/spi/Kconfig   |7 +
 drivers/spi/Makefile  |1 +
 drivers/spi/nxp_fspi.c| 1088 +
 drivers/spi/nxp_fspi.h|  422 
 5 files changed, 1528 insertions(+)
 create mode 100644 drivers/spi/nxp_fspi.c
 create mode 100644 drivers/spi/nxp_fspi.h

diff --git a/arch/arm/cpu/armv8/fsl-layerscape/Kconfig 
b/arch/arm/cpu/armv8/fsl-layerscape/Kconfig
index f2111fadc0..5280d33ec8 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/Kconfig
+++ b/arch/arm/cpu/armv8/fsl-layerscape/Kconfig
@@ -317,6 +317,16 @@ config QSPI_AHB_INIT
  But some QSPI flash size up to 64MBytes, so initialize the QSPI AHB
  bus for those flashes to support the full QSPI flash size.
 
+config SYS_FSPI_AHB_INIT
+   bool "Initialize the FlexSPI controller for AHB mode"
+   depends on NXP_FSPI
+   default n
+   help
+ Initialize the FlexSPI controller for AHB mode and mark default
+ read mode as AHB mode. In AHB mode, direct memory copying is
+ performed. Default LUT programmed in AHB mode is Fast Read command
+ with 4-byte addressing enabled.
+
 config SYS_CCI400_OFFSET
hex "Offset for CCI400 base"
depends on SYS_FSL_HAS_CCI400
diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index dcd719ff0a..7c2ccfa6bc 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -242,6 +242,13 @@ config ZYNQMP_GQSPI
  This option is used to enable ZynqMP QSPI controller driver which
  is used to communicate with qspi flash devices.
 
+config NXP_FSPI
+   bool "NXP FLEXSPI driver"
+   help
+ Enable the NXP Flex-SPI (FSPI) driver. This driver can be used to
+ access SPI NOR flash on platforms embedding this NXP IP code.
+ This driver support SPI flash read, write and erase.
+
 endif # if DM_SPI
 
 config SOFT_SPI
diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile
index 728e30c538..71f914543c 100644
--- a/drivers/spi/Makefile
+++ b/drivers/spi/Makefile
@@ -27,6 +27,7 @@ obj-$(CONFIG_EXYNOS_SPI) += exynos_spi.o
 obj-$(CONFIG_FSL_DSPI) += fsl_dspi.o
 obj-$(CONFIG_FSL_ESPI) += fsl_espi.o
 obj-$(CONFIG_FSL_QSPI) += fsl_qspi.o
+obj-$(CONFIG_NXP_FSPI) += nxp_fspi.o
 obj-$(CONFIG_ICH_SPI) +=  ich.o
 obj-$(CONFIG_KIRKWOOD_SPI) += kirkwood_spi.o
 obj-$(CONFIG_LPC32XX_SSP) += lpc32xx_ssp.o
diff --git a/drivers/spi/nxp_fspi.c b/drivers/spi/nxp_fspi.c
new file mode 100644
index 00..9a9e6371c8
--- /dev/null
+++ b/drivers/spi/nxp_fspi.c
@@ -0,0 +1,1088 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2018 NXP
+ *
+ * NXP Flex Serial Peripheral Interface (FSPI) driver
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "nxp_fspi.h"
+
+DECLARE_GLOBAL_DATA_PTR;
+
+/* default SCK frequency, unit: HZ */
+#define NXP_FSPI_DEFAULT_SCK_FREQ  5000
+
+/* FSPI max chipselect signals number */
+#define NXP_FSPI_MAX_CHIPSELECT_NUM 4
+
+#define NXP_FSPI_MAX_TIMEOUT_AHBCMD0xFF
+#define NXP_FSPI_MAX_TIMEOUT_IPCMD 0xFF
+#define NXP_FSPI_SER_CLK_DIV   0x00
+
+#define FSPI_FLAG_REGMAP_ENDIAN_BIGBIT(0)
+
+#define FSPI_RX_MAX_IPBUF_SIZE 0x200 /* 64 * 64bits  */
+#define FSPI_TX_MAX_IPBUF_SIZE 0x400 /* 128 * 64bits */
+#define FSPI_RX_MAX_AHBBUF_SIZE0x800 /* 256 * 64bits */
+#define FSPI_TX_MAX_AHBBUF_SIZE0x40  /* 8 * 64bits   */
+
+#define TX_IPBUF_SIZE  FSPI_TX_MAX_IPBUF_SIZE
+#define RX_IPBUF_SIZE  FSPI_RX_MAX_IPBUF_SIZE
+#define RX_AHBBUF_SIZE FSPI_RX_MAX_AHBBUF_SIZE
+#define TX_AHBBUF_SIZE FSPI_TX_MAX_AHBBUF_SIZE
+
+/* SEQID */
+#define SEQID_READ 0
+#define SEQID_WREN 1
+#define SEQID_FAST_READ2
+#define SEQID_RDSR 3
+#define SEQID_SE   4
+#define SEQID_CHIP_ERASE   5
+#define SEQID_PP   6
+#define SEQID_RDID 7
+#define SEQID_BE_4K8
+#define SEQID_RDFSR9
+#define SEQID_ENTR4BYTE10
+#define SEQID_OCTAL_READ   11
+
+/* FSPI CMD */
+#define FSPI_CMD_PP0x02/* Page program (up to 256 bytes) */
+#define FSPI_CMD_RDSR  0x05/* Read status register */
+#define FSPI_CMD_RDFSR 0x70/* Read flag status register */
+#define FSPI_CMD_WREN  0x06/* Write enable */
+#define FSPI_CMD_READ  0x03/* Read data bytes */
+#define FSPI_CMD_FAST_READ 0x0b/* Read data bytes (h

[U-Boot] [PATCH] fsl-lsch3: Add FSPI address space in immap_lsch3

2018-09-25 Thread Ashish Kumar
Signed-off-by: Priyanka Jain 
Signed-off-by: Sriram Dash 
Signed-off-by: Ashish Kumar 
---

depends upon: 
http://patchwork.ozlabs.org/patch/962357/

 arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h 
b/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h
index b0cec74db0..56f596 100644
--- a/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h
+++ b/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h
@@ -19,7 +19,11 @@
 #define CONFIG_SYS_FSL_CH3_CLK_GRPA_ADDR   (CONFIG_SYS_IMMR + 0x0030)
 #define CONFIG_SYS_FSL_CH3_CLK_GRPB_ADDR   (CONFIG_SYS_IMMR + 0x0031)
 #define CONFIG_SYS_FSL_CH3_CLK_CTRL_ADDR   (CONFIG_SYS_IMMR + 0x0037)
+#ifndef CONFIG_NXP_LSCH3_2
 #define SYS_FSL_QSPI_ADDR  (CONFIG_SYS_IMMR + 0x010c)
+#else
+#define SYS_FSL_FSPI_ADDR  (CONFIG_SYS_IMMR + 0x010c)
+#endif
 #define CONFIG_SYS_FSL_ESDHC_ADDR  (CONFIG_SYS_IMMR + 0x0114)
 #define CONFIG_SYS_IFC_ADDR(CONFIG_SYS_IMMR + 0x0124)
 #define CONFIG_SYS_NS16550_COM1(CONFIG_SYS_IMMR + 
0x011C0500)
-- 
2.17.1

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


[U-Boot] [PATCH] fsl-lsch3: soc: Enable AHB support flexspi controller

2018-09-25 Thread Ashish Kumar
Enable AHB support for flexspi controller interface meaning
memory can be accessed via md command using absolute addresses

Signed-off-by: Yogesh Gaur 
Signed-off-by: Rajat Srivastava 
Signed-off-by: Ashish Kumar 
---
 arch/arm/cpu/armv8/fsl-layerscape/Kconfig | 10 ++
 arch/arm/cpu/armv8/fsl-layerscape/soc.c   | 42 +++
 2 files changed, 52 insertions(+)

diff --git a/arch/arm/cpu/armv8/fsl-layerscape/Kconfig 
b/arch/arm/cpu/armv8/fsl-layerscape/Kconfig
index 5280d33ec8..8d66783b7c 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/Kconfig
+++ b/arch/arm/cpu/armv8/fsl-layerscape/Kconfig
@@ -327,6 +327,16 @@ config SYS_FSPI_AHB_INIT
  performed. Default LUT programmed in AHB mode is Fast Read command
  with 4-byte addressing enabled.
 
+config FSPI_AHB_EN_4BYTE
+   bool "Enable 4-byte Fast Read cmd for AHB mode"
+   depends on NXP_FSPI
+   default n
+   help
+ The default setting for FSPI AHB bus just supports 3-byte addressing.
+ But some FSPI flash sizes are up to 64MBytes.
+ This flag enables fast read cmd for AHB mode and modifies required
+ LUT to support full FSPI flash.
+
 config SYS_CCI400_OFFSET
hex "Offset for CCI400 base"
depends on SYS_FSL_HAS_CCI400
diff --git a/arch/arm/cpu/armv8/fsl-layerscape/soc.c 
b/arch/arm/cpu/armv8/fsl-layerscape/soc.c
index 3f15cb08ff..60beb0dc96 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/soc.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/soc.c
@@ -640,6 +640,45 @@ void fsl_lsch2_early_init_f(void)
 }
 #endif
 
+#ifdef CONFIG_FSPI_AHB_EN_4BYTE
+int fspi_ahb_init(void)
+{
+   /* Enable 4bytes address support and fast read */
+   u32 *fspi_lut, lut_key, *fspi_key;
+
+   fspi_key = (void *)SYS_FSL_FSPI_ADDR + 0x18;
+   fspi_lut = (void *)SYS_FSL_FSPI_ADDR + 0x200;
+
+   lut_key = in_be32(fspi_key);
+
+   if (lut_key == 0x5af05af0) {
+   /* That means the register is BE */
+   out_be32(fspi_key, 0x5af05af0);
+   /* Unlock the lut table */
+   out_be32(fspi_key + 1, 0x0002);
+   out_be32(fspi_lut, 0x0820040c);
+   out_be32(fspi_lut + 1, 0x24003008);
+   out_be32(fspi_lut + 2, 0x);
+   /* Lock the lut table */
+   out_be32(fspi_key, 0x5af05af0);
+   out_be32(fspi_key + 1, 0x0001);
+   } else {
+   /* That means the register is LE */
+   out_le32(fspi_key, 0x5af05af0);
+   /* Unlock the lut table */
+   out_le32(fspi_key + 1, 0x0002);
+   out_le32(fspi_lut, 0x0820040c);
+   out_le32(fspi_lut + 1, 0x24003008);
+   out_le32(fspi_lut + 2, 0x);
+   /* Lock the lut table */
+   out_le32(fspi_key, 0x5af05af0);
+   out_le32(fspi_key + 1, 0x0001);
+   }
+
+   return 0;
+}
+#endif
+
 #ifdef CONFIG_QSPI_AHB_INIT
 /* Enable 4bytes address support and fast read */
 int qspi_ahb_init(void)
@@ -688,6 +727,9 @@ int board_late_init(void)
 #ifdef CONFIG_QSPI_AHB_INIT
qspi_ahb_init();
 #endif
+#ifdef CONFIG_FSPI_AHB_EN_4BYTE
+   fspi_ahb_init();
+#endif
 
return 0;
 }
-- 
2.17.1

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


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

2018-09-25 Thread Jean-Jacques Hiblot
Add 2 functions to wrap the calls to board_usb_init() and
board_usb_cleanup().
This is a preparatory work for DM support for UDC drivers (DM_USB_DEV).

Signed-off-by: Jean-Jacques Hiblot 
Reviewed-by: Lukasz Majewski 

---

Changes in v3: None
Changes in v2:
- Updated commit log
- Fixed typo in thordown.c

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

diff --git a/cmd/fastboot.c b/cmd/fastboot.c
index ae3a5f6..0be83b7 100644
--- a/cmd/fastboot.c
+++ b/cmd/fastboot.c
@@ -51,7 +51,7 @@ static int do_fastboot_usb(int argc, char *const argv[],
return CMD_RET_FAILURE;
}
 
-   ret = board_usb_init(controller_index, USB_INIT_DEVICE);
+   ret = usb_gadget_initialize(controller_index);
if (ret) {
pr_err("USB init failed: %d\n", ret);
return CMD_RET_FAILURE;
@@ -82,7 +82,7 @@ static int do_fastboot_usb(int argc, char *const argv[],
 exit:
g_dnl_unregister();
g_dnl_clear_detach();
-   board_usb_cleanup(controller_index, USB_INIT_DEVICE);
+   usb_gadget_release(controller_index);
 
return ret;
 #else
diff --git a/cmd/rockusb.c b/cmd/rockusb.c
index 8206643..e0c1480 100644
--- a/cmd/rockusb.c
+++ b/cmd/rockusb.c
@@ -33,7 +33,7 @@ static int do_rockusb(cmd_tbl_t *cmdtp, int flag, int argc, 
char *const argv[])
dev_index = simple_strtoul(devnum, NULL, 0);
rockusb_dev_init(devtype, dev_index);
 
-   ret = board_usb_init(controller_index, USB_INIT_DEVICE);
+   ret = usb_gadget_initialize(controller_index);
if (ret) {
printf("USB init failed: %d\n", ret);
return CMD_RET_FAILURE;
@@ -62,7 +62,7 @@ static int do_rockusb(cmd_tbl_t *cmdtp, int flag, int argc, 
char *const argv[])
 exit:
g_dnl_unregister();
g_dnl_clear_detach();
-   board_usb_cleanup(controller_index, USB_INIT_DEVICE);
+   usb_gadget_release(controller_index);
 
return ret;
 }
diff --git a/cmd/thordown.c b/cmd/thordown.c
index 2615ada..ce3660d 100644
--- a/cmd/thordown.c
+++ b/cmd/thordown.c
@@ -30,7 +30,7 @@ int do_thor_down(cmd_tbl_t *cmdtp, int flag, int argc, char * 
const argv[])
goto done;
 
int controller_index = simple_strtoul(usb_controller, NULL, 0);
-   ret = board_usb_init(controller_index, USB_INIT_DEVICE);
+   ret = usb_gadget_initialize(controller_index);
if (ret) {
pr_err("USB init failed: %d\n", ret);
ret = CMD_RET_FAILURE;
@@ -55,7 +55,7 @@ int do_thor_down(cmd_tbl_t *cmdtp, int flag, int argc, char * 
const argv[])
 
 exit:
g_dnl_unregister();
-   board_usb_cleanup(controller_index, USB_INIT_DEVICE);
+   usb_gadget_release(controller_index);
 done:
dfu_free_entities();
 
diff --git a/cmd/usb_gadget_sdp.c b/cmd/usb_gadget_sdp.c
index ba1f66a..808ed97 100644
--- a/cmd/usb_gadget_sdp.c
+++ b/cmd/usb_gadget_sdp.c
@@ -20,7 +20,7 @@ static int do_sdp(cmd_tbl_t *cmdtp, int flag, int argc, char 
* const argv[])
 
char *usb_controller = argv[1];
int controller_index = simple_strtoul(usb_controller, NULL, 0);
-   board_usb_init(controller_index, USB_INIT_DEVICE);
+   usb_gadget_initialize(controller_index);
 
g_dnl_clear_detach();
g_dnl_register("usb_dnl_sdp");
@@ -37,7 +37,7 @@ static int do_sdp(cmd_tbl_t *cmdtp, int flag, int argc, char 
* const argv[])
 
 exit:
g_dnl_unregister();
-   board_usb_cleanup(controller_index, USB_INIT_DEVICE);
+   usb_gadget_release(controller_index);
 
return ret;
 }
diff --git a/cmd/usb_mass_storage.c b/cmd/usb_mass_storage.c
index 0d55114..753ae4f 100644
--- a/cmd/usb_mass_storage.c
+++ b/cmd/usb_mass_storage.c
@@ -160,7 +160,7 @@ static int do_usb_mass_storage(cmd_tbl_t *cmdtp, int flag,
 
controller_index = (unsigned int)(simple_strtoul(
usb_controller, NULL, 0));
-   if (board_usb_init(controller_index, USB_INIT_DEVICE)) {
+   if (usb_gadget_initialize(controller_index)) {
pr_err("Couldn't init USB controller.\n");
rc = CMD_RET_FAILURE;
goto cleanup_ums_init;
@@ -231,7 +231,7 @@ static int do_usb_mass_storage(cmd_tbl_t *cmdtp, int flag,
 cleanup_register:
g_dnl_unregister();
 cleanup_board:
-   board_usb_cleanup(controller_index, USB_INIT_DEVICE);
+   usb_gadget_release(controller_index);
 cleanup_ums_init:
ums_fini();
 
diff --git a/common/dfu.c b/common/dfu.c
index 2620d32..44d1484 100644
--- a/common/dfu.c
+++ b/common/dfu.c
@@ -23,9 +23,9 @@ int run_usb_dnl_gadget(int usbctrl_index, char 
*usb_dn

[U-Boot] [PATCH v3 0/8] Improvements for the dwc3_generic driver

2018-09-25 Thread Jean-Jacques Hiblot

This series aims at bringing improvements to the dwc3_generic driver so
that it can be used by most of the platforms using the dwc3 controller.

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

Michal Simek has tested this series:
" I have tested it on zcu100 with usb stick, usb to ethernet converter and
also dfu.
Tested-by: Michal Simek "

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


Changes in v3:
- fixes bug dwc3_setup_phy(): the phy arrays wasn't returned. This was
  visible only when the device is removed.
- Stub the DWC3 PHY operations if CONFIG_IS_ENABLED(PHY) is false.
  This fixes all build issues but one (evb-rk3328).
- Fix build issue with evb-rk3328 by enabling CONFIG_USB_DWC3. This has
  little impact on the footprint and should not break the runtime as the
  xhci-rockchip driver has its own probe function.
  Nevertheless this was !!! NOT TESTED !!! by lack of hw

Changes in v2:
- Updated commit log
- Fixed typo in thordown.c
- select DM_USB_DEV by default for zynqmp platforms

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

 arch/arm/Kconfig  |   2 +
 cmd/fastboot.c|   4 +-
 cmd/rockusb.c |   4 +-
 cmd/thordown.c|   4 +-
 cmd/usb_gadget_sdp.c  |   4 +-
 cmd/usb_mass_storage.c|   4 +-
 common/dfu.c  |   6 +-
 configs/evb-rk3328_defconfig  |   1 +
 drivers/usb/Kconfig   |   6 ++
 drivers/usb/dwc3/Kconfig  |   7 +-
 drivers/usb/dwc3/core.c   |  89 +++-
 drivers/usb/dwc3/dwc3-generic.c   | 207 +-
 drivers/usb/dwc3/ep0.c|   1 -
 drivers/usb/gadget/ether.c|  38 +--
 drivers/usb/gadget/udc/udc-core.c |  44 +++-
 drivers/usb/host/xhci-dwc3.c  |  95 ++---
 include/dwc3-uboot.h  |  19 
 include/linux/usb/gadget.h|  18 
 18 files changed, 367 insertions(+), 186 deletions(-)

-- 
2.7.4

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


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

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

Signed-off-by: Jean-Jacques Hiblot 
Reviewed-by: Lukasz Majewski 

---

Changes in v3: None
Changes in v2:
- select DM_USB_DEV by default for zynqmp platforms

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

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

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


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

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

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

Changes in v3: None
Changes in v2: None

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

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

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


[U-Boot] [PATCH v3 8/8] dwc3-generic: Add select_dr_mode operation

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

Signed-off-by: Jean-Jacques Hiblot 

---

Changes in v3: None
Changes in v2: None

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

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

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


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

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

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

Changes in v3: None
Changes in v2: None

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

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

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

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

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

Signed-off-by: Jean-Jacques Hiblot 
Reviewed-by: Lukasz Majewski 
---

Changes in v3: None
Changes in v2: None

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

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

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


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

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

Signed-off-by: Jean-Jacques Hiblot 

---

Changes in v3:
- fixes bug dwc3_setup_phy(): the phy arrays wasn't returned. This was
  visible only when the device is removed.
- Stub the DWC3 PHY operations if CONFIG_IS_ENABLED(PHY) is false.
  This fixes all build issues but one (evb-rk3328).

Changes in v2: None

 drivers/usb/dwc3/core.c  | 89 -
 drivers/usb/dwc3/ep0.c   |  1 -
 drivers/usb/host/xhci-dwc3.c | 95 
 include/dwc3-uboot.h | 19 +
 4 files changed, 113 insertions(+), 91 deletions(-)

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

[U-Boot] [PATCH v3 6/8] configs: evb-rk3328: Enable CONFIG_USB_DWC3

2018-09-25 Thread Jean-Jacques Hiblot
This is now required because the PHY operations used by xhci-dwc3 are part
of the dwc3 core.

Signed-off-by: Jean-Jacques Hiblot 

---

Changes in v3:
- Fix build issue with evb-rk3328 by enabling CONFIG_USB_DWC3. This has
  little impact on the footprint and should not break the runtime as the
  xhci-rockchip driver has its own probe function.
  Nevertheless this was !!! NOT TESTED !!! by lack of hw

Changes in v2: None

 configs/evb-rk3328_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/evb-rk3328_defconfig b/configs/evb-rk3328_defconfig
index 5b3bb8e..f022163 100644
--- a/configs/evb-rk3328_defconfig
+++ b/configs/evb-rk3328_defconfig
@@ -49,6 +49,7 @@ CONFIG_BAUDRATE=150
 CONFIG_DEBUG_UART_SHIFT=2
 CONFIG_SYSRESET=y
 CONFIG_USB=y
+CONFIG_USB_DWC3=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_EHCI_HCD=y
-- 
2.7.4

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


Re: [U-Boot] [PATCH] fw_setenv: avoid writing environment when nothing has changed

2018-09-25 Thread Rasmus Villemoes
On 2018-09-24 09:42, Alex Kiernan wrote:
> On Wed, Sep 5, 2018 at 8:23 PM Rasmus Villemoes
>  wrote:
>>
>> In the case where one deletes an already-non-existing variable, or sets
>> a variable to the value it already has, there is no point in writing the
>> environment back, thus reducing wear on the underlying storage
>> device.
>>
>> Signed-off-by: Rasmus Villemoes 
> 
> If you were running with a redundant env, and you were trying to sync
> both copies, wouldn't you want a non-changing write to happen?

Hm, probably, yes. But I'd still like to avoid it if they are already in
sync, so perhaps I could just add

  if (memcmp(environment.data, redundant->data, ENV_SIZE))
environment.dirty = 1;

after reading in the second copy [using that environment.data at that
point is still ((struct env_image_redundant *)addr0)->data ].

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


[U-Boot] [PATCH v2 1/2] efi_loader: typedef struct efi_object *efi_handle_t

2018-09-25 Thread Heinrich Schuchardt
All our handles point to a struct efi_object. So let's define the
efi_handle_t accordingly. This helps us to discover coding errors much
more easily. This becomes evident by the corrections to the usage of
handles in this patch.

Signed-off-by: Heinrich Schuchardt 
---
v2
no change
---
 cmd/bootefi.c  |  4 ++--
 include/efi.h  |  2 +-
 include/efi_api.h  |  8 
 lib/efi/efi.c  |  2 +-
 lib/efi_loader/efi_boottime.c  | 18 +-
 lib/efi_selftest/efi_selftest_devicepath.c |  2 +-
 6 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index 9c51a2cbd1..05eb168e4a 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -447,7 +447,7 @@ static efi_status_t do_bootefi_exec(void *efi,
}
 #endif
 
-   ret = efi_do_enter(image_handle, &systab, entry);
+   ret = efi_do_enter(&image_handle->parent, &systab, entry);
 
 exit:
/* image has returned, loaded-image obj goes *poof*: */
@@ -561,7 +561,7 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, 
char * const argv[])
/* Transfer environment variable efi_selftest as load options */
set_load_options(loaded_image_info, "efi_selftest");
/* Execute the test */
-   r = efi_selftest(image_handle, &systab);
+   r = efi_selftest(&image_handle->parent, &systab);
efi_restore_gd();
free(loaded_image_info->load_options);
efi_delete_handle(&image_handle->parent);
diff --git a/include/efi.h b/include/efi.h
index b1deb609b4..b5e2c64f38 100644
--- a/include/efi.h
+++ b/include/efi.h
@@ -96,7 +96,7 @@ typedef struct {
 typedef unsigned long efi_status_t;
 typedef u64 efi_physical_addr_t;
 typedef u64 efi_virtual_addr_t;
-typedef void *efi_handle_t;
+typedef struct efi_object *efi_handle_t;
 
 #define EFI_GUID(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) \
{{ (a) & 0xff, ((a) >> 8) & 0xff, ((a) >> 16) & 0xff, \
diff --git a/include/efi_api.h b/include/efi_api.h
index c42df6900a..e6566bb358 100644
--- a/include/efi_api.h
+++ b/include/efi_api.h
@@ -86,10 +86,10 @@ struct efi_boot_services {
efi_status_t (EFIAPI *check_event)(struct efi_event *event);
 #define EFI_NATIVE_INTERFACE   0x
efi_status_t (EFIAPI *install_protocol_interface)(
-   void **handle, const efi_guid_t *protocol,
+   efi_handle_t *handle, const efi_guid_t *protocol,
int protocol_interface_type, void *protocol_interface);
efi_status_t (EFIAPI *reinstall_protocol_interface)(
-   void *handle, const efi_guid_t *protocol,
+   efi_handle_t handle, const efi_guid_t *protocol,
void *old_interface, void *new_interface);
efi_status_t (EFIAPI *uninstall_protocol_interface)(
efi_handle_t handle, const efi_guid_t *protocol,
@@ -165,9 +165,9 @@ struct efi_boot_services {
efi_status_t (EFIAPI *locate_protocol)(const efi_guid_t *protocol,
void *registration, void **protocol_interface);
efi_status_t (EFIAPI *install_multiple_protocol_interfaces)(
-   void **handle, ...);
+   efi_handle_t *handle, ...);
efi_status_t (EFIAPI *uninstall_multiple_protocol_interfaces)(
-   void *handle, ...);
+   efi_handle_t handle, ...);
efi_status_t (EFIAPI *calculate_crc32)(const void *data,
   efi_uintn_t data_size,
   u32 *crc32);
diff --git a/lib/efi/efi.c b/lib/efi/efi.c
index c6639f96cc..2c6a50824f 100644
--- a/lib/efi/efi.c
+++ b/lib/efi/efi.c
@@ -69,7 +69,7 @@ int efi_init(struct efi_priv *priv, const char *banner, 
efi_handle_t image,
efi_putc(priv, ' ');
 
ret = boot->open_protocol(priv->parent_image, &loaded_image_guid,
- (void **)&loaded_image, &priv->parent_image,
+ (void **)&loaded_image, priv->parent_image,
  NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL);
if (ret) {
efi_puts(priv, "Failed to get loaded image protocol\n");
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index 8e3c7456e1..bc6ad84495 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -1019,7 +1019,7 @@ efi_status_t efi_add_protocol(const efi_handle_t handle,
  * Return: status code
  */
 static efi_status_t EFIAPI efi_install_protocol_interface(
-   void **handle, const efi_guid_t *protocol,
+   efi_handle_t *handle, const efi_guid_t *protocol,
int protocol_interface_type, void *protoc

[U-Boot] [PATCH v2 0/2] efi_loader: eliminate handle member

2018-09-25 Thread Heinrich Schuchardt
Up to now we have treated handles as separate objects to EFI objects. This
confusion has lead to hidden bugs like those corrected by the first patch.
By changing the efi_handle_t typedef we can avoid this problem in future.

As handles are pointers to EFI objects there is no need for a handle member
in struct efi_object. This allows to simplify our coding.

v2
replace remaining parent.handle in efi_disk.c
https://travis-ci.org/xypron2/u-boot/builds/432798389 shows only
unrelated errors

Heinrich Schuchardt (2):
  efi_loader: typedef struct efi_object *efi_handle_t
  efi_loader: eliminate handle member

 cmd/bootefi.c  |  4 +-
 include/efi.h  |  2 +-
 include/efi_api.h  |  8 +--
 include/efi_loader.h   | 26 +---
 lib/efi/efi.c  |  2 +-
 lib/efi_loader/efi_boottime.c  | 77 +++---
 lib/efi_loader/efi_console.c   | 20 +++---
 lib/efi_loader/efi_device_path.c   |  2 +-
 lib/efi_loader/efi_disk.c  | 14 ++--
 lib/efi_loader/efi_gop.c   |  2 +-
 lib/efi_loader/efi_net.c   |  6 +-
 lib/efi_selftest/efi_selftest_devicepath.c |  2 +-
 12 files changed, 86 insertions(+), 79 deletions(-)

-- 
2.19.0

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


[U-Boot] [PATCH v2 2/2] efi_loader: eliminate handle member

2018-09-25 Thread Heinrich Schuchardt
A pointer to a struct efi_object is a handle. We do not need any handle
member in this structure. Let's eliminate it.

Signed-off-by: Heinrich Schuchardt 
---
v2
replace remaining parent.handle in efi_disk.c
---
 include/efi_loader.h | 26 +-
 lib/efi_loader/efi_boottime.c| 59 
 lib/efi_loader/efi_console.c | 20 +--
 lib/efi_loader/efi_device_path.c |  2 +-
 lib/efi_loader/efi_disk.c| 14 
 lib/efi_loader/efi_gop.c |  2 +-
 lib/efi_loader/efi_net.c |  6 ++--
 7 files changed, 68 insertions(+), 61 deletions(-)

diff --git a/include/efi_loader.h b/include/efi_loader.h
index 74df070316..6846bb03f3 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -173,20 +173,28 @@ struct efi_handler {
struct list_head open_infos;
 };
 
-/*
- * UEFI has a poor man's OO model where one "object" can be polymorphic and 
have
- * multiple different protocols (classes) attached to it.
+/**
+ * struct efi_object - dereferenced EFI handle
+ *
+ * @link:  pointers to put the handle into a linked list
+ * @protocols: linked list with the protocol interfaces installed on this
+ * handle
+ *
+ * UEFI offers a flexible and expandable object model. The objects in the UEFI
+ * API are devices, drivers, and loaded images. struct efi_object is our 
storage
+ * structure for these objects.
+ *
+ * When including this structure into a larger structure always put it first so
+ * that when deleting a handle the whole encompassing structure can be freed.
  *
- * This struct is the parent struct for all of our actual implementation 
objects
- * that can include it to make themselves an EFI object
+ * A pointer to this structure is referred to as a handle. Typedef efi_handle_t
+ * has been created for such pointers.
  */
 struct efi_object {
/* Every UEFI object is part of a global object list */
struct list_head link;
/* The list of protocols */
struct list_head protocols;
-   /* The object spawner can either use this for data or as identifier */
-   void *handle;
 };
 
 /**
@@ -296,11 +304,11 @@ void efi_runtime_relocate(ulong offset, struct 
efi_mem_desc *map);
 /* Call this to set the current device name */
 void efi_set_bootdev(const char *dev, const char *devnr, const char *path);
 /* Add a new object to the object list. */
-void efi_add_handle(struct efi_object *obj);
+void efi_add_handle(efi_handle_t obj);
 /* Create handle */
 efi_status_t efi_create_handle(efi_handle_t *handle);
 /* Delete handle */
-void efi_delete_handle(struct efi_object *obj);
+void efi_delete_handle(efi_handle_t obj);
 /* Call this to validate a handle and find the EFI object for it */
 struct efi_object *efi_search_obj(const efi_handle_t handle);
 /* Find a protocol on a handle */
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index bc6ad84495..f7d63a3178 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -416,13 +416,12 @@ static efi_status_t EFIAPI efi_free_pool_ext(void *buffer)
  *
  * The protocols list is initialized. The object handle is set.
  */
-void efi_add_handle(struct efi_object *obj)
+void efi_add_handle(efi_handle_t handle)
 {
-   if (!obj)
+   if (!handle)
return;
-   INIT_LIST_HEAD(&obj->protocols);
-   obj->handle = obj;
-   list_add_tail(&obj->link, &efi_obj_list);
+   INIT_LIST_HEAD(&handle->protocols);
+   list_add_tail(&handle->link, &efi_obj_list);
 }
 
 /**
@@ -440,7 +439,7 @@ efi_status_t efi_create_handle(efi_handle_t *handle)
return EFI_OUT_OF_RESOURCES;
 
efi_add_handle(obj);
-   *handle = obj->handle;
+   *handle = obj;
 
return EFI_SUCCESS;
 }
@@ -536,13 +535,13 @@ efi_status_t efi_remove_all_protocols(const efi_handle_t 
handle)
  *
  * @obj: handle to delete
  */
-void efi_delete_handle(struct efi_object *obj)
+void efi_delete_handle(efi_handle_t handle)
 {
-   if (!obj)
+   if (!handle)
return;
-   efi_remove_all_protocols(obj->handle);
-   list_del(&obj->link);
-   free(obj);
+   efi_remove_all_protocols(handle);
+   list_del(&handle->link);
+   free(handle);
 }
 
 /**
@@ -927,7 +926,7 @@ struct efi_object *efi_search_obj(const efi_handle_t handle)
struct efi_object *efiobj;
 
list_for_each_entry(efiobj, &efi_obj_list, link) {
-   if (efiobj->handle == handle)
+   if (efiobj == handle)
return efiobj;
}
 
@@ -1052,7 +1051,7 @@ out:
 
 /**
  * efi_get_drivers() - get all drivers associated to a controller
- * @efiobj:   handle of the controller
+ * @handle:   handle of the controller
  * @protocol: protocol GUID (optional)
  * @number_of_drivers:number of child controllers
  * @driver_handle_buffer: handles of the the drivers
@@ -1061,7 +1060,7 @@ out:

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

2018-09-25 Thread Jens Wiklander
Hi Simon,

On Fri, Sep 14, 2018 at 12:54 PM, Simon Glass  wrote:
> Hi Jens,
>
> On 3 September 2018 at 16:47, Jens Wiklander  
> wrote:
>> With CONFIG_SANDBOX malloc a buffer in get_sector_buf() and return that
>> instead of returning CONFIG_FASTBOOT_BUF_ADDR since there's no such
>> buffer reserved.
>>
>> Signed-off-by: Jens Wiklander 
>> ---
>>  include/avb_verify.h | 9 +
>>  1 file changed, 9 insertions(+)
>>
>> diff --git a/include/avb_verify.h b/include/avb_verify.h
>> index a532a2331aea..7b95409d247e 100644
>> --- a/include/avb_verify.h
>> +++ b/include/avb_verify.h
>> @@ -76,7 +76,16 @@ static inline size_t get_sector_buf_size(void)
>>
>>  static inline void *get_sector_buf(void)
>>  {
>> +#ifdef CONFIG_SANDBOX
>> +   static void *p;
>> +
>> +   if (!p)
>> +   p = avb_malloc_(get_sector_buf_size());
>> +
>> +   return p;
>> +#else
>> return (void *)CONFIG_FASTBOOT_BUF_ADDR;
>
> Can you not define this on sandbox? We don't want sandbox to have
> special-case code if we can avoid it.
>
> If you do define it, you should change the code to:
>
> return map_sysmem(CONFIG_..., size);
>
> which works on sandbox and other archs too.

Thanks, I'll use that.

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


[U-Boot] Recommended location of board device tree source (DTS)

2018-09-25 Thread Ian Kane

Hello, new here and learning...

The project documentation regarding flat device trees (FDT) (
http://git.denx.de/?p=u-boot.git;a=blob;f=doc/README.fdt-control)
recommends device tree source (DTS) be placed in one location that
appears inconsistent with practice.  

The linked README recommends placing DTS files
in board//dts/.dts, a very board specific location, yet
searching the distributed source tree seems to indicate common practice
is to place DTS somewhere in /arch/arm/dts/.dts

The documentation reads: 

   Configuration
   -

   Use:

   #define CONFIG_DEFAULT_DEVICE_TREE  ""

   to set the filename of the device tree source. Then put your device
   treefile into

   board//dts/.dts

   This should include your CPU or SOC's device tree file, placed in
   arch//dts, and then make any adjustments required.

Am I missing something obvious? Looking for a little clarification,
perhaps it's a simple matter of practice moving forward in front of
documentation? 

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


Re: [U-Boot] Call for speakers for the Devicetree Microconference @ the 2018 LPC in Vancouver

2018-09-25 Thread darknighte
+Frank Rowand

On Mon, Sep 24, 2018 at 7:53 AM darknighte  wrote:
>
> The Devicetree Microconference has been accepted into the 2018 Linux Plumbers 
> Conference, which will be held in Vancouver, British Columbia, Canada from 
> Tuesday, November 13 through Thursday, November 15.  If you are interested in 
> speaking, please contact myself, or co-leader Frank Rowand (on CC), to 
> request a slot.
>
> For more details, here is the LPC announcement :
>
> We are pleased to announce the the Devicetree Microconference
> has been accepted into the 2018 Linux Plumbers Conference!
>
> Devicetree provides hardware description for many platforms, such
> as Linux [1], U-Boot [2], BSD [3], and Zephyr [4]. Devicetree
> continues to evolve to become more robust and attempt to provide the
> features desired by the varied users.
>
> Some of the overlay related needs are now being addressed by
> U-boot, but there remain use cases for run time overlay management in
> the Linux kernel. Support for run time overlay management in the Linux
> kernel is slowly moving forward, but significant issues remain [5].
>
> Devicetree verification has been an ongoing project for several years,
> with the most recent in person discussion occurring at the Devicetree
> Workshop [6] at Kernel Summit 2017. Progress continues on mail lists,
> and will be an important topic at the microconference.
>
> Other Devicetree related tools, such as the dtc compiler and libfdt [7]
> continue to see active development.
>
> Additional possible issues to be discussed may include potential
> changes to the Flattened Device Tree (FDT) format, reducing the
> Devicetree memory and storage size in the Linux kernel, creating new
> architecture to provide solutions to current problems, updating the
> Devicetree Specification, and using devicetrees in constrained contexts.
>
> LPC [8] will be held in Vancouver, British Columbia, Canada
> from Tuesday, November 13 through Thursday, November 15.
>
> [1] https://elinux.org/Device_Tree_Reference
> [2] https://github.com/lentinj/u-boot/blob/master/doc/README.fdt-control
> [3] https://wiki.freebsd.org/FlattenedDeviceTree
> [4] http://docs.zephyrproject.org/devices/dts/device_tree.html
> [5] https://elinux.org/Frank%27s_Evolving_Overlay_Thoughts
> [6] 
> https://elinux.org/Device_tree_future#Kernel_Summit_2017.2C_Devicetree_Workshop
> [7] https://elinux.org/Device_Tree_Reference#dtc_.28upstream_project.29
> [8] https://linuxplumbersconf.org/
>
>
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] net: phy: add TSE PCS support to dwmac-socfpga

2018-09-25 Thread Ooi, Joyce
This adds support for TSE PCS that uses SGMII adapter when the
phy-mode in device tree is set to sgmii.

Signed-off-by: Ooi, Joyce 
---
 drivers/net/Makefile   |   3 +-
 drivers/net/designware.c   |   5 ++
 drivers/net/designware.h   |   1 +
 drivers/net/dwmac_socfpga.c| 121 +
 drivers/net/phy/altr_tse_pcs.c | 197 +
 drivers/net/phy/altr_tse_pcs.h |  59 
 6 files changed, 385 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/phy/altr_tse_pcs.c
 create mode 100644 drivers/net/phy/altr_tse_pcs.h

diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index 48a2878..c2333b5 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -14,7 +14,7 @@ obj-$(CONFIG_CALXEDA_XGMAC) += calxedaxgmac.o
 obj-$(CONFIG_CS8900) += cs8900.o
 obj-$(CONFIG_TULIP) += dc2114x.o
 obj-$(CONFIG_ETH_DESIGNWARE) += designware.o
-obj-$(CONFIG_ETH_DESIGNWARE_SOCFPGA) += dwmac_socfpga.o
+obj-$(CONFIG_ETH_DESIGNWARE_SOCFPGA) += dwmac-socfpga.o
 obj-$(CONFIG_DRIVER_DM9000) += dm9000x.o
 obj-$(CONFIG_DNET) += dnet.o
 obj-$(CONFIG_E1000) += e1000.o
@@ -73,3 +73,4 @@ obj-$(CONFIG_PIC32_ETH) += pic32_mdio.o pic32_eth.o
 obj-$(CONFIG_DWC_ETH_QOS) += dwc_eth_qos.o
 obj-$(CONFIG_FSL_PFE) += pfe_eth/
 obj-$(CONFIG_SNI_AVE) += sni_ave.o
+dwmac-socfpga-objs := phy/altr_tse_pcs.o dwmac_socfpga.o
diff --git a/drivers/net/designware.c b/drivers/net/designware.c
index 19db0a8..666cf41 100644
--- a/drivers/net/designware.c
+++ b/drivers/net/designware.c
@@ -235,6 +235,8 @@ static int dw_adjust_link(struct dw_eth_dev *priv, struct 
eth_mac_regs *mac_p,
  struct phy_device *phydev)
 {
u32 conf = readl(&mac_p->conf) | FRAMEBURSTENABLE | DISABLERXOWN;
+   struct udevice *dev = priv->phydev->dev;
+   struct dw_eth_pdata *dw_pdata = dev_get_platdata(dev);
 
if (!phydev->link) {
printf("%s: No link.\n", phydev->dev->name);
@@ -254,6 +256,9 @@ static int dw_adjust_link(struct dw_eth_dev *priv, struct 
eth_mac_regs *mac_p,
 
writel(conf, &mac_p->conf);
 
+   if (dw_pdata->pcs_adjust_link)
+   dw_pdata->pcs_adjust_link(dev, phydev);
+
printf("Speed: %d, %s duplex%s\n", phydev->speed,
   (phydev->duplex) ? "full" : "half",
   (phydev->port == PORT_FIBRE) ? ", fiber mode" : "");
diff --git a/drivers/net/designware.h b/drivers/net/designware.h
index dea12b7..3a5a93f 100644
--- a/drivers/net/designware.h
+++ b/drivers/net/designware.h
@@ -255,6 +255,7 @@ extern const struct eth_ops designware_eth_ops;
 struct dw_eth_pdata {
struct eth_pdata eth_pdata;
u32 reset_delays[3];
+   void (*pcs_adjust_link)(struct udevice *dev, struct phy_device *phydev);
 };
 
 int designware_eth_init(struct dw_eth_dev *priv, u8 *enetaddr);
diff --git a/drivers/net/dwmac_socfpga.c b/drivers/net/dwmac_socfpga.c
index 08fc967..a096d29 100644
--- a/drivers/net/dwmac_socfpga.c
+++ b/drivers/net/dwmac_socfpga.c
@@ -9,12 +9,16 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include "designware.h"
+#include "phy/altr_tse_pcs.h"
 
+#include 
+#include 
 #include 
 
 enum dwmac_type {
@@ -27,8 +31,122 @@ struct dwmac_socfpga_platdata {
struct dw_eth_pdata dw_eth_pdata;
enum dwmac_type type;
void*phy_intf;
+   struct tse_pcs  pcs;
 };
 
+static void socfpga_tse_pcs_adjust_link(struct udevice *dev,
+   struct phy_device *phydev)
+{
+   struct dwmac_socfpga_platdata *pdata = dev_get_platdata(dev);
+   phys_addr_t tse_pcs_base = pdata->pcs.tse_pcs_base;
+   phys_addr_t sgmii_adapter_base = pdata->pcs.sgmii_adapter_base;
+
+   if ((tse_pcs_base) && (sgmii_adapter_base))
+   writew(SGMII_ADAPTER_DISABLE,
+  sgmii_adapter_base + SGMII_ADAPTER_CTRL_REG);
+
+   if ((tse_pcs_base) && (sgmii_adapter_base))
+   tse_pcs_fix_mac_speed(&pdata->pcs, phydev, phydev->speed);
+}
+
+static int socfpga_dw_tse_pcs_init(struct udevice *dev)
+{
+   struct dwmac_socfpga_platdata *pdata = dev_get_platdata(dev);
+   struct dw_eth_pdata *dw_pdata = &pdata->dw_eth_pdata;
+   struct eth_pdata *eth_pdata = &pdata->dw_eth_pdata.eth_pdata;
+   phys_addr_t tse_pcs_base = pdata->pcs.tse_pcs_base;
+   phys_addr_t sgmii_adapter_base = pdata->pcs.sgmii_adapter_base;
+   const fdt32_t *reg;
+   int ret = 0;
+   int parent, index, na, ns, offset, len;
+
+   offset = fdtdec_lookup_phandle(gd->fdt_blob, dev_of_offset(dev),
+  "altr,gmii-to-sgmii-converter");
+   if (offset > 0) {
+   /* check FPGA status */
+   ret = mbox_get_fpga_config_status(MBOX_CONFIG_STATUS);
+   if (ret) {
+   debug("%s: FPGA status returns %d\n", __func__, ret);
+   

[U-Boot] [PATCH] arm: socfpga: stratix10: add sgmii in phymode setup

2018-09-25 Thread Ooi, Joyce
Additional sgmii phymode is added in socfpga_phymode_setup() along with
a minor fix for maximum number of GMACs.

Signed-off-by: Ooi, Joyce 
---
 arch/arm/mach-socfpga/misc_s10.c |5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-socfpga/misc_s10.c b/arch/arm/mach-socfpga/misc_s10.c
index 918baac..e599362 100644
--- a/arch/arm/mach-socfpga/misc_s10.c
+++ b/arch/arm/mach-socfpga/misc_s10.c
@@ -36,7 +36,8 @@ static u32 socfpga_phymode_setup(u32 gmac_index, const char 
*phymode)
if (!phymode)
return -EINVAL;
 
-   if (!strcmp(phymode, "mii") || !strcmp(phymode, "gmii"))
+   if (!strcmp(phymode, "mii") || !strcmp(phymode, "gmii") ||
+   !strcmp(phymode, "sgmii"))
modereg = SYSMGR_EMACGRP_CTRL_PHYSEL_ENUM_GMII_MII;
else if (!strcmp(phymode, "rgmii"))
modereg = SYSMGR_EMACGRP_CTRL_PHYSEL_ENUM_RGMII;
@@ -58,7 +59,7 @@ static int socfpga_set_phymode(void)
struct fdtdec_phandle_args args;
const char *phy_mode;
u32 gmac_index;
-   int nodes[2];   /* Max. 3 GMACs */
+   int nodes[3];   /* Max. 3 GMACs */
int ret, count;
int i, node;
 
-- 
1.7.1

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


[U-Boot] [PATCH RESEND] u-boot: fixup the iommu-map property of fsl-mc node

2018-09-25 Thread Nipun Gupta
The iommu-map property in the fsl-mc node is updated by
valid stream-ids by u-boot. This patch is to fixup this
property for LS208x and LS1088.

Signed-off-by: Nipun Gupta 
---
This patch fixes iommu-map property added for fsl-mc in kernel patch
series: https://patchwork.kernel.org/patch/10594185/
Kernel patch series is accepted and would be available in kernel 4.20.

This patch is backward compatible and have only a debug log if the property
is not found in kernel.

 .../asm/arch-fsl-layerscape/stream_id_lsch3.h  |  3 ++
 board/freescale/ls1088a/ls1088a.c  |  2 ++
 board/freescale/ls2080a/ls2080a.c  |  2 ++
 board/freescale/ls2080aqds/ls2080aqds.c|  2 ++
 board/freescale/ls2080ardb/ls2080ardb.c|  2 ++
 drivers/net/fsl-mc/mc.c| 34 ++
 include/fsl-mc/fsl_mc.h|  1 +
 7 files changed, 46 insertions(+)

diff --git a/arch/arm/include/asm/arch-fsl-layerscape/stream_id_lsch3.h 
b/arch/arm/include/asm/arch-fsl-layerscape/stream_id_lsch3.h
index afea9b8..8d002da 100644
--- a/arch/arm/include/asm/arch-fsl-layerscape/stream_id_lsch3.h
+++ b/arch/arm/include/asm/arch-fsl-layerscape/stream_id_lsch3.h
@@ -35,6 +35,9 @@
  *  -DPAA2
  * -u-boot will allocate a range of stream IDs to be used by the Management
  *  Complex for containers and will set these values in the MC DPC image.
+ * -u-boot will fixup the iommu-map property in the fsl-mc node in the
+ *  device tree (see 
Documentation/devicetree/bindings/misc/fsl,qoriq-mc.txt
+ *  for more info on the msi-map definition)
  * -the MC is responsible for allocating and setting up 'isolation context
  *  IDs (ICIDs) based on the allocated stream IDs for all DPAA2 devices.
  *
diff --git a/board/freescale/ls1088a/ls1088a.c 
b/board/freescale/ls1088a/ls1088a.c
index a0dab6f..517a8ce 100644
--- a/board/freescale/ls1088a/ls1088a.c
+++ b/board/freescale/ls1088a/ls1088a.c
@@ -575,6 +575,8 @@ int ft_board_setup(void *blob, bd_t *bd)
 
fdt_fixup_memory_banks(blob, base, size, CONFIG_NR_DRAM_BANKS);
 
+   fdt_fsl_mc_fixup_iommu_map_entry(blob);
+
fsl_fdt_fixup_flash(blob);
 
 #ifdef CONFIG_FSL_MC_ENET
diff --git a/board/freescale/ls2080a/ls2080a.c 
b/board/freescale/ls2080a/ls2080a.c
index 75014fd..698ae1f 100644
--- a/board/freescale/ls2080a/ls2080a.c
+++ b/board/freescale/ls2080a/ls2080a.c
@@ -127,6 +127,8 @@ int ft_board_setup(void *blob, bd_t *bd)
 
fdt_fixup_memory_banks(blob, base, size, 2);
 
+   fdt_fsl_mc_fixup_iommu_map_entry(blob);
+
 #if defined(CONFIG_FSL_MC_ENET) && !defined(CONFIG_SPL_BUILD)
fdt_fixup_board_enet(blob);
 #endif
diff --git a/board/freescale/ls2080aqds/ls2080aqds.c 
b/board/freescale/ls2080aqds/ls2080aqds.c
index c811e99..d336ef8 100644
--- a/board/freescale/ls2080aqds/ls2080aqds.c
+++ b/board/freescale/ls2080aqds/ls2080aqds.c
@@ -332,6 +332,8 @@ int ft_board_setup(void *blob, bd_t *bd)
 
fdt_fixup_memory_banks(blob, base, size, 2);
 
+   fdt_fsl_mc_fixup_iommu_map_entry(blob);
+
fsl_fdt_fixup_dr_usb(blob, bd);
 
 #if defined(CONFIG_FSL_MC_ENET) && !defined(CONFIG_SPL_BUILD)
diff --git a/board/freescale/ls2080ardb/ls2080ardb.c 
b/board/freescale/ls2080ardb/ls2080ardb.c
index 46b18cf..cf91bc3 100644
--- a/board/freescale/ls2080ardb/ls2080ardb.c
+++ b/board/freescale/ls2080ardb/ls2080ardb.c
@@ -394,6 +394,8 @@ int ft_board_setup(void *blob, bd_t *bd)
 
fdt_fixup_memory_banks(blob, base, size, 2);
 
+   fdt_fsl_mc_fixup_iommu_map_entry(blob);
+
fsl_fdt_fixup_dr_usb(blob, bd);
 
fsl_fdt_fixup_flash(blob);
diff --git a/drivers/net/fsl-mc/mc.c b/drivers/net/fsl-mc/mc.c
index 940025a..cb2fbe9 100644
--- a/drivers/net/fsl-mc/mc.c
+++ b/drivers/net/fsl-mc/mc.c
@@ -278,6 +278,40 @@ static int mc_fixup_dpl_mac_addr(void *blob, int dpmac_id,
 MC_FIXUP_DPL);
 }
 
+void fdt_fsl_mc_fixup_iommu_map_entry(void *blob)
+{
+   u32 *prop;
+   u32 iommu_map[4];
+   int offset;
+   int lenp;
+
+   /* find fsl-mc node */
+   offset = fdt_path_offset(blob, "/soc/fsl-mc");
+   if (offset < 0)
+   offset = fdt_path_offset(blob, "/fsl-mc");
+   if (offset < 0) {
+   printf("%s: fsl-mc: ERR: fsl-mc node not found in DT, err %d\n",
+  __func__, offset);
+   return;
+   }
+
+   prop = fdt_getprop_w(blob, offset, "iommu-map", &lenp);
+   if (!prop) {
+   debug("%s: fsl-mc: ERR: missing iommu-map in fsl-mc bus node\n",
+ __func__);
+   return;
+   }
+
+   iommu_map[0] = cpu_to_fdt32(FSL_DPAA2_STREAM_ID_START);
+   iommu_map[1] = *++prop;
+   iommu_map[2] = cpu_to_fdt32(FSL_DPAA2_STREAM_ID_START);
+   iommu_map[3] = cpu_to_fdt32(FSL_DPAA2_STREAM_ID_END -
+   FSL_DPAA2_STREAM_ID_START + 1);
+
+   fdt_setprop_inplace(blob, offset, "

[U-Boot] SYS_CONFIG_NAME resolved with quotation marks

2018-09-25 Thread König , Florian
Hi,
i try to integrate a new board into u-boot.  I created a 
configs/myboard_defconfig file with  CONFIG_TARGET_MYBOARD=y inside. Then I 
extended arch/arm/mach-imx/mx6/Kconfig with the following lines:

config TARGET_MYBOARD
bool "myboard"

source "board/freescale/myboard/Kconfig"



Then I created board/freescale/myboard/Kconfig with following content:

if TARGET_MYBOARD

config SYS_BOARD
default "myboard"

config SYS_VENDOR
default "freescale"

config SYS_CONFIG_NAME
default "myboard"
endif




When I now try to build it, it fails and returns this line where the 
SYS_CONFIG_NAME got quotation marks, but e.g. in CONFIG_BOARDDIR the values got 
no quotation marks?

echo \#define CONFIG_BOARDDIR board/freescale/myboard; echo \#include 
\; echo \#include \; echo \#include 
\;



This code Is build by scripst/Makefile.autoconf by line 106-109:

echo \#define CONFIG_BOARDDIR board/$(if $(VENDOR),$(VENDOR)/)$(BOARD);\
echo \#include \;   
   \
echo \#include \;  
  \
echo \#include \; 
\


SYS_BOARD is accessible with $(BOARD)
SYS_VENDOR is accessible with $(VENDOR)
But SYS_CONFIG_NAME is accessible with $(CONFIG_SYS_CONFIG_NAME) and then 
returns It with quotation marks.


I look at the other board configurations and don't get it, but what do I wrong 
? thx for help.
florian
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2 1/2] efi_loader: typedef struct efi_object *efi_handle_t

2018-09-25 Thread Mark Kettenis
> From: Heinrich Schuchardt 
> Date: Tue, 25 Sep 2018 12:19:17 +0200
> 
> All our handles point to a struct efi_object. So let's define the
> efi_handle_t accordingly. This helps us to discover coding errors much
> more easily. This becomes evident by the corrections to the usage of
> handles in this patch.
> 
> Signed-off-by: Heinrich Schuchardt 
> ---
> v2
>   no change
> ---
>  cmd/bootefi.c  |  4 ++--
>  include/efi.h  |  2 +-
>  include/efi_api.h  |  8 
>  lib/efi/efi.c  |  2 +-
>  lib/efi_loader/efi_boottime.c  | 18 +-
>  lib/efi_selftest/efi_selftest_devicepath.c |  2 +-
>  6 files changed, 18 insertions(+), 18 deletions(-)
> 
> diff --git a/cmd/bootefi.c b/cmd/bootefi.c
> index 9c51a2cbd1..05eb168e4a 100644
> --- a/cmd/bootefi.c
> +++ b/cmd/bootefi.c
> @@ -447,7 +447,7 @@ static efi_status_t do_bootefi_exec(void *efi,
>   }
>  #endif
>  
> - ret = efi_do_enter(image_handle, &systab, entry);
> + ret = efi_do_enter(&image_handle->parent, &systab, entry);

This bit makes absolutely no sense to me :(.  What about the other
efi_do_enter() calls?  And why is the variable called image_handle if
it isn't a handle?

>  
>  exit:
>   /* image has returned, loaded-image obj goes *poof*: */
> @@ -561,7 +561,7 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int 
> argc, char * const argv[])
>   /* Transfer environment variable efi_selftest as load options */
>   set_load_options(loaded_image_info, "efi_selftest");
>   /* Execute the test */
> - r = efi_selftest(image_handle, &systab);
> + r = efi_selftest(&image_handle->parent, &systab);
>   efi_restore_gd();
>   free(loaded_image_info->load_options);
>   efi_delete_handle(&image_handle->parent);
> diff --git a/include/efi.h b/include/efi.h
> index b1deb609b4..b5e2c64f38 100644
> --- a/include/efi.h
> +++ b/include/efi.h
> @@ -96,7 +96,7 @@ typedef struct {
>  typedef unsigned long efi_status_t;
>  typedef u64 efi_physical_addr_t;
>  typedef u64 efi_virtual_addr_t;
> -typedef void *efi_handle_t;
> +typedef struct efi_object *efi_handle_t;
>  
>  #define EFI_GUID(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) \
>   {{ (a) & 0xff, ((a) >> 8) & 0xff, ((a) >> 16) & 0xff, \
> diff --git a/include/efi_api.h b/include/efi_api.h
> index c42df6900a..e6566bb358 100644
> --- a/include/efi_api.h
> +++ b/include/efi_api.h
> @@ -86,10 +86,10 @@ struct efi_boot_services {
>   efi_status_t (EFIAPI *check_event)(struct efi_event *event);
>  #define EFI_NATIVE_INTERFACE 0x
>   efi_status_t (EFIAPI *install_protocol_interface)(
> - void **handle, const efi_guid_t *protocol,
> + efi_handle_t *handle, const efi_guid_t *protocol,
>   int protocol_interface_type, void *protocol_interface);
>   efi_status_t (EFIAPI *reinstall_protocol_interface)(
> - void *handle, const efi_guid_t *protocol,
> + efi_handle_t handle, const efi_guid_t *protocol,
>   void *old_interface, void *new_interface);
>   efi_status_t (EFIAPI *uninstall_protocol_interface)(
>   efi_handle_t handle, const efi_guid_t *protocol,
> @@ -165,9 +165,9 @@ struct efi_boot_services {
>   efi_status_t (EFIAPI *locate_protocol)(const efi_guid_t *protocol,
>   void *registration, void **protocol_interface);
>   efi_status_t (EFIAPI *install_multiple_protocol_interfaces)(
> - void **handle, ...);
> + efi_handle_t *handle, ...);
>   efi_status_t (EFIAPI *uninstall_multiple_protocol_interfaces)(
> - void *handle, ...);
> + efi_handle_t handle, ...);
>   efi_status_t (EFIAPI *calculate_crc32)(const void *data,
>  efi_uintn_t data_size,
>  u32 *crc32);
> diff --git a/lib/efi/efi.c b/lib/efi/efi.c
> index c6639f96cc..2c6a50824f 100644
> --- a/lib/efi/efi.c
> +++ b/lib/efi/efi.c
> @@ -69,7 +69,7 @@ int efi_init(struct efi_priv *priv, const char *banner, 
> efi_handle_t image,
>   efi_putc(priv, ' ');
>  
>   ret = boot->open_protocol(priv->parent_image, &loaded_image_guid,
> -   (void **)&loaded_image, &priv->parent_image,
> +   (void **)&loaded_image, priv->parent_image,
> NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL);
>   if (ret) {
>   efi_puts(priv, "Failed to get loaded image protocol\n");
> diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
> index 8e3c7456e1..bc6ad84495 100644
> --- a/lib/efi_loader/efi_boottime.c
> +++ b/lib/efi_loader/efi_boottime.c
> @@ -1019,7 +1019,7 @@ efi_st

Re: [U-Boot] [PATCH v3 0/8] Improvements for the dwc3_generic driver

2018-09-25 Thread Lukasz Majewski
Dear All,

> This series aims at bringing improvements to the dwc3_generic driver
> so that it can be used by most of the platforms using the dwc3
> controller.
> 
> I tested this on with DRA7 and AM57x platforms for both Peripheral
> and Host operations. The code to enable DM USB host & dev support for
> those platforms will be submitted in a separate series.
> 
> Michal Simek has tested this series:
> " I have tested it on zcu100 with usb stick, usb to ethernet
> converter and also dfu.
> Tested-by: Michal Simek "
> 
> Enhancements:
> - use separate Kconfig option for DM USB Periphal and DM USB Host.
> This allow platforms to keep their non-DM USB peripheral code and use
> the DM USB host.
> - fixes the bind/probe confusion in dwc3_generic. The probe is done
> when the USB device is first needed.
> - handles PHYs when in the peripheral mode. The code to handle the
> PHYs is shared with the host side
> - handles clock and reset
> - bind host controller to the more generic driver 'xhci-dwc3'
> 
> 
> Changes in v3:
> - fixes bug dwc3_setup_phy(): the phy arrays wasn't returned. This was
>   visible only when the device is removed.
> - Stub the DWC3 PHY operations if CONFIG_IS_ENABLED(PHY) is false.
>   This fixes all build issues but one (evb-rk3328).
> - Fix build issue with evb-rk3328 by enabling CONFIG_USB_DWC3. This
> has little impact on the footprint and should not break the runtime
> as the xhci-rockchip driver has its own probe function.
>   Nevertheless this was !!! NOT TESTED !!! by lack of hw

Can somebody test this patch set on rk3328 and provide Tested-by tag?

> 
> Changes in v2:
> - Updated commit log
> - Fixed typo in thordown.c
> - select DM_USB_DEV by default for zynqmp platforms
> 
> Jean-Jacques Hiblot (8):
>   usb: gadget: Do not call board_usb_xxx() directly in USB gadget
> drivers
>   usb: introduce a separate config option for DM USB device
>   usb: udc: implement DM versions of
> usb_gadget_initialize()/_release()/_handle_interrupt()
>   dwc3_generic: do not probe the USB device driver when it's bound
>   dwc3: move phy operation to core.c
>   configs: evb-rk3328: Enable CONFIG_USB_DWC3
>   dwc3-generic: Handle the PHYs, the clocks and the reset lines
>   dwc3-generic: Add select_dr_mode operation
> 
>  arch/arm/Kconfig  |   2 +
>  cmd/fastboot.c|   4 +-
>  cmd/rockusb.c |   4 +-
>  cmd/thordown.c|   4 +-
>  cmd/usb_gadget_sdp.c  |   4 +-
>  cmd/usb_mass_storage.c|   4 +-
>  common/dfu.c  |   6 +-
>  configs/evb-rk3328_defconfig  |   1 +
>  drivers/usb/Kconfig   |   6 ++
>  drivers/usb/dwc3/Kconfig  |   7 +-
>  drivers/usb/dwc3/core.c   |  89 +++-
>  drivers/usb/dwc3/dwc3-generic.c   | 207
> +-
> drivers/usb/dwc3/ep0.c|   1 -
> drivers/usb/gadget/ether.c|  38 +--
> drivers/usb/gadget/udc/udc-core.c |  44 +++-
> drivers/usb/host/xhci-dwc3.c  |  95 ++---
> include/dwc3-uboot.h  |  19 
> include/linux/usb/gadget.h|  18  18 files changed, 367
> insertions(+), 186 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


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


Re: [U-Boot] [PATCH v2 1/2] efi_loader: typedef struct efi_object *efi_handle_t

2018-09-25 Thread Heinrich Schuchardt


On 09/25/2018 01:15 PM, Mark Kettenis wrote:
>> From: Heinrich Schuchardt 
>> Date: Tue, 25 Sep 2018 12:19:17 +0200
>>
>> All our handles point to a struct efi_object. So let's define the
>> efi_handle_t accordingly. This helps us to discover coding errors much
>> more easily. This becomes evident by the corrections to the usage of
>> handles in this patch.
>>
>> Signed-off-by: Heinrich Schuchardt 
>> ---
>> v2
>>  no change
>> ---
>>  cmd/bootefi.c  |  4 ++--
>>  include/efi.h  |  2 +-
>>  include/efi_api.h  |  8 
>>  lib/efi/efi.c  |  2 +-
>>  lib/efi_loader/efi_boottime.c  | 18 +-
>>  lib/efi_selftest/efi_selftest_devicepath.c |  2 +-
>>  6 files changed, 18 insertions(+), 18 deletions(-)
>>
>> diff --git a/cmd/bootefi.c b/cmd/bootefi.c
>> index 9c51a2cbd1..05eb168e4a 100644
>> --- a/cmd/bootefi.c
>> +++ b/cmd/bootefi.c
>> @@ -447,7 +447,7 @@ static efi_status_t do_bootefi_exec(void *efi,
>>  }
>>  #endif
>>  
>> -ret = efi_do_enter(image_handle, &systab, entry);
>> +ret = efi_do_enter(&image_handle->parent, &systab, entry);
> This bit makes absolutely no sense to me :(.  What about the other
> efi_do_enter() calls?  And why is the variable called image_handle if
> it isn't a handle?
> 
>>  

Thanks for pointing to this misnomer. We should rename image_handle to
image_obj in this function.

And we should be consistent about how we pass the address.

Regards

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


[U-Boot] [PATCH 0/6] Add support for VCore III SoCs found in Microsemi switches

2018-09-25 Thread Gregory CLEMENT
Hello,

This series add the support of 2 SoCs: Ocelot and Luton from
Microsemi. Both of them belongs to the same family Vcore III.

We found them on various advanced switches product.

The support for Ocelot already have been submit to Linux, but not yet
the Luton support.

Besides this series 3 others patches are needed but they are driver
related:
DW SPI: Allow to overload the management of the external CS
gpio: mscc-bitbang-spi: Add a simple gpio driver for bitbgang spi
pinctrl: mscc: Add gpio and pinctrl driver for MSCC MIPS SoCs (VcoreIII based)

They will be submitted separately.

Thanks,

Gregory


Gregory CLEMENT (6):
  MIPS: move create_tlb() in an proper header: mipsregs.h
  MSCC: add support for VCoreIII SoCs
  MSCC: add board support for the VCoreIII based evaluation boards
  MSCC: add device tree for Ocelot and Luton (boards and SoCs)
  MSCC: add configuration for Ocelot and Luton based boards
  MIPS: bootm: Add support for Vcore III linux kernel

 arch/mips/Kconfig |   6 +
 arch/mips/Makefile|   1 +
 arch/mips/cpu/cpu.c   |  10 -
 arch/mips/dts/luton_pcb091.dts|  36 +
 arch/mips/dts/mscc,luton.dtsi |  87 ++
 arch/mips/dts/mscc,ocelot.dtsi| 132 +++
 arch/mips/dts/mscc,ocelot_pcb.dtsi|  37 +
 arch/mips/dts/ocelot_pcb120.dts   |  12 +
 arch/mips/dts/ocelot_pcb123.dts   |  12 +
 arch/mips/include/asm/mipsregs.h  |  11 +
 arch/mips/lib/bootm.c |  62 +-
 arch/mips/mach-mscc/Kconfig   | 101 ++
 arch/mips/mach-mscc/Makefile  |   6 +
 arch/mips/mach-mscc/cpu.c |  72 ++
 arch/mips/mach-mscc/dram.c|  62 ++
 arch/mips/mach-mscc/include/ioremap.h |  49 +
 arch/mips/mach-mscc/include/mach/cache.h  |  36 +
 arch/mips/mach-mscc/include/mach/common.h |  31 +
 arch/mips/mach-mscc/include/mach/ddr.h| 753 +++
 .../mips/mach-mscc/include/mach/luton/luton.h |  37 +
 .../include/mach/luton/luton_devcpu_gcb.h |  16 +
 .../include/mach/luton/luton_icpu_cfg-ref.h   | 884 ++
 .../include/mach/luton/luton_icpu_cfg.h   | 247 +
 .../mach-mscc/include/mach/ocelot/ocelot.h|  35 +
 .../include/mach/ocelot/ocelot_devcpu_gcb.h   | 353 +++
 .../include/mach/ocelot/ocelot_icpu_cfg.h | 884 ++
 arch/mips/mach-mscc/include/mach/tlb.h|  65 ++
 arch/mips/mach-mscc/lowlevel_init.S   |  29 +
 arch/mips/mach-mscc/lowlevel_init_luton.S |  63 ++
 arch/mips/mach-mscc/reset.c   |  37 +
 board/mscc/common/board.c |  29 +
 board/mscc/luton/Kconfig  |  14 +
 board/mscc/luton/Makefile |   4 +
 board/mscc/luton/luton.c  |  14 +
 board/mscc/ocelot/Kconfig |  24 +
 board/mscc/ocelot/Makefile|   5 +
 board/mscc/ocelot/ocelot.c|  38 +
 configs/mscc_luton_defconfig  |  66 ++
 configs/mscc_ocelot_defconfig |  57 ++
 configs/mscc_ocelot_pcb120_defconfig  |  56 ++
 include/configs/vcoreiii.h|  72 ++
 41 files changed, 4515 insertions(+), 30 deletions(-)
 create mode 100644 arch/mips/dts/luton_pcb091.dts
 create mode 100644 arch/mips/dts/mscc,luton.dtsi
 create mode 100644 arch/mips/dts/mscc,ocelot.dtsi
 create mode 100644 arch/mips/dts/mscc,ocelot_pcb.dtsi
 create mode 100644 arch/mips/dts/ocelot_pcb120.dts
 create mode 100644 arch/mips/dts/ocelot_pcb123.dts
 create mode 100644 arch/mips/mach-mscc/Kconfig
 create mode 100644 arch/mips/mach-mscc/Makefile
 create mode 100644 arch/mips/mach-mscc/cpu.c
 create mode 100644 arch/mips/mach-mscc/dram.c
 create mode 100644 arch/mips/mach-mscc/include/ioremap.h
 create mode 100644 arch/mips/mach-mscc/include/mach/cache.h
 create mode 100644 arch/mips/mach-mscc/include/mach/common.h
 create mode 100644 arch/mips/mach-mscc/include/mach/ddr.h
 create mode 100644 arch/mips/mach-mscc/include/mach/luton/luton.h
 create mode 100644 arch/mips/mach-mscc/include/mach/luton/luton_devcpu_gcb.h
 create mode 100644 arch/mips/mach-mscc/include/mach/luton/luton_icpu_cfg-ref.h
 create mode 100644 arch/mips/mach-mscc/include/mach/luton/luton_icpu_cfg.h
 create mode 100644 arch/mips/mach-mscc/include/mach/ocelot/ocelot.h
 create mode 100644 arch/mips/mach-mscc/include/mach/ocelot/ocelot_devcpu_gcb.h
 create mode 100644 arch/mips/mach-mscc/include/mach/ocelot/ocelot_icpu_cfg.h
 create mode 100644 arch/mips/mach-mscc/include/mach/tlb.h
 create mode 100644 arch/mips/mach-mscc/lowlevel_init.S
 create mode 100644 arch/mips/mach-mscc/lowlevel_init_luton.S
 create mode 100644 arch/mips/mach-mscc/reset.c
 create mode 100644 board/mscc/common/board.c
 create mode 100644 board/mscc/luton/Kconfig
 create mode 100644 board/mscc/luton/Makefile
 create mode

[U-Boot] [PATCH 1/6] MIPS: move create_tlb() in an proper header: mipsregs.h

2018-09-25 Thread Gregory CLEMENT
Export create_tlb() as an inline function in mipsregs.h. It allows to
remove the declaration of the function from the board files.

Then it will allow also to use this function very early in the boot when
the stack is not usable.

Signed-off-by: Gregory CLEMENT 
---
 arch/mips/cpu/cpu.c  | 10 --
 arch/mips/include/asm/mipsregs.h | 11 +++
 2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/arch/mips/cpu/cpu.c b/arch/mips/cpu/cpu.c
index 5c56ab0289..a403ff729b 100644
--- a/arch/mips/cpu/cpu.c
+++ b/arch/mips/cpu/cpu.c
@@ -28,16 +28,6 @@ int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * 
const argv[])
 }
 #endif
 
-void write_one_tlb(int index, u32 pagemask, u32 hi, u32 low0, u32 low1)
-{
-   write_c0_entrylo0(low0);
-   write_c0_pagemask(pagemask);
-   write_c0_entrylo1(low1);
-   write_c0_entryhi(hi);
-   write_c0_index(index);
-   tlb_write_indexed();
-}
-
 int arch_cpu_init(void)
 {
mips_cache_probe();
diff --git a/arch/mips/include/asm/mipsregs.h b/arch/mips/include/asm/mipsregs.h
index 48fa1f1f7f..930562ebb2 100644
--- a/arch/mips/include/asm/mipsregs.h
+++ b/arch/mips/include/asm/mipsregs.h
@@ -2005,6 +2005,17 @@ static inline unsigned int get_ebase_cpunum(void)
return read_c0_ebase() & 0x3ff;
 }
 
+static inline void write_one_tlb(int index, u32 pagemask, u32 hi, u32 low0,
+u32 low1)
+{
+   write_c0_entrylo0(low0);
+   write_c0_pagemask(pagemask);
+   write_c0_entrylo1(low1);
+   write_c0_entryhi(hi);
+   write_c0_index(index);
+   tlb_write_indexed();
+}
+
 #endif /* !__ASSEMBLY__ */
 
 #endif /* _ASM_MIPSREGS_H */
-- 
2.19.0

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


[U-Boot] [PATCH 4/6] MSCC: add device tree for Ocelot and Luton (boards and SoCs)

2018-09-25 Thread Gregory CLEMENT
Adding device tree for Ocelot SoC (extract from Linux) and the 2
evaluation boards using this SoC: PCB120 and PCB132.

Adding device tree for Luton SoC (not yet in Linux) and the evaluation
boards using this SoC: PCB91.

Signed-off-by: Gregory CLEMENT 
---
 arch/mips/dts/luton_pcb091.dts |  36 
 arch/mips/dts/mscc,luton.dtsi  |  87 +++
 arch/mips/dts/mscc,ocelot.dtsi | 132 +
 arch/mips/dts/mscc,ocelot_pcb.dtsi |  37 
 arch/mips/dts/ocelot_pcb120.dts|  12 +++
 arch/mips/dts/ocelot_pcb123.dts|  12 +++
 6 files changed, 316 insertions(+)
 create mode 100644 arch/mips/dts/luton_pcb091.dts
 create mode 100644 arch/mips/dts/mscc,luton.dtsi
 create mode 100644 arch/mips/dts/mscc,ocelot.dtsi
 create mode 100644 arch/mips/dts/mscc,ocelot_pcb.dtsi
 create mode 100644 arch/mips/dts/ocelot_pcb120.dts
 create mode 100644 arch/mips/dts/ocelot_pcb123.dts

diff --git a/arch/mips/dts/luton_pcb091.dts b/arch/mips/dts/luton_pcb091.dts
new file mode 100644
index 00..b5e0df8d04
--- /dev/null
+++ b/arch/mips/dts/luton_pcb091.dts
@@ -0,0 +1,36 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (c) 2018 Microsemi Corporation
+ */
+
+/dts-v1/;
+#include "mscc,luton.dtsi"
+
+/ {
+   model = "Luton PCB091 Reference Board";
+   compatible = "mscc,luton-pcb091", "mscc,luton";
+
+   aliases {
+   serial0 = &uart0;
+   spi0 = &spi0;
+   };
+
+   chosen {
+   stdout-path = "serial0:115200n8";
+   };
+
+};
+
+&uart0 {
+   status = "okay";
+};
+
+&spi0 {
+   status = "okay";
+   spi-flash@0 {
+   compatible = "spi-flash";
+spi-max-frequency = <1800>; /* input clock */
+reg = <0>; /* CS0 */
+   };
+};
+
diff --git a/arch/mips/dts/mscc,luton.dtsi b/arch/mips/dts/mscc,luton.dtsi
new file mode 100644
index 00..6a4ad2a5be
--- /dev/null
+++ b/arch/mips/dts/mscc,luton.dtsi
@@ -0,0 +1,87 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (c) 2018 Microsemi Corporation
+ */
+
+#include 
+
+/ {
+   #address-cells = <1>;
+   #size-cells = <1>;
+   compatible = "mscc,luton";
+
+   cpus {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   cpu@0 {
+   compatible = "mips,mips24KEc";
+   device_type = "cpu";
+   reg = <0>;
+   };
+   };
+
+   aliases {
+   serial0 = &uart0;
+   };
+
+   ahb_clk: ahb-clk {
+   compatible = "fixed-clock";
+   #clock-cells = <0>;
+   clock-frequency = <20833>;
+   };
+
+   ahb {
+   compatible = "simple-bus";
+   #address-cells = <1>;
+   #size-cells = <1>;
+   ranges = <0 0x6000 0x1020>;
+
+   uart0: serial@1010 {
+   pinctrl-0 = <&uart_pins>;
+   pinctrl-names = "default";
+
+   compatible = "ns16550a";
+   reg = <0x1010 0x20>;
+   clocks = <&ahb_clk>;
+   reg-io-width = <4>;
+   reg-shift = <2>;
+
+   status = "disabled";
+   };
+
+   gpio: pinctrl@70068 {
+   compatible = "mscc,luton-pinctrl";
+   reg = <0x70068 0x68>;
+   gpio-controller;
+   #gpio-cells = <2>;
+   gpio-ranges = <&gpio 0 0 32>;
+
+   uart_pins: uart-pins {
+   pins = "GPIO_30", "GPIO_31";
+   function = "uart";
+   };
+
+   };
+
+   gpio_spi_bitbang: gpio@1064 {
+   compatible = "mscc,spi-bitbang-gpio";
+   reg = <0x1064 0x4>;
+   gpio-controller;
+   #gpio-cells = <2>;
+
+   };
+
+   spi0: spi-bitbang {
+   compatible = "spi-gpio";
+   status = "okay";
+   gpio-sck = <&gpio_spi_bitbang 6 0>;
+   gpio-miso = <&gpio_spi_bitbang 0 0>;
+   gpio-mosi = <&gpio_spi_bitbang 5 0>;
+   cs-gpios = <&gpio_spi_bitbang 1 0>;
+   num-chipselects = <1>;
+   #address-cells = <1>;
+   #size-cells = <0>;
+   };
+   };
+};
diff --git a/arch/mips/dts/mscc,ocelot.dtsi b/arch/mips/dts/mscc,ocelot.dtsi
new file mode 100644
index 00..81afdffd4b
--- /dev/null
+++ b/arch/mips/dts/mscc,ocelot.dtsi
@@ -0,0 +1,132 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (c) 2018 Microsemi Corporation
+ */
+
+/ {
+   #address-cells = <1>;

[U-Boot] [PATCH 3/6] MSCC: add board support for the VCoreIII based evaluation boards

2018-09-25 Thread Gregory CLEMENT
Adding the support for 3 boards sharing common code:
 - PCB120 and PCB 123 for Ocelot chip
 - PCB 91 for Luton chip

Signed-off-by: Gregory CLEMENT 
---
 board/mscc/common/board.c  | 29 +
 board/mscc/luton/Kconfig   | 14 ++
 board/mscc/luton/Makefile  |  4 
 board/mscc/luton/luton.c   | 14 ++
 board/mscc/ocelot/Kconfig  | 24 
 board/mscc/ocelot/Makefile |  5 +
 board/mscc/ocelot/ocelot.c | 38 ++
 7 files changed, 128 insertions(+)
 create mode 100644 board/mscc/common/board.c
 create mode 100644 board/mscc/luton/Kconfig
 create mode 100644 board/mscc/luton/Makefile
 create mode 100644 board/mscc/luton/luton.c
 create mode 100644 board/mscc/ocelot/Kconfig
 create mode 100644 board/mscc/ocelot/Makefile
 create mode 100644 board/mscc/ocelot/ocelot.c

diff --git a/board/mscc/common/board.c b/board/mscc/common/board.c
new file mode 100644
index 00..86e7bf3353
--- /dev/null
+++ b/board/mscc/common/board.c
@@ -0,0 +1,29 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (c) 2018 Microsemi Corporation
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
+
+int board_early_init_r(void)
+{
+   u32 ctrl;
+
+   /* Prepare SPI controller to be used in master mode */
+   writel(0, REG_CFG(ICPU_SW_MODE));
+   ctrl = readl(REG_CFG(ICPU_GENERAL_CTRL));
+
+   writel((ctrl & ~ICPU_GENERAL_CTRL_IF_SI_OWNER_M) |
+  ICPU_GENERAL_CTRL_IF_SI_OWNER(2),
+  REG_CFG(ICPU_GENERAL_CTRL));
+
+   /* Address of boot parameters */
+   gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE;
+   return 0;
+}
diff --git a/board/mscc/luton/Kconfig b/board/mscc/luton/Kconfig
new file mode 100644
index 00..e1199808d5
--- /dev/null
+++ b/board/mscc/luton/Kconfig
@@ -0,0 +1,14 @@
+# SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+
+if SOC_LUTON
+
+config SYS_VENDOR
+   default "mscc"
+
+config SYS_BOARD
+   default "luton"
+
+config SYS_CONFIG_NAME
+   default "luton"
+
+endif
diff --git a/board/mscc/luton/Makefile b/board/mscc/luton/Makefile
new file mode 100644
index 00..98bc47ba82
--- /dev/null
+++ b/board/mscc/luton/Makefile
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+
+obj-$(CONFIG_SOC_LUTON):= luton.o
+obj-y += ../common/board.o
diff --git a/board/mscc/luton/luton.c b/board/mscc/luton/luton.c
new file mode 100644
index 00..8c31bbb12a
--- /dev/null
+++ b/board/mscc/luton/luton.c
@@ -0,0 +1,14 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (c) 2018 Microsemi Corporation
+ */
+
+#include 
+#include 
+
+void board_debug_uart_init(void)
+{
+   /* too early for the pinctrl driver, so configure the UART pins here */
+   writel(BIT(30)|BIT(31), REG_GCB((0x68+8*4)));
+   writel(~(BIT(30)|BIT(31)), REG_GCB((0x68+9*4)));
+}
diff --git a/board/mscc/ocelot/Kconfig b/board/mscc/ocelot/Kconfig
new file mode 100644
index 00..0804f5081d
--- /dev/null
+++ b/board/mscc/ocelot/Kconfig
@@ -0,0 +1,24 @@
+# SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+
+config SYS_VENDOR
+   default "mscc"
+
+if SOC_OCELOT
+
+config SYS_BOARD
+   default "ocelot"
+
+config SYS_CONFIG_NAME
+   default "ocelot"
+
+endif
+
+if SOC_LUTON
+
+config SYS_BOARD
+   default "luton"
+
+config SYS_CONFIG_NAME
+   default "luton"
+
+endif
diff --git a/board/mscc/ocelot/Makefile b/board/mscc/ocelot/Makefile
new file mode 100644
index 00..f6a665ca83
--- /dev/null
+++ b/board/mscc/ocelot/Makefile
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+
+obj-$(CONFIG_SOC_OCELOT)   := ocelot.o
+obj-y += ../common/board.o
+
diff --git a/board/mscc/ocelot/ocelot.c b/board/mscc/ocelot/ocelot.c
new file mode 100644
index 00..971fa93d07
--- /dev/null
+++ b/board/mscc/ocelot/ocelot.c
@@ -0,0 +1,38 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (c) 2018 Microsemi Corporation
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
+
+void external_cs_manage(struct udevice *dev, bool enable)
+{
+   u32 cs = spi_chip_select(dev);
+/* IF_SI0_OWNER, select the owner of the SI interface
+ * Encoding: 0: SI Slave
+ *   1: SI Boot Master
+ *   2: SI Master Controller
+ */
+if (!enable) {
+writel(ICPU_SW_MODE_SW_PIN_CTRL_MODE |
+  ICPU_SW_MODE_SW_SPI_CS(BIT(cs)),
+  REG_CFG(ICPU_SW_MODE));
+writel((readl(REG_CFG(ICPU_GENERAL_CTRL))
+   & ~ICPU_GENERAL_CTRL_IF_SI_OWNER_M) |
+  ICPU_GENERAL_CTRL_IF_SI_OWNER(2),
+  REG_CFG(ICPU_GENERAL_CTRL));
+} else {
+writel(0, REG_CFG(ICPU_SW_MODE));
+writel((readl(REG_CFG(ICPU_GENERAL_CTRL)) &
+  

[U-Boot] [PATCH 6/6] MIPS: bootm: Add support for Vcore III linux kernel

2018-09-25 Thread Gregory CLEMENT
The kernels built for the Vcore III linux kernel have different
expectation in the way the data were passed.

Unlike with yamon, the command line is expected to be a single string
passed in argv[1]. An other expectation is that the arguments are located
in the cached address space.

However, like yamon, they expect that rd_start and rd_size was passed by
the bootloader in the command line of the kernel, and besides that it
also wait for the root=/dev/ram0.

Signed-off-by: Gregory CLEMENT 
---
 arch/mips/lib/bootm.c | 62 +--
 1 file changed, 42 insertions(+), 20 deletions(-)

diff --git a/arch/mips/lib/bootm.c b/arch/mips/lib/bootm.c
index deca5189e3..417f5ce452 100644
--- a/arch/mips/lib/bootm.c
+++ b/arch/mips/lib/bootm.c
@@ -44,22 +44,38 @@ void arch_lmb_reserve(struct lmb *lmb)
lmb_reserve(lmb, sp, gd->ram_top - sp);
 }
 
-static void linux_cmdline_init(void)
+static void linux_cmdline_init(int vcoreiii)
 {
+   if (!vcoreiii) {
+   linux_argv = (char **)UNCACHED_SDRAM(gd->bd->bi_boot_params);
+   linux_argp = (char *)(linux_argv + LINUX_MAX_ARGS);
+   } else {
+   /*
+* Vcore III linux kernels expect arguments in the cached
+* address space. They also expect the command line being a
+* single string in the first argument
+*/
+   linux_argv = (char **)(gd->bd->bi_boot_params);
+   linux_argp = (char *)(linux_argv + LINUX_MAX_ARGS);
+   linux_argv[1] = linux_argp;
+   }
linux_argc = 1;
-   linux_argv = (char **)UNCACHED_SDRAM(gd->bd->bi_boot_params);
linux_argv[0] = 0;
-   linux_argp = (char *)(linux_argv + LINUX_MAX_ARGS);
 }
 
-static void linux_cmdline_set(const char *value, size_t len)
+static void linux_cmdline_set(const char *value, size_t len, int vcoreiii)
 {
-   linux_argv[linux_argc] = linux_argp;
memcpy(linux_argp, value, len);
-   linux_argp[len] = 0;
-
+   if (!vcoreiii)  {
+   linux_argv[linux_argc] = linux_argp;
+   linux_argp[len] = 0;
+   linux_argc++;
+   } else {
+   linux_argp[len] = ' ';
+   linux_argp[len + 1] = 0;
+   linux_argc = 2;
+   }
linux_argp += len + 1;
-   linux_argc++;
 }
 
 static void linux_cmdline_dump(void)
@@ -73,12 +89,10 @@ static void linux_cmdline_dump(void)
debug("   arg %03d: %s\n", i, linux_argv[i]);
 }
 
-static void linux_cmdline_legacy(bootm_headers_t *images)
+static void linux_cmdline_legacy(bootm_headers_t *images, int vcoreiii)
 {
const char *bootargs, *next, *quote;
-
-   linux_cmdline_init();
-
+   linux_cmdline_init(vcoreiii);
bootargs = env_get("bootargs");
if (!bootargs)
return;
@@ -104,7 +118,7 @@ static void linux_cmdline_legacy(bootm_headers_t *images)
if (!next)
next = bootargs + strlen(bootargs);
 
-   linux_cmdline_set(bootargs, next - bootargs);
+   linux_cmdline_set(bootargs, next - bootargs, vcoreiii);
 
if (*next)
next++;
@@ -113,7 +127,7 @@ static void linux_cmdline_legacy(bootm_headers_t *images)
}
 }
 
-static void linux_cmdline_append(bootm_headers_t *images)
+static void linux_cmdline_append(bootm_headers_t *images, int vcoreiii)
 {
char buf[24];
ulong mem, rd_start, rd_size;
@@ -121,7 +135,7 @@ static void linux_cmdline_append(bootm_headers_t *images)
/* append mem */
mem = gd->ram_size >> 20;
sprintf(buf, "mem=%luM", mem);
-   linux_cmdline_set(buf, strlen(buf));
+   linux_cmdline_set(buf, strlen(buf), vcoreiii);
 
/* append rd_start and rd_size */
rd_start = images->initrd_start;
@@ -129,9 +143,13 @@ static void linux_cmdline_append(bootm_headers_t *images)
 
if (rd_size) {
sprintf(buf, "rd_start=0x%08lX", rd_start);
-   linux_cmdline_set(buf, strlen(buf));
+   linux_cmdline_set(buf, strlen(buf), vcoreiii);
sprintf(buf, "rd_size=0x%lX", rd_size);
-   linux_cmdline_set(buf, strlen(buf));
+   linux_cmdline_set(buf, strlen(buf), vcoreiii);
+   if (vcoreiii) {
+   sprintf(buf, "root=/dev/ram0");
+   linux_cmdline_set(buf, strlen(buf), vcoreiii);
+   }
}
 }
 
@@ -276,11 +294,15 @@ static void boot_prep_linux(bootm_headers_t *images)
boot_reloc_fdt(images);
boot_setup_fdt(images);
} else {
-   if (CONFIG_IS_ENABLED(MIPS_BOOT_CMDLINE_LEGACY)) {
-   linux_cmdline_legacy(images);
+   if (CONFIG_IS_ENABLED(SOC_VCOREIII)) {
+   linux_cmdline_legacy(images, 1);
+   linux_cmdline_append(images, 1);
+

[U-Boot] [PATCH 5/6] MSCC: add configuration for Ocelot and Luton based boards

2018-09-25 Thread Gregory CLEMENT
Add common configuration header for the VCore III SoCs (currently Ocelot
and Luton), but also the defconfig for the evaluation boards of these
SoCs.

Signed-off-by: Gregory CLEMENT 
---
 configs/mscc_luton_defconfig | 66 +
 configs/mscc_ocelot_defconfig| 57 ++
 configs/mscc_ocelot_pcb120_defconfig | 56 ++
 include/configs/vcoreiii.h   | 72 
 4 files changed, 251 insertions(+)
 create mode 100644 configs/mscc_luton_defconfig
 create mode 100644 configs/mscc_ocelot_defconfig
 create mode 100644 configs/mscc_ocelot_pcb120_defconfig
 create mode 100644 include/configs/vcoreiii.h

diff --git a/configs/mscc_luton_defconfig b/configs/mscc_luton_defconfig
new file mode 100644
index 00..47fe12b6ee
--- /dev/null
+++ b/configs/mscc_luton_defconfig
@@ -0,0 +1,66 @@
+CONFIG_MIPS=y
+CONFIG_SYS_TEXT_BASE=0x4000
+CONFIG_SYS_MALLOC_F_LEN=0x2000
+CONFIG_DEBUG_UART_BOARD_INIT=y
+CONFIG_DEBUG_UART_BASE=0x7010
+CONFIG_DEBUG_UART_CLOCK=20833
+CONFIG_ARCH_MSCC=y
+CONFIG_TARGET_LUTON_PCB091=y
+CONFIG_DDRTYPE_MT47H128M8HQ=y
+CONFIG_SYS_LITTLE_ENDIAN=y
+CONFIG_MIPS_BOOT_FDT=y
+CONFIG_DEFAULT_DEVICE_TREE="luton_pcb091"
+CONFIG_DEBUG_UART=y
+CONFIG_FIT=y
+CONFIG_BOOTDELAY=3
+CONFIG_USE_BOOTARGS=y
+CONFIG_BOOTARGS="console=ttyS0,115200"
+CONFIG_LOGLEVEL=7
+CONFIG_DISPLAY_CPUINFO=y
+CONFIG_SYS_PROMPT="pcb091 # "
+# CONFIG_CMD_BDI is not set
+# CONFIG_CMD_CONSOLE is not set
+# CONFIG_CMD_ELF is not set
+# CONFIG_CMD_EXPORTENV is not set
+# CONFIG_CMD_IMPORTENV is not set
+# CONFIG_CMD_CRC32 is not set
+CONFIG_CMD_MD5SUM=y
+CONFIG_CMD_MEMINFO=y
+CONFIG_CMD_MEMTEST=y
+# CONFIG_CMD_FLASH is not set
+CONFIG_CMD_GPIO=y
+CONFIG_CMD_SF=y
+CONFIG_CMD_SPI=y
+CONFIG_CMD_DHCP=y
+# CONFIG_NET_TFTP_VARS is not set
+# CONFIG_CMD_NFS is not set
+CONFIG_CMD_PING=y
+CONFIG_CMD_MTDPARTS=y
+CONFIG_MTDIDS_DEFAULT="nor0=spi_flash"
+CONFIG_MTDPARTS_DEFAULT="mtdparts=spi_flash:512k(UBoot),256k(Env),256k(conf),6m@1m(linux)"
+# CONFIG_ISO_PARTITION is not set
+CONFIG_OF_EMBED=y
+CONFIG_ENV_IS_IN_SPI_FLASH=y
+CONFIG_NET_RANDOM_ETHADDR=y
+CONFIG_CLK=y
+CONFIG_DM_GPIO=y
+CONFIG_DM_SPI_FLASH=y
+CONFIG_SPI_FLASH=y
+CONFIG_SPI_FLASH_BAR=y
+CONFIG_SPI_FLASH_GIGADEVICE=y
+CONFIG_SPI_FLASH_MACRONIX=y
+CONFIG_SPI_FLASH_SPANSION=y
+CONFIG_SPI_FLASH_STMICRO=y
+CONFIG_SPI_FLASH_WINBOND=y
+CONFIG_SPI_FLASH_MTD=y
+CONFIG_DM_ETH=y
+CONFIG_PINCTRL=y
+CONFIG_PINCONF=y
+CONFIG_DM_SERIAL=y
+CONFIG_DEBUG_UART_SHIFT=2
+CONFIG_SYS_NS16550=y
+CONFIG_SPI=y
+CONFIG_DM_SPI=y
+CONFIG_SOFT_SPI=y
+CONFIG_LZMA=y
+CONFIG_XZ=y
diff --git a/configs/mscc_ocelot_defconfig b/configs/mscc_ocelot_defconfig
new file mode 100644
index 00..eb0566189a
--- /dev/null
+++ b/configs/mscc_ocelot_defconfig
@@ -0,0 +1,57 @@
+CONFIG_MIPS=y
+CONFIG_SYS_TEXT_BASE=0x4000
+CONFIG_SYS_MALLOC_F_LEN=0x2000
+CONFIG_ARCH_MSCC=y
+CONFIG_TARGET_OCELOT_PCB123=y
+CONFIG_SYS_LITTLE_ENDIAN=y
+CONFIG_DEFAULT_DEVICE_TREE="ocelot_pcb123"
+CONFIG_FIT=y
+CONFIG_BOOTDELAY=3
+CONFIG_USE_BOOTARGS=y
+CONFIG_BOOTARGS="console=ttyS0,115200"
+CONFIG_LOGLEVEL=7
+CONFIG_DISPLAY_CPUINFO=y
+CONFIG_SYS_PROMPT="pcb123 # "
+# CONFIG_CMD_BDI is not set
+# CONFIG_CMD_CONSOLE is not set
+# CONFIG_CMD_ELF is not set
+# CONFIG_CMD_EXPORTENV is not set
+# CONFIG_CMD_IMPORTENV is not set
+# CONFIG_CMD_CRC32 is not set
+CONFIG_CMD_MD5SUM=y
+CONFIG_CMD_MEMINFO=y
+CONFIG_CMD_MEMTEST=y
+# CONFIG_CMD_FLASH is not set
+CONFIG_CMD_GPIO=y
+CONFIG_CMD_SF=y
+CONFIG_CMD_SPI=y
+CONFIG_CMD_DHCP=y
+# CONFIG_NET_TFTP_VARS is not set
+# CONFIG_CMD_NFS is not set
+CONFIG_CMD_PING=y
+CONFIG_CMD_MTDPARTS=y
+CONFIG_MTDIDS_DEFAULT="nor0=spi_flash"
+CONFIG_MTDPARTS_DEFAULT="mtdparts=spi_flash:512k(UBoot),256k(Env),256k(conf),15m(linux),15m(linux.bk)"
+# CONFIG_ISO_PARTITION is not set
+CONFIG_OF_EMBED=y
+CONFIG_ENV_IS_IN_SPI_FLASH=y
+CONFIG_NET_RANDOM_ETHADDR=y
+CONFIG_CLK=y
+CONFIG_DM_GPIO=y
+CONFIG_DM_SPI_FLASH=y
+CONFIG_SPI_FLASH=y
+CONFIG_SPI_FLASH_BAR=y
+CONFIG_SPI_FLASH_GIGADEVICE=y
+CONFIG_SPI_FLASH_MACRONIX=y
+CONFIG_SPI_FLASH_SPANSION=y
+CONFIG_SPI_FLASH_WINBOND=y
+CONFIG_SPI_FLASH_MTD=y
+CONFIG_DM_ETH=y
+CONFIG_PINCTRL=y
+CONFIG_PINCONF=y
+CONFIG_DM_SERIAL=y
+CONFIG_SYS_NS16550=y
+CONFIG_SPI=y
+CONFIG_DM_SPI=y
+CONFIG_DESIGNWARE_SPI=y
+CONFIG_LZMA=y
diff --git a/configs/mscc_ocelot_pcb120_defconfig 
b/configs/mscc_ocelot_pcb120_defconfig
new file mode 100644
index 00..40cdec45f1
--- /dev/null
+++ b/configs/mscc_ocelot_pcb120_defconfig
@@ -0,0 +1,56 @@
+CONFIG_MIPS=y
+CONFIG_SYS_TEXT_BASE=0x4000
+CONFIG_SYS_MALLOC_F_LEN=0x2000
+CONFIG_ARCH_MSCC=y
+CONFIG_SYS_LITTLE_ENDIAN=y
+CONFIG_DEFAULT_DEVICE_TREE="ocelot_pcb120"
+CONFIG_FIT=y
+CONFIG_BOOTDELAY=3
+CONFIG_USE_BOOTARGS=y
+CONFIG_BOOTARGS="console=ttyS0,115200"
+CONFIG_LOGLEVEL=7
+CONFIG_DISPLAY_CPUINFO=y
+CONFIG_SYS_PROMPT="pcb120 # "
+# CONFIG_CMD_BDI is not set
+# CONFIG_CMD_CONSOLE is not set
+# CONFIG_CMD_ELF is not set
+# CONFIG_CMD_EXPORTENV is not 

[U-Boot] [PATCH] pinctrl: mscc: Add gpio and pinctrl driver for MSCC MIPS SoCs (VcoreIII based)

2018-09-25 Thread Gregory CLEMENT
This driver supports the pin and gpio controller found in the Ocelot and
Luton SoCs.

The driver was inspired from the pinctrl driver in Linux, but was
simplified and was modified to allow supporting an other SoCs (Luton).

For Ocelot and Luton the controller is the same, only the pins to program
differ.

Signed-off-by: Gregory CLEMENT 
---
 drivers/pinctrl/Kconfig   |   1 +
 drivers/pinctrl/Makefile  |   1 +
 drivers/pinctrl/mscc/Kconfig  |  22 +++
 drivers/pinctrl/mscc/Makefile |   5 +
 drivers/pinctrl/mscc/mscc-common.c| 258 ++
 drivers/pinctrl/mscc/mscc-common.h|  51 +
 drivers/pinctrl/mscc/pinctrl-luton.c  | 176 ++
 drivers/pinctrl/mscc/pinctrl-ocelot.c | 190 +++
 8 files changed, 704 insertions(+)
 create mode 100644 drivers/pinctrl/mscc/Kconfig
 create mode 100644 drivers/pinctrl/mscc/Makefile
 create mode 100644 drivers/pinctrl/mscc/mscc-common.c
 create mode 100644 drivers/pinctrl/mscc/mscc-common.h
 create mode 100644 drivers/pinctrl/mscc/pinctrl-luton.c
 create mode 100644 drivers/pinctrl/mscc/pinctrl-ocelot.c

diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig
index ad0b8daba6..cc82f91579 100644
--- a/drivers/pinctrl/Kconfig
+++ b/drivers/pinctrl/Kconfig
@@ -305,6 +305,7 @@ source "drivers/pinctrl/nxp/Kconfig"
 source "drivers/pinctrl/renesas/Kconfig"
 source "drivers/pinctrl/uniphier/Kconfig"
 source "drivers/pinctrl/exynos/Kconfig"
+source "drivers/pinctrl/mscc/Kconfig"
 source "drivers/pinctrl/mvebu/Kconfig"
 source "drivers/pinctrl/broadcom/Kconfig"
 
diff --git a/drivers/pinctrl/Makefile b/drivers/pinctrl/Makefile
index a3a6c6d163..2461dba293 100644
--- a/drivers/pinctrl/Makefile
+++ b/drivers/pinctrl/Makefile
@@ -16,6 +16,7 @@ obj-$(CONFIG_PINCTRL_UNIPHIER)+= uniphier/
 obj-$(CONFIG_PINCTRL_PIC32)+= pinctrl_pic32.o
 obj-$(CONFIG_PINCTRL_EXYNOS)   += exynos/
 obj-$(CONFIG_PINCTRL_MESON)+= meson/
+obj-y  += mscc/
 obj-$(CONFIG_ARCH_MVEBU)   += mvebu/
 obj-$(CONFIG_PINCTRL_SINGLE)   += pinctrl-single.o
 obj-$(CONFIG_PINCTRL_STI)  += pinctrl-sti.o
diff --git a/drivers/pinctrl/mscc/Kconfig b/drivers/pinctrl/mscc/Kconfig
new file mode 100644
index 00..cfc6c06076
--- /dev/null
+++ b/drivers/pinctrl/mscc/Kconfig
@@ -0,0 +1,22 @@
+# SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+
+config PINCTRL_MSCC
+   bool
+
+config PINCTRL_MSCC_OCELOT
+   depends on SOC_OCELOT && PINCTRL_FULL && OF_CONTROL
+   select PINCTRL_MSCC
+   default y
+   bool "Microsemi ocelot family pin control driver"
+   help
+  Support pin multiplexing and pin configuration control on
+  Microsemi ocelot SoCs.
+
+config PINCTRL_MSCC_LUTON
+   depends on SOC_LUTON && PINCTRL_FULL && OF_CONTROL
+   select PINCTRL_MSCC
+   default y
+   bool "Microsemi luton family pin control driver"
+   help
+  Support pin multiplexing and pin configuration control on
+  Microsemi luton SoCs.
diff --git a/drivers/pinctrl/mscc/Makefile b/drivers/pinctrl/mscc/Makefile
new file mode 100644
index 00..941f418ff9
--- /dev/null
+++ b/drivers/pinctrl/mscc/Makefile
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+
+obj-$(CONFIG_PINCTRL_MSCC) += mscc-common.o
+obj-$(CONFIG_PINCTRL_MSCC_OCELOT) += pinctrl-ocelot.o
+obj-$(CONFIG_PINCTRL_MSCC_LUTON) += pinctrl-luton.o
diff --git a/drivers/pinctrl/mscc/mscc-common.c 
b/drivers/pinctrl/mscc/mscc-common.c
new file mode 100644
index 00..84b6844daa
--- /dev/null
+++ b/drivers/pinctrl/mscc/mscc-common.c
@@ -0,0 +1,258 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
+/*
+ * Microsemi SoCs pinctrl driver
+ *
+ * Author: 
+ * License: Dual MIT/GPL
+ * Copyright (c) 2017 Microsemi Corporation
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "mscc-common.h"
+
+#define clrbits(addr, clear) writel(readl(addr) & ~(clear), (addr))
+
+#define setbits(addr, set) writel(readl(addr) | (set), (addr))
+
+#define MSCC_GPIO_OUT_SET  0x0
+#define MSCC_GPIO_OUT_CLR  0x4
+#define MSCC_GPIO_OUT  0x8
+#define MSCC_GPIO_IN   0xc
+#define MSCC_GPIO_OE   0x10
+#define MSCC_GPIO_INTR 0x14
+#define MSCC_GPIO_INTR_ENA 0x18
+#define MSCC_GPIO_INTR_IDENT   0x1c
+#define MSCC_GPIO_ALT0 0x20
+#define MSCC_GPIO_ALT1 0x24
+
+static int mscc_get_functions_count(struct udevice *dev)
+{
+   struct mscc_pinctrl *info = dev_get_priv(dev);
+
+   return info->num_func;
+}
+
+static const char *mscc_get_function_name(struct udevice *dev,
+   unsigned int function)
+{
+   struct mscc_pinctrl *info = dev_get_priv(dev);
+
+   return info->function_names[function];
+}
+
+static int mscc_pin_function_idx(unsigned int pin, unsigned int function,
+const struct mscc_pin_

[U-Boot] [PATCH] gpio: mscc-bitbang-spi: Add a simple gpio driver for bitbgang spi

2018-09-25 Thread Gregory CLEMENT
The VCore III SoCs such as the Luton but also the Ocelot can remap an SPI
flash directly in memory. However, for writing in the flash the
communication has to be done by software.

Each of the signal used for the SPI are exposed in a single register. In
order to be able to use the soft-spi driver, the management of this pin
is done through this simple gpio driver.

Even if the main purpose of this driver is to be used by soft-spi, it can
still be used as a normal gpio driver but with limitation: for example
the first pin can't be used as output.

Signed-off-by: Gregory CLEMENT 
---
 drivers/gpio/Kconfig |   7 ++
 drivers/gpio/Makefile|   1 +
 drivers/gpio/gpio-mscc-bitbang-spi.c | 126 +++
 3 files changed, 134 insertions(+)
 create mode 100644 drivers/gpio/gpio-mscc-bitbang-spi.c

diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index 5cd8b34400..947a59cce3 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -99,6 +99,13 @@ config LPC32XX_GPIO
help
  Support for the LPC32XX GPIO driver.
 
+config MSCC_BITBANG_SPI_GPIO
+   bool "Microsemi bitbang spi GPIO driver"
+   depends on DM_GPIO && SOC_VCOREIII
+   help
+ Support controlling the GPIO used for SPI bitbang by software. Can
+ be used by the VCoreIII SoCs, but it was mainly useful for Luton.
+
 config MSM_GPIO
bool "Qualcomm GPIO driver"
depends on DM_GPIO
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
index f186120684..2085dd3cba 100644
--- a/drivers/gpio/Makefile
+++ b/drivers/gpio/Makefile
@@ -58,3 +58,4 @@ obj-$(CONFIG_MVEBU_GPIO)  += mvebu_gpio.o
 obj-$(CONFIG_MSM_GPIO) += msm_gpio.o
 obj-$(CONFIG_$(SPL_)PCF8575_GPIO)  += pcf8575_gpio.o
 obj-$(CONFIG_PM8916_GPIO)  += pm8916_gpio.o
+obj-$(CONFIG_MSCC_BITBANG_SPI_GPIO)+= gpio-mscc-bitbang-spi.o
diff --git a/drivers/gpio/gpio-mscc-bitbang-spi.c 
b/drivers/gpio/gpio-mscc-bitbang-spi.c
new file mode 100644
index 00..572107d010
--- /dev/null
+++ b/drivers/gpio/gpio-mscc-bitbang-spi.c
@@ -0,0 +1,126 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
+/*
+ * Microsemi SoCs pinctrl driver
+ *
+ * Author: 
+ * License: Dual MIT/GPL
+ * Copyright (c) 2018 Microsemi Corporation
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+enum {
+   SDI,
+   CS0,
+   CS1,
+   CS2,
+   CS3,
+   SDO,
+   SCK
+};
+
+int pinmap[] = {0, 5, 6, 7, 8, 10, 12};
+
+#define SW_SPI_CSn_OE   0x1E /* bits 1 to 4 */
+#define SW_SPI_CS0_OE   BIT(1)
+#define SW_SPI_SDO_OE   BIT(9)
+#define SW_SPI_SCK_OE   BIT(11)
+#define SW_PIN_CTRL_MODE BIT(13)
+
+struct mscc_bb_spi_gpio {
+   u32 *regs;
+   u32 cache_val;
+};
+
+static int mscc_bb_spi_gpio_set(struct udevice *dev, unsigned oft, int val)
+{
+   struct mscc_bb_spi_gpio *gpio = dev_get_priv(dev);
+
+   if (val)
+   gpio->cache_val |= BIT(pinmap[oft]);
+   else
+   gpio->cache_val &= ~BIT(pinmap[oft]);
+
+   writel(gpio->cache_val, gpio->regs);
+
+   return 0;
+}
+
+static int mscc_bb_spi_gpio_direction_output(struct udevice *dev, unsigned oft,
+  int val)
+{
+   if (oft == 0) {
+   pr_err("SW_SPI_DSI can't be used as output\n");
+   return -ENOTSUPP;
+   }
+
+   mscc_bb_spi_gpio_set(dev, oft, val);
+
+   return 0;
+}
+
+static int mscc_bb_spi_gpio_direction_input(struct udevice *dev, unsigned oft)
+{
+   return 0;
+}
+
+static int mscc_bb_spi_gpio_get(struct udevice *dev, unsigned int oft)
+{
+   struct mscc_bb_spi_gpio *gpio = dev_get_priv(dev);
+   u32 val = readl(gpio->regs);
+
+   return !!(val & BIT(pinmap[oft]));
+}
+
+static const struct dm_gpio_ops mscc_bb_spi_gpio_ops = {
+   .direction_output   = mscc_bb_spi_gpio_direction_output,
+   .direction_input= mscc_bb_spi_gpio_direction_input,
+   .set_value  = mscc_bb_spi_gpio_set,
+   .get_value  = mscc_bb_spi_gpio_get,
+};
+
+static int mscc_bb_spi_gpio_probe(struct udevice *dev)
+{
+   struct mscc_bb_spi_gpio *gpio = dev_get_priv(dev);
+   struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
+   fdt_addr_t addr;
+   fdt_size_t size;
+
+   addr = devfdt_get_addr_size_index(dev, 0, &size);
+   if (addr == FDT_ADDR_T_NONE)
+   return -EINVAL;
+
+   gpio->regs = ioremap(addr, size);
+
+   uc_priv->bank_name = dev->name;
+   uc_priv->gpio_count = ARRAY_SIZE(pinmap);
+   /*
+* Enable software mode to control the SPI pin, enables the
+* output mode for most of the pin and initialize the cache
+* value in the same time
+*/
+
+   gpio->cache_val = SW_PIN_CTRL_MODE | SW_SPI_SCK_OE | SW_SPI_SDO_OE |
+   SW_SPI_CS0_OE;
+   writel(gpio->cache_val, gpio->regs);
+
+   return 0;
+}
+
+static const struct udevice_id ms

[U-Boot] [PATCH] DW SPI: Allow to overload the management of the external CS

2018-09-25 Thread Gregory CLEMENT
On some platforms, as the Ocelot ones, when wanting to control the CS
through software, it is not possible to do it through the GPIO
controller. Indeed, this signal is managed through a dedicated range of
registers inside the SoC..

By declaring the external_cs_manage function as weak, it is possible to
manage the CS at platform level and then using the appropriate registers.

Signed-off-by: Gregory CLEMENT 
---
 drivers/spi/designware_spi.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/designware_spi.c b/drivers/spi/designware_spi.c
index d8b73ea326..fe6e753bff 100644
--- a/drivers/spi/designware_spi.c
+++ b/drivers/spi/designware_spi.c
@@ -334,7 +334,13 @@ static int poll_transfer(struct dw_spi_priv *priv)
return 0;
 }
 
-static void external_cs_manage(struct udevice *dev, bool on)
+/*
+ * We define external_cs_manage function as 'weak' as some targets
+ * (like OCELOT) don't control the external CS pin using a GPIO
+ * controller. These SoCs use specific registers to controll by
+ * software the SPI pins (and especially the CS).
+ */
+__weak void external_cs_manage(struct udevice *dev, bool on)
 {
 #if defined(CONFIG_DM_GPIO) && !defined(CONFIG_SPL_BUILD)
struct dw_spi_priv *priv = dev_get_priv(dev->parent);
-- 
2.19.0

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


[U-Boot] [PATCH 1/1] ARM: meson: Extend mem_map to support 3GiB of RAM

2018-09-25 Thread Loic Devulder
The current mem_map definition for Meson SoCs has support for up
to 2GiB of RAM. According to S905, S905X, S912 and S805X datasheets
the DDR region is set from 0x to 0xBFFF, so mem_map's
definition should be changed accordingly.

It is also needed to be able to boot Khadas VIM2 board with S912
SoC.

Signed-off-by: Loic Devulder 
---
 arch/arm/mach-meson/board.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-meson/board.c b/arch/arm/mach-meson/board.c
index 1ef7e5a6d1..48096ca7cf 100644
--- a/arch/arm/mach-meson/board.c
+++ b/arch/arm/mach-meson/board.c
@@ -111,13 +111,13 @@ static struct mm_region gx_mem_map[] = {
{
.virt = 0x0UL,
.phys = 0x0UL,
-   .size = 0x8000UL,
+   .size = 0xc000UL,
.attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
 PTE_BLOCK_INNER_SHARE
}, {
-   .virt = 0x8000UL,
-   .phys = 0x8000UL,
-   .size = 0x8000UL,
+   .virt = 0xc000UL,
+   .phys = 0xc000UL,
+   .size = 0xf000UL,
.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
 PTE_BLOCK_NON_SHARE |
 PTE_BLOCK_PXN | PTE_BLOCK_UXN
-- 
2.16.4

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


Re: [U-Boot] [PATCH 1/2] pico-imx6ul, pico-imx7d: Use eMMC user partition by default

2018-09-25 Thread Fabio Estevam
On Sat, Sep 22, 2018 at 3:23 AM, Otavio Salvador
 wrote:
> After discussing with TechNexion about how its default setting, it is
> better to install on the eMMC user partition by default, when using
> DFU, so it works out of box for majority of users.
>
> Signed-off-by: Otavio Salvador 

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


Re: [U-Boot] [PATCH 2/2] pico-imx6ul, pico-imx7d: Enable USB and PXE boot support

2018-09-25 Thread Fabio Estevam
On Sat, Sep 22, 2018 at 3:23 AM, Otavio Salvador
 wrote:
> Signed-off-by: Otavio Salvador 

Please provide a commit log stating the motivation for doing this.
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 1/1] ARM: meson: Extend mem_map to support 3GiB of RAM

2018-09-25 Thread Loic Devulder
The current mem_map definition for Meson SoCs has support for up
to 2GiB of RAM. According to S905, S905X, S912 and S805X datasheets
the DDR region is set from 0x to 0xBFFF, so mem_map's
definition should be changed accordingly.

It is also needed to be able to boot Khadas VIM2 board with S912
SoC.

Signed-off-by: Loic Devulder 
---
v2: set the correct size for devices memory map

 arch/arm/mach-meson/board.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-meson/board.c b/arch/arm/mach-meson/board.c
index 1ef7e5a6d1..48096ca7cf 100644
--- a/arch/arm/mach-meson/board.c
+++ b/arch/arm/mach-meson/board.c
@@ -111,13 +111,13 @@ static struct mm_region gx_mem_map[] = {
{
.virt = 0x0UL,
.phys = 0x0UL,
-   .size = 0x8000UL,
+   .size = 0xc000UL,
.attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
 PTE_BLOCK_INNER_SHARE
}, {
-   .virt = 0x8000UL,
-   .phys = 0x8000UL,
-   .size = 0x8000UL,
+   .virt = 0xc000UL,
+   .phys = 0xc000UL,
+   .size = 0x3000UL,
.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
 PTE_BLOCK_NON_SHARE |
 PTE_BLOCK_PXN | PTE_BLOCK_UXN
-- 
2.16.4

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


[U-Boot] [PATCH v4 00/19] AVB using OP-TEE

2018-09-25 Thread Jens Wiklander
Hi,

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

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

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

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

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

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

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

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

changes in v4:
* Addressed review comments from Simon Glass
* Rebased on v2018.09
* "avb_verify: bugfix avb_ops_free() skipping free" removed due to the rebase
* Commits "dt/bindings: add bindings for optee",
  "sandbox: imply CONFIG_TEE (TEE uclass)",
  "tee: add sandbox driver",
  "avb_verify: support using OP-TEE TA AVB",
  "test_avb: Update pymark.buildconfigspec information for the AVB tests",
  "Kconfig: sandbox: enable cmd_avb and dependencies",
  Reviewed-by: Simon Glass 
* Added descriptions of additional structs and functions
* In commit "avb_verify: support sandbox configuration" avoid the
  #ifdef CONFIG_SANDBOX in get_sector_buf() as suggested by Simon.

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

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

Thanks,
Jens

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

 MAINTAINERS  

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

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

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

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

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


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

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

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

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

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


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

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

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

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


[U-Boot] [PATCH v4 04/19] mmc: rpmb: add mmc_rpmb_route_frames()

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

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

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

[U-Boot] [PATCH v4 06/19] dt/bindings: add bindings for optee

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

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

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

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

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


[U-Boot] [PATCH v4 05/19] Add UCLASS_TEE for Trusted Execution Environment

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

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

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

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

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

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

[U-Boot] [PATCH v4 09/19] arm: dt: hikey: Add optee node

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

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

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

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


[U-Boot] [PATCH v4 08/19] Documentation: tee uclass and op-tee driver

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

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

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


[U-Boot] [PATCH v4 07/19] tee: add OP-TEE driver

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

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

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

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

[U-Boot] [PATCH v4 14/19] tee: add sandbox driver

2018-09-25 Thread Jens Wiklander
Adds a sandbox tee driver which emulates a generic TEE with the OP-TEE
AVB TA.

Reviewed-by: Simon Glass 
Signed-off-by: Jens Wiklander 
---
 drivers/tee/Kconfig   |  18 ++-
 drivers/tee/Makefile  |   1 +
 drivers/tee/optee/Kconfig |   2 +-
 drivers/tee/sandbox.c | 308 ++
 include/sandboxtee.h  |  21 +++
 5 files changed, 347 insertions(+), 3 deletions(-)
 create mode 100644 drivers/tee/sandbox.c
 create mode 100644 include/sandboxtee.h

diff --git a/drivers/tee/Kconfig b/drivers/tee/Kconfig
index 835c256e9239..5c0c89043fac 100644
--- a/drivers/tee/Kconfig
+++ b/drivers/tee/Kconfig
@@ -1,8 +1,8 @@
 # Generic Trusted Execution Environment Configuration
 config TEE
bool "Trusted Execution Environment support"
-   depends on ARM && (ARM64 || CPU_V7A)
-   select ARM_SMCCC
+   depends on (ARM && (ARM64 || CPU_V7A)) || SANDBOX
+   select ARM_SMCCC if ARM
help
  This implements a generic interface towards a Trusted Execution
  Environment (TEE). A TEE is a trusted OS running in some secure
@@ -14,6 +14,20 @@ if TEE
 
 menu "TEE drivers"
 
+config SANDBOX_TEE
+   bool "Sandbox TEE emulator"
+   depends on SANDBOX
+   default y
+   help
+ This emulates a generic TEE needed for testing including the AVB
+ TA. The emulation provides all callbacks of a regular TEE and
+ supports session and shared memory management. The AVB TA is
+ emulated with rollback indexes and device lock-state, the state
+ of the TA is only kept in RAM and will be reset on each boot.
+ The emulation only supports one open session at a time.
+ Interaction from the U-Boot command line in possible via the
+ "avb" commands.
+
 source "drivers/tee/optee/Kconfig"
 
 endmenu
diff --git a/drivers/tee/Makefile b/drivers/tee/Makefile
index 19633b60f235..f72c68c09f33 100644
--- a/drivers/tee/Makefile
+++ b/drivers/tee/Makefile
@@ -1,4 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0+
 
 obj-y += tee-uclass.o
+obj-$(CONFIG_SANDBOX) += sandbox.o
 obj-$(CONFIG_OPTEE) += optee/
diff --git a/drivers/tee/optee/Kconfig b/drivers/tee/optee/Kconfig
index dbfa7846a30f..d489834df926 100644
--- a/drivers/tee/optee/Kconfig
+++ b/drivers/tee/optee/Kconfig
@@ -10,7 +10,7 @@ config OPTEE
  handle Remote Procedure Calls (RPC) from OP-TEE needed to
  execute a service. For more information see: https://www.op-tee.org
 
-if OPTEE
+if OPTEE || SANDBOX
 
 menu "OP-TEE options"
 
diff --git a/drivers/tee/sandbox.c b/drivers/tee/sandbox.c
new file mode 100644
index ..10a1e8dffa69
--- /dev/null
+++ b/drivers/tee/sandbox.c
@@ -0,0 +1,308 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2018 Linaro Limited
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/*
+ * The sandbox tee driver tries to emulate a generic Trusted Exectution
+ * Environment (TEE) with the Trusted Application (TA) OPTEE_TA_AVB
+ * available.
+ */
+
+/**
+ * struct ta_entry - TA entries
+ * @uuid:  UUID of an emulated TA
+ * @open_session   Called when a session is openened to the TA
+ * @invoke_funcCalled when a function in the TA is to be 
invoked
+ *
+ * This struct is used to register TAs in this sandbox emulation of a TEE.
+ */
+struct ta_entry {
+   struct tee_optee_ta_uuid uuid;
+   u32 (*open_session)(uint num_params, struct tee_param *params);
+   u32 (*invoke_func)(u32 func, uint num_params, struct tee_param *params);
+};
+
+#ifdef CONFIG_OPTEE_TA_AVB
+static u32 get_attr(uint n, uint num_params, struct tee_param *params)
+{
+   if (n >= num_params)
+   return TEE_PARAM_ATTR_TYPE_NONE;
+
+   return params[n].attr;
+}
+
+static u32 check_params(u8 p0, u8 p1, u8 p2, u8 p3, uint num_params,
+   struct tee_param *params)
+{
+   u8 p[] = { p0, p1, p2, p3};
+   uint n;
+
+   for (n = 0; n < ARRAY_SIZE(p); n++)
+   if (p[n] != get_attr(n, num_params, params))
+   goto bad_params;
+
+   for (; n < num_params; n++)
+   if (get_attr(n, num_params, params))
+   goto bad_params;
+
+   return TEE_SUCCESS;
+
+bad_params:
+   printf("Bad param attrs\n");
+
+   return TEE_ERROR_BAD_PARAMETERS;
+}
+
+static u64 ta_avb_rollback_indexes[TA_AVB_MAX_ROLLBACK_LOCATIONS];
+static u32 ta_avb_lock_state;
+
+static u32 ta_avb_open_session(uint num_params, struct tee_param *params)
+{
+   /*
+* We don't expect additional parameters when opening a session to
+* this TA.
+*/
+   return check_params(TEE_PARAM_ATTR_TYPE_NONE, TEE_PARAM_ATTR_TYPE_NONE,
+   TEE_PARAM_ATTR_TYPE_NONE, TEE_PARAM_ATTR_TYPE_NONE,
+   num_params, params);
+}
+
+static u32 ta_avb_invoke_func(u32 func, uint num_params,
+ struct tee_param *params)
+{
+   

[U-Boot] [PATCH v4 10/19] optee: support routing of rpmb data frames to mmc

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

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

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

[U-Boot] [PATCH v4 11/19] tee: optee: support AVB trusted application

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

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

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

[U-Boot] [PATCH v4 12/19] sandbox: dt: add sandbox_tee node

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

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

diff --git a/arch/sandbox/dts/sandbox.dts b/arch/sandbox/dts/sandbox.dts
index 6ac37f1ed7be..af7f12aa5889 100644
--- a/arch/sandbox/dts/sandbox.dts
+++ b/arch/sandbox/dts/sandbox.dts
@@ -322,6 +322,10 @@
reg = <0x0 0x400>;
};
};
+
+   sandbox_tee {
+   compatible = "sandbox,tee";
+   };
 };
 
 #include "cros-ec-keyboard.dtsi"
diff --git a/arch/sandbox/dts/sandbox64.dts b/arch/sandbox/dts/sandbox64.dts
index 9e65d2fda3d3..0e32fdad9d81 100644
--- a/arch/sandbox/dts/sandbox64.dts
+++ b/arch/sandbox/dts/sandbox64.dts
@@ -311,6 +311,10 @@
};
};
};
+
+   sandbox_tee {
+   compatible = "sandbox,tee";
+   };
 };
 
 #include "cros-ec-keyboard.dtsi"
diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index 366826333181..997f8f996f23 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -630,6 +630,10 @@
};
};
};
+
+   sandbox_tee {
+   compatible = "sandbox,tee";
+   };
 };
 
 #include "sandbox_pmic.dtsi"
-- 
2.17.1

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


[U-Boot] [PATCH v4 13/19] sandbox: imply CONFIG_TEE (TEE uclass)

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

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

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


[U-Boot] [PATCH v4 18/19] avb_verify: support sandbox configuration

2018-09-25 Thread Jens Wiklander
Change get_sector_buf() to use map_sysmem() to get a pointer to the
CONFIG_FASTBOOT_BUF_ADDR in memory.

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

diff --git a/include/avb_verify.h b/include/avb_verify.h
index a532a2331aea..18278f829e41 100644
--- a/include/avb_verify.h
+++ b/include/avb_verify.h
@@ -9,6 +9,7 @@
 #define _AVB_VERIFY_H
 
 #include <../lib/libavb/libavb.h>
+#include 
 #include 
 
 #define AVB_MAX_ARGS   1024
@@ -76,7 +77,7 @@ static inline size_t get_sector_buf_size(void)
 
 static inline void *get_sector_buf(void)
 {
-   return (void *)CONFIG_FASTBOOT_BUF_ADDR;
+   return map_sysmem(CONFIG_FASTBOOT_BUF_ADDR, CONFIG_FASTBOOT_BUF_SIZE);
 }
 
 static inline bool is_buf_unaligned(void *buffer)
-- 
2.17.1

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


[U-Boot] [PATCH v4 16/19] avb_verify: support using OP-TEE TA AVB

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

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

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

[U-Boot] [PATCH v4 15/19] test: tee: test TEE uclass

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

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

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

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


[U-Boot] [PATCH v2 2/2] pico-imx6ul, pico-imx7d: Enable USB and PXE boot support

2018-09-25 Thread Otavio Salvador
This allow the use of a USB storage or PXE network booting as
fallback, allowing for example for manufacturing installation of eMMC
storage in an easy way.

Signed-off-by: Otavio Salvador 
---

Changes in v2:
- improve commit log (fabio)

 include/configs/pico-imx6ul.h | 2 ++
 include/configs/pico-imx7d.h  | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/include/configs/pico-imx6ul.h b/include/configs/pico-imx6ul.h
index 0fea2d65dd..8082b74c9c 100644
--- a/include/configs/pico-imx6ul.h
+++ b/include/configs/pico-imx6ul.h
@@ -103,6 +103,8 @@
 
 #define BOOT_TARGET_DEVICES(func) \
func(MMC, mmc, 0) \
+   func(USB, usb, 0) \
+   func(PXE, pxe, na) \
func(DHCP, dhcp, na)
 
 #include 
diff --git a/include/configs/pico-imx7d.h b/include/configs/pico-imx7d.h
index 614be99d93..2bc42a04a0 100644
--- a/include/configs/pico-imx7d.h
+++ b/include/configs/pico-imx7d.h
@@ -92,6 +92,8 @@
 
 #define BOOT_TARGET_DEVICES(func) \
func(MMC, mmc, 0) \
+   func(USB, usb, 0) \
+   func(PXE, pxe, na) \
func(DHCP, dhcp, na)
 
 #include 
-- 
2.19.0

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


[U-Boot] [PATCH v4 17/19] test_avb: Update pymark.buildconfigspec information for the AVB tests

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

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

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

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


[U-Boot] [PATCH v2 1/2] pico-imx6ul, pico-imx7d: Use eMMC user partition by default

2018-09-25 Thread Otavio Salvador
After discussing with TechNexion about how its default setting, it is
better to install on the eMMC user partition by default, when using
DFU, so it works out of box for majority of users.

Reviewed-by: Fabio Estevam 
Signed-off-by: Otavio Salvador 
---

Changes in v2: None

 include/configs/pico-imx6ul.h | 4 ++--
 include/configs/pico-imx7d.h  | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/configs/pico-imx6ul.h b/include/configs/pico-imx6ul.h
index 3d93205535..0fea2d65dd 100644
--- a/include/configs/pico-imx6ul.h
+++ b/include/configs/pico-imx6ul.h
@@ -56,8 +56,8 @@
 
 #define CONFIG_DFU_ENV_SETTINGS \
"dfu_alt_info=" \
-   "spl raw 0x2 0x400 mmcpart 1;" \
-   "u-boot raw 0x8a 0x400 mmcpart 1;" \
+   "spl raw 0x2 0x400;" \
+   "u-boot raw 0x8a 0x400;" \
"/boot/zImage ext4 0 1;" \
"/boot/imx6ul-pico-hobbit.dtb ext4 0 1;" \
"/boot/imx6ul-pico-pi.dtb ext4 0 1;" \
diff --git a/include/configs/pico-imx7d.h b/include/configs/pico-imx7d.h
index 0e770bf41f..614be99d93 100644
--- a/include/configs/pico-imx7d.h
+++ b/include/configs/pico-imx7d.h
@@ -45,8 +45,8 @@
 
 #define CONFIG_DFU_ENV_SETTINGS \
"dfu_alt_info=" \
-   "spl raw 0x2 0x400 mmcpart 1;" \
-   "u-boot raw 0x8a 0x400 mmcpart 1;" \
+   "spl raw 0x2 0x400;" \
+   "u-boot raw 0x8a 0x400;" \
"/boot/zImage ext4 0 1;" \
"/boot/imx7d-pico-hobbit.dtb ext4 0 1;" \
"/boot/imx7d-pico-pi.dtb ext4 0 1;" \
-- 
2.19.0

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


[U-Boot] [PATCH v4 19/19] Kconfig: sandbox: enable cmd_avb and dependencies

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

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

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

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


Re: [U-Boot] [PATCH] net: phy: add TSE PCS support to dwmac-socfpga

2018-09-25 Thread Dinh Nguyen


On 09/25/2018 01:24 AM, Ooi, Joyce wrote:
> This adds support for TSE PCS that uses SGMII adapter when the
> phy-mode in device tree is set to sgmii.

Can you add a bit more description to your commit message? TSE(Triple
Speed Ethernet), but what is PCS?

> 
> Signed-off-by: Ooi, Joyce 
> ---
>  drivers/net/Makefile   |   3 +-
>  drivers/net/designware.c   |   5 ++
>  drivers/net/designware.h   |   1 +
>  drivers/net/dwmac_socfpga.c| 121 +
>  drivers/net/phy/altr_tse_pcs.c | 197 
> +
>  drivers/net/phy/altr_tse_pcs.h |  59 
>  6 files changed, 385 insertions(+), 1 deletion(-)
>  create mode 100644 drivers/net/phy/altr_tse_pcs.c
>  create mode 100644 drivers/net/phy/altr_tse_pcs.h
> 
> diff --git a/drivers/net/Makefile b/drivers/net/Makefile
> index 48a2878..c2333b5 100644
> --- a/drivers/net/Makefile
> +++ b/drivers/net/Makefile
> @@ -14,7 +14,7 @@ obj-$(CONFIG_CALXEDA_XGMAC) += calxedaxgmac.o
>  obj-$(CONFIG_CS8900) += cs8900.o
>  obj-$(CONFIG_TULIP) += dc2114x.o
>  obj-$(CONFIG_ETH_DESIGNWARE) += designware.o
> -obj-$(CONFIG_ETH_DESIGNWARE_SOCFPGA) += dwmac_socfpga.o
> +obj-$(CONFIG_ETH_DESIGNWARE_SOCFPGA) += dwmac-socfpga.o

Huh? What's this change for?

Also, I'm getting these compile errors against the latest U-Boot, top
commit = "284b27cf81da10d55 Merge branch 'master' of
git://git.denx.de/u-boot-mips"   :

drivers/net/dwmac_socfpga.c: In function ‘socfpga_dw_tse_pcs_init’:
drivers/net/dwmac_socfpga.c:67:9: warning: implicit declaration of
function ‘mbox_get_fpga_config_status’ [-Wimplicit-function-declaration]
   ret = mbox_get_fpga_config_status(MBOX_CONFIG_STATUS);
 ^~~
  LD  common/built-in.o
  LD  drivers/net/dwmac-socfpga.o
  LD  drivers/net/built-in.o
  LD  cmd/built-in.o
  CC  lib/smbios.o
  CC  lib/display_options.o
  CC  lib/efi_loader/efi_reloc.o
  CC  lib/efi_loader/helloworld.o
  LD  lib/efi_loader/helloworld_efi.so
  OBJCOPY lib/efi_loader/helloworld.efi
rm lib/efi_loader/helloworld_efi.so lib/efi_loader/helloworld.o
  LD  lib/built-in.o
  LD  u-boot
drivers/net/built-in.o: In function `dwmac_socfpga_ofdata_to_platdata':
/home/dinguyen/linux_dev/u-boot/drivers/net/dwmac_socfpga.c:170:
undefined reference to `syscon_node_to_regmap'
/home/dinguyen/linux_dev/u-boot/drivers/net/dwmac_socfpga.c:177:
undefined reference to `regmap_get_range'
drivers/net/built-in.o: In function `socfpga_dw_tse_pcs_init':
/home/dinguyen/linux_dev/u-boot/drivers/net/dwmac_socfpga.c:67:
undefined reference to `mbox_get_fpga_config_status'


In the future, please test before submitting patches.

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


Re: [U-Boot] [PATCH] DW SPI: Allow to overload the management of the external CS

2018-09-25 Thread Alexandre Belloni
Hi,

On 25/09/2018 15:17:31+0200, Gregory CLEMENT wrote:
> On some platforms, as the Ocelot ones, when wanting to control the CS
> through software, it is not possible to do it through the GPIO
> controller. Indeed, this signal is managed through a dedicated range of
> registers inside the SoC..
> 
> By declaring the external_cs_manage function as weak, it is possible to
> manage the CS at platform level and then using the appropriate registers.
> 
> Signed-off-by: Gregory CLEMENT 
> ---
>  drivers/spi/designware_spi.c | 8 +++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/spi/designware_spi.c b/drivers/spi/designware_spi.c
> index d8b73ea326..fe6e753bff 100644
> --- a/drivers/spi/designware_spi.c
> +++ b/drivers/spi/designware_spi.c
> @@ -334,7 +334,13 @@ static int poll_transfer(struct dw_spi_priv *priv)
>   return 0;
>  }
>  
> -static void external_cs_manage(struct udevice *dev, bool on)
> +/*
> + * We define external_cs_manage function as 'weak' as some targets
> + * (like OCELOT) don't control the external CS pin using a GPIO

MSCC Ocelot maybe?

> + * controller. These SoCs use specific registers to controll by
   ^ control

> + * software the SPI pins (and especially the CS).
> + */
> +__weak void external_cs_manage(struct udevice *dev, bool on)
>  {
>  #if defined(CONFIG_DM_GPIO) && !defined(CONFIG_SPL_BUILD)
>   struct dw_spi_priv *priv = dev_get_priv(dev->parent);
> -- 
> 2.19.0
> 

-- 
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 0/6] Add support for VCore III SoCs found in Microsemi switches

2018-09-25 Thread Gregory CLEMENT
Hi,
 
 On mar., sept. 25 2018, Gregory CLEMENT  wrote:

> Hello,
>
> This series add the support of 2 SoCs: Ocelot and Luton from
> Microsemi. Both of them belongs to the same family Vcore III.
>
> We found them on various advanced switches product.
>
> The support for Ocelot already have been submit to Linux, but not yet
> the Luton support.
>
> Besides this series 3 others patches are needed but they are driver
> related:
> DW SPI: Allow to overload the management of the external CS
> gpio: mscc-bitbang-spi: Add a simple gpio driver for bitbgang spi
> pinctrl: mscc: Add gpio and pinctrl driver for MSCC MIPS SoCs (VcoreIII based)
>
> They will be submitted separately.
>
> Thanks,
>
> Gregory
>
>
> Gregory CLEMENT (6):
>   MIPS: move create_tlb() in an proper header: mipsregs.h

>   MSCC: add support for VCoreIII SoCs
This patch didn't reach the mailing because it was too large. Actually,
many defined were not used, so I removed then, and I am going to send
the missing patch now.

Gregory


>   MSCC: add board support for the VCoreIII based evaluation boards
>   MSCC: add device tree for Ocelot and Luton (boards and SoCs)
>   MSCC: add configuration for Ocelot and Luton based boards
>   MIPS: bootm: Add support for Vcore III linux kernel
>
>  arch/mips/Kconfig |   6 +
>  arch/mips/Makefile|   1 +
>  arch/mips/cpu/cpu.c   |  10 -
>  arch/mips/dts/luton_pcb091.dts|  36 +
>  arch/mips/dts/mscc,luton.dtsi |  87 ++
>  arch/mips/dts/mscc,ocelot.dtsi| 132 +++
>  arch/mips/dts/mscc,ocelot_pcb.dtsi|  37 +
>  arch/mips/dts/ocelot_pcb120.dts   |  12 +
>  arch/mips/dts/ocelot_pcb123.dts   |  12 +
>  arch/mips/include/asm/mipsregs.h  |  11 +
>  arch/mips/lib/bootm.c |  62 +-
>  arch/mips/mach-mscc/Kconfig   | 101 ++
>  arch/mips/mach-mscc/Makefile  |   6 +
>  arch/mips/mach-mscc/cpu.c |  72 ++
>  arch/mips/mach-mscc/dram.c|  62 ++
>  arch/mips/mach-mscc/include/ioremap.h |  49 +
>  arch/mips/mach-mscc/include/mach/cache.h  |  36 +
>  arch/mips/mach-mscc/include/mach/common.h |  31 +
>  arch/mips/mach-mscc/include/mach/ddr.h| 753 +++
>  .../mips/mach-mscc/include/mach/luton/luton.h |  37 +
>  .../include/mach/luton/luton_devcpu_gcb.h |  16 +
>  .../include/mach/luton/luton_icpu_cfg-ref.h   | 884 ++
>  .../include/mach/luton/luton_icpu_cfg.h   | 247 +
>  .../mach-mscc/include/mach/ocelot/ocelot.h|  35 +
>  .../include/mach/ocelot/ocelot_devcpu_gcb.h   | 353 +++
>  .../include/mach/ocelot/ocelot_icpu_cfg.h | 884 ++
>  arch/mips/mach-mscc/include/mach/tlb.h|  65 ++
>  arch/mips/mach-mscc/lowlevel_init.S   |  29 +
>  arch/mips/mach-mscc/lowlevel_init_luton.S |  63 ++
>  arch/mips/mach-mscc/reset.c   |  37 +
>  board/mscc/common/board.c |  29 +
>  board/mscc/luton/Kconfig  |  14 +
>  board/mscc/luton/Makefile |   4 +
>  board/mscc/luton/luton.c  |  14 +
>  board/mscc/ocelot/Kconfig |  24 +
>  board/mscc/ocelot/Makefile|   5 +
>  board/mscc/ocelot/ocelot.c|  38 +
>  configs/mscc_luton_defconfig  |  66 ++
>  configs/mscc_ocelot_defconfig |  57 ++
>  configs/mscc_ocelot_pcb120_defconfig  |  56 ++
>  include/configs/vcoreiii.h|  72 ++
>  41 files changed, 4515 insertions(+), 30 deletions(-)
>  create mode 100644 arch/mips/dts/luton_pcb091.dts
>  create mode 100644 arch/mips/dts/mscc,luton.dtsi
>  create mode 100644 arch/mips/dts/mscc,ocelot.dtsi
>  create mode 100644 arch/mips/dts/mscc,ocelot_pcb.dtsi
>  create mode 100644 arch/mips/dts/ocelot_pcb120.dts
>  create mode 100644 arch/mips/dts/ocelot_pcb123.dts
>  create mode 100644 arch/mips/mach-mscc/Kconfig
>  create mode 100644 arch/mips/mach-mscc/Makefile
>  create mode 100644 arch/mips/mach-mscc/cpu.c
>  create mode 100644 arch/mips/mach-mscc/dram.c
>  create mode 100644 arch/mips/mach-mscc/include/ioremap.h
>  create mode 100644 arch/mips/mach-mscc/include/mach/cache.h
>  create mode 100644 arch/mips/mach-mscc/include/mach/common.h
>  create mode 100644 arch/mips/mach-mscc/include/mach/ddr.h
>  create mode 100644 arch/mips/mach-mscc/include/mach/luton/luton.h
>  create mode 100644 arch/mips/mach-mscc/include/mach/luton/luton_devcpu_gcb.h
>  create mode 100644 
> arch/mips/mach-mscc/include/mach/luton/luton_icpu_cfg-ref.h
>  create mode 100644 arch/mips/mach-mscc/include/mach/luton/luton_icpu_cfg.h
>  create mode 100644 arch/mips/mach-mscc/include/mach/ocelot/ocelot.h
>  create mode 100644 
> arch/mips/mach-mscc/include/mach/ocelot/ocelot_devcpu_gcb.h
>  create mode 100644 arch/mips/mach-

[U-Boot] [PATCH 2/6] MSCC: add support for VCoreIII SoCs

2018-09-25 Thread Gregory CLEMENT
These families of SoCs are found in the Microsemi Switches solution.

Currently the support for two families support is added:
 - Ocelot (VSC7513, VSC7514) already supported in Linux
 - Luton (Luton10: VSC7423, VSC7424, VSC7428 and Luton26: VSC7425,
   VSC7426, VSC7426, VSC7427, VSC7429)

Signed-off-by: Gregory CLEMENT 
---
Hi,

Actually this is the second version of this patch.

Compared to the previous version which did not reach the mailing list,
I remove a lot of unused defines in the header.
They can be add later when needed.

Sorry for the noise

Gregory


 arch/mips/Kconfig |   6 +
 arch/mips/Makefile|   1 +
 arch/mips/mach-mscc/Kconfig   | 101 +++
 arch/mips/mach-mscc/Makefile  |   6 +
 arch/mips/mach-mscc/cpu.c |  72 ++
 arch/mips/mach-mscc/dram.c|  62 ++
 arch/mips/mach-mscc/include/ioremap.h |  49 ++
 arch/mips/mach-mscc/include/mach/cache.h  |  36 +
 arch/mips/mach-mscc/include/mach/common.h |  31 +
 arch/mips/mach-mscc/include/mach/ddr.h| 753 ++
 .../mips/mach-mscc/include/mach/luton/luton.h |  37 +
 .../include/mach/luton/luton_devcpu_gcb.h |  16 +
 .../include/mach/luton/luton_icpu_cfg.h   | 247 ++
 .../mach-mscc/include/mach/ocelot/ocelot.h|  35 +
 .../include/mach/ocelot/ocelot_devcpu_gcb.h   |  49 ++
 .../include/mach/ocelot/ocelot_icpu_cfg.h | 278 +++
 arch/mips/mach-mscc/include/mach/tlb.h|  65 ++
 arch/mips/mach-mscc/lowlevel_init.S   |  29 +
 arch/mips/mach-mscc/lowlevel_init_luton.S |  63 ++
 arch/mips/mach-mscc/reset.c   |  37 +
 20 files changed, 1973 insertions(+)
 create mode 100644 arch/mips/mach-mscc/Kconfig
 create mode 100644 arch/mips/mach-mscc/Makefile
 create mode 100644 arch/mips/mach-mscc/cpu.c
 create mode 100644 arch/mips/mach-mscc/dram.c
 create mode 100644 arch/mips/mach-mscc/include/ioremap.h
 create mode 100644 arch/mips/mach-mscc/include/mach/cache.h
 create mode 100644 arch/mips/mach-mscc/include/mach/common.h
 create mode 100644 arch/mips/mach-mscc/include/mach/ddr.h
 create mode 100644 arch/mips/mach-mscc/include/mach/luton/luton.h
 create mode 100644 arch/mips/mach-mscc/include/mach/luton/luton_devcpu_gcb.h
 create mode 100644 arch/mips/mach-mscc/include/mach/luton/luton_icpu_cfg.h
 create mode 100644 arch/mips/mach-mscc/include/mach/ocelot/ocelot.h
 create mode 100644 arch/mips/mach-mscc/include/mach/ocelot/ocelot_devcpu_gcb.h
 create mode 100644 arch/mips/mach-mscc/include/mach/ocelot/ocelot_icpu_cfg.h
 create mode 100644 arch/mips/mach-mscc/include/mach/tlb.h
 create mode 100644 arch/mips/mach-mscc/lowlevel_init.S
 create mode 100644 arch/mips/mach-mscc/lowlevel_init_luton.S
 create mode 100644 arch/mips/mach-mscc/reset.c

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 6e5e0ffe65..c4fc3d077b 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -58,6 +58,11 @@ config ARCH_ATH79
select OF_CONTROL
imply CMD_DM
 
+config ARCH_MSCC
+   bool "Support MSCC VCore-III"
+   select OF_CONTROL
+   select DM
+
 config ARCH_BMIPS
bool "Support BMIPS SoCs"
select CLK
@@ -118,6 +123,7 @@ source "board/imgtec/xilfpga/Kconfig"
 source "board/micronas/vct/Kconfig"
 source "board/qemu-mips/Kconfig"
 source "arch/mips/mach-ath79/Kconfig"
+source "arch/mips/mach-mscc/Kconfig"
 source "arch/mips/mach-bmips/Kconfig"
 source "arch/mips/mach-pic32/Kconfig"
 
diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index a36f5f1fb6..acb1340942 100644
--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
@@ -14,6 +14,7 @@ libs-y += arch/mips/lib/
 machine-$(CONFIG_ARCH_ATH79) += ath79
 machine-$(CONFIG_ARCH_BMIPS) += bmips
 machine-$(CONFIG_MACH_PIC32) += pic32
+machine-$(CONFIG_ARCH_MSCC) += mscc
 
 machdirs := $(patsubst %,arch/mips/mach-%/,$(machine-y))
 libs-y += $(machdirs)
diff --git a/arch/mips/mach-mscc/Kconfig b/arch/mips/mach-mscc/Kconfig
new file mode 100644
index 00..20148bfe15
--- /dev/null
+++ b/arch/mips/mach-mscc/Kconfig
@@ -0,0 +1,101 @@
+# SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+
+if ARCH_MSCC
+
+config SYS_DCACHE_SIZE
+   default 32768
+
+config SYS_DCACHE_LINE_SIZE
+   default 32
+
+config SYS_ICACHE_SIZE
+   default 32768
+
+config SYS_ICACHE_LINE_SIZE
+   default 32
+
+endif
+
+menu "MSCC VCore-III platforms"
+   depends on ARCH_MSCC
+
+config SOC_VCOREIII
+   select SUPPORTS_LITTLE_ENDIAN
+   select SUPPORTS_BIG_ENDIAN
+   select SUPPORTS_CPU_MIPS32_R1
+   select SUPPORTS_CPU_MIPS32_R2
+   select ROM_EXCEPTION_VECTORS
+   select MIPS_TUNE_24KC
+   bool
+
+config SYS_SOC
+   default "mscc"
+
+config SOC_OCELOT
+   bool
+   select SOC_VCOREIII
+   help
+ This supports MSCC Ocelot family of SOCs.
+
+config SOC_LUTON
+   bool
+   select SOC_VCOREIII
+   help
+ This supports MSCC Luton famil

Re: [U-Boot] [PATCH 1/6] ofnode: Add missing address translation into ofnode_get_addr_size()

2018-09-25 Thread Bin Meng
Hi Marek,

On Sat, Sep 22, 2018 at 6:59 AM Marek Vasut  wrote:
>
> Of CONFIG_OF_TRANSLATE is enabled, this function still returns
> untranslated bogus results. Add the missing translation.
>
> Signed-off-by: Marek Vasut 
> Cc: Simon Glass 
> Cc: Tom Rini 
> ---
>  drivers/core/ofnode.c | 9 -
>  1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c
> index a7e1927723..035023ca91 100644
> --- a/drivers/core/ofnode.c
> +++ b/drivers/core/ofnode.c
> @@ -542,8 +542,15 @@ fdt_addr_t ofnode_get_addr_size(ofnode node, const char 
> *property,
> return FDT_ADDR_T_NONE;
> na = of_n_addr_cells(np);
> ns = of_n_addr_cells(np);

There is an unrelated bug. It should be:

ns = of_n_size_cells(np);

> +
> *sizep = of_read_number(prop + na, ns);
> -   return of_read_number(prop, na);
> +
> +   if (IS_ENABLED(CONFIG_OF_TRANSLATE) && ns > 0) {
> +   return of_translate_address(ofnode_to_np(node), prop);

Just use np instead of ofnode_to_np(node)

> +   } else {
> +   na = of_n_addr_cells(ofnode_to_np(node));

This line is unnecessary.

> +   return of_read_number(prop, na);
> +   }
> } else {
> return fdtdec_get_addr_size(gd->fdt_blob,
> ofnode_to_offset(node), property,
> --

However, I have to point out that this patch (along with the unrelated
bug I pointed out above) is not related to "support parsing PCI
controller DT subnodes". Both of_translate_address() and
of_read_number() are not designed to handle PCI-specific address
formats. See my comments in patch 3 and 5.

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


Re: [U-Boot] [PATCH 2/6] pci: Check ops before using them for config space access

2018-09-25 Thread Bin Meng
Hi Marek,

On Sat, Sep 22, 2018 at 7:00 AM Marek Vasut  wrote:
>
> The code fails to check if ops is non-NULL before using it's members.
> Add the missing check and while at it, flip the condition to make it
> more obvious what is actually happening.
>

Though adding the NULL pointer check makes the codes more robust, I
would like to know with what calling sequence current codes are
broken? I did a grep and looks every PCI controller driver registers a
non-NULL dm_pci_ops so the ops can't be NULL, which means adding the
check seems unnecessary.

> Signed-off-by: Marek Vasut 
> Cc: Simon Glass 
> Cc: Tom Rini 
> ---
>  drivers/pci/pci-uclass.c | 12 ++--
>  1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c
> index eb118f3496..de523a76ad 100644
> --- a/drivers/pci/pci-uclass.c
> +++ b/drivers/pci/pci-uclass.c
> @@ -241,9 +241,9 @@ int pci_bus_write_config(struct udevice *bus, pci_dev_t 
> bdf, int offset,
> struct dm_pci_ops *ops;
>
> ops = pci_get_ops(bus);
> -   if (!ops->write_config)
> -   return -ENOSYS;
> -   return ops->write_config(bus, bdf, offset, value, size);
> +   if (ops && ops->write_config)
> +   return ops->write_config(bus, bdf, offset, value, size);
> +   return -ENOSYS;
>  }
>
>  int pci_bus_clrset_config32(struct udevice *bus, pci_dev_t bdf, int offset,
> @@ -321,9 +321,9 @@ int pci_bus_read_config(struct udevice *bus, pci_dev_t 
> bdf, int offset,
> struct dm_pci_ops *ops;
>
> ops = pci_get_ops(bus);
> -   if (!ops->read_config)
> -   return -ENOSYS;
> -   return ops->read_config(bus, bdf, offset, valuep, size);
> +   if (ops && ops->read_config)
> +   return ops->read_config(bus, bdf, offset, valuep, size);
> +   return -ENOSYS;
>  }
>
>  int pci_read_config(pci_dev_t bdf, int offset, unsigned long *valuep,
> --

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


Re: [U-Boot] [PATCH 4/6] pci: Update documentation to make 'compatible' string optional

2018-09-25 Thread Bin Meng
On Sat, Sep 22, 2018 at 7:02 AM Marek Vasut  wrote:
>
> Reword the documentation to make it clear the compatible string is now
> optional, yet still matching on it takes precedence over PCI IDs and
> PCI classes.
>
> Signed-off-by: Marek Vasut 
> Cc: Simon Glass 
> Cc: Tom Rini 
> ---
>  doc/driver-model/pci-info.txt | 14 +-
>  1 file changed, 9 insertions(+), 5 deletions(-)
>

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


Re: [U-Boot] [PATCH 5/6] test: Add PCI device entry without compat string and with DT node

2018-09-25 Thread Bin Meng
Hi Marek,

On Sat, Sep 22, 2018 at 7:02 AM Marek Vasut  wrote:
>
> Add PCI entry without compatible string and with a DT node only with
> reg = <...> property into the DT. This is needed for the tests to
> verify whether such a setup creates an U-Boot PCI device with the
> DT node associated with it in udevice.node.
>
> Signed-off-by: Marek Vasut 
> Cc: Simon Glass 
> Cc: Tom Rini 
> ---
>  arch/sandbox/dts/test.dts | 9 +++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
> index b8524e3b7d..c13a270c2e 100644
> --- a/arch/sandbox/dts/test.dts
> +++ b/arch/sandbox/dts/test.dts
> @@ -354,9 +354,14 @@
> #address-cells = <3>;
> #size-cells = <2>;
> ranges = <0x0200 0 0x3000 0x3000 0 0x2000
> -   0x0100 0 0x4000 0x4000 0 0x2000>;
> + 0x0100 0 0x4000 0x4000 0 0x2000
> + 0x8000 0 0x 0x8000 0 0x2000>;

Adding this line makes no sense. You can't translate a PCI bus
configuration space address (0x8000) to something in its parent bus's
(MMIO) address space. See my related comments in patch 1 and 3.

> sandbox,dev-info = <0x08 0x00 0x1234 0x5678
> -   0x0c 0x00 0x1234 0x5678>;
> +   0x0c 0x00 0x1234 0x5678
> +   0x10 0x00 0x1234 0x5678>;
> +   pci@10,0 {
> +   reg = <0x8000 0 0 0 0>;
> +   };
> };
>
> pci2: pci-controller2 {
> --

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


Re: [U-Boot] [PATCH 6/6] test: Add test for PCI device without compat string and with DT node

2018-09-25 Thread Bin Meng
On Sat, Sep 22, 2018 at 7:02 AM Marek Vasut  wrote:
>
> Add test which checks if a PCI device described in DT with an
> entry and reg = <...> property, but without compatible string
> results in a valid U-Boot PCI udevice with the udevice.node
> populated with reference to this DT node. Also check if the
> other PCI device without a DT node does not contain any bogus
> udevice.node.
>
> Signed-off-by: Marek Vasut 
> Cc: Simon Glass 
> Cc: Tom Rini 
> ---
>  test/dm/pci.c | 5 +
>  1 file changed, 5 insertions(+)
>

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


Re: [U-Boot] [PATCH 3/6] pci: Support parsing PCI controller DT subnodes

2018-09-25 Thread Bin Meng
Hi Marek,

On Sat, Sep 22, 2018 at 7:00 AM Marek Vasut  wrote:
>
> The PCI controller can have DT subnodes describing extra properties
> of particular PCI devices, ie. a PHY attached to an EHCI controller
> on a PCI bus. This patch parses those DT subnodes and assigns a node
> to the PCI device instance, so that the driver can extract details
> from that node and ie. configure the PHY using the PHY subsystem.
>
> Signed-off-by: Marek Vasut 
> Cc: Simon Glass 
> Cc: Tom Rini 
> ---
>  drivers/pci/pci-uclass.c | 30 +++---
>  1 file changed, 27 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c
> index de523a76ad..e274632428 100644
> --- a/drivers/pci/pci-uclass.c
> +++ b/drivers/pci/pci-uclass.c
> @@ -90,6 +90,25 @@ int pci_get_ff(enum pci_size_t size)
> }
>  }
>
> +static void pci_dev_find_ofnode(struct udevice *bus, phys_addr_t bdf,
> +   ofnode *rnode)
> +{
> +   ofnode node;
> +
> +   dev_for_each_subnode(node, bus) {
> +   phys_addr_t df, size;
> +   df = ofnode_get_addr_size(node, "reg", &size);

Using API ofnode_get_addr_size() is wrong. It cannot handle
PCI-specific address formats. I understand why you added "0x8000 0
0x 0x8000 0 0x2000" to the bus ranges property in patch 5,
is to make ofnode_get_addr_size() work, but that's the wrong approach.
The correct API should be ofnode_read_pci_addr(). To call it like
this:

ret = ofnode_read_pci_addr(node, FDT_PCI_SPACE_CONFIG, "reg", &addr);
if (!ret)
df = addr.phys_hi & 0xff00;

> +   if (df == FDT_ADDR_T_NONE)
> +   continue;
> +
> +   if (PCI_MASK_BUS(df) != PCI_MASK_BUS(bdf))
> +   continue;
> +
> +   *rnode = node;
> +   break;
> +   }
> +};
> +
>  int pci_bus_find_devfn(struct udevice *bus, pci_dev_t find_devfn,
>struct udevice **devp)
>  {
> @@ -641,6 +660,7 @@ static int pci_find_and_bind_driver(struct udevice 
> *parent,
> pci_dev_t bdf, struct udevice **devp)
>  {
> struct pci_driver_entry *start, *entry;
> +   ofnode node = ofnode_null();
> const char *drv;
> int n_ents;
> int ret;
> @@ -651,6 +671,10 @@ static int pci_find_and_bind_driver(struct udevice 
> *parent,
>
> debug("%s: Searching for driver: vendor=%x, device=%x\n", __func__,
>   find_id->vendor, find_id->device);
> +
> +   /* Determine optional OF node */
> +   pci_dev_find_ofnode(parent, bdf, &node);
> +
> start = ll_entry_start(struct pci_driver_entry, pci_driver_entry);
> n_ents = ll_entry_count(struct pci_driver_entry, pci_driver_entry);
> for (entry = start; entry != start + n_ents; entry++) {
> @@ -684,8 +708,8 @@ static int pci_find_and_bind_driver(struct udevice 
> *parent,
>  * find another driver. For now this doesn't seem
>  * necesssary, so just bind the first match.
>  */
> -   ret = device_bind(parent, drv, drv->name, NULL, -1,
> - &dev);
> +   ret = device_bind_ofnode(parent, drv, drv->name, NULL,
> +node, &dev);
> if (ret)
> goto error;
> debug("%s: Match found: %s\n", __func__, drv->name);
> @@ -712,7 +736,7 @@ static int pci_find_and_bind_driver(struct udevice 
> *parent,
> return -ENOMEM;
> drv = bridge ? "pci_bridge_drv" : "pci_generic_drv";
>
> -   ret = device_bind_driver(parent, drv, str, devp);
> +   ret = device_bind_driver_to_node(parent, drv, str, node, devp);
> if (ret) {
> debug("%s: Failed to bind generic driver: %d\n", __func__, 
> ret);
> free(str);
> --

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


Re: [U-Boot] [PATCH v2 2/2] pico-imx6ul, pico-imx7d: Enable USB and PXE boot support

2018-09-25 Thread Fabio Estevam
On Tue, Sep 25, 2018 at 11:41 AM, Otavio Salvador
 wrote:

>  #include 
> diff --git a/include/configs/pico-imx7d.h b/include/configs/pico-imx7d.h
> index 614be99d93..2bc42a04a0 100644
> --- a/include/configs/pico-imx7d.h
> +++ b/include/configs/pico-imx7d.h
> @@ -92,6 +92,8 @@
>
>  #define BOOT_TARGET_DEVICES(func) \
> func(MMC, mmc, 0) \
> +   func(USB, usb, 0) \

We still need to add USB host suport for this board, but this can be
done in a separate patch:

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


[U-Boot] chain-loading u-boot from u-boot?

2018-09-25 Thread rpjday

  colleague just asked me how to (if possible) chain-load a modified
u-boot from a u-boot currently stored in flash, and from having done
this once *years* ago, i'm fairly sure i can make this happen, i just
want to confirm my plan. (the current running version is based off of
u-boot v2015.07 -- i have no freedom to change that.)

  the newer u-boot will do nothing more than add a couple commands
("mii" and "mdio"), and i've already tweaked the configuration to
add those commands to the configuration, compiled and verified that
those commands are now listed in the u-boot.map file, so that part
seems fine.

  at this point, i've been told that there is a proprietary pre-boot
loader in ROM which, among other things, loads u-boot from flash
into RAM and jumps to that address -- i assume, at that point, i
just need to download my new u-boot binary from the server to
some address in RAM currently *not* occupied by u-boot, and "go"
to that new address.

  my only question is, what do i change in the configuration to
identify where i will load the enhanced u-boot? i vaguely recall
that i need to change the text base, and load the new binary at
precisely that address, is that correct?

  finally (as an aside), i've read a number of pieces online
that describe how the second u-boot should try to avoid doing
low-level H/W initialization that the first has already done,
but for now, i'm just going to assume idempotency for all of
that early initialization unless proven wrong.

  so ... what must i change in the config to support loading
the new version of u-boot at a different address? thanks.

rday


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


Re: [U-Boot] [PATCH v1 0/4] Add USB EHCI and gadget support for STM32MP1

2018-09-25 Thread Patrice CHOTARD
Hi

It's a gentle reminder to not forget thise series for U-boot 2018.11
release.

Thanks

Patrice

On 08/10/2018 05:12 PM, Patrice Chotard wrote:
> 
> This series :
>   - Adds DT nodes to add usb gadget support for stm32mp157-ev1 board
>   - Adds DT nodes to add EHCI support for stm32mp157-ev1 board
>   - Enables all USB relative flags needed for USB EHCI, DWC2 gadget and
> mass storage support
>   - Update stm32mp1 board by populating board_usb_init() to initialize
> USB gadget driver
> 
> 
> Patrice Chotard (4):
>   ARM: dts: stm32mp1: Add usb gadget support for stm32mp157c-ev1 board
>   ARM: dts: stm32mp1: Add EHCI support for stm32mp157c-ev1 board
>   configs: stm32mp15: Enable USB relative flags
>   board: st: stm32mp1: Add usb gadget support
> 
>  arch/arm/dts/stm32mp157-pinctrl.dtsi |   6 ++
>  arch/arm/dts/stm32mp157c-ev1-u-boot.dtsi |   5 +
>  arch/arm/dts/stm32mp157c-ev1.dts |  15 +++
>  arch/arm/dts/stm32mp157c.dtsi|  36 +++
>  board/st/stm32mp1/stm32mp1.c | 168 
> +++
>  configs/stm32mp15_basic_defconfig|  16 +++
>  6 files changed, 246 insertions(+)
> 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] fsl-lsch3: soc: Enable AHB support flexspi controller

2018-09-25 Thread York Sun
On 09/25/2018 01:44 AM, Ashish Kumar wrote:
> Enable AHB support for flexspi controller interface meaning
> memory can be accessed via md command using absolute addresses
> 
> Signed-off-by: Yogesh Gaur 
> Signed-off-by: Rajat Srivastava 
> Signed-off-by: Ashish Kumar 
> ---
>  arch/arm/cpu/armv8/fsl-layerscape/Kconfig | 10 ++
>  arch/arm/cpu/armv8/fsl-layerscape/soc.c   | 42 +++
>  2 files changed, 52 insertions(+)
> 
> diff --git a/arch/arm/cpu/armv8/fsl-layerscape/Kconfig 
> b/arch/arm/cpu/armv8/fsl-layerscape/Kconfig
> index 5280d33ec8..8d66783b7c 100644
> --- a/arch/arm/cpu/armv8/fsl-layerscape/Kconfig
> +++ b/arch/arm/cpu/armv8/fsl-layerscape/Kconfig
> @@ -327,6 +327,16 @@ config SYS_FSPI_AHB_INIT
> performed. Default LUT programmed in AHB mode is Fast Read command
> with 4-byte addressing enabled.
>  
> +config FSPI_AHB_EN_4BYTE
> + bool "Enable 4-byte Fast Read cmd for AHB mode"

s/cmd/command

> + depends on NXP_FSPI
> + default n
> + help
> +   The default setting for FSPI AHB bus just supports 3-byte addressing.
> +   But some FSPI flash sizes are up to 64MBytes.
> +   This flag enables fast read cmd for AHB mode and modifies required
> +   LUT to support full FSPI flash.
> +

It is FlexSPI, not FSPI, nor flexspi. Please use consistent term for
FlexSPI in subject, commit message, document and comment. If you have to
use FSPI in macro names, make sure it it has clear meaning.

>  config SYS_CCI400_OFFSET
>   hex "Offset for CCI400 base"
>   depends on SYS_FSL_HAS_CCI400
> diff --git a/arch/arm/cpu/armv8/fsl-layerscape/soc.c 
> b/arch/arm/cpu/armv8/fsl-layerscape/soc.c
> index 3f15cb08ff..60beb0dc96 100644
> --- a/arch/arm/cpu/armv8/fsl-layerscape/soc.c
> +++ b/arch/arm/cpu/armv8/fsl-layerscape/soc.c
> @@ -640,6 +640,45 @@ void fsl_lsch2_early_init_f(void)
>  }
>  #endif
>  
> +#ifdef CONFIG_FSPI_AHB_EN_4BYTE
> +int fspi_ahb_init(void)
> +{
> + /* Enable 4bytes address support and fast read */
> + u32 *fspi_lut, lut_key, *fspi_key;
> +
> + fspi_key = (void *)SYS_FSL_FSPI_ADDR + 0x18;
> + fspi_lut = (void *)SYS_FSL_FSPI_ADDR + 0x200;
> +
> + lut_key = in_be32(fspi_key);
> +
> + if (lut_key == 0x5af05af0) {
> + /* That means the register is BE */
> + out_be32(fspi_key, 0x5af05af0);
> + /* Unlock the lut table */
> + out_be32(fspi_key + 1, 0x0002);
> + out_be32(fspi_lut, 0x0820040c);
> + out_be32(fspi_lut + 1, 0x24003008);
> + out_be32(fspi_lut + 2, 0x);
> + /* Lock the lut table */
> + out_be32(fspi_key, 0x5af05af0);
> + out_be32(fspi_key + 1, 0x0001);
> + } else {
> + /* That means the register is LE */
> + out_le32(fspi_key, 0x5af05af0);
> + /* Unlock the lut table */
> + out_le32(fspi_key + 1, 0x0002);
> + out_le32(fspi_lut, 0x0820040c);
> + out_le32(fspi_lut + 1, 0x24003008);
> + out_le32(fspi_lut + 2, 0x);
> + /* Lock the lut table */
> + out_le32(fspi_key, 0x5af05af0);
> + out_le32(fspi_key + 1, 0x0001);

Is there anyway you can make the magic numbers more meaningful?

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


Re: [U-Boot] [PATCH v9 8/8] Enable CONFIG_BLK and CONFIG_DM_MMC to Kconfig

2018-09-25 Thread York Sun
On 09/24/2018 11:51 PM, Yinbo Zhu wrote:
> This enables the folowing to Kconfig:
>   CONFIG_BLK
>   CONFIG_DM_MMC
> 
> Signed-off-by: Yinbo Zhu 
> ---
> Change in v9:
>   fix ls1021atwr_sdcard_ifc_SECURE_BOOT_defconfig compiling errors

You didn't "fix" it. You simply dropped the change to
ls1021atwr_sdcard_ifc_SECURE_BOOT_defconfig. Do you know why
ls1021atwr_nor_SECURE_BOOT_defconfig and ls1021atwr_sdcard_ifc_defconfig
work, but not ls1021atwr_sdcard_ifc_SECURE_BOOT_defconfig?

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


Re: [U-Boot] [PATCH v2 1/3] qe: kconfig: U QE kconfig

2018-09-25 Thread York Sun
On 09/24/2018 11:45 PM, Ran Wang wrote:
> add Kconfig option for U QUICC Engine.
> 
> Signed-off-by: Ran Wang 
> ---
> Change in v2:
>   Add more conditional define to support more platforms.
> 
>  drivers/Kconfig|  2 ++
>  drivers/qe/Kconfig | 12 
>  2 files changed, 14 insertions(+)
>  create mode 100644 drivers/qe/Kconfig
> 
> diff --git a/drivers/Kconfig b/drivers/Kconfig
> index 56536c4b19..884a945a19 100644
> --- a/drivers/Kconfig
> +++ b/drivers/Kconfig
> @@ -74,6 +74,8 @@ source "drivers/power/Kconfig"
>  
>  source "drivers/pwm/Kconfig"
>  
> +source "drivers/qe/Kconfig"
> +
>  source "drivers/ram/Kconfig"
>  
>  source "drivers/remoteproc/Kconfig"
> diff --git a/drivers/qe/Kconfig b/drivers/qe/Kconfig
> new file mode 100644
> index 00..c47b54ab12
> --- /dev/null
> +++ b/drivers/qe/Kconfig
> @@ -0,0 +1,12 @@
> +#
> +# QUICC Engine Drivers
> +#
> +config  U_QE

Did you notice you have extra space here?

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


Re: [U-Boot] [PATCH v2 2/3] arm: layerscape: Remove CONFIG_U_QE define in head files

2018-09-25 Thread York Sun
On 09/24/2018 11:45 PM, Ran Wang wrote:
> Because it has been moved to drivers/qe/Kconfig instead.
> Following platforms are involved:
> T102xQDS, T102xRDB, T1040QDS, ls1021aqds, ls1021atwr, ls1043ardb
> 
> Signed-off-by: Ran Wang 
> ---
> Change in v2:
>   Remove CONFIG_U_QE from more platforms besides ls1021a
> 
>  include/configs/T102xQDS.h   | 1 -
>  include/configs/T102xRDB.h   | 1 -
>  include/configs/T1040QDS.h   | 1 -
>  include/configs/ls1021aqds.h | 1 -
>  include/configs/ls1021atwr.h | 1 -
>  include/configs/ls1043ardb.h | 7 ---
>  6 files changed, 12 deletions(-)

After removing all defines, please remove it from config_whitelist.txt.

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


Re: [U-Boot] [PATCH] net: phy: add TSE PCS support to dwmac-socfpga

2018-09-25 Thread Dinh Nguyen


On 09/25/2018 10:00 AM, Dinh Nguyen wrote:
> 
> 
> On 09/25/2018 01:24 AM, Ooi, Joyce wrote:
>> This adds support for TSE PCS that uses SGMII adapter when the
>> phy-mode in device tree is set to sgmii.
> 
> Can you add a bit more description to your commit message? TSE(Triple
> Speed Ethernet), but what is PCS?
> 
>>
>> Signed-off-by: Ooi, Joyce 
>> ---
>>  drivers/net/Makefile   |   3 +-
>>  drivers/net/designware.c   |   5 ++
>>  drivers/net/designware.h   |   1 +
>>  drivers/net/dwmac_socfpga.c| 121 +
>>  drivers/net/phy/altr_tse_pcs.c | 197 
>> +
>>  drivers/net/phy/altr_tse_pcs.h |  59 
>>  6 files changed, 385 insertions(+), 1 deletion(-)
>>  create mode 100644 drivers/net/phy/altr_tse_pcs.c
>>  create mode 100644 drivers/net/phy/altr_tse_pcs.h
>>
>> diff --git a/drivers/net/Makefile b/drivers/net/Makefile
>> index 48a2878..c2333b5 100644
>> --- a/drivers/net/Makefile
>> +++ b/drivers/net/Makefile
>> @@ -14,7 +14,7 @@ obj-$(CONFIG_CALXEDA_XGMAC) += calxedaxgmac.o
>>  obj-$(CONFIG_CS8900) += cs8900.o
>>  obj-$(CONFIG_TULIP) += dc2114x.o
>>  obj-$(CONFIG_ETH_DESIGNWARE) += designware.o
>> -obj-$(CONFIG_ETH_DESIGNWARE_SOCFPGA) += dwmac_socfpga.o
>> +obj-$(CONFIG_ETH_DESIGNWARE_SOCFPGA) += dwmac-socfpga.o
> 
> Huh? What's this change for?
> 
> Also, I'm getting these compile errors against the latest U-Boot, top
> commit = "284b27cf81da10d55 Merge branch 'master' of
> git://git.denx.de/u-boot-mips"   :
> 
> drivers/net/dwmac_socfpga.c: In function ‘socfpga_dw_tse_pcs_init’:
> drivers/net/dwmac_socfpga.c:67:9: warning: implicit declaration of
> function ‘mbox_get_fpga_config_status’ [-Wimplicit-function-declaration]
>ret = mbox_get_fpga_config_status(MBOX_CONFIG_STATUS);
>  ^~~
>   LD  common/built-in.o
>   LD  drivers/net/dwmac-socfpga.o
>   LD  drivers/net/built-in.o
>   LD  cmd/built-in.o
>   CC  lib/smbios.o
>   CC  lib/display_options.o
>   CC  lib/efi_loader/efi_reloc.o
>   CC  lib/efi_loader/helloworld.o
>   LD  lib/efi_loader/helloworld_efi.so
>   OBJCOPY lib/efi_loader/helloworld.efi
> rm lib/efi_loader/helloworld_efi.so lib/efi_loader/helloworld.o
>   LD  lib/built-in.o
>   LD  u-boot
> drivers/net/built-in.o: In function `dwmac_socfpga_ofdata_to_platdata':
> /home/dinguyen/linux_dev/u-boot/drivers/net/dwmac_socfpga.c:170:
> undefined reference to `syscon_node_to_regmap'
> /home/dinguyen/linux_dev/u-boot/drivers/net/dwmac_socfpga.c:177:
> undefined reference to `regmap_get_range'
> drivers/net/built-in.o: In function `socfpga_dw_tse_pcs_init':
> /home/dinguyen/linux_dev/u-boot/drivers/net/dwmac_socfpga.c:67:
> undefined reference to `mbox_get_fpga_config_status'
> 
> 
> In the future, please test before submitting patches.
> 

For the arria10 defconfig, I get the following compile error:

drivers/net/dwmac_socfpga.c: In function ‘socfpga_dw_tse_pcs_init’:
drivers/net/dwmac_socfpga.c:67:9: warning: implicit declaration of
function ‘mbox_get_fpga_config_status’ [-Wimplicit-function-declaration]
   ret = mbox_get_fpga_config_status(MBOX_CONFIG_STATUS);
 ^~~
drivers/net/dwmac_socfpga.c:74:3: error: too many arguments to function
‘socfpga_bridges_reset’
   socfpga_bridges_reset(1);
   ^
In file included from ./arch/arm/include/asm/arch/reset_manager.h:44:0,
 from drivers/net/dwmac_socfpga.c:21:
./arch/arm/include/asm/arch/reset_manager_arria10.h:15:5: note: declared
here
 int socfpga_bridges_reset(void);

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


Re: [U-Boot] [PATCH v3 6/8] powerpc: mpc85xx: Use binman to embed dtb inside U-Boot

2018-09-25 Thread York Sun
On 09/02/2018 10:08 PM, Jagdish Gediya wrote:
> Below is the sequence to embed dtb inside U-Boot,
> 1. Remove bootpg and resetvec section if needed
> 2. Append dtb
> 3. Append bootpg and resetvec section back if removed in step 1
> 
> Above procedure is required only when CONFIG_MPC85xx and
> CONFIG_OF_SEPARATE are defined.
> 
> Add new config CONFIG_MPC85XX_HAVE_RESET_VECTOR to indicate that
> image has resetvec section. Step 1 and step 3 described above are
> required only if this config is y.
> 
> Signed-off-by: Jagdish Gediya 
> ---
> Changes for v2:
>   - Don't change the generic target
>   - Add new config option to use binman
> 
> Changes for v3:
>   - Commit message change('u-boot' -> 'U-Boot')
> 
>  Makefile | 23 ++-
>  arch/powerpc/cpu/mpc85xx/Kconfig |  4 
>  2 files changed, 26 insertions(+), 1 deletion(-)
> 
> diff --git a/Makefile b/Makefile
> index b5bf8ab..03baa74 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -861,6 +861,10 @@ ifneq ($(CONFIG_SYS_INIT_SP_BSS_OFFSET),)
>  ALL-y += init_sp_bss_offset_check
>  endif
>  
> +ifeq ($(CONFIG_MPC85xx)$(CONFIG_OF_SEPARATE),yy)
> +ALL-y += u-boot-with-dtb.bin
> +endif
> +

One thing confuses me is the output file. My understand is we will use
u-boot-with-dtb.bin file. Other files are intermediate files. It would
be helpful to explain each output file, especially for debugging, and
let other know we switch from one file to another after this patch set.

CONFIG_OF_SEPARATE seems not be selected explicitly anywhere. Are we
relying on the first choice to be selected automatically? Is it guaranteed?

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


Re: [U-Boot] [PATCH v4 6/6] common: Generic loader for file system

2018-09-25 Thread Tom Rini
On Tue, Sep 25, 2018 at 07:02:42AM +, Chee, Tien Fong wrote:

> On Thu, 2018-09-20 at 21:42 -0700, Chee, Tien Fong wrote:
> > > 
> If everybody agree with current framework, then the next version i will
> include the fixes:
> 1. Adding DM_FLAG_PRE_RELOC, this would allow runtime to choose the
> right fs_loader if the chosen node u-boot, fs-loader is not defined.
> 
> 2. Let driver model handles all memory allocation
> 
> 3. Using local variable instead of messy casts.

A new version of this series, or a follow up series?  Thanks again!

-- 
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 v4 6/6] common: Generic loader for file system

2018-09-25 Thread Simon Glass
Hi,

On 25 September 2018 at 01:02, Chee, Tien Fong  wrote:
> On Thu, 2018-09-20 at 21:42 -0700, Chee, Tien Fong wrote:
>> >
> If everybody agree with current framework, then the next version i will
> include the fixes:
> 1. Adding DM_FLAG_PRE_RELOC, this would allow runtime to choose the
> right fs_loader if the chosen node u-boot, fs-loader is not defined.
>
> 2. Let driver model handles all memory allocation
>
> 3. Using local variable instead of messy casts.

Sounds good.

Can you please give an example of this? If you just mean within a
function, that's fine. We try to avoid static variables with driver
model.

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


Re: [U-Boot] Fixes the load command return code under btrfs

2018-09-25 Thread Tom Rini
On Thu, Sep 13, 2018 at 06:48:41PM +, Stephane Gilbert wrote:

> Hi,
> 
> I am submitting the following patch to resolve issue below:
> When using the load command with a btrfs filesystem, the return code of
> that command if always success even if the command failed. The problem
> is the do_load command in fs.c who assume any positive return code from
> fs_read as success. However the brtfs read function returns positive
> error code in case of failure. Other fs read fonction like fat and ext4
> returns negative error codes on failure. So this patch change the
> return code of the btrfs read function to be consistent with other read
> functions. This way it will be possible to use the return code in the
> Hush shell with btrfs file systems as with other filesystems.
> 
> >From 8b8141dbdfc43456b85585e99a2dfa4340800a95 Mon Sep 17 00:00:00 2001
> From: Stephane Gilbert 
> Date: Thu, 13 Sep 2018 14:47:16 -0400
> Subject: [PATCH] Fixes the load command return code under btrfs
> filesystem
> ---
>  fs/btrfs/btrfs.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
>   if (!len)
> @@ -200,7 +200,7 @@ int btrfs_read(const char *file, void *buf, loff_t
> offset, loff_t len,
>   rd = btrfs_file_read(&root, inr, offset, len, buf);
>   if (rd == -1ULL) {
>   printf("An error occured while reading file %s\n",
> file);
> - return 1;
> + return -5;
>   }
>  
>   *actread = rd;
> 
> diff --git a/fs/btrfs/btrfs.c b/fs/btrfs/btrfs.c
> index 6f35854823..64ec1af5a9 100644
> --- a/fs/btrfs/btrfs.c
> +++ b/fs/btrfs/btrfs.c
> @@ -183,12 +183,12 @@ int btrfs_read(const char *file, void *buf,
> loff_t offset, loff_t len,
>  
>   if (inr == -1ULL) {
>   printf("Cannot lookup file %s\n", file);
> - return 1;
> + return -2;
>   }
>  
>   if (type != BTRFS_FT_REG_FILE) {
>   printf("Not a regular file: %s\n", file);
> - return 1;
> + return -2;
>   }
>  

Your patch itself seems to have been garbled, please resubmit as v2,
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 v2 1/3] qe: kconfig: U QE kconfig

2018-09-25 Thread Ran Wang
Hi York,

> -Original Message-
> From: York Sun
> Sent: Wednesday, September 26, 2018 01:02
> To: Ran Wang ; Alison Wang 
> Cc: Qiang Zhao ; u-boot@lists.denx.de
> Subject: Re: [PATCH v2 1/3] qe: kconfig: U QE kconfig
> 
> On 09/24/2018 11:45 PM, Ran Wang wrote:
> > add Kconfig option for U QUICC Engine.
> >
> > Signed-off-by: Ran Wang 
> > ---
> > Change in v2:
> > Add more conditional define to support more platforms.
> >
> >  drivers/Kconfig|  2 ++
> >  drivers/qe/Kconfig | 12 
> >  2 files changed, 14 insertions(+)
> >  create mode 100644 drivers/qe/Kconfig
> >
> > diff --git a/drivers/Kconfig b/drivers/Kconfig index
> > 56536c4b19..884a945a19 100644
> > --- a/drivers/Kconfig
> > +++ b/drivers/Kconfig
> > @@ -74,6 +74,8 @@ source "drivers/power/Kconfig"
> >
> >  source "drivers/pwm/Kconfig"
> >
> > +source "drivers/qe/Kconfig"
> > +
> >  source "drivers/ram/Kconfig"
> >
> >  source "drivers/remoteproc/Kconfig"
> > diff --git a/drivers/qe/Kconfig b/drivers/qe/Kconfig new file mode
> > 100644 index 00..c47b54ab12
> > --- /dev/null
> > +++ b/drivers/qe/Kconfig
> > @@ -0,0 +1,12 @@
> > +#
> > +# QUICC Engine Drivers
> > +#
> > +config  U_QE
> 
> Did you notice you have extra space here?

My bad, will correct it, thanks for point out.

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


Re: [U-Boot] [PATCH v2 2/3] arm: layerscape: Remove CONFIG_U_QE define in head files

2018-09-25 Thread Ran Wang
Hi York,

> -Original Message-
> From: York Sun
> Sent: Wednesday, September 26, 2018 01:02
> To: Ran Wang ; Alison Wang 
> Cc: Qiang Zhao ; u-boot@lists.denx.de
> Subject: Re: [PATCH v2 2/3] arm: layerscape: Remove CONFIG_U_QE define in
> head files
> 
> On 09/24/2018 11:45 PM, Ran Wang wrote:
> > Because it has been moved to drivers/qe/Kconfig instead.
> > Following platforms are involved:
> > T102xQDS, T102xRDB, T1040QDS, ls1021aqds, ls1021atwr, ls1043ardb
> >
> > Signed-off-by: Ran Wang 
> > ---
> > Change in v2:
> > Remove CONFIG_U_QE from more platforms besides ls1021a
> >
> >  include/configs/T102xQDS.h   | 1 -
> >  include/configs/T102xRDB.h   | 1 -
> >  include/configs/T1040QDS.h   | 1 -
> >  include/configs/ls1021aqds.h | 1 -
> >  include/configs/ls1021atwr.h | 1 -
> >  include/configs/ls1043ardb.h | 7 ---
> >  6 files changed, 12 deletions(-)
> 
> After removing all defines, please remove it from config_whitelist.txt.

Got it, will add it in next version.

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


  1   2   >