[U-Boot] [PATCH] arm: ls1021a: Add QSPI or IFC support in SD boot for LS1021AQDS board

2016-02-01 Thread Alison Wang
As QSPI and IFC are pin-multiplexed on LS1021A, only IFC is supported
in SD boot now. For the customer's demand, QSPI needs to be supported
in SD boot too.

This patch adds QSPI or IFC support in SD boot according to the
corresponding defconfig. For detail, ls1021aqds_sdcard_ifc_defconfig
is used to support IFC in SD boot and ls1021aqds_sdcard_qspi_defconfig
is used to support QSPI in SD boot.

Signed-off-by: Alison Wang 
---
 board/freescale/ls1021aqds/MAINTAINERS |  3 ++-
 board/freescale/ls1021aqds/ls1021aqds.c|  4 ++--
 board/freescale/ls1021aqds/ls102xa_rcw_sd.cfg  | 14 --
 board/freescale/ls1021aqds/ls102xa_rcw_sd_ifc.cfg  | 14 ++
 board/freescale/ls1021aqds/ls102xa_rcw_sd_qspi.cfg | 14 ++
 configs/ls1021aqds_sdcard_defconfig|  8 
 configs/ls1021aqds_sdcard_ifc_defconfig|  8 
 configs/ls1021aqds_sdcard_qspi_defconfig   | 16 
 include/configs/ls1021aqds.h   | 21 +
 9 files changed, 73 insertions(+), 29 deletions(-)
 delete mode 100644 board/freescale/ls1021aqds/ls102xa_rcw_sd.cfg
 create mode 100644 board/freescale/ls1021aqds/ls102xa_rcw_sd_ifc.cfg
 create mode 100644 board/freescale/ls1021aqds/ls102xa_rcw_sd_qspi.cfg
 delete mode 100644 configs/ls1021aqds_sdcard_defconfig
 create mode 100644 configs/ls1021aqds_sdcard_ifc_defconfig
 create mode 100644 configs/ls1021aqds_sdcard_qspi_defconfig

diff --git a/board/freescale/ls1021aqds/MAINTAINERS 
b/board/freescale/ls1021aqds/MAINTAINERS
index 820d322..c37ab99 100644
--- a/board/freescale/ls1021aqds/MAINTAINERS
+++ b/board/freescale/ls1021aqds/MAINTAINERS
@@ -8,6 +8,7 @@ F:  configs/ls1021aqds_ddr4_nor_defconfig
 F: configs/ls1021aqds_ddr4_nor_lpuart_defconfig
 F: configs/ls1021aqds_nor_SECURE_BOOT_defconfig
 F: configs/ls1021aqds_nor_lpuart_defconfig
-F: configs/ls1021aqds_sdcard_defconfig
+F: configs/ls1021aqds_sdcard_ifc_defconfig
+F: configs/ls1021aqds_sdcard_qspi_defconfig
 F: configs/ls1021aqds_qspi_defconfig
 F: configs/ls1021aqds_nand_defconfig
diff --git a/board/freescale/ls1021aqds/ls1021aqds.c 
b/board/freescale/ls1021aqds/ls1021aqds.c
index 5f4ec9d..b43b379 100644
--- a/board/freescale/ls1021aqds/ls1021aqds.c
+++ b/board/freescale/ls1021aqds/ls1021aqds.c
@@ -61,7 +61,7 @@ enum {
 
 int checkboard(void)
 {
-#ifndef CONFIG_QSPI_BOOT
+#if !defined(CONFIG_QSPI_BOOT) && !defined(CONFIG_SD_BOOT_QSPI)
char buf[64];
 #endif
 #if !defined(CONFIG_SD_BOOT) && !defined(CONFIG_QSPI_BOOT)
@@ -90,7 +90,7 @@ int checkboard(void)
printf("invalid setting of SW%u\n", QIXIS_LBMAP_SWITCH);
 #endif
 
-#ifndef CONFIG_QSPI_BOOT
+#if !defined(CONFIG_QSPI_BOOT) && !defined(CONFIG_SD_BOOT_QSPI)
printf("Sys ID:0x%02x, Sys Ver: 0x%02x\n",
   QIXIS_READ(id), QIXIS_READ(arch));
 
diff --git a/board/freescale/ls1021aqds/ls102xa_rcw_sd.cfg 
b/board/freescale/ls1021aqds/ls102xa_rcw_sd.cfg
deleted file mode 100644
index 9d99bd8..000
--- a/board/freescale/ls1021aqds/ls102xa_rcw_sd.cfg
+++ /dev/null
@@ -1,14 +0,0 @@
-#PBL preamble and RCW header
-aa55aa55 01ee0100
-
-#enable IFC, disable QSPI and DSPI
-0608000a   
-6000 00407900 60040a00 21046000
-   00038000
- 001b7200  
-
-#disable IFC, enable QSPI and DSPI
-#0608000a   
-#6000 00407900 60040a00 21046000
-#   00038000
-#20024800 001b7200  
diff --git a/board/freescale/ls1021aqds/ls102xa_rcw_sd_ifc.cfg 
b/board/freescale/ls1021aqds/ls102xa_rcw_sd_ifc.cfg
new file mode 100644
index 000..9d99bd8
--- /dev/null
+++ b/board/freescale/ls1021aqds/ls102xa_rcw_sd_ifc.cfg
@@ -0,0 +1,14 @@
+#PBL preamble and RCW header
+aa55aa55 01ee0100
+
+#enable IFC, disable QSPI and DSPI
+0608000a   
+6000 00407900 60040a00 21046000
+   00038000
+ 001b7200  
+
+#disable IFC, enable QSPI and DSPI
+#0608000a   
+#6000 00407900 60040a00 21046000
+#   00038000
+#20024800 001b7200  
diff --git a/board/freescale/ls1021aqds/ls102xa_rcw_sd_qspi.cfg 
b/board/freescale/ls1021aqds/ls102xa_rcw_sd_qspi.cfg
new file mode 100644
index 000..2bd398c
--- /dev/null
+++ b/board/freescale/ls1021aqds/ls102xa_rcw_sd_qspi.cfg
@@ -0,0 +1,14 @@
+#PBL preamble and RCW header
+aa55aa55 01ee0100
+
+#enable IFC, disable QSPI and DSPI
+#0608000a   
+#6000 00407900 60040a00 21046000
+#   00038000
+# 001b7200  
+
+#disable IFC, enable QSPI and DSPI
+0608000a   
+6000 00407900 60040a00 21046000
+   00038000
+20024800 001b7200  
diff --git a/configs/ls1021aqds_sdcard_defconfig 
b/configs/ls1021aqds_sdca

Re: [U-Boot] 64-bit x86 U-Boot?

2016-02-01 Thread Bin Meng
Hi Simon,

On Tue, Feb 2, 2016 at 11:58 AM, Simon Glass  wrote:
> +Bin (sorry, meant to copy you before)
>
> Hi Albert,
>
> On 1 February 2016 at 00:14, Albert ARIBAUD  wrote:
>> Hello Simon,
>>
>> On Sun, 31 Jan 2016 19:20:31 -0700, Simon Glass 
>> wrote:
>>> Hi Bin,
>>>
>>> At present U-Boot supports booting a 64-bit kernel directly. It can
>>> also be loaded as a 64-bit payload from EFI. But it cannot be built as
>>> a 64-bit boot loader.
>>>
>>> I took a bit of a look at this. It looks like we need to stay in
>>> 32-bit mode until the FSP is loaded. Also, to get to 64-bit mode I'm
>>> pretty sure we need page tables, which means we need somewhere to put
>>> them!
>>>

Yes unfortunately that is the FSP limitation.

>>> Looking at the board_f init sequence, it seems that arch_cpu_init() is
>>> the earlist we could switch to 64-bit. We'd need to grab some memory
>>> from somewhere to do this - I wonder if this can be CAR? There is no
>>> SRAM on x86 chips I think.
>>>
>>> For non-FSP devices we don't init the RAM until much later -
>>> dram_init(). That means that a significant portion of the init
>>> sequence would be 32-bit code. I'm not sure that will work.
>>>

I believe we can do dram_init() in 64-bit mode as well if MRC is
written in pure C.

>>> I suppose one option is to only go to 64-bit mode when relocating. But
>>> then we end up with lots of code that needs to run in 32-bit and
>>> 64-bit.
>>>
>>> Do you have any ideas on this?
>>
>> How about starting with implementing the last option, i.e. switch to 64
>> bits when DDR is available, mainline that, then progressively work your
>> way toward an earlier switch?
>
> The tricky thing is that I'm not sure we can run 32-bit code in 64-bit
> mode or vice-versa. The instruction set is similar but there are data
> size settings that probably make it incompatible.
>

No, it's not 100% compatible. We have to switch back and forth unfortunately.

> I wonder whether we might need to resort to SPL for the 32-bit
> portion, and jump to a 64-bit U-Boot from there? Tegra does something
> similar to that.
>

What's the benefit of doing a 64-bit bootloader? Intel's UEFI BIOS has
a 32-bit and 64-bit version, and has caused some troubles for the next
stage loader (bootia32.efi vs. bootx64.efi). I know for PowerPC, a
64-bit U-Boot does not exist as 32-bit U-Boot can load 32-bit and
64-bit kernel, just like what we have for x86. 64-bit U-Boot was only
seen on ARMv8, but that's the architecture limitation I believe, and
we have to do that.

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


Re: [U-Boot] [PATCH v4 5/6] rockchip: kylin: Enable boot with android boot image

2016-02-01 Thread Jeffy Chen

Hi Tom,

Sorry for being late..

On 2016-1-26 3:07, Tom Rini wrote:

On Fri, Jan 15, 2016 at 10:20:43AM +0800, Jeffy Chen wrote:

Hi Tom,

On 2016-1-15 8:59, Tom Rini wrote:

On Fri, Jan 15, 2016 at 08:53:06AM +0800, Jeffy Chen wrote:

Hi Tom,

On 2016-1-15 0:22, Tom Rini wrote:

On Thu, Jan 14, 2016 at 10:31:34AM +0800, Jeffy Chen wrote:

Hi Tom,

On 2016-1-13 23:28, Tom Rini wrote:

On Wed, Jan 13, 2016 at 04:53:19PM +0800, Jeffy Chen wrote:


The android kernel is using appended dtb by default, and store
ramdisk right after kernel & dtb.
So we needs to relocate ramdisk, and use atags to pass params.

Signed-off-by: Jeffy Chen 
Acked-by: Simon Glass 
---

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

  include/configs/kylin_rk3036.h | 23 +++
  1 file changed, 23 insertions(+)

diff --git a/include/configs/kylin_rk3036.h b/include/configs/kylin_rk3036.h
index b750b26..49997ec 100644
--- a/include/configs/kylin_rk3036.h
+++ b/include/configs/kylin_rk3036.h
@@ -35,6 +35,29 @@
  #undef CONFIG_EXTRA_ENV_SETTINGS
  #define CONFIG_EXTRA_ENV_SETTINGS \
"partitions=" PARTS_DEFAULT \
+   "mmcdev=0\0" \
+   "mmcpart=5\0" \
+   "loadaddr=" __stringify(CONFIG_SYS_LOAD_ADDR) "\0" \
+
+#define CONFIG_ANDROID_BOOT_IMAGE
+#define CONFIG_SYS_BOOT_RAMDISK_HIGH

This should already be set.

Right, i'll remove it...

+#define CONFIG_SYS_HUSH_PARSER
+
+#undef CONFIG_BOOTCOMMAND
+#define CONFIG_BOOTCOMMAND \
+   "mmc dev ${mmcdev}; if mmc rescan; then " \
+   "part start mmc ${mmcdev} ${mmcpart} boot_start;" \
+   "part size mmc ${mmcdev} ${mmcpart} boot_size;" \
+   "mmc read ${loadaddr} ${boot_start} ${boot_size};" \
+   "bootm start ${loadaddr}; bootm ramdisk;" \
+   "bootm prep; bootm go;" \
+   "fi;" \
+
+/* Enable atags */
+#define CONFIG_SYS_BOOTPARAMS_LEN  (64*1024)
+#define CONFIG_INITRD_TAG
+#define CONFIG_SETUP_MEMORY_TAGS
+#define CONFIG_CMDLINE_TAG

But I'm confused as to what exactly is going on here.  Appended dtb is
not the same as ATAGS.  And you shouldn't need to split up bootm like
that.  Can you please explain a bit more?  Thanks!

The u-boot will pass atags to kernel, and kernel will merge those
atags into the appended dtb(fdt).

The default bootm flow would not pass ramdisk state, but we need it,
so we should add this state into default flow, or just use split
bootm cmds :)

That seems very strange.  Is the ramdisk concatenated with the kernel
and dtb as well (and that's why bootm ramdisk somehow finds it but
normal bootm doesn't as you aren't passing in a ramdisk address) ?

Yes, the ramdisk concatenated with the kernel and dtb as
well(u-boot/include/android_image.h: struct andr_img_hdr).

And the normal bootm cmd would find it by parsing andr_img_hdr struct.
But we still need bootm ramdisk state, because it will call
boot_ramdisk_high to relocate ramdisk area :)

I found if not relocate it to somewhere else, it would be corrupted
after kernel's decompressing(during update fdt area).

So 'bootm $loadaddr' of an Android image sees, but does not relocate the
ramdisk that is included in the image, but bootm ramdisk does?  That
sounds like a bug in the regular bootm handling.

Yep, the default bootm flow would not contain ramdisk relocate state:

vi common/cmd_bootm.c
 return do_bootm_states(cmdtp, flag, argc, argv, BOOTM_STATE_START |
 BOOTM_STATE_FINDOS | BOOTM_STATE_FINDOTHER |
 BOOTM_STATE_LOADOS |
#if defined(CONFIG_PPC) || defined(CONFIG_MIPS)
 BOOTM_STATE_OS_CMDLINE |
#endif
 BOOTM_STATE_OS_PREP | BOOTM_STATE_OS_FAKE_GO |
 BOOTM_STATE_OS_GO, &images, 1);

But i'm not sure if it's ok to add it here...

So, I've poked aruond a bit more on some of my TI platforms at least.
Can you look at the following things on yours?
1) Do you still see the problem on top of tree? Masahiro fixed at least
one problem just before v2016.01
Yes, after rebase to tag "v2016.01-rc4", i could still repro it with the 
normal bootm cmd.


It seems we would call boot_ramdisk_high if fdt enabled in the prep stage:

 vi common/image.c

#ifdef CONFIG_LMB
int image_setup_linux(bootm_headers_t *images)
{
...
if (IMAGE_ENABLE_RAMDISK_HIGH) {
rd_len = images->rd_end - images->rd_start;
ret = boot_ramdisk_high(lmb, images->rd_start, rd_len,
initrd_start, initrd_end);
if (ret)
return ret;
}

 vi arch/arm/lib/bootm.c

/* Subcommand: PREP */
static void boot_prep_linux(bootm_headers_t *images)

if (IMAGE_ENABLE_OF_LIBFDT && images->ft_len) {
#ifdef CONFIG_OF_LIBFDT
debug("using: FDT\n");
if (image_setup_linux(images)) {
printf("FDT creation failed! hanging...");
hang();
}
#endif


And as Daniel said, these wo

Re: [U-Boot] [PATCH] ls2-2085a: Increase default hugepage count

2016-02-01 Thread Ashish Kumar
Agree, Please drop this while merging.

Regards
Ashish

-Original Message-
From: york sun 
Sent: Tuesday, February 02, 2016 11:50 AM
To: Ashish Kumar ; u-boot@lists.denx.de
Subject: Re: [PATCH] ls2-2085a: Increase default hugepage count

On 02/01/2016 10:09 PM, Ashish Kumar wrote:
> Hello York,
> 
> It is like a  heads-up, that user needs to erase the environment variable 
> location before flashing a new uboot for the changes to reflect.

You are changing default environmental variables. It is up to the users to set 
correct variables. I don't believe the note clarifies anything in the context 
of this patch. You don't need to send an update if you agree. I can drop the 
note when merging the patch.

York


> 
> Regards
> Ashish
> 
> -Original Message-
> From: york sun [mailto:york@nxp.com]
> Sent: Monday, February 01, 2016 10:17 PM
> To: Ashish Kumar ; u-boot@lists.denx.de
> Subject: Re: [PATCH] ls2-2085a: Increase default hugepage count
> 
> On 01/14/2016 04:42 AM, Ashish Kumar wrote:
>>  * Increase default hugepage count to 256 from 16
>>  * Note: default env variables are stored at 0x58020/0x58420
>> of size 0x2000
>>
> 
> Ashish,
> 
> What does the default env location have anything to do with this patch?
> 
> York
> 

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


Re: [U-Boot] [PATCH v3] Enable snooping on transactions from CAAM block

2016-02-01 Thread Huan Wang
Hi, York,

> -Original Message-
> From: york sun [mailto:york@nxp.com]
> Sent: Tuesday, February 02, 2016 1:06 AM
> To: Aneesh Bansal; u-boot@lists.denx.de; Huan Wang-B18965
> Cc: Ruchika Gupta; Prabhakar Kushwaha; Nitesh Lal
> Subject: Re: [PATCH v3] Enable snooping on transactions from CAAM block
> 
> +Alison to comment on my question at the end of this email
> 
> Aneesh,
> 
> A few comments to this patch.
> 
> First, please prefix the subject with a meaningful tag. In this case, it
> should be armv7: ls1020a.
> 
> On 01/17/2016 10:16 PM, Aneesh Bansal wrote:
> > To enable snooping on CAAM transactions following programming is done
> >
> > 1. Enable core snooping (CCI interface, Core is Slave5 on CCI) This
> > setting is also required for making the system coherent
> >
> > 2. CAAM IP lies behind SMMU3 in the system. Configure SMMU3 to do the
> following:
> > a) Program SCR to bypass transactions with stream ID other than that
> > of CAAM
> > b) Program S2CR to change memroy attributes of transactions with
> > CAAM's stream ID (0x10) to cacheable.
> 
> Second, the commit message should not exceed 72 characters.
> Third, the commit message should explain why and what this patch is
> doing. I don't see any change related to enabling snooping on CCI in
> this patch.
> 
> >
> > Signed-off-by: Ruchika Gupta 
> > Signed-off-by: Nitesh Narayan Lal 
> > Signed-off-by: Aneesh Bansal 
> > ---
> > Changes in v3:
> > Modified the commit message.
> >
> > Changes in v2:
> > Avoid mixing the use of u32 and uint32_t.
> > Using uint32_t at all places.
> >
> >  arch/arm/include/asm/arch-ls102xa/config.h |  1 +
> >  .../include/asm/arch-ls102xa/ls102xa_stream_id.h   | 34
> 
> >  board/freescale/common/ls102xa_stream_id.c | 36
> +-
> >  board/freescale/ls1021aqds/ls1021aqds.c|  4 +++
> >  board/freescale/ls1021atwr/ls1021atwr.c|  4 +++
> >  5 files changed, 78 insertions(+), 1 deletion(-)
> >
> > diff --git a/arch/arm/include/asm/arch-ls102xa/config.h
> > b/arch/arm/include/asm/arch-ls102xa/config.h
> > index f066480..f14ea2f 100644
> > --- a/arch/arm/include/asm/arch-ls102xa/config.h
> > +++ b/arch/arm/include/asm/arch-ls102xa/config.h
> > @@ -38,6 +38,7 @@
> >  #define CONFIG_SYS_LS102XA_XHCI_USB1_ADDR  (CONFIG_SYS_IMMR +
> 0x0210)
> >  #define CONFIG_SYS_LS102XA_USB1_ADDR \
> > (CONFIG_SYS_IMMR + CONFIG_SYS_LS102XA_USB1_OFFSET)
> > +#define CONFIG_SYS_SMMU3_ADDR  (CONFIG_SYS_IMMR +
> 0x30)
> >
> >  #define CONFIG_SYS_FSL_SEC_OFFSET  0x0070
> >  #define CONFIG_SYS_LS102XA_USB1_OFFSET 0x0760
> > diff --git a/arch/arm/include/asm/arch-ls102xa/ls102xa_stream_id.h
> > b/arch/arm/include/asm/arch-ls102xa/ls102xa_stream_id.h
> > index fa571b3..68e4e02 100644
> > --- a/arch/arm/include/asm/arch-ls102xa/ls102xa_stream_id.h
> > +++ b/arch/arm/include/asm/arch-ls102xa/ls102xa_stream_id.h
> > @@ -6,6 +6,39 @@
> >
> >  #ifndef __FSL_LS102XA_STREAM_ID_H_
> >  #define __FSL_LS102XA_STREAM_ID_H_
> > +#define CONFIG_SMMU_NSCR_OFFSET0x400
> > +#define CONFIG_SMMU_SMR_OFFSET 0x800
> > +#define CONFIG_SMMU_S2CR_OFFSET0xc00
> > +
> > +#define SMMU_NSCR_CLIENTPD_SHIFT   0
> > +#define SMMU_NSCR_MTCFG_SHIFT  20
> > +
> > +#define SMR_SMR_VALID_SHIFT31
> > +#define SMR_ID_MASK0x7fff
> > +#define SMR_MASK_SHIFT 16
> > +
> > +#define S2CR_WACFG_SHIFT   22
> > +#define S2CR_WACFG_MASK0x3
> > +#define S2CR_WACFG_WRITE_ALLOCATE  0x2
> > +
> > +#define S2CR_RACFG_SHIFT   20
> > +#define S2CR_RACFG_MASK0x3
> > +#define S2CR_RACFG_READ_ALLOCATE   0x2
> > +
> > +#define S2CR_TYPE_SHIFT16
> > +#define S2CR_TYPE_MASK 0x3
> > +#define S2CR_TYPE_BYPASS   0x01
> > +
> > +#define S2CR_MEM_ATTR_SHIFT12
> > +#define S2CR_MEM_ATTR_MASK 0xf
> > +#define S2CR_MEM_ATTR_CACHEABLE0xa
> > +
> > +#define S2CR_MTCFG 0x0800
> > +
> > +#define S2CR_SHCFG_SHIFT   8
> > +#define S2CR_SHCFG_MASK0x3
> > +#define S2CR_SHCFG_OUTER_CACHEABLE 0x1
> > +#define S2CR_SHCFG_INNER_CACHEABLE 0x2
> >
> >  #include 
> >
> > @@ -71,4 +104,5 @@ struct smmu_stream_id {
> >
> >  void ls1021x_config_caam_stream_id(struct liodn_id_table *tbl, int
> > size);  void ls102xa_config_smmu_stream_id(struct smmu_stream_id *id,
> > uint32_t num);
> > +void ls1021x_config_smmu3(uint32_t liodn);
> >  #endif
> > diff --git a/board/freescale/common/ls102xa_stream_id.c
> > b/board/freescale/common/ls102xa_stream_id.c
> > index f434269..9ae29b8 100644
> > --- a/board/freescale/common/ls102xa_stream_id.c
> > +++ b/board/freescale/common/ls102xa_stream_id.c
> > @@ -20,7 +20,7 @@ void ls102xa_config_smmu_stream_id(struct
> > smmu_stream_id *id, uint32_t num)  void
> > ls10

Re: [U-Boot] UBI attach issues

2016-02-01 Thread Heiko Schocher

Hello Andy,

Am 01.02.2016 um 14:42 schrieb Andy Ng:

Thank you for your reply.

by going to update u-boot, does it guaranty corruption free UBI if the
power goes away during the phase where u-boot fetches uImage from the
ubifs?


I cannot guarantee this. The problem can be also in the underlying nand
driver. Try current code, also enable UBI debug messages, may this
shows the problem...

bye,
Heiko


best regards,
Andy

On Mon, Feb 1, 2016 at 9:34 AM, Heiko Schocher  wrote:

Hello Andy,

Am 01.02.2016 um 09:58 schrieb Andy Ng:


Dear u-boot team,

Occasionally, I get corrupted rootfs if the system power goes away
while u-boot is attaching the root file system in order to fetch the
kernel.

I am using imx6 Solo and u-boot 2013-10.

Is there any way to stop uboot messing up the file system while making
attachment of UBI? Does the latest u-boot provides a better way to
protect the ubi file system during attachment.


Any advice or guidance will be very much appreciated.



In principle U-Boot has the same code as Linux. Current
U-Boot uses Linux code from:

linux v4.2 commit 64291f7db5bd8150a74ad2036f1037e6a0428df2

see U-Boot commit: 0195a7bb36a0abc71145da419001377bf56662fd

2013-10 uses an older Source Base, so update to current U-Boot
is recommended... yes.

Do you see this issue also with Linux?

Do you use UBI FASTMAP?

bye,
Heiko
--
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany




--
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] spl: define BOOT_DEVICE_USB

2016-02-01 Thread Masahiro Yamada
This macro is referenced from common/spl/spl.c

Signed-off-by: Masahiro Yamada 
---

 arch/arm/include/asm/spl.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/include/asm/spl.h b/arch/arm/include/asm/spl.h
index 5c5d33f..19c38f4 100644
--- a/arch/arm/include/asm/spl.h
+++ b/arch/arm/include/asm/spl.h
@@ -24,6 +24,7 @@ enum {
BOOT_DEVICE_NOR,
BOOT_DEVICE_UART,
BOOT_DEVICE_SPI,
+   BOOT_DEVICE_USB,
BOOT_DEVICE_SATA,
BOOT_DEVICE_I2C,
BOOT_DEVICE_BOARD,
-- 
1.9.1

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


Re: [U-Boot] [PATCH] ls2-2085a: Increase default hugepage count

2016-02-01 Thread york sun
On 02/01/2016 10:09 PM, Ashish Kumar wrote:
> Hello York,
> 
> It is like a  heads-up, that user needs to erase the environment variable 
> location before flashing a new uboot for the changes to reflect.

You are changing default environmental variables. It is up to the users to set
correct variables. I don't believe the note clarifies anything in the context of
this patch. You don't need to send an update if you agree. I can drop the note
when merging the patch.

York


> 
> Regards
> Ashish
> 
> -Original Message-
> From: york sun [mailto:york@nxp.com] 
> Sent: Monday, February 01, 2016 10:17 PM
> To: Ashish Kumar ; u-boot@lists.denx.de
> Subject: Re: [PATCH] ls2-2085a: Increase default hugepage count
> 
> On 01/14/2016 04:42 AM, Ashish Kumar wrote:
>>  * Increase default hugepage count to 256 from 16
>>  * Note: default env variables are stored at 0x58020/0x58420
>> of size 0x2000
>>
> 
> Ashish,
> 
> What does the default env location have anything to do with this patch?
> 
> York
> 

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


Re: [U-Boot] [PATCH 00/23] x86: Convert to use DM PCI APIs completely

2016-02-01 Thread Bin Meng
Hi Simon,

On Tue, Feb 2, 2016 at 11:55 AM, Simon Glass  wrote:
> Hi Bin,
>
> On 1 February 2016 at 19:25, Bin Meng  wrote:
>> Hi Simon,
>>
>> On Tue, Feb 2, 2016 at 12:19 AM, Simon Glass  wrote:
>>> Hi Bin,
>>>
>>> On 1 February 2016 at 02:40, Bin Meng  wrote:
 There are still some codes that use the legacy PCI APIs to access
 the configuration space registers. This series converts those codes
 to completely use DM PCI APIs.

 This includes adding several new ops to the PCH uclass driver, and
 some clean up to the SPI/GPIO/IRQ drivers.

 Tested on QEMU and Crown Bay. This series is available in pci-working
 branch of u-boot-x86 repo.
>>>
>>> Looks great! This is a big step forward.
>>>
>>> I've tested it on minnowmax and will test on link in the next day or so.
>>>
>>> Here are a few things that I think can still be cleaned up:
>>> - void pci_assign_irqs(int bus, int device, u8 irq[4]) should use a
>>> struct udevice
>>
>> I guess no, unless we expand struct udevice to include interrupt
>> routing information? But that's not generic across architectures. I am
>> not sure how.
>
> I suppose we can adjust it to take a struct udevice and drop the bus
> and device parameters. But then we need to be able to support reading
> from different functions, so will need to use pci_bus_read_config().
> But at least that is a DM function. Hmmm
>

Currently bus and device parameters come from the device tree
 property. If we just pass struct udevice, that
means we have to saving the routing information >
>>> - pci_x86_read/write_config() move into drivers/pci/pci_x86.c (needs
>>> ivybridge fix which I'll look at)
>>
>> Yep. I wanted to do this when reviewing one of previous patches.
>
> OK let's see what I find.
>
>>
>>> - disable DM_PCI_COMPAT for x86
>>
>> Looks e1000 and pch_gbe (Crown Bay) ethernet drivers are still using
>> legacy PCI APIs. e1000 might need quite amount of work as it is being
>> widely used on lots of boards. I can update pch_gbe driver later.
>
> I converted rtl8169 using #ifdef and it seemed to work OK. We don't
> need to remove the old code.
>
>>
>>> - use the PCI mmio access method instead of I/O once it becomes possible
>>
>> Yep.
>>
>>> - moving vesa video to driver model (UCLASS_VIDEO)
>>
>> I was not following the dm video changes recently, but I guess yes.
>
> It only merged recently. I haven't tried looking at that.
>
> On another note, I just got an Edison. What do you think about
> supporting that in U-Boot?
>

I think that's Intel Edison [1] you are talking about? It's based on
one Atom (don't know which exact model it is) plus one Quark
processor. Did Intel release any open source SDK for this board?

[1] 
http://www.intel.com/buy/us/en/product/emergingtechnologies/intel-edison-compute-module-iot-463633

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


Re: [U-Boot] [PATCH v1 1/2] Revert "powerpc: mpc85xx: remove P2020DS board support"

2016-02-01 Thread york sun
On 02/01/2016 07:42 PM, Bin Meng wrote:



Bin,

> We should add device tree to these platforms. The non-device tree
> (U_BOOT_DEVICES) was mainly for some SPL boards which does not have
> enough RAM before memory is initialized. I think you may refer to this
> patch: http://patchwork.ozlabs.org/patch/561853/

I looked into ls1021atwr earlier, ns16550 driver takes default value
CONFIG_SYS_NS16550_CLK when the device tree doesn't have the clock-frequency
node. It is a smart solution for device-tree enabled platforms.

Even I believe we want to go with device tree for new boards, I don't believe
driver model has to be used with device tree. We have many boards with
sd/spi/nand boot options, including the P2020DS I am trying to bring back.

York

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


Re: [U-Boot] [PATCH v3 1/3] ARM: at91: clock: add PLLB enable/disable functions

2016-02-01 Thread Yang, Wenyou
Hello Heiko,

Thank you very much for your test.

> -Original Message-
> From: Heiko Schocher [mailto:h...@denx.de]
> Sent: 2016年2月2日 13:33
> To: Yang, Wenyou 
> Cc: U-Boot Mailing List 
> Subject: Re: [U-Boot] [PATCH v3 1/3] ARM: at91: clock: add PLLB enable/disable
> functions
> 
> Hello Wenyou,
> 
> Am 02.02.2016 um 04:35 schrieb Wenyou Yang:
> > To avoid the duplicated code, add the PLLB handle functions.
> >
> > Signed-off-by: Wenyou Yang 
> > Reviewed-by: Andreas Bießmann 
> > ---
> >
> > Changes in v3: None
> > Changes in v2: None
> >
> >   arch/arm/mach-at91/arm926ejs/clock.c  |   38
> +
> >   arch/arm/mach-at91/include/mach/clk.h |2 ++
> >   2 files changed, 40 insertions(+)
> 
> Tested-by: Heiko Schocher 
> 
> bye,
> Heiko
> >
> > diff --git a/arch/arm/mach-at91/arm926ejs/clock.c
> > b/arch/arm/mach-at91/arm926ejs/clock.c
> > index c8b5e10..c8d24ae 100644
> > --- a/arch/arm/mach-at91/arm926ejs/clock.c
> > +++ b/arch/arm/mach-at91/arm926ejs/clock.c
> > @@ -18,6 +18,8 @@
> >   # error You need to define CONFIG_AT91FAMILY in your board config!
> >   #endif
> >
> > +#define EN_PLLB_TIMEOUT500
> > +
> >   DECLARE_GLOBAL_DATA_PTR;
> >
> >   static unsigned long at91_css_to_rate(unsigned long css) @@ -242,3
> > +244,39 @@ void at91_mck_init(u32 mckr)
> > while (!(readl(&pmc->sr) & AT91_PMC_MCKRDY))
> > ;
> >   }
> > +
> > +int at91_pllb_clk_enable(u32 pllbr)
> > +{
> > +   struct at91_pmc *pmc = (at91_pmc_t *)ATMEL_BASE_PMC;
> > +   ulong start_time, tmp_time;
> > +
> > +   start_time = get_timer(0);
> > +   writel(pllbr, &pmc->pllbr);
> > +   while ((readl(&pmc->sr) & AT91_PMC_LOCKB) != AT91_PMC_LOCKB) {
> > +   tmp_time = get_timer(0);
> > +   if ((tmp_time - start_time) > EN_PLLB_TIMEOUT) {
> > +   printf("ERROR: failed to enable PLLB\n");
> > +   return -1;
> > +   }
> > +   }
> > +
> > +   return 0;
> > +}
> > +
> > +int at91_pllb_clk_disable(void)
> > +{
> > +   struct at91_pmc *pmc = (at91_pmc_t *)ATMEL_BASE_PMC;
> > +   ulong start_time, tmp_time;
> > +
> > +   start_time = get_timer(0);
> > +   writel(0, &pmc->pllbr);
> > +   while ((readl(&pmc->sr) & AT91_PMC_LOCKB) != 0) {
> > +   tmp_time = get_timer(0);
> > +   if ((tmp_time - start_time) > EN_PLLB_TIMEOUT) {
> > +   printf("ERROR: failed to disable PLLB\n");
> > +   return -1;
> > +   }
> > +   }
> > +
> > +   return 0;
> > +}
> > diff --git a/arch/arm/mach-at91/include/mach/clk.h
> > b/arch/arm/mach-at91/include/mach/clk.h
> > index b2604ef..64dec52 100644
> > --- a/arch/arm/mach-at91/include/mach/clk.h
> > +++ b/arch/arm/mach-at91/include/mach/clk.h
> > @@ -133,5 +133,7 @@ void at91_system_clk_disable(int sys_clk);
> >   int at91_upll_clk_enable(void);
> >   int at91_upll_clk_disable(void);
> >   void at91_usb_clk_init(u32 value);
> > +int at91_pllb_clk_enable(u32 pllbr);
> > +int at91_pllb_clk_disable(void);
> >
> >   #endif /* __ASM_ARM_ARCH_CLK_H__ */
> >
> 
> --
> DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany


Best Regards,
Wenyou Yang
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] ls2-2085a: Increase default hugepage count

2016-02-01 Thread Ashish Kumar
Hello York,

It is like a  heads-up, that user needs to erase the environment variable 
location before flashing a new uboot for the changes to reflect.

Regards
Ashish

-Original Message-
From: york sun [mailto:york@nxp.com] 
Sent: Monday, February 01, 2016 10:17 PM
To: Ashish Kumar ; u-boot@lists.denx.de
Subject: Re: [PATCH] ls2-2085a: Increase default hugepage count

On 01/14/2016 04:42 AM, Ashish Kumar wrote:
>  * Increase default hugepage count to 256 from 16
>  * Note: default env variables are stored at 0x58020/0x58420
> of size 0x2000
> 

Ashish,

What does the default env location have anything to do with this patch?

York



> Signed-off-by: Ashish Kumar 
> ---
>  include/configs/ls2080a_common.h |2 +-
>  include/configs/ls2080ardb.h |2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/include/configs/ls2080a_common.h 
> b/include/configs/ls2080a_common.h
> index 4ae7d11..a503934 100644
> --- a/include/configs/ls2080a_common.h
> +++ b/include/configs/ls2080a_common.h
> @@ -272,7 +272,7 @@ unsigned long long get_qixis_addr(void);
>  #define CONFIG_BOOTARGS  "console=ttyS0,115200 root=/dev/ram0 " \
>   "earlycon=uart8250,mmio,0x21c0500" \
>   "ramdisk_size=0x200 default_hugepagesz=2m" \
> - " hugepagesz=2m hugepages=16"
> + " hugepagesz=2m hugepages=256"
>  #define CONFIG_BOOTCOMMAND   "cp.b $kernel_start $kernel_load " \
>   "$kernel_size && bootm $kernel_load"
>  #define CONFIG_BOOTDELAY 10
> diff --git a/include/configs/ls2080ardb.h 
> b/include/configs/ls2080ardb.h index 116dbcd..356d254 100644
> --- a/include/configs/ls2080ardb.h
> +++ b/include/configs/ls2080ardb.h
> @@ -333,7 +333,7 @@ unsigned long get_board_sys_clk(void);
>  #define CONFIG_BOOTARGS  "console=ttyS1,115200 root=/dev/ram0 " \
>   "earlycon=uart8250,mmio,0x21c0600" \
>   "ramdisk_size=0x200 default_hugepagesz=2m" \
> - " hugepagesz=2m hugepages=16"
> + " hugepagesz=2m hugepages=256"
>  
>  /* MAC/PHY configuration */
>  #ifdef CONFIG_FSL_MC_ENET
> 

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


Re: [U-Boot] [PATCH v3 1/3] ARM: at91: clock: add PLLB enable/disable functions

2016-02-01 Thread Heiko Schocher

Hello Wenyou,

Am 02.02.2016 um 04:35 schrieb Wenyou Yang:

To avoid the duplicated code, add the PLLB handle functions.

Signed-off-by: Wenyou Yang 
Reviewed-by: Andreas Bießmann 
---

Changes in v3: None
Changes in v2: None

  arch/arm/mach-at91/arm926ejs/clock.c  |   38 +
  arch/arm/mach-at91/include/mach/clk.h |2 ++
  2 files changed, 40 insertions(+)


Tested-by: Heiko Schocher 

bye,
Heiko


diff --git a/arch/arm/mach-at91/arm926ejs/clock.c 
b/arch/arm/mach-at91/arm926ejs/clock.c
index c8b5e10..c8d24ae 100644
--- a/arch/arm/mach-at91/arm926ejs/clock.c
+++ b/arch/arm/mach-at91/arm926ejs/clock.c
@@ -18,6 +18,8 @@
  # error You need to define CONFIG_AT91FAMILY in your board config!
  #endif

+#define EN_PLLB_TIMEOUT500
+
  DECLARE_GLOBAL_DATA_PTR;

  static unsigned long at91_css_to_rate(unsigned long css)
@@ -242,3 +244,39 @@ void at91_mck_init(u32 mckr)
while (!(readl(&pmc->sr) & AT91_PMC_MCKRDY))
;
  }
+
+int at91_pllb_clk_enable(u32 pllbr)
+{
+   struct at91_pmc *pmc = (at91_pmc_t *)ATMEL_BASE_PMC;
+   ulong start_time, tmp_time;
+
+   start_time = get_timer(0);
+   writel(pllbr, &pmc->pllbr);
+   while ((readl(&pmc->sr) & AT91_PMC_LOCKB) != AT91_PMC_LOCKB) {
+   tmp_time = get_timer(0);
+   if ((tmp_time - start_time) > EN_PLLB_TIMEOUT) {
+   printf("ERROR: failed to enable PLLB\n");
+   return -1;
+   }
+   }
+
+   return 0;
+}
+
+int at91_pllb_clk_disable(void)
+{
+   struct at91_pmc *pmc = (at91_pmc_t *)ATMEL_BASE_PMC;
+   ulong start_time, tmp_time;
+
+   start_time = get_timer(0);
+   writel(0, &pmc->pllbr);
+   while ((readl(&pmc->sr) & AT91_PMC_LOCKB) != 0) {
+   tmp_time = get_timer(0);
+   if ((tmp_time - start_time) > EN_PLLB_TIMEOUT) {
+   printf("ERROR: failed to disable PLLB\n");
+   return -1;
+   }
+   }
+
+   return 0;
+}
diff --git a/arch/arm/mach-at91/include/mach/clk.h 
b/arch/arm/mach-at91/include/mach/clk.h
index b2604ef..64dec52 100644
--- a/arch/arm/mach-at91/include/mach/clk.h
+++ b/arch/arm/mach-at91/include/mach/clk.h
@@ -133,5 +133,7 @@ void at91_system_clk_disable(int sys_clk);
  int at91_upll_clk_enable(void);
  int at91_upll_clk_disable(void);
  void at91_usb_clk_init(u32 value);
+int at91_pllb_clk_enable(u32 pllbr);
+int at91_pllb_clk_disable(void);

  #endif /* __ASM_ARM_ARCH_CLK_H__ */



--
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v3 2/3] drivers: usb: ohci-at91: clean up the PLLB code

2016-02-01 Thread Heiko Schocher

Hello Wenyou,

Am 02.02.2016 um 04:35 schrieb Wenyou Yang:

Due to introducing the new PLLB clock handle functions,
use these functions to clean up the PLLB enable/disable code.

Signed-off-by: Wenyou Yang 
Reviewed-by: Andreas Bießmann 
---

Changes in v3:
  - collect Reviewed-by from Andreas.

Changes in v2:
  - add return value for timeout checking at91_pllb_clk_enable/disable().

  drivers/usb/host/ohci-at91.c |   22 +++---
  1 file changed, 7 insertions(+), 15 deletions(-)


Tested-by: Heiko Schocher 

bye,
Heiko


diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index 6ae6959..e030a0a 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -9,20 +9,14 @@

  #if defined(CONFIG_USB_OHCI_NEW) && defined(CONFIG_SYS_USB_OHCI_CPU_INIT)

-#include 
-#include 
-#include 
  #include 

  int usb_cpu_init(void)
  {
-   at91_pmc_t *pmc = (at91_pmc_t *)ATMEL_BASE_PMC;
-
  #ifdef CONFIG_USB_ATMEL_CLK_SEL_PLLB
-   /* Enable PLLB */
-   writel(get_pllb_init(), &pmc->pllbr);
-   while ((readl(&pmc->sr) & AT91_PMC_LOCKB) != AT91_PMC_LOCKB)
-   ;
+   if (at91_pllb_clk_enable(get_pllb_init()))
+   return -1;
+
  #ifdef CONFIG_AT91SAM9N12
at91_usb_clk_init(AT91_PMC_USBS_USB_PLLB | AT91_PMC_USB_DIV_2);
  #endif
@@ -45,8 +39,6 @@ int usb_cpu_init(void)

  int usb_cpu_stop(void)
  {
-   at91_pmc_t *pmc = (at91_pmc_t *)ATMEL_BASE_PMC;
-
at91_periph_clk_disable(ATMEL_ID_UHP);

at91_system_clk_disable(ATMEL_PMC_UHP);
@@ -58,10 +50,10 @@ int usb_cpu_stop(void)
  #ifdef CONFIG_AT91SAM9N12
at91_usb_clk_init(0);
  #endif
-   /* Disable PLLB */
-   writel(0, &pmc->pllbr);
-   while ((readl(&pmc->sr) & AT91_PMC_LOCKB) != 0)
-   ;
+
+   if (at91_pllb_clk_disable())
+   return -1;
+
  #elif defined(CONFIG_USB_ATMEL_CLK_SEL_UPLL)
if (at91_upll_clk_disable())
return -1;



--
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v3 3/3] board: atmel: siemens: clean up PLLB code

2016-02-01 Thread Heiko Schocher

Hello Wenyou,

Am 02.02.2016 um 04:35 schrieb Wenyou Yang:

Due to introducing the new PLLB clock handle functions,
use these functions to clean up the PLLB enable code.

Signed-off-by: Wenyou Yang 
Reviewed-by: Andreas Bießmann 
---

Changes in v3: None
Changes in v2:
  - collect Reviewed-by from Andreas.

  board/siemens/smartweb/smartweb.c |6 +-
  board/siemens/taurus/taurus.c |6 +-
  2 files changed, 2 insertions(+), 10 deletions(-)


Tested-by: Heiko Schocher 

bye,
Heiko


diff --git a/board/siemens/smartweb/smartweb.c 
b/board/siemens/smartweb/smartweb.c
index e7ee65c..47a60a7 100644
--- a/board/siemens/smartweb/smartweb.c
+++ b/board/siemens/smartweb/smartweb.c
@@ -115,12 +115,8 @@ static void smartweb_macb_hw_init(void)

  void at91_udp_hw_init(void)
  {
-   at91_pmc_t *pmc = (at91_pmc_t *)ATMEL_BASE_PMC;
-
/* Enable PLLB */
-   writel(get_pllb_init(), &pmc->pllbr);
-   while ((readl(&pmc->sr) & AT91_PMC_LOCKB) != AT91_PMC_LOCKB)
-   ;
+   at91_pllb_clk_enable(get_pllb_init());

/* Enable UDPCK clock, MCK is enabled in at91_clock_init() */
at91_periph_clk_enable(ATMEL_ID_UDP);
diff --git a/board/siemens/taurus/taurus.c b/board/siemens/taurus/taurus.c
index 9374064..b0385d8 100644
--- a/board/siemens/taurus/taurus.c
+++ b/board/siemens/taurus/taurus.c
@@ -289,12 +289,8 @@ void spi_cs_deactivate(struct spi_slave *slave)

  void at91_udp_hw_init(void)
  {
-   at91_pmc_t *pmc = (at91_pmc_t *)ATMEL_BASE_PMC;
-
/* Enable PLLB */
-   writel(get_pllb_init(), &pmc->pllbr);
-   while ((readl(&pmc->sr) & AT91_PMC_LOCKB) != AT91_PMC_LOCKB)
-   ;
+   at91_pllb_clk_enable(get_pllb_init());

/* Enable UDPCK clock, MCK is enabled in at91_clock_init() */
at91_periph_clk_enable(ATMEL_ID_UDP);



--
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v3 3/3] board: atmel: clean up the PMC_PLLICPR init code

2016-02-01 Thread Wenyou Yang
Due to introducing the PMC_PLLICPR init function, use this
function to clean up the code.

Signed-off-by: Wenyou Yang 
Tested-by: Heiko Schocher 
---

Changes in v3:
 - collect Tested-by from Heiko Schocher.

Changes in v2: None

 board/atmel/sama5d3_xplained/sama5d3_xplained.c |4 +---
 board/atmel/sama5d3xek/sama5d3xek.c |4 +---
 board/atmel/sama5d4_xplained/sama5d4_xplained.c |4 +---
 board/atmel/sama5d4ek/sama5d4ek.c   |4 +---
 4 files changed, 4 insertions(+), 12 deletions(-)

diff --git a/board/atmel/sama5d3_xplained/sama5d3_xplained.c 
b/board/atmel/sama5d3_xplained/sama5d3_xplained.c
index d180b41..6532970 100644
--- a/board/atmel/sama5d3_xplained/sama5d3_xplained.c
+++ b/board/atmel/sama5d3_xplained/sama5d3_xplained.c
@@ -10,7 +10,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -198,7 +197,6 @@ void mem_init(void)
 
 void at91_pmc_init(void)
 {
-   struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
u32 tmp;
 
tmp = AT91_PMC_PLLAR_29 |
@@ -207,7 +205,7 @@ void at91_pmc_init(void)
  AT91_PMC_PLLXR_DIV(1);
at91_plla_init(tmp);
 
-   writel(0x3 << 8, &pmc->pllicpr);
+   at91_pllicpr_init(AT91_PMC_IPLL_PLLA(0x3));
 
tmp = AT91_PMC_MCKR_MDIV_4 |
  AT91_PMC_MCKR_CSS_PLLA;
diff --git a/board/atmel/sama5d3xek/sama5d3xek.c 
b/board/atmel/sama5d3xek/sama5d3xek.c
index 777e57e..7a804e8 100644
--- a/board/atmel/sama5d3xek/sama5d3xek.c
+++ b/board/atmel/sama5d3xek/sama5d3xek.c
@@ -10,7 +10,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -457,7 +456,6 @@ void mem_init(void)
 
 void at91_pmc_init(void)
 {
-   struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
u32 tmp;
 
tmp = AT91_PMC_PLLAR_29 |
@@ -466,7 +464,7 @@ void at91_pmc_init(void)
  AT91_PMC_PLLXR_DIV(1);
at91_plla_init(tmp);
 
-   writel(0x3 << 8, &pmc->pllicpr);
+   at91_pllicpr_init(AT91_PMC_IPLL_PLLA(0x3));
 
tmp = AT91_PMC_MCKR_MDIV_4 |
  AT91_PMC_MCKR_CSS_PLLA;
diff --git a/board/atmel/sama5d4_xplained/sama5d4_xplained.c 
b/board/atmel/sama5d4_xplained/sama5d4_xplained.c
index e95310c..3fec662 100644
--- a/board/atmel/sama5d4_xplained/sama5d4_xplained.c
+++ b/board/atmel/sama5d4_xplained/sama5d4_xplained.c
@@ -8,7 +8,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -397,7 +396,6 @@ void mem_init(void)
 
 void at91_pmc_init(void)
 {
-   struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
u32 tmp;
 
tmp = AT91_PMC_PLLAR_29 |
@@ -406,7 +404,7 @@ void at91_pmc_init(void)
  AT91_PMC_PLLXR_DIV(1);
at91_plla_init(tmp);
 
-   writel(0x0 << 8, &pmc->pllicpr);
+   at91_pllicpr_init(AT91_PMC_IPLL_PLLA(0x0));
 
tmp = AT91_PMC_MCKR_H32MXDIV |
  AT91_PMC_MCKR_PLLADIV_2 |
diff --git a/board/atmel/sama5d4ek/sama5d4ek.c 
b/board/atmel/sama5d4ek/sama5d4ek.c
index c92e2588..6ccbc64 100644
--- a/board/atmel/sama5d4ek/sama5d4ek.c
+++ b/board/atmel/sama5d4ek/sama5d4ek.c
@@ -8,7 +8,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -393,7 +392,6 @@ void mem_init(void)
 
 void at91_pmc_init(void)
 {
-   struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
u32 tmp;
 
tmp = AT91_PMC_PLLAR_29 |
@@ -402,7 +400,7 @@ void at91_pmc_init(void)
  AT91_PMC_PLLXR_DIV(1);
at91_plla_init(tmp);
 
-   writel(0x0 << 8, &pmc->pllicpr);
+   at91_pllicpr_init(AT91_PMC_IPLL_PLLA(0x0));
 
tmp = AT91_PMC_MCKR_H32MXDIV |
  AT91_PMC_MCKR_PLLADIV_2 |
-- 
1.7.9.5

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


[U-Boot] [PATCH v3 0/3] ARM: at91: add PMC_PLLICPR init function

2016-02-01 Thread Wenyou Yang
To reduce the duplicated code, add PLLICPR init function, use
the function to clean up the PMC_PLLICPR directly writing code.

It is based on the following patch set.
http://lists.denx.de/pipermail/u-boot/2016-February/244370.html
http://lists.denx.de/pipermail/u-boot/2016-February/244399.html
http://lists.denx.de/pipermail/u-boot/2016-February/244408.html

Changes in v3:
 - collect Tested-by from Heiko Schocher.

Changes in v2:
 - move at91_pllicpr_init() definition to the common file, clock.c.
 - fix checkpatch errors.

Wenyou Yang (3):
  ARM: at91: clock: add PMC_PLLICPR init function
  ARM: at91: clean up the PMC_PLLICPR init code
  board: atmel: clean up the PMC_PLLICPR init code

 arch/arm/mach-at91/clock.c  |7 +++
 arch/arm/mach-at91/include/mach/at91_pmc.h  |7 +++
 arch/arm/mach-at91/include/mach/clk.h   |1 +
 arch/arm/mach-at91/spl_at91.c   |5 +
 board/atmel/sama5d3_xplained/sama5d3_xplained.c |4 +---
 board/atmel/sama5d3xek/sama5d3xek.c |4 +---
 board/atmel/sama5d4_xplained/sama5d4_xplained.c |4 +---
 board/atmel/sama5d4ek/sama5d4ek.c   |4 +---
 8 files changed, 20 insertions(+), 16 deletions(-)

-- 
1.7.9.5

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


[U-Boot] [PATCH v3 1/3] ARM: at91: clock: add PMC_PLLICPR init function

2016-02-01 Thread Wenyou Yang
To avoid the duplicated code, add the PMC_PLLICPR init function.

Signed-off-by: Wenyou Yang 
Tested-by: Heiko Schocher 
---

Changes in v3: None
Changes in v2:
 - move at91_pllicpr_init() definition to the common file, clock.c.
 - fix checkpatch errors.

 arch/arm/mach-at91/clock.c |7 +++
 arch/arm/mach-at91/include/mach/at91_pmc.h |7 +++
 arch/arm/mach-at91/include/mach/clk.h  |1 +
 3 files changed, 15 insertions(+)

diff --git a/arch/arm/mach-at91/clock.c b/arch/arm/mach-at91/clock.c
index 6d115c9..8a6149e 100644
--- a/arch/arm/mach-at91/clock.c
+++ b/arch/arm/mach-at91/clock.c
@@ -118,3 +118,10 @@ void at91_usb_clk_init(u32 value)
 
writel(value, &pmc->usb);
 }
+
+void at91_pllicpr_init(u32 icpr)
+{
+   struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
+
+   writel(icpr, &pmc->pllicpr);
+}
diff --git a/arch/arm/mach-at91/include/mach/at91_pmc.h 
b/arch/arm/mach-at91/include/mach/at91_pmc.h
index eb40194..7684f09 100644
--- a/arch/arm/mach-at91/include/mach/at91_pmc.h
+++ b/arch/arm/mach-at91/include/mach/at91_pmc.h
@@ -246,4 +246,11 @@ typedef struct at91_pmc {
 #defineAT91_PMC_GCKRDY (1 << 24)
 
 #defineAT91_PMC_PROTKEY0x504d4301  /* Activation 
Code */
+
+/* PLL Charge Pump Current Register (PMC_PLLICPR) */
+#define AT91_PMC_ICP_PLLA(x)   (((x) & 0x3) << 0)
+#define AT91_PMC_IPLL_PLLA(x)  (((x) & 0x7) << 8)
+#define AT91_PMC_ICP_PLLU(x)   (((x) & 0x3) << 16)
+#define AT91_PMC_IVCO_PLLU(x)  (((x) & 0x3) << 24)
+
 #endif
diff --git a/arch/arm/mach-at91/include/mach/clk.h 
b/arch/arm/mach-at91/include/mach/clk.h
index 64dec52..8577c74 100644
--- a/arch/arm/mach-at91/include/mach/clk.h
+++ b/arch/arm/mach-at91/include/mach/clk.h
@@ -135,5 +135,6 @@ int at91_upll_clk_disable(void);
 void at91_usb_clk_init(u32 value);
 int at91_pllb_clk_enable(u32 pllbr);
 int at91_pllb_clk_disable(void);
+void at91_pllicpr_init(u32 icpr);
 
 #endif /* __ASM_ARM_ARCH_CLK_H__ */
-- 
1.7.9.5

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


[U-Boot] [PATCH v3 2/3] ARM: at91: clean up the PMC_PLLICPR init code

2016-02-01 Thread Wenyou Yang
Due to introducing the PMC_PLLICPR init function, use this
function to clean up the code.

Signed-off-by: Wenyou Yang 
Tested-by: Heiko Schocher 
---

Changes in v3: None
Changes in v2: None

 arch/arm/mach-at91/spl_at91.c |5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/arch/arm/mach-at91/spl_at91.c b/arch/arm/mach-at91/spl_at91.c
index b19f95b..cc3341a 100644
--- a/arch/arm/mach-at91/spl_at91.c
+++ b/arch/arm/mach-at91/spl_at91.c
@@ -14,7 +14,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -77,8 +76,6 @@ void __weak spl_board_init(void)
 
 void board_init_f(ulong dummy)
 {
-   struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
-
lowlevel_clock_init();
at91_disable_wdt();
 
@@ -86,7 +83,7 @@ void board_init_f(ulong dummy)
 * At this stage the main oscillator is supposed to be enabled
 * PCK = MCK = MOSC
 */
-   writel(0x00, &pmc->pllicpr);
+   at91_pllicpr_init(0x00);
 
/* Configure PLLA = MOSC * (PLL_MULA + 1) / PLL_DIVA */
at91_plla_init(CONFIG_SYS_AT91_PLLA);
-- 
1.7.9.5

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


Re: [U-Boot] 64-bit x86 U-Boot?

2016-02-01 Thread Simon Glass
+Bin (sorry, meant to copy you before)

Hi Albert,

On 1 February 2016 at 00:14, Albert ARIBAUD  wrote:
> Hello Simon,
>
> On Sun, 31 Jan 2016 19:20:31 -0700, Simon Glass 
> wrote:
>> Hi Bin,
>>
>> At present U-Boot supports booting a 64-bit kernel directly. It can
>> also be loaded as a 64-bit payload from EFI. But it cannot be built as
>> a 64-bit boot loader.
>>
>> I took a bit of a look at this. It looks like we need to stay in
>> 32-bit mode until the FSP is loaded. Also, to get to 64-bit mode I'm
>> pretty sure we need page tables, which means we need somewhere to put
>> them!
>>
>> Looking at the board_f init sequence, it seems that arch_cpu_init() is
>> the earlist we could switch to 64-bit. We'd need to grab some memory
>> from somewhere to do this - I wonder if this can be CAR? There is no
>> SRAM on x86 chips I think.
>>
>> For non-FSP devices we don't init the RAM until much later -
>> dram_init(). That means that a significant portion of the init
>> sequence would be 32-bit code. I'm not sure that will work.
>>
>> I suppose one option is to only go to 64-bit mode when relocating. But
>> then we end up with lots of code that needs to run in 32-bit and
>> 64-bit.
>>
>> Do you have any ideas on this?
>
> How about starting with implementing the last option, i.e. switch to 64
> bits when DDR is available, mainline that, then progressively work your
> way toward an earlier switch?

The tricky thing is that I'm not sure we can run 32-bit code in 64-bit
mode or vice-versa. The instruction set is similar but there are data
size settings that probably make it incompatible.

I wonder whether we might need to resort to SPL for the 32-bit
portion, and jump to a 64-bit U-Boot from there? Tegra does something
similar to that.

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


Re: [U-Boot] [PATCH 00/23] x86: Convert to use DM PCI APIs completely

2016-02-01 Thread Simon Glass
Hi Bin,

On 1 February 2016 at 19:25, Bin Meng  wrote:
> Hi Simon,
>
> On Tue, Feb 2, 2016 at 12:19 AM, Simon Glass  wrote:
>> Hi Bin,
>>
>> On 1 February 2016 at 02:40, Bin Meng  wrote:
>>> There are still some codes that use the legacy PCI APIs to access
>>> the configuration space registers. This series converts those codes
>>> to completely use DM PCI APIs.
>>>
>>> This includes adding several new ops to the PCH uclass driver, and
>>> some clean up to the SPI/GPIO/IRQ drivers.
>>>
>>> Tested on QEMU and Crown Bay. This series is available in pci-working
>>> branch of u-boot-x86 repo.
>>
>> Looks great! This is a big step forward.
>>
>> I've tested it on minnowmax and will test on link in the next day or so.
>>
>> Here are a few things that I think can still be cleaned up:
>> - void pci_assign_irqs(int bus, int device, u8 irq[4]) should use a
>> struct udevice
>
> I guess no, unless we expand struct udevice to include interrupt
> routing information? But that's not generic across architectures. I am
> not sure how.

I suppose we can adjust it to take a struct udevice and drop the bus
and device parameters. But then we need to be able to support reading
from different functions, so will need to use pci_bus_read_config().
But at least that is a DM function. Hmmm

>
>> - pci_x86_read/write_config() move into drivers/pci/pci_x86.c (needs
>> ivybridge fix which I'll look at)
>
> Yep. I wanted to do this when reviewing one of previous patches.

OK let's see what I find.

>
>> - disable DM_PCI_COMPAT for x86
>
> Looks e1000 and pch_gbe (Crown Bay) ethernet drivers are still using
> legacy PCI APIs. e1000 might need quite amount of work as it is being
> widely used on lots of boards. I can update pch_gbe driver later.

I converted rtl8169 using #ifdef and it seemed to work OK. We don't
need to remove the old code.

>
>> - use the PCI mmio access method instead of I/O once it becomes possible
>
> Yep.
>
>> - moving vesa video to driver model (UCLASS_VIDEO)
>
> I was not following the dm video changes recently, but I guess yes.

It only merged recently. I haven't tried looking at that.

On another note, I just got an Edison. What do you think about
supporting that in U-Boot?

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


Re: [U-Boot] [PATCH v2] ARM: uniphier: update U-Boot file names

2016-02-01 Thread Simon Glass
On 1 February 2016 at 20:53, Masahiro Yamada
 wrote:
> Since commit ad1ecd2063da ("fdt: Build a U-Boot binary without device
> tree") and commit 03c25bcd263a ("fdt: Build an SPL binary without
> device tree"), we can use shorter file names for the output images.
>
> The default configuration for UniPhier SoCs enables CONFIG_OF_SEPARATE
> and CONFIG_SPL_OF_CONTROL.  In this case, spl/u-boot-spl-dtb.bin is
> the same as spl/u-boot-spl.bin.  Likewise, u-boot-dtb.img is the same
> as u-boot.img.  So, this change of the flow has no impact.
>
> Signed-off-by: Masahiro Yamada 
> ---
>
> Changes in v2:
>   - Also update include/configs/uniphier.h
>
>  doc/README.uniphier| 6 +++---
>  include/configs/uniphier.h | 4 ++--
>  2 files changed, 5 insertions(+), 5 deletions(-)

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


[U-Boot] [PATCH v2] ARM: uniphier: update U-Boot file names

2016-02-01 Thread Masahiro Yamada
Since commit ad1ecd2063da ("fdt: Build a U-Boot binary without device
tree") and commit 03c25bcd263a ("fdt: Build an SPL binary without
device tree"), we can use shorter file names for the output images.

The default configuration for UniPhier SoCs enables CONFIG_OF_SEPARATE
and CONFIG_SPL_OF_CONTROL.  In this case, spl/u-boot-spl-dtb.bin is
the same as spl/u-boot-spl.bin.  Likewise, u-boot-dtb.img is the same
as u-boot.img.  So, this change of the flow has no impact.

Signed-off-by: Masahiro Yamada 
---

Changes in v2:
  - Also update include/configs/uniphier.h

 doc/README.uniphier| 6 +++---
 include/configs/uniphier.h | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/doc/README.uniphier b/doc/README.uniphier
index bce70cf..bcf0ac3 100644
--- a/doc/README.uniphier
+++ b/doc/README.uniphier
@@ -68,8 +68,8 @@ Burn U-Boot images to NAND
 --
 
 Write two files to the NAND device as follows:
- - spl/u-boot-spl-dtb.bin at the offset address 0x
- - u-boot-dtb.img at the offset address 0x0001
+ - spl/u-boot-spl.bin at the offset address 0x
+ - u-boot.img at the offset address 0x0001
 
 If a TFTP server is available, the images can be easily updated.
 Just copy the u-boot-spl-dtb.bin and u-boot-dtb.img to the TFTP public
@@ -145,4 +145,4 @@ newer SoCs.  Even if it is, EA[25] is not connected on most 
of the boards.
 
 --
 Masahiro Yamada 
-Aug. 2015
+Feb. 2016
diff --git a/include/configs/uniphier.h b/include/configs/uniphier.h
index 97168e9..8856044 100644
--- a/include/configs/uniphier.h
+++ b/include/configs/uniphier.h
@@ -230,9 +230,9 @@
"nor_base=0x4200\0" \
"bootm_low=0x8000\0"\
"nandupdate=nand erase 0 0x0010 &&" \
-   "tftpboot u-boot-spl-dtb.bin &&"\
+   "tftpboot u-boot-spl.bin &&"\
"nand write $loadaddr 0 0x0001 &&"  \
-   "tftpboot u-boot-dtb.img &&"\
+   "tftpboot u-boot.img &&"\
"nand write $loadaddr 0x0001 0x000f\0"  \
LINUXBOOT_ENV_SETTINGS
 
-- 
1.9.1

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


Re: [U-Boot] [PATCH v1 1/2] Revert "powerpc: mpc85xx: remove P2020DS board support"

2016-02-01 Thread Bin Meng
Hi York,

On Tue, Feb 2, 2016 at 11:31 AM, york sun  wrote:
> On 02/01/2016 07:19 PM, Bin Meng wrote:
>> Hi York,
>>
>> On Tue, Feb 2, 2016 at 11:11 AM, york sun  wrote:
>>> On 02/01/2016 04:05 PM, Simon Glass wrote:
>>> 
>
> I will take this chance to convert P2020DS to use DM. Need some guidance 
> here.
> For NS16550, it needs the clock. To keep it simple, let's presume 
> platform data
> is used. My trouble is the clock is not unknown at compiling time. It 
> needs to
> be updated by checking the board/soc configuration after power up. The 
> clock is
> only available after get_clocks() is called in init_sequance. Is there a 
> way I
> can update the clocks before the driver is initialized?
>
> York

 See this commit:

 858530a8 dm: tegra: Enable driver model for serial

 It sets up its own clock.
>>>
>>> Simon,
>>>
>>> Thanks for the pointer. I actually noticed this commit but it adds some
>>> confusion to me. Take your code as an example
>>>
>>> U_BOOT_DRIVER(serial_ns16550) = {
>>>.name   = "serial_tegra20",
>>>.id = UCLASS_SERIAL,
>>>.of_match = tegra_serial_ids,
>>>.ofdata_to_platdata = tegra_serial_ofdata_to_platdata,
>>>.platdata_auto_alloc_size = sizeof(struct ns16550_platdata),
>>>.priv_auto_alloc_size = sizeof(struct NS16550),
>>>.probe = ns16550_serial_probe,
>>>.ops= &ns16550_serial_ops,
>>> };
>>>
>>> The name "serial_ns16550" is not directly used anywhere. So I guess you 
>>> didn't
>>> have to name it as "serial_ns16550", right?
>>>
>>
>> The commit Simon gave was an old one. Now all ns16550 driver has been
>> unified into one.
>>
>>> One step forward, if I want to create a new driver, say "fsl_ns16550", I 
>>> will
>>> have to use ofdata_to_platdata to fill in plat->clock. But for majority 
>>> powerpc
>>> SoCs, we don't use device tree. We may start to use device tree on new 
>>> products.
>>> But it is probably not a good idea to force every platform to change.
>>>
>>
>> Please do not create a new driver for FSL chipset. Does FSL have any
>
> That's a relief. I don't want to create a new driver just for the clock.
>
>> plan to continue maintaining all these PowerPC SoCs in U-Boot? If yes,
>> I believe the intention is to bring driver model and device tree to
>> these boards.
>
> I'd rather to add the device tree step by step, not all at once. And probably
> leave some legacy boards behind.
>

Agreed. We can add device tree and driver model drivers to these
PowerPC boards step by step as long as they are maintained. There is
no need to add them in a bunch. It's easy to convert these PowerPC
boards to driver model, given they share some of the IPs in the new
LayerScape ARM SoCs.

>>
>>> Is there another way to update plat->clock?
>>>
>>
>> You can define CONFIG_SYS_NS16550_CLK to a routine that gets the
>> correct clock freq at runtime: eg: get_serial_clock()
>
> Please explain in detail. I want to go down this path. For non-device tree
> platforms (for the time being), doesn't U_BOOT_DEVICES evaluate the platdata 
> at
> compiling time? How can I use a routine as the clock for ns16550_platdata?
> It is pretty simple for fixed clock, as I am looking at an example
> arch/arm/cpu/armv7/am33xx/board.c.
>

We should add device tree to these platforms. The non-device tree
(U_BOOT_DEVICES) was mainly for some SPL boards which does not have
enough RAM before memory is initialized. I think you may refer to this
patch: http://patchwork.ozlabs.org/patch/561853/

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


[U-Boot] [PATCH v3 1/3] ARM: at91: clock: add PLLB enable/disable functions

2016-02-01 Thread Wenyou Yang
To avoid the duplicated code, add the PLLB handle functions.

Signed-off-by: Wenyou Yang 
Reviewed-by: Andreas Bießmann 
---

Changes in v3: None
Changes in v2: None

 arch/arm/mach-at91/arm926ejs/clock.c  |   38 +
 arch/arm/mach-at91/include/mach/clk.h |2 ++
 2 files changed, 40 insertions(+)

diff --git a/arch/arm/mach-at91/arm926ejs/clock.c 
b/arch/arm/mach-at91/arm926ejs/clock.c
index c8b5e10..c8d24ae 100644
--- a/arch/arm/mach-at91/arm926ejs/clock.c
+++ b/arch/arm/mach-at91/arm926ejs/clock.c
@@ -18,6 +18,8 @@
 # error You need to define CONFIG_AT91FAMILY in your board config!
 #endif
 
+#define EN_PLLB_TIMEOUT500
+
 DECLARE_GLOBAL_DATA_PTR;
 
 static unsigned long at91_css_to_rate(unsigned long css)
@@ -242,3 +244,39 @@ void at91_mck_init(u32 mckr)
while (!(readl(&pmc->sr) & AT91_PMC_MCKRDY))
;
 }
+
+int at91_pllb_clk_enable(u32 pllbr)
+{
+   struct at91_pmc *pmc = (at91_pmc_t *)ATMEL_BASE_PMC;
+   ulong start_time, tmp_time;
+
+   start_time = get_timer(0);
+   writel(pllbr, &pmc->pllbr);
+   while ((readl(&pmc->sr) & AT91_PMC_LOCKB) != AT91_PMC_LOCKB) {
+   tmp_time = get_timer(0);
+   if ((tmp_time - start_time) > EN_PLLB_TIMEOUT) {
+   printf("ERROR: failed to enable PLLB\n");
+   return -1;
+   }
+   }
+
+   return 0;
+}
+
+int at91_pllb_clk_disable(void)
+{
+   struct at91_pmc *pmc = (at91_pmc_t *)ATMEL_BASE_PMC;
+   ulong start_time, tmp_time;
+
+   start_time = get_timer(0);
+   writel(0, &pmc->pllbr);
+   while ((readl(&pmc->sr) & AT91_PMC_LOCKB) != 0) {
+   tmp_time = get_timer(0);
+   if ((tmp_time - start_time) > EN_PLLB_TIMEOUT) {
+   printf("ERROR: failed to disable PLLB\n");
+   return -1;
+   }
+   }
+
+   return 0;
+}
diff --git a/arch/arm/mach-at91/include/mach/clk.h 
b/arch/arm/mach-at91/include/mach/clk.h
index b2604ef..64dec52 100644
--- a/arch/arm/mach-at91/include/mach/clk.h
+++ b/arch/arm/mach-at91/include/mach/clk.h
@@ -133,5 +133,7 @@ void at91_system_clk_disable(int sys_clk);
 int at91_upll_clk_enable(void);
 int at91_upll_clk_disable(void);
 void at91_usb_clk_init(u32 value);
+int at91_pllb_clk_enable(u32 pllbr);
+int at91_pllb_clk_disable(void);
 
 #endif /* __ASM_ARM_ARCH_CLK_H__ */
-- 
1.7.9.5

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


[U-Boot] [PATCH v3 3/3] board: atmel: siemens: clean up PLLB code

2016-02-01 Thread Wenyou Yang
Due to introducing the new PLLB clock handle functions,
use these functions to clean up the PLLB enable code.

Signed-off-by: Wenyou Yang 
Reviewed-by: Andreas Bießmann 
---

Changes in v3: None
Changes in v2:
 - collect Reviewed-by from Andreas.

 board/siemens/smartweb/smartweb.c |6 +-
 board/siemens/taurus/taurus.c |6 +-
 2 files changed, 2 insertions(+), 10 deletions(-)

diff --git a/board/siemens/smartweb/smartweb.c 
b/board/siemens/smartweb/smartweb.c
index e7ee65c..47a60a7 100644
--- a/board/siemens/smartweb/smartweb.c
+++ b/board/siemens/smartweb/smartweb.c
@@ -115,12 +115,8 @@ static void smartweb_macb_hw_init(void)
 
 void at91_udp_hw_init(void)
 {
-   at91_pmc_t *pmc = (at91_pmc_t *)ATMEL_BASE_PMC;
-
/* Enable PLLB */
-   writel(get_pllb_init(), &pmc->pllbr);
-   while ((readl(&pmc->sr) & AT91_PMC_LOCKB) != AT91_PMC_LOCKB)
-   ;
+   at91_pllb_clk_enable(get_pllb_init());
 
/* Enable UDPCK clock, MCK is enabled in at91_clock_init() */
at91_periph_clk_enable(ATMEL_ID_UDP);
diff --git a/board/siemens/taurus/taurus.c b/board/siemens/taurus/taurus.c
index 9374064..b0385d8 100644
--- a/board/siemens/taurus/taurus.c
+++ b/board/siemens/taurus/taurus.c
@@ -289,12 +289,8 @@ void spi_cs_deactivate(struct spi_slave *slave)
 
 void at91_udp_hw_init(void)
 {
-   at91_pmc_t *pmc = (at91_pmc_t *)ATMEL_BASE_PMC;
-
/* Enable PLLB */
-   writel(get_pllb_init(), &pmc->pllbr);
-   while ((readl(&pmc->sr) & AT91_PMC_LOCKB) != AT91_PMC_LOCKB)
-   ;
+   at91_pllb_clk_enable(get_pllb_init());
 
/* Enable UDPCK clock, MCK is enabled in at91_clock_init() */
at91_periph_clk_enable(ATMEL_ID_UDP);
-- 
1.7.9.5

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


[U-Boot] [PATCH v3 2/3] drivers: usb: ohci-at91: clean up the PLLB code

2016-02-01 Thread Wenyou Yang
Due to introducing the new PLLB clock handle functions,
use these functions to clean up the PLLB enable/disable code.

Signed-off-by: Wenyou Yang 
Reviewed-by: Andreas Bießmann 
---

Changes in v3:
 - collect Reviewed-by from Andreas.

Changes in v2:
 - add return value for timeout checking at91_pllb_clk_enable/disable().

 drivers/usb/host/ohci-at91.c |   22 +++---
 1 file changed, 7 insertions(+), 15 deletions(-)

diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index 6ae6959..e030a0a 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -9,20 +9,14 @@
 
 #if defined(CONFIG_USB_OHCI_NEW) && defined(CONFIG_SYS_USB_OHCI_CPU_INIT)
 
-#include 
-#include 
-#include 
 #include 
 
 int usb_cpu_init(void)
 {
-   at91_pmc_t *pmc = (at91_pmc_t *)ATMEL_BASE_PMC;
-
 #ifdef CONFIG_USB_ATMEL_CLK_SEL_PLLB
-   /* Enable PLLB */
-   writel(get_pllb_init(), &pmc->pllbr);
-   while ((readl(&pmc->sr) & AT91_PMC_LOCKB) != AT91_PMC_LOCKB)
-   ;
+   if (at91_pllb_clk_enable(get_pllb_init()))
+   return -1;
+
 #ifdef CONFIG_AT91SAM9N12
at91_usb_clk_init(AT91_PMC_USBS_USB_PLLB | AT91_PMC_USB_DIV_2);
 #endif
@@ -45,8 +39,6 @@ int usb_cpu_init(void)
 
 int usb_cpu_stop(void)
 {
-   at91_pmc_t *pmc = (at91_pmc_t *)ATMEL_BASE_PMC;
-
at91_periph_clk_disable(ATMEL_ID_UHP);
 
at91_system_clk_disable(ATMEL_PMC_UHP);
@@ -58,10 +50,10 @@ int usb_cpu_stop(void)
 #ifdef CONFIG_AT91SAM9N12
at91_usb_clk_init(0);
 #endif
-   /* Disable PLLB */
-   writel(0, &pmc->pllbr);
-   while ((readl(&pmc->sr) & AT91_PMC_LOCKB) != 0)
-   ;
+
+   if (at91_pllb_clk_disable())
+   return -1;
+
 #elif defined(CONFIG_USB_ATMEL_CLK_SEL_UPLL)
if (at91_upll_clk_disable())
return -1;
-- 
1.7.9.5

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


[U-Boot] [PATCH v3 0/3] ARM: at91: add PLLB handle functions

2016-02-01 Thread Wenyou Yang
To reduce the duplicated code, add PLLB enable/disable functions,
replace the UTMI PLL handle code with these functions.

It is based on the following patch set.
http://lists.denx.de/pipermail/u-boot/2016-February/244370.html
http://lists.denx.de/pipermail/u-boot/2016-February/244399.html

Changes in v3:
 - collect Reviewed-by from Andreas.

Changes in v2:
 - add return value for timeout checking at91_pllb_clk_enable/disable().
 - collect Reviewed-by from Andreas.

Wenyou Yang (3):
  ARM: at91: clock: add PLLB enable/disable functions
  drivers: usb: ohci-at91: clean up the PLLB code
  board: atmel: siemens: clean up PLLB code

 arch/arm/mach-at91/arm926ejs/clock.c  |   38 +
 arch/arm/mach-at91/include/mach/clk.h |2 ++
 board/siemens/smartweb/smartweb.c |6 +-
 board/siemens/taurus/taurus.c |6 +-
 drivers/usb/host/ohci-at91.c  |   22 ++-
 5 files changed, 49 insertions(+), 25 deletions(-)

-- 
1.7.9.5

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


[U-Boot] [PATCH v3] armv8/ls1043a: Implement workaround for erratum A009660

2016-02-01 Thread Mingkai Hu
From: Mingkai Hu 

Memory controller performance is not optimal with default internal
target queue register value, write required value for optimal DDR
performance.

Signed-off-by: Mingkai Hu 
---
v3:
 - Move the macro check to soc.c.

v2: 
 - Add a check to make sure A009660 and A008514 is are not both enabled.
 - Add comment for the offset of eddrtqcr1.

 arch/arm/cpu/armv8/fsl-layerscape/soc.c   | 19 +++
 arch/arm/include/asm/arch-fsl-layerscape/config.h |  1 +
 2 files changed, 20 insertions(+)

diff --git a/arch/arm/cpu/armv8/fsl-layerscape/soc.c 
b/arch/arm/cpu/armv8/fsl-layerscape/soc.c
index 7ff0148..213ce3a 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/soc.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/soc.c
@@ -213,6 +213,24 @@ static void erratum_a009929(void)
 #endif
 }
 
+/*
+ * This erratum requires setting a value to eddrtqcr1 to optimal
+ * the DDR performance. The eddrtqcr1 register is in SCFG space
+ * of LS1043A and the offset is 0x157_020c.
+ */
+#if defined(CONFIG_SYS_FSL_ERRATUM_A009660) \
+   && defined(CONFIG_SYS_FSL_ERRATUM_A008514)
+#error A009660 and A008514 can not be both enabled.
+#endif
+
+static void erratum_a009660(void)
+{
+#ifdef CONFIG_SYS_FSL_ERRATUM_A009660
+   u32 *eddrtqcr1 = (void *)CONFIG_SYS_FSL_SCFG_ADDR + 0x20c;
+   out_be32(eddrtqcr1, 0x63b20042);
+#endif
+}
+
 void fsl_lsch2_early_init_f(void)
 {
struct ccsr_cci400 *cci = (struct ccsr_cci400 *)CONFIG_SYS_CCI400_ADDR;
@@ -238,6 +256,7 @@ void fsl_lsch2_early_init_f(void)
 
/* Erratum */
erratum_a009929();
+   erratum_a009660();
 }
 #endif
 
diff --git a/arch/arm/include/asm/arch-fsl-layerscape/config.h 
b/arch/arm/include/asm/arch-fsl-layerscape/config.h
index f1b164f..7f8de3d 100644
--- a/arch/arm/include/asm/arch-fsl-layerscape/config.h
+++ b/arch/arm/include/asm/arch-fsl-layerscape/config.h
@@ -171,6 +171,7 @@
 
 #define CONFIG_SYS_FSL_ERRATUM_A009663
 #define CONFIG_SYS_FSL_ERRATUM_A009929
+#define CONFIG_SYS_FSL_ERRATUM_A009660
 #else
 #error SoC not defined
 #endif
-- 
2.1.0.27.g96db324

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


Re: [U-Boot] [PATCH v1 1/2] Revert "powerpc: mpc85xx: remove P2020DS board support"

2016-02-01 Thread york sun
On 02/01/2016 07:19 PM, Bin Meng wrote:
> Hi York,
> 
> On Tue, Feb 2, 2016 at 11:11 AM, york sun  wrote:
>> On 02/01/2016 04:05 PM, Simon Glass wrote:
>> 

 I will take this chance to convert P2020DS to use DM. Need some guidance 
 here.
 For NS16550, it needs the clock. To keep it simple, let's presume platform 
 data
 is used. My trouble is the clock is not unknown at compiling time. It 
 needs to
 be updated by checking the board/soc configuration after power up. The 
 clock is
 only available after get_clocks() is called in init_sequance. Is there a 
 way I
 can update the clocks before the driver is initialized?

 York
>>>
>>> See this commit:
>>>
>>> 858530a8 dm: tegra: Enable driver model for serial
>>>
>>> It sets up its own clock.
>>
>> Simon,
>>
>> Thanks for the pointer. I actually noticed this commit but it adds some
>> confusion to me. Take your code as an example
>>
>> U_BOOT_DRIVER(serial_ns16550) = {
>>.name   = "serial_tegra20",
>>.id = UCLASS_SERIAL,
>>.of_match = tegra_serial_ids,
>>.ofdata_to_platdata = tegra_serial_ofdata_to_platdata,
>>.platdata_auto_alloc_size = sizeof(struct ns16550_platdata),
>>.priv_auto_alloc_size = sizeof(struct NS16550),
>>.probe = ns16550_serial_probe,
>>.ops= &ns16550_serial_ops,
>> };
>>
>> The name "serial_ns16550" is not directly used anywhere. So I guess you 
>> didn't
>> have to name it as "serial_ns16550", right?
>>
> 
> The commit Simon gave was an old one. Now all ns16550 driver has been
> unified into one.
> 
>> One step forward, if I want to create a new driver, say "fsl_ns16550", I will
>> have to use ofdata_to_platdata to fill in plat->clock. But for majority 
>> powerpc
>> SoCs, we don't use device tree. We may start to use device tree on new 
>> products.
>> But it is probably not a good idea to force every platform to change.
>>
> 
> Please do not create a new driver for FSL chipset. Does FSL have any

That's a relief. I don't want to create a new driver just for the clock.

> plan to continue maintaining all these PowerPC SoCs in U-Boot? If yes,
> I believe the intention is to bring driver model and device tree to
> these boards.

I'd rather to add the device tree step by step, not all at once. And probably
leave some legacy boards behind.

> 
>> Is there another way to update plat->clock?
>>
> 
> You can define CONFIG_SYS_NS16550_CLK to a routine that gets the
> correct clock freq at runtime: eg: get_serial_clock()

Please explain in detail. I want to go down this path. For non-device tree
platforms (for the time being), doesn't U_BOOT_DEVICES evaluate the platdata at
compiling time? How can I use a routine as the clock for ns16550_platdata?
It is pretty simple for fixed clock, as I am looking at an example
arch/arm/cpu/armv7/am33xx/board.c.

York

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


[U-Boot] [PATCH] doc: uniphier: update U-Boot file names

2016-02-01 Thread Masahiro Yamada
Since commit ad1ecd2063da ("fdt: Build a U-Boot binary without device
tree") and commit 03c25bcd263a ("fdt: Build an SPL binary without
device tree"), we can use shorter file names for the output images.

The default configuration for UniPhier SoCs enables CONFIG_OF_SEPARATE
and CONFIG_SPL_OF_CONTROL.  In this case, spl/u-boot-spl-dtb.bin is
the same as spl/u-boot-spl.bin.  Likewise, u-boot-dtb.img is the same
as u-boot.img.  So, this change of the flow has no impact.

Signed-off-by: Masahiro Yamada 
---

 doc/README.uniphier | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/doc/README.uniphier b/doc/README.uniphier
index bce70cf..bcf0ac3 100644
--- a/doc/README.uniphier
+++ b/doc/README.uniphier
@@ -68,8 +68,8 @@ Burn U-Boot images to NAND
 --
 
 Write two files to the NAND device as follows:
- - spl/u-boot-spl-dtb.bin at the offset address 0x
- - u-boot-dtb.img at the offset address 0x0001
+ - spl/u-boot-spl.bin at the offset address 0x
+ - u-boot.img at the offset address 0x0001
 
 If a TFTP server is available, the images can be easily updated.
 Just copy the u-boot-spl-dtb.bin and u-boot-dtb.img to the TFTP public
@@ -145,4 +145,4 @@ newer SoCs.  Even if it is, EA[25] is not connected on most 
of the boards.
 
 --
 Masahiro Yamada 
-Aug. 2015
+Feb. 2016
-- 
1.9.1

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


Re: [U-Boot] [PATCH v1 1/2] Revert "powerpc: mpc85xx: remove P2020DS board support"

2016-02-01 Thread Bin Meng
Hi York,

On Tue, Feb 2, 2016 at 11:11 AM, york sun  wrote:
> On 02/01/2016 04:05 PM, Simon Glass wrote:
> 
>>>
>>> I will take this chance to convert P2020DS to use DM. Need some guidance 
>>> here.
>>> For NS16550, it needs the clock. To keep it simple, let's presume platform 
>>> data
>>> is used. My trouble is the clock is not unknown at compiling time. It needs 
>>> to
>>> be updated by checking the board/soc configuration after power up. The 
>>> clock is
>>> only available after get_clocks() is called in init_sequance. Is there a 
>>> way I
>>> can update the clocks before the driver is initialized?
>>>
>>> York
>>
>> See this commit:
>>
>> 858530a8 dm: tegra: Enable driver model for serial
>>
>> It sets up its own clock.
>
> Simon,
>
> Thanks for the pointer. I actually noticed this commit but it adds some
> confusion to me. Take your code as an example
>
> U_BOOT_DRIVER(serial_ns16550) = {
>.name   = "serial_tegra20",
>.id = UCLASS_SERIAL,
>.of_match = tegra_serial_ids,
>.ofdata_to_platdata = tegra_serial_ofdata_to_platdata,
>.platdata_auto_alloc_size = sizeof(struct ns16550_platdata),
>.priv_auto_alloc_size = sizeof(struct NS16550),
>.probe = ns16550_serial_probe,
>.ops= &ns16550_serial_ops,
> };
>
> The name "serial_ns16550" is not directly used anywhere. So I guess you didn't
> have to name it as "serial_ns16550", right?
>

The commit Simon gave was an old one. Now all ns16550 driver has been
unified into one.

> One step forward, if I want to create a new driver, say "fsl_ns16550", I will
> have to use ofdata_to_platdata to fill in plat->clock. But for majority 
> powerpc
> SoCs, we don't use device tree. We may start to use device tree on new 
> products.
> But it is probably not a good idea to force every platform to change.
>

Please do not create a new driver for FSL chipset. Does FSL have any
plan to continue maintaining all these PowerPC SoCs in U-Boot? If yes,
I believe the intention is to bring driver model and device tree to
these boards.

> Is there another way to update plat->clock?
>

You can define CONFIG_SYS_NS16550_CLK to a routine that gets the
correct clock freq at runtime: eg: get_serial_clock()

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


[U-Boot] [PATCH v3 4/4] board: atmel: siemens: clean up UTMI PLL code

2016-02-01 Thread Wenyou Yang
Due to introducing the new UTMI PLL clock handle functions,
use the functions to reduce the duplicated code.

Signed-off-by: Wenyou Yang 
Tested-by: Heiko Schocher 
---

Changes in v3:
 - collect Tested-by from Heiko Schocher.

Changes in v2: None

 board/siemens/corvus/board.c |4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/board/siemens/corvus/board.c b/board/siemens/corvus/board.c
index 8729fe9..658e029 100644
--- a/board/siemens/corvus/board.c
+++ b/board/siemens/corvus/board.c
@@ -207,10 +207,8 @@ int board_early_init_f(void)
 /* from ./arch/arm/mach-at91/armv7/sama5d3_devices.c */
 void at91_udp_hw_init(void)
 {
-   struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
-
/* Enable UPLL clock */
-   writel(AT91_PMC_UPLLEN | AT91_PMC_BIASEN, &pmc->uckr);
+   at91_upll_clk_enable();
 
/* Enable UDPHS clock */
at91_periph_clk_enable(ATMEL_ID_UDPHS);
-- 
1.7.9.5

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


[U-Boot] [PATCH v3 3/4] drivers: usb: atmel: clean up the UTMI PLL code

2016-02-01 Thread Wenyou Yang
Due to introducing the new UTMI PLL clock handle functions,
use these function to reduce the duplicated code.

Signed-off-by: Wenyou Yang 
Tested-by: Heiko Schocher 
---

Changes in v3: None
Changes in v2:
 - remain asm/io.h include.

 drivers/usb/host/ehci-atmel.c |   38 --
 drivers/usb/host/ohci-at91.c  |   20 +++-
 2 files changed, 11 insertions(+), 47 deletions(-)

diff --git a/drivers/usb/host/ehci-atmel.c b/drivers/usb/host/ehci-atmel.c
index a33fb49..1d7d280 100644
--- a/drivers/usb/host/ehci-atmel.c
+++ b/drivers/usb/host/ehci-atmel.c
@@ -7,37 +7,18 @@
  */
 
 #include 
-#include 
 #include 
 #include 
-#include 
-#include 
 #include 
 
 #include "ehci.h"
 
-/* Enable UTMI PLL time out 500us
- * 10 times as datasheet specified
- */
-#define EN_UPLL_TIMEOUT500UL
-
 int ehci_hcd_init(int index, enum usb_init_type init,
struct ehci_hccr **hccr, struct ehci_hcor **hcor)
 {
-   at91_pmc_t *pmc = (at91_pmc_t *)ATMEL_BASE_PMC;
-   ulong start_time, tmp_time;
-
-   start_time = get_timer(0);
/* Enable UTMI PLL */
-   writel(AT91_PMC_UPLLEN | AT91_PMC_BIASEN, &pmc->uckr);
-   while ((readl(&pmc->sr) & AT91_PMC_LOCKU) != AT91_PMC_LOCKU) {
-   WATCHDOG_RESET();
-   tmp_time = get_timer(0);
-   if ((tmp_time - start_time) > EN_UPLL_TIMEOUT) {
-   printf("ERROR: failed to enable UPLL\n");
-   return -1;
-   }
-   }
+   if (at91_upll_clk_enable())
+   return -1;
 
/* Enable USB Host clock */
at91_periph_clk_enable(ATMEL_ID_UHPHS);
@@ -51,23 +32,12 @@ int ehci_hcd_init(int index, enum usb_init_type init,
 
 int ehci_hcd_stop(int index)
 {
-   at91_pmc_t *pmc = (at91_pmc_t *)ATMEL_BASE_PMC;
-   ulong start_time, tmp_time;
-
/* Disable USB Host Clock */
at91_periph_clk_disable(ATMEL_ID_UHPHS);
 
-   start_time = get_timer(0);
/* Disable UTMI PLL */
-   writel(readl(&pmc->uckr) & ~AT91_PMC_UPLLEN, &pmc->uckr);
-   while ((readl(&pmc->sr) & AT91_PMC_LOCKU) == AT91_PMC_LOCKU) {
-   WATCHDOG_RESET();
-   tmp_time = get_timer(0);
-   if ((tmp_time - start_time) > EN_UPLL_TIMEOUT) {
-   printf("ERROR: failed to stop UPLL\n");
-   return -1;
-   }
-   }
+   if (at91_upll_clk_disable())
+   return -1;
 
return 0;
 }
diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index da85111..6ae6959 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -24,17 +24,13 @@ int usb_cpu_init(void)
while ((readl(&pmc->sr) & AT91_PMC_LOCKB) != AT91_PMC_LOCKB)
;
 #ifdef CONFIG_AT91SAM9N12
-   writel(AT91_PMC_USBS_USB_PLLB | AT91_PMC_USB_DIV_2, &pmc->usb);
+   at91_usb_clk_init(AT91_PMC_USBS_USB_PLLB | AT91_PMC_USB_DIV_2);
 #endif
 #elif defined(CONFIG_USB_ATMEL_CLK_SEL_UPLL)
-   /* Enable UPLL */
-   writel(readl(&pmc->uckr) | AT91_PMC_UPLLEN | AT91_PMC_BIASEN,
-   &pmc->uckr);
-   while ((readl(&pmc->sr) & AT91_PMC_LOCKU) != AT91_PMC_LOCKU)
-   ;
+   if (at91_upll_clk_enable())
+   return -1;
 
-   /* Select PLLA as input clock of OHCI */
-   writel(AT91_PMC_USBS_USB_UPLL | AT91_PMC_USBDIV_10, &pmc->usb);
+   at91_usb_clk_init(AT91_PMC_USBS_USB_UPLL | AT91_PMC_USBDIV_10);
 #endif
 
at91_periph_clk_enable(ATMEL_ID_UHP);
@@ -60,17 +56,15 @@ int usb_cpu_stop(void)
 
 #ifdef CONFIG_USB_ATMEL_CLK_SEL_PLLB
 #ifdef CONFIG_AT91SAM9N12
-   writel(0, &pmc->usb);
+   at91_usb_clk_init(0);
 #endif
/* Disable PLLB */
writel(0, &pmc->pllbr);
while ((readl(&pmc->sr) & AT91_PMC_LOCKB) != 0)
;
 #elif defined(CONFIG_USB_ATMEL_CLK_SEL_UPLL)
-   /* Disable UPLL */
-   writel(readl(&pmc->uckr) & (~AT91_PMC_UPLLEN), &pmc->uckr);
-   while ((readl(&pmc->sr) & AT91_PMC_LOCKU) == AT91_PMC_LOCKU)
-   ;
+   if (at91_upll_clk_disable())
+   return -1;
 #endif
 
return 0;
-- 
1.7.9.5

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


[U-Boot] [PATCH v3 2/4] ARM: at91: armv7: clean up UTMI PLL handle code

2016-02-01 Thread Wenyou Yang
Due to introducing the UTMI PLL enable function, use this function
to reduce the duplicated code.

Signed-off-by: Wenyou Yang 
Tested-by: Heiko Schocher 
---

Changes in v3: None
Changes in v2: None

 arch/arm/mach-at91/armv7/sama5d2_devices.c |5 +
 arch/arm/mach-at91/armv7/sama5d3_devices.c |5 +
 arch/arm/mach-at91/armv7/sama5d4_devices.c |5 +
 3 files changed, 3 insertions(+), 12 deletions(-)

diff --git a/arch/arm/mach-at91/armv7/sama5d2_devices.c 
b/arch/arm/mach-at91/armv7/sama5d2_devices.c
index 88f8f2c..978eac2 100644
--- a/arch/arm/mach-at91/armv7/sama5d2_devices.c
+++ b/arch/arm/mach-at91/armv7/sama5d2_devices.c
@@ -7,7 +7,6 @@
 
 #include 
 #include 
-#include 
 #include 
 #include 
 
@@ -48,9 +47,7 @@ char *get_cpu_name()
 #ifdef CONFIG_USB_GADGET_ATMEL_USBA
 void at91_udp_hw_init(void)
 {
-   struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
-
-   writel(AT91_PMC_UPLLEN | AT91_PMC_BIASEN, &pmc->uckr);
+   at91_upll_clk_enable();
 
at91_periph_clk_enable(ATMEL_ID_UDPHS);
 }
diff --git a/arch/arm/mach-at91/armv7/sama5d3_devices.c 
b/arch/arm/mach-at91/armv7/sama5d3_devices.c
index 78ecfc8..64ac262 100644
--- a/arch/arm/mach-at91/armv7/sama5d3_devices.c
+++ b/arch/arm/mach-at91/armv7/sama5d3_devices.c
@@ -8,7 +8,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -208,10 +207,8 @@ void at91_lcd_hw_init(void)
 #ifdef CONFIG_USB_GADGET_ATMEL_USBA
 void at91_udp_hw_init(void)
 {
-   struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
-
/* Enable UPLL clock */
-   writel(AT91_PMC_UPLLEN | AT91_PMC_BIASEN, &pmc->uckr);
+   at91_upll_clk_enable();
/* Enable UDPHS clock */
at91_periph_clk_enable(ATMEL_ID_UDPHS);
 }
diff --git a/arch/arm/mach-at91/armv7/sama5d4_devices.c 
b/arch/arm/mach-at91/armv7/sama5d4_devices.c
index ce33cd4..ebb779e 100644
--- a/arch/arm/mach-at91/armv7/sama5d4_devices.c
+++ b/arch/arm/mach-at91/armv7/sama5d4_devices.c
@@ -8,7 +8,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -37,10 +36,8 @@ char *get_cpu_name()
 #ifdef CONFIG_USB_GADGET_ATMEL_USBA
 void at91_udp_hw_init(void)
 {
-   struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
-
/* Enable UPLL clock */
-   writel(AT91_PMC_UPLLEN | AT91_PMC_BIASEN, &pmc->uckr);
+   at91_upll_clk_enable();
/* Enable UDPHS clock */
at91_periph_clk_enable(ATMEL_ID_UDPHS);
 }
-- 
1.7.9.5

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


[U-Boot] [PATCH v3 1/4] ARM: at91: clock: add UTMI PLL enable/disable function

2016-02-01 Thread Wenyou Yang
To avoid the duplicated code, add the UTMI PLL handle functions,
and add PMC_USB init function too.

Signed-off-by: Wenyou Yang 
Tested-by: Heiko Schocher 
---

Changes in v3: None
Changes in v2: None

 arch/arm/mach-at91/clock.c|   48 +
 arch/arm/mach-at91/include/mach/clk.h |3 +++
 2 files changed, 51 insertions(+)

diff --git a/arch/arm/mach-at91/clock.c b/arch/arm/mach-at91/clock.c
index d1c4b76..6d115c9 100644
--- a/arch/arm/mach-at91/clock.c
+++ b/arch/arm/mach-at91/clock.c
@@ -10,6 +10,8 @@
 #include 
 #include 
 
+#define EN_UPLL_TIMEOUT500
+
 void at91_periph_clk_enable(int id)
 {
struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
@@ -70,3 +72,49 @@ void at91_system_clk_disable(int sys_clk)
 
writel(sys_clk, &pmc->scdr);
 }
+
+int at91_upll_clk_enable(void)
+{
+   struct at91_pmc *pmc = (at91_pmc_t *)ATMEL_BASE_PMC;
+   ulong start_time, tmp_time;
+
+   if ((readl(&pmc->uckr) & AT91_PMC_UPLLEN) == AT91_PMC_UPLLEN)
+   return 0;
+
+   start_time = get_timer(0);
+   writel(AT91_PMC_UPLLEN | AT91_PMC_BIASEN, &pmc->uckr);
+   while ((readl(&pmc->sr) & AT91_PMC_LOCKU) != AT91_PMC_LOCKU) {
+   tmp_time = get_timer(0);
+   if ((tmp_time - start_time) > EN_UPLL_TIMEOUT) {
+   printf("ERROR: failed to enable UPLL\n");
+   return -1;
+   }
+   }
+
+   return 0;
+}
+
+int at91_upll_clk_disable(void)
+{
+   struct at91_pmc *pmc = (at91_pmc_t *)ATMEL_BASE_PMC;
+   ulong start_time, tmp_time;
+
+   start_time = get_timer(0);
+   writel(readl(&pmc->uckr) & ~AT91_PMC_UPLLEN, &pmc->uckr);
+   while ((readl(&pmc->sr) & AT91_PMC_LOCKU) == AT91_PMC_LOCKU) {
+   tmp_time = get_timer(0);
+   if ((tmp_time - start_time) > EN_UPLL_TIMEOUT) {
+   printf("ERROR: failed to stop UPLL\n");
+   return -1;
+   }
+   }
+
+   return 0;
+}
+
+void at91_usb_clk_init(u32 value)
+{
+   struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
+
+   writel(value, &pmc->usb);
+}
diff --git a/arch/arm/mach-at91/include/mach/clk.h 
b/arch/arm/mach-at91/include/mach/clk.h
index bef4e1c..b2604ef 100644
--- a/arch/arm/mach-at91/include/mach/clk.h
+++ b/arch/arm/mach-at91/include/mach/clk.h
@@ -130,5 +130,8 @@ int at91_enable_periph_generated_clk(u32 id, u32 
clk_source, u32 div);
 u32 at91_get_periph_generated_clk(u32 id);
 void at91_system_clk_enable(int sys_clk);
 void at91_system_clk_disable(int sys_clk);
+int at91_upll_clk_enable(void);
+int at91_upll_clk_disable(void);
+void at91_usb_clk_init(u32 value);
 
 #endif /* __ASM_ARM_ARCH_CLK_H__ */
-- 
1.7.9.5

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


[U-Boot] [PATCH v3 0/4] ARM: at91: add UTMI PLL handle functions

2016-02-01 Thread Wenyou Yang
To reduce the duplicated code, add UTMI PLL enable/disable functions,
replace the UTMI PLL handle code with these functions.

It is based on the following patch set.
http://lists.denx.de/pipermail/u-boot/2016-February/244370.html

Changes in v3:
 - collect Tested-by from Heiko Schocher.

Changes in v2:
 - remain asm/io.h include.

Wenyou Yang (4):
  ARM: at91: clock: add UTMI PLL enable/disable function
  ARM: at91: armv7: clean up UTMI PLL handle code
  drivers: usb: atmel: clean up the UTMI PLL code
  board: atmel: siemens: clean up UTMI PLL code

 arch/arm/mach-at91/armv7/sama5d2_devices.c |5 +--
 arch/arm/mach-at91/armv7/sama5d3_devices.c |5 +--
 arch/arm/mach-at91/armv7/sama5d4_devices.c |5 +--
 arch/arm/mach-at91/clock.c |   48 
 arch/arm/mach-at91/include/mach/clk.h  |3 ++
 board/siemens/corvus/board.c   |4 +--
 drivers/usb/host/ehci-atmel.c  |   38 +++---
 drivers/usb/host/ohci-at91.c   |   20 
 8 files changed, 66 insertions(+), 62 deletions(-)

-- 
1.7.9.5

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


Re: [U-Boot] [PATCH v1 1/2] Revert "powerpc: mpc85xx: remove P2020DS board support"

2016-02-01 Thread york sun
On 02/01/2016 04:05 PM, Simon Glass wrote:

>>
>> I will take this chance to convert P2020DS to use DM. Need some guidance 
>> here.
>> For NS16550, it needs the clock. To keep it simple, let's presume platform 
>> data
>> is used. My trouble is the clock is not unknown at compiling time. It needs 
>> to
>> be updated by checking the board/soc configuration after power up. The clock 
>> is
>> only available after get_clocks() is called in init_sequance. Is there a way 
>> I
>> can update the clocks before the driver is initialized?
>>
>> York
> 
> See this commit:
> 
> 858530a8 dm: tegra: Enable driver model for serial
> 
> It sets up its own clock.

Simon,

Thanks for the pointer. I actually noticed this commit but it adds some
confusion to me. Take your code as an example

U_BOOT_DRIVER(serial_ns16550) = {
   .name   = "serial_tegra20",
   .id = UCLASS_SERIAL,
   .of_match = tegra_serial_ids,
   .ofdata_to_platdata = tegra_serial_ofdata_to_platdata,
   .platdata_auto_alloc_size = sizeof(struct ns16550_platdata),
   .priv_auto_alloc_size = sizeof(struct NS16550),
   .probe = ns16550_serial_probe,
   .ops= &ns16550_serial_ops,
};

The name "serial_ns16550" is not directly used anywhere. So I guess you didn't
have to name it as "serial_ns16550", right?

One step forward, if I want to create a new driver, say "fsl_ns16550", I will
have to use ofdata_to_platdata to fill in plat->clock. But for majority powerpc
SoCs, we don't use device tree. We may start to use device tree on new products.
But it is probably not a good idea to force every platform to change.

Is there another way to update plat->clock?

York

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


Re: [U-Boot] patch for 64bit access issue found in FDT

2016-02-01 Thread Bin Meng
Hi Terry,

On Tue, Feb 2, 2016 at 11:03 AM, Terry Zhou  wrote:
> Hi Bin,
> I tried but failed to send it with "git sendmail" and "git imap-send", I am 
> not sure if the mail server of my company can support this command.
> Would you please give me some suggestion?
>
> Error:
> " terry@terry-OptiPlex-780:~/project/git/denx_uboot/u-boot$ git format-patch 
> -1 --cover-letter --stdout origin/master | git imap-send Resolving 
> outlook.marvell.com... ok Connecting to [10.93.176.90]:993... SSL requested 
> but SSL support not compiled in

I don't use imap-send, but am using send-email. Does your company
email server support pop3/smtp? Maybe you can try that.

> read: Bad file descriptor
> failed to open store "
>
> Best Regards,
> Terry
>

Also please avoid using top-posting.

Regards,
Bin

> -Original Message-
> From: Bin Meng [mailto:bmeng...@gmail.com]
> Sent: 2016年2月2日 10:55
> To: Terry Zhou 
> Cc: u-boot@lists.denx.de
> Subject: Re: [U-Boot] patch for 64bit access issue found in FDT
>
> Hi Terry,
>
> On Tue, Feb 2, 2016 at 10:14 AM, Terry Zhou  wrote:
>> Hi all:
>> I found a bug in FDT, which will cause system crash when calling 
>> "fdtdec_get_uint64" if the fdt item is not on 8bytes boundary, here is the 
>> patch.
>> Thanks.
>>
>
> Can you use 'git send-mail' so that it's easier for people on the list to 
> review?
>
> Regards,
> Bin
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] patch for 64bit access issue found in FDT

2016-02-01 Thread Terry Zhou
Hi Bin,
I tried but failed to send it with "git sendmail" and "git imap-send", I am not 
sure if the mail server of my company can support this command.
Would you please give me some suggestion?

Error:
" terry@terry-OptiPlex-780:~/project/git/denx_uboot/u-boot$ git format-patch -1 
--cover-letter --stdout origin/master | git imap-send Resolving 
outlook.marvell.com... ok Connecting to [10.93.176.90]:993... SSL requested but 
SSL support not compiled in
read: Bad file descriptor
failed to open store "

Best Regards,
Terry


-Original Message-
From: Bin Meng [mailto:bmeng...@gmail.com] 
Sent: 2016年2月2日 10:55
To: Terry Zhou 
Cc: u-boot@lists.denx.de
Subject: Re: [U-Boot] patch for 64bit access issue found in FDT

Hi Terry,

On Tue, Feb 2, 2016 at 10:14 AM, Terry Zhou  wrote:
> Hi all:
> I found a bug in FDT, which will cause system crash when calling 
> "fdtdec_get_uint64" if the fdt item is not on 8bytes boundary, here is the 
> patch.
> Thanks.
>

Can you use 'git send-mail' so that it's easier for people on the list to 
review?

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


Re: [U-Boot] patch for 64bit access issue found in FDT

2016-02-01 Thread Bin Meng
Hi Terry,

On Tue, Feb 2, 2016 at 10:14 AM, Terry Zhou  wrote:
> Hi all:
> I found a bug in FDT, which will cause system crash when calling 
> "fdtdec_get_uint64" if the fdt item is not on 8bytes boundary, here is the 
> patch.
> Thanks.
>

Can you use 'git send-mail' so that it's easier for people on the list
to review?

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


[U-Boot] patch for 64bit access issue found in FDT

2016-02-01 Thread Terry Zhou
Hi all:
I found a bug in FDT, which will cause system crash when calling 
"fdtdec_get_uint64" if the fdt item is not on 8bytes boundary, here is the 
patch.
Thanks.

Best Regards,
Terry



-cover-letter.patch
Description: -cover-letter.patch


0001-fix-fdt-solve-the-alignment-issue-when-parsing-uint6.patch
Description: 0001-fix-fdt-solve-the-alignment-issue-when-parsing-uint6.patch
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 15/16] efi_loader: Add README section in README.efi

2016-02-01 Thread Alexander Graf
To preserve all cover letter knowledge of the status on UEFI payload
support, let's add some sections to README.efi.

Signed-off-by: Alexander Graf 
---
 doc/README.efi | 69 +-
 1 file changed, 68 insertions(+), 1 deletion(-)

diff --git a/doc/README.efi b/doc/README.efi
index 23a3cdd..5834bcc 100644
--- a/doc/README.efi
+++ b/doc/README.efi
@@ -4,6 +4,27 @@
 # SPDX-License-Identifier: GPL-2.0+
 #
 
+=== Table of Contents ===
+
+  1  U-Boot on EFI
+  1.1  In God's Name, Why?
+  1.2  Status
+  1.3  Build Instructions
+  1.4  Trying it out
+  1.5  Inner workings
+  1.6  EFI Application
+  1.7  EFI Payload
+  1.8  Tables
+  1.9  Interrupts
+  1.10 32/64-bit
+  1.11 Future work
+  1.12 Where is the code?
+
+  2  EFI on U-Boot
+  2.1  In God's Name, Why?
+  2.2  Status
+  1.3  Future work
+
 U-Boot on EFI
 =
 This document provides information about U-Boot running on top of EFI, either
@@ -234,7 +255,6 @@ board/efi/efi-x86/efi.c
 common/cmd_efi.c
the 'efi' command
 
-
 --
 Ben Stoltz, Simon Glass
 Google, Inc
@@ -242,3 +262,50 @@ July 2015
 
 [1] http://www.qemu.org
 [2] http://www.tianocore.org/ovmf/
+
+---
+
+EFI on U-Boot
+=
+
+In addition to support for running U-Boot as a UEFI application, U-Boot itself
+can also expose the UEFI interfaces and thus allow UEFI payloads to run under
+it.
+
+In God's Name, Why?
+---
+
+With this support in place, you can run any UEFI payload (such as the Linux
+kernel, grub2 or gummiboot) on U-Boot. This dramatically simplifies boot loader
+configuration, as U-Boot based systems now look and feel (almost) the same way
+as TianoCore based systems.
+
+Status
+--
+
+I am successfully able to run grub2 and Linux EFI binaries with this code on
+ARMv7 as well as AArch64 systems.
+
+When enabled, the resulting U-Boot binary only grows by ~10kb, so it's very
+light weight.
+
+All storage devices are directly accessible from the uEFI payload
+
+Removable media booting (search for /efi/boot/boota{a64,arm}.efi) is supported.
+
+Simple use cases like "Plug this SD card into my ARM device and it just
+boots into grub which boots into Linux", work very well.
+
+Future work
+---
+
+Of course, there are still a few things one could do on top:
+
+   - Improve disk media detection (don't scan, use what information we
+have)
+   - Add EFI variable support using NVRAM
+   - Add GFX support
+   - Make EFI Shell work
+   - Network device support
+   - Support for payload exit
+   - Payload Watchdog support
-- 
2.6.2

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


[U-Boot] [PATCH 14/16] efi_loader: Add distro boot script for removable media

2016-02-01 Thread Alexander Graf
UEFI defines a simple boot protocol for removable media. There we should look
at the EFI (first GPT FAT) partition and search for /efi/boot/bootXXX.efi with
XXX being different between different platforms (x86, x64, arm, aa64, ...).

This patch implements a simple version of that protocol for the default distro
boot script. With this we can automatically boot from valid UEFI enabled
removable media.

Because from all I could see U-Boot by default doesn't deliver device tree
blobs with its firmware, we also need to load the dtb from somewhere. Traverse
the same EFI partition for an fdt file that fits our current board so that
an OS receives a valid device tree when booted automatically.

Signed-off-by: Alexander Graf 
Reviewed-by: Simon Glass 
---
 include/config_distro_bootcmd.h | 47 -
 1 file changed, 46 insertions(+), 1 deletion(-)

diff --git a/include/config_distro_bootcmd.h b/include/config_distro_bootcmd.h
index 37c6b43..c19f1b0 100644
--- a/include/config_distro_bootcmd.h
+++ b/include/config_distro_bootcmd.h
@@ -90,6 +90,48 @@
BOOT_TARGET_DEVICES_references_UBIFS_without_CONFIG_CMD_UBIFS
 #endif
 
+#ifdef CONFIG_EFI_LOADER
+#if defined(CONFIG_ARM64)
+#define BOOTEFI_NAME "bootaa64.efi"
+#elif defined(CONFIG_ARM)
+#define BOOTEFI_NAME "bootarm.efi"
+#endif
+#endif
+
+#ifdef BOOTEFI_NAME
+#define BOOTENV_SHARED_EFI\
+   "boot_efi_binary="\
+   "load ${devtype} ${devnum}:${distro_bootpart} "   \
+   "${kernel_addr_r} efi/boot/"BOOTEFI_NAME"; "  \
+   "bootefi ${kernel_addr_r}\0"  \
+   \
+   "load_efi_dtb="   \
+   "load ${devtype} ${devnum}:${distro_bootpart} "   \
+   "${fdt_addr_r} ${prefix}${fdt_name}; "   \
+   "fdt addr ${fdt_addr_r}\0"\
+   \
+   "efi_dtb_prefixes=/ /dtb/ /dtb/current/\0"\
+   "scan_dev_for_efi="   \
+   "for prefix in ${efi_dtb_prefixes}; do "  \
+   "if test -e ${devtype} "  \
+   "${devnum}:${distro_bootpart} "   \
+   "${prefix}${fdt_name}; then " \
+   "run load_efi_dtb; "  \
+   "fi;" \
+   "done;"   \
+   "if test -e ${devtype} ${devnum}:${distro_bootpart} " \
+   "efi/boot/"BOOTEFI_NAME"; then "  \
+   "echo Found EFI removable media binary "  \
+   "efi/boot/"BOOTEFI_NAME"; "   \
+   "run boot_efi_binary; "   \
+   "echo EFI LOAD FAILED: continuing...; "   \
+   "fi; "
+#define SCAN_DEV_FOR_EFI "run scan_dev_for_efi;"
+#else
+#define BOOTENV_SHARED_EFI
+#define SCAN_DEV_FOR_EFI
+#endif
+
 #ifdef CONFIG_CMD_SATA
 #define BOOTENV_SHARED_SATABOOTENV_SHARED_BLKDEV(sata)
 #define BOOTENV_DEV_SATA   BOOTENV_DEV_BLKDEV
@@ -217,6 +259,7 @@
BOOTENV_SHARED_SCSI \
BOOTENV_SHARED_IDE \
BOOTENV_SHARED_UBIFS \
+   BOOTENV_SHARED_EFI \
"boot_prefixes=/ /boot/\0" \
"boot_scripts=boot.scr.uimg boot.scr\0" \
"boot_script_dhcp=boot.scr.uimg\0" \
@@ -258,7 +301,9 @@
"for prefix in ${boot_prefixes}; do " \
"run scan_dev_for_extlinux; " \
"run scan_dev_for_scripts; "  \
-   "done\0"  \
+   "done;"   \
+   SCAN_DEV_FOR_EFI  \
+   "\0"  \
\
"scan_dev_for_boot_part=" \
"part list ${devtype} ${devnum} -bootable devplist; " \
-- 
2.6.2

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


[U-Boot] [PATCH 16/16] efi_loader: Add MAINTAINERS entry

2016-02-01 Thread Alexander Graf
Now that everything's in place, let's add myself as the maintainer for
the efi payload support.

Signed-off-by: Alexander Graf 
---
 MAINTAINERS | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index b387207..b3b0ab8 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -230,6 +230,13 @@ F: drivers/core/
 F: include/dm/
 F: test/dm/
 
+EFI PAYLOAD
+M: Alexander Graf 
+S: Maintained
+F: include/efi_loader.h
+F: lib/efi_loader/
+F: cmd/bootefi.c
+
 FLATTENED DEVICE TREE
 M: Simon Glass 
 S: Maintained
-- 
2.6.2

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


[U-Boot] [PATCH 12/16] efi_loader: Add DCACHE_OFF support for arm64

2016-02-01 Thread Alexander Graf
On arm64, boards can declare that they want to run with dcache disabled.

However, uEFI guarantees to payloads that they're running with the dcache
enabled which on arm64 means that they can do unaligned accesses.

To not leave those systems out of the door, let's handle the unaligned traps.
In the typical boot case, the OS will set up page tables and dcache itself
early on anyway once it's done talking with uEFI.

Signed-off-by: Alexander Graf 
---
 arch/arm/cpu/armv8/exceptions.S |  10 ++
 arch/arm/lib/Makefile   |   3 +
 arch/arm/lib/interrupts_64.c|  19 +++
 arch/arm/lib/unaligned_64.c | 284 
 cmd/bootefi.c   |   5 +
 5 files changed, 321 insertions(+)
 create mode 100644 arch/arm/lib/unaligned_64.c

diff --git a/arch/arm/cpu/armv8/exceptions.S b/arch/arm/cpu/armv8/exceptions.S
index 4f4f526..97101c3 100644
--- a/arch/arm/cpu/armv8/exceptions.S
+++ b/arch/arm/cpu/armv8/exceptions.S
@@ -144,3 +144,13 @@ exception_exit:
ldp x27, x28, [sp],#16
ldp x29, x30, [sp],#16
eret
+
+.global read_far
+read_far:
+   switch_el x1, 3f, 2f, 1f
+3: mrs x0, far_el3
+   ret
+2: mrs x0, far_el2
+   ret
+1: mrs x0, far_el1
+   ret
diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile
index f3db7b5..ce5ed99 100644
--- a/arch/arm/lib/Makefile
+++ b/arch/arm/lib/Makefile
@@ -42,6 +42,9 @@ else ifdef CONFIG_ARM64
 obj-y  += ccn504.o
 obj-y  += gic_64.o
 obj-y  += interrupts_64.o
+ifeq ($(CONFIG_SYS_DCACHE_OFF),y)
+obj-$(CONFIG_EFI_LOADER)   += unaligned_64.o
+endif
 else
 obj-y  += interrupts.o
 endif
diff --git a/arch/arm/lib/interrupts_64.c b/arch/arm/lib/interrupts_64.c
index 7c9cfce..4aa36de 100644
--- a/arch/arm/lib/interrupts_64.c
+++ b/arch/arm/lib/interrupts_64.c
@@ -81,12 +81,31 @@ void do_bad_error(struct pt_regs *pt_regs, unsigned int esr)
panic("Resetting CPU ...\n");
 }
 
+#if defined(CONFIG_EFI_LOADER) && defined(CONFIG_SYS_DCACHE_OFF)
+int do_unaligned_data(struct pt_regs *pt_regs, unsigned int esr);
+#else
+static int do_unaligned_data(struct pt_regs *pt_regs, unsigned int esr)
+{
+   return -1;
+}
+#endif
+
 /*
  * do_sync handles the Synchronous Abort exception.
  */
 void do_sync(struct pt_regs *pt_regs, unsigned int esr)
 {
efi_restore_gd();
+
+   /*
+* EFI guarantees that unaligned accesses do succeed, so while we
+* still need hardware access and thus are unsure whether we can
+* enable the dcache to have the CPU deal with them, we fix unaligned
+* accesses up ourselves.
+*/
+   if (!do_unaligned_data(pt_regs, esr))
+   return;
+
printf("\"Synchronous Abort\" handler, esr 0x%08x\n", esr);
show_regs(pt_regs);
panic("Resetting CPU ...\n");
diff --git a/arch/arm/lib/unaligned_64.c b/arch/arm/lib/unaligned_64.c
new file mode 100644
index 000..b307b7e
--- /dev/null
+++ b/arch/arm/lib/unaligned_64.c
@@ -0,0 +1,284 @@
+/*
+ * (C) Copyright 2016
+ * Alexander Graf 
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+
+#define ESR_EC_MASK0xFC00
+#define ESR_EC_SHIFT   26
+#define ESR_IL_MASK0x0200
+#define ESR_IL_SHIFT   25
+#define ESR_ISS_MASK   0x01FF
+#define ESR_ISS_SHIFT  0
+
+#define EC_DATA_SL 0x25
+
+#define ISS_ISV_MASK   0x0100
+#define ISS_ISV_SHIFT  24
+#define ISS_SAS_MASK   0x00C0
+#define ISS_SAS_SHIFT  22
+#define ISS_SSE_MASK   0x0020
+#define ISS_SSE_SHIFT  21
+#define ISS_SRT_MASK   0x000F
+#define ISS_SRT_SHIFT  16
+#define ISS_SF_MASK0x8000
+#define ISS_SF_SHIFT   15
+#define ISS_AR_MASK0x4000
+#define ISS_AR_SHIFT   14
+#define ISS_EA_MASK0x0200
+#define ISS_EA_SHIFT   9
+#define ISS_CM_MASK0x0100
+#define ISS_CM_SHIFT   8
+#define ISS_S1PTW_MASK 0x0080
+#define ISS_S1PTW_SHIFT7
+#define ISS_WNR_MASK   0x0040
+#define ISS_WNR_SHIFT  6
+#define WNR_READ   0
+#define WNR_WRITE  1
+#define ISS_DFSC_MASK  0x003F
+#define ISS_DFSC_SHIFT 0
+
+#define ISV_VALID  1
+#define DFSC_ALIGN 0x21
+
+ulong read_far(void);
+int do_unaligned_data(struct pt_regs *pt_regs, unsigned int esr);
+
+static inline int32_t sextract32(uint32_t value, int start, int length)
+{
+   return ((int32_t)(value << (32 - length - start))) >> (32 - length);
+}
+
+static inline uint32_t extract32(uint32_t value, int start, int length)
+{
+   return (value >> start) & (~0U >> (32 - length));
+}
+
+static int insn_iss_ldst(uint32_t insn, int iss, int *wb_reg, ulong *wb_val)
+{
+   int rt = extract32(insn, 0, 5);
+   int rn = extract32(insn, 5, 5);
+   int idx = extract32(insn, 10, 2);
+   int imm9 = sextract32(insn, 12, 9);
+   int opc = extract32(insn, 22, 2);
+   int size = extract32(insn, 30, 2);
+   bool is_signed = false;
+   bool is_store = false;
+   bool is_extended = false;
+   boo

[U-Boot] [PATCH 09/16] efi_loader: Implement memory allocation and map

2016-02-01 Thread Alexander Graf
The EFI loader needs to maintain views of memory - general system memory
windows as well as used locations inside those and potential runtime service
MMIO windows.

To manage all of these, add a few helpers that maintain an internal
representation of the map the similar to how the EFI API later on reports
it to the application.

For allocations, the scheme is very simple. We basically allow allocations
to replace chunks of previously done maps, so that a new LOADER_DATA
allocation for example can remove a piece of the RAM map. When no specific
address is given, we just take the highest possible address in the lowest
RAM map that fits the allocation size.

Signed-off-by: Alexander Graf 

---

v2 -> v3:

  - Rewrite memory allocation and map
  - Document header
---
 common/board_r.c|   3 +
 include/efi_loader.h|  19 +++
 lib/efi_loader/efi_memory.c | 314 
 3 files changed, 336 insertions(+)
 create mode 100644 lib/efi_loader/efi_memory.c

diff --git a/common/board_r.c b/common/board_r.c
index 420e2c8..2ed8e4b 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -785,6 +785,9 @@ init_fnc_t init_sequence_r[] = {
 #ifdef CONFIG_CLOCKS
set_cpu_clk_info, /* Setup clock information */
 #endif
+#ifdef CONFIG_EFI_LOADER
+   efi_memory_init,
+#endif
stdio_init_tables,
initr_serial,
initr_announce,
diff --git a/include/efi_loader.h b/include/efi_loader.h
index 91ab6cb..e38be12 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -109,6 +109,25 @@ efi_status_t efi_exit_func(efi_status_t ret);
 /* Call this to relocate the runtime section to an address space */
 void efi_runtime_relocate(ulong offset, struct efi_mem_desc *map);
 
+/* Generic EFI memory allocator, call this to get memory */
+void *efi_alloc(uint64_t len, int memory_type);
+/* More specific EFI memory allocator, called by EFI payloads */
+efi_status_t efi_allocate_pages(int type, int memory_type, unsigned long pages,
+   uint64_t *memory);
+/* EFI memory free function. Not implemented today */
+efi_status_t efi_free_pages(uint64_t memory, unsigned long pages);
+/* Returns the EFI memory map */
+efi_status_t efi_get_memory_map(unsigned long *memory_map_size,
+   struct efi_mem_desc *memory_map,
+   unsigned long *map_key,
+   unsigned long *descriptor_size,
+   uint32_t *descriptor_version);
+/* Adds a range into the EFI memory map */
+uint64_t efi_add_memory_map(uint64_t start, uint64_t pages, int memory_type,
+   bool overlap_only_ram);
+/* Called by board init to initialize the EFI memory map */
+int efi_memory_init(void);
+
 /*
  * Use these to indicate that your code / data should go into the EFI runtime
  * section and thus still be available when the OS is running
diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
new file mode 100644
index 000..e58d190
--- /dev/null
+++ b/lib/efi_loader/efi_memory.c
@@ -0,0 +1,314 @@
+/*
+ *  EFI application memory management
+ *
+ *  Copyright (c) 2016 Alexander Graf
+ *
+ *  SPDX-License-Identifier: GPL-2.0+
+ */
+
+/* #define DEBUG_EFI */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
+
+struct efi_mem_list {
+   struct list_head link;
+   struct efi_mem_desc desc;
+};
+
+/* This list contains all memory map items */
+LIST_HEAD(efi_mem);
+
+/*
+ * Unmaps all memory occupied by the carve_desc region from the
+ * list entry pointed to by map.
+ *
+ * Returns 1 if carving was performed or 0 if the regions don't overlap.
+ * Returns -1 if it would affect non-RAM regions but overlap_only_ram is set.
+ * Carving is only guaranteed to complete when all regions return 0.
+ */
+static int efi_mem_carve_out(struct efi_mem_list *map,
+struct efi_mem_desc *carve_desc,
+bool overlap_only_ram)
+{
+   struct efi_mem_list *newmap;
+   struct efi_mem_desc *map_desc = &map->desc;
+   uint64_t map_start = map_desc->physical_start;
+   uint64_t map_end = map_start + (map_desc->num_pages << 12);
+   uint64_t carve_start = carve_desc->physical_start;
+   uint64_t carve_end = carve_start + (carve_desc->num_pages << 12);
+
+   /* check whether we're overlapping */
+   if ((carve_end <= map_start) || (carve_start >= map_end))
+   return 0;
+
+   /* We're overlapping with non-RAM, warn the caller if desired */
+   if (overlap_only_ram && (map_desc->type != EFI_CONVENTIONAL_MEMORY))
+   return -1;
+
+   /* Sanitize carve_start and carve_end to lie within our bounds */
+   carve_start = max(carve_start, map_start);
+   carve_end = min(carve_end, map_end);
+
+   /* Carving at the beginning of our map? Just move it! */
+   if (carve_star

[U-Boot] [PATCH 11/16] arm64: Allow EFI payload code to take exceptions

2016-02-01 Thread Alexander Graf
There are 2 ways an EFI payload could return into u-boot:

  - Callback function
  - Exception

While in EFI payload mode, x18 is owned by the payload and may not contain
a valid pointer to gd, so we need to fix it up. We do that properly for the
payload to callback path already.

This patch also adds gd pointer restoral for the exception path.

Signed-off-by: Alexander Graf 
---
 arch/arm/lib/interrupts_64.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/arch/arm/lib/interrupts_64.c b/arch/arm/lib/interrupts_64.c
index b476722..7c9cfce 100644
--- a/arch/arm/lib/interrupts_64.c
+++ b/arch/arm/lib/interrupts_64.c
@@ -7,6 +7,7 @@
 
 #include 
 #include 
+#include 
 
 
 int interrupt_init(void)
@@ -41,6 +42,7 @@ void show_regs(struct pt_regs *regs)
  */
 void do_bad_sync(struct pt_regs *pt_regs, unsigned int esr)
 {
+   efi_restore_gd();
printf("Bad mode in \"Synchronous Abort\" handler, esr 0x%08x\n", esr);
show_regs(pt_regs);
panic("Resetting CPU ...\n");
@@ -51,6 +53,7 @@ void do_bad_sync(struct pt_regs *pt_regs, unsigned int esr)
  */
 void do_bad_irq(struct pt_regs *pt_regs, unsigned int esr)
 {
+   efi_restore_gd();
printf("Bad mode in \"Irq\" handler, esr 0x%08x\n", esr);
show_regs(pt_regs);
panic("Resetting CPU ...\n");
@@ -61,6 +64,7 @@ void do_bad_irq(struct pt_regs *pt_regs, unsigned int esr)
  */
 void do_bad_fiq(struct pt_regs *pt_regs, unsigned int esr)
 {
+   efi_restore_gd();
printf("Bad mode in \"Fiq\" handler, esr 0x%08x\n", esr);
show_regs(pt_regs);
panic("Resetting CPU ...\n");
@@ -71,6 +75,7 @@ void do_bad_fiq(struct pt_regs *pt_regs, unsigned int esr)
  */
 void do_bad_error(struct pt_regs *pt_regs, unsigned int esr)
 {
+   efi_restore_gd();
printf("Bad mode in \"Error\" handler, esr 0x%08x\n", esr);
show_regs(pt_regs);
panic("Resetting CPU ...\n");
@@ -81,6 +86,7 @@ void do_bad_error(struct pt_regs *pt_regs, unsigned int esr)
  */
 void do_sync(struct pt_regs *pt_regs, unsigned int esr)
 {
+   efi_restore_gd();
printf("\"Synchronous Abort\" handler, esr 0x%08x\n", esr);
show_regs(pt_regs);
panic("Resetting CPU ...\n");
@@ -91,6 +97,7 @@ void do_sync(struct pt_regs *pt_regs, unsigned int esr)
  */
 void do_irq(struct pt_regs *pt_regs, unsigned int esr)
 {
+   efi_restore_gd();
printf("\"Irq\" handler, esr 0x%08x\n", esr);
show_regs(pt_regs);
panic("Resetting CPU ...\n");
@@ -101,6 +108,7 @@ void do_irq(struct pt_regs *pt_regs, unsigned int esr)
  */
 void do_fiq(struct pt_regs *pt_regs, unsigned int esr)
 {
+   efi_restore_gd();
printf("\"Fiq\" handler, esr 0x%08x\n", esr);
show_regs(pt_regs);
panic("Resetting CPU ...\n");
@@ -114,6 +122,7 @@ void do_fiq(struct pt_regs *pt_regs, unsigned int esr)
  */
 void __weak do_error(struct pt_regs *pt_regs, unsigned int esr)
 {
+   efi_restore_gd();
printf("\"Error\" handler, esr 0x%08x\n", esr);
show_regs(pt_regs);
panic("Resetting CPU ...\n");
-- 
2.6.2

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


[U-Boot] [PATCH 10/16] arm64: Allow exceptions to return

2016-02-01 Thread Alexander Graf
Our current arm64 exception handlers all panic and never return to the
exception triggering code.

But if any handler wanted to continue execution after fixups, it would
need help from the exception handling code to restore all registers.

This patch implements that help. With this code, exception handlers on
aarch64 can successfully return to the place the exception happened (or
somewhere else if they modify elr).

Signed-off-by: Alexander Graf 
---
 arch/arm/cpu/armv8/exceptions.S | 34 ++
 1 file changed, 34 insertions(+)

diff --git a/arch/arm/cpu/armv8/exceptions.S b/arch/arm/cpu/armv8/exceptions.S
index baf9401..4f4f526 100644
--- a/arch/arm/cpu/armv8/exceptions.S
+++ b/arch/arm/cpu/armv8/exceptions.S
@@ -82,31 +82,65 @@ vectors:
 _do_bad_sync:
exception_entry
bl  do_bad_sync
+   b   exception_exit
 
 _do_bad_irq:
exception_entry
bl  do_bad_irq
+   b   exception_exit
 
 _do_bad_fiq:
exception_entry
bl  do_bad_fiq
+   b   exception_exit
 
 _do_bad_error:
exception_entry
bl  do_bad_error
+   b   exception_exit
 
 _do_sync:
exception_entry
bl  do_sync
+   b   exception_exit
 
 _do_irq:
exception_entry
bl  do_irq
+   b   exception_exit
 
 _do_fiq:
exception_entry
bl  do_fiq
+   b   exception_exit
 
 _do_error:
exception_entry
bl  do_error
+   b   exception_exit
+
+exception_exit:
+   ldp x2, x0, [sp],#16
+   switch_el x11, 3f, 2f, 1f
+3: msr elr_el3, x2
+   b   0f
+2: msr elr_el2, x2
+   b   0f
+1: msr elr_el1, x2
+0:
+   ldp x1, x2, [sp],#16
+   ldp x3, x4, [sp],#16
+   ldp x5, x6, [sp],#16
+   ldp x7, x8, [sp],#16
+   ldp x9, x10, [sp],#16
+   ldp x11, x12, [sp],#16
+   ldp x13, x14, [sp],#16
+   ldp x15, x16, [sp],#16
+   ldp x17, x18, [sp],#16
+   ldp x19, x20, [sp],#16
+   ldp x21, x22, [sp],#16
+   ldp x23, x24, [sp],#16
+   ldp x25, x26, [sp],#16
+   ldp x27, x28, [sp],#16
+   ldp x29, x30, [sp],#16
+   eret
-- 
2.6.2

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


[U-Boot] [PATCH 13/16] efi_loader: hook up in build environment

2016-02-01 Thread Alexander Graf
Now that we have all the bits and pieces ready for EFI payload loading
support, hook them up in Makefiles and KConfigs so that we can build.

Signed-off-by: Alexander Graf 
Reviewed-by: Simon Glass 

---

v1 -> v2:

  - Move to GPLv2+
  - Default to y

v2 -> v3:

  - Add memory file
---
 lib/Kconfig |  1 +
 lib/Makefile|  1 +
 lib/efi_loader/Kconfig  |  9 +
 lib/efi_loader/Makefile | 12 
 4 files changed, 23 insertions(+)
 create mode 100644 lib/efi_loader/Kconfig
 create mode 100644 lib/efi_loader/Makefile

diff --git a/lib/Kconfig b/lib/Kconfig
index 46d7034..f3cdd98 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -129,5 +129,6 @@ config ERRNO_STR
  - if errno is negative - a pointer to errno related message
 
 source lib/efi/Kconfig
+source lib/efi_loader/Kconfig
 
 endmenu
diff --git a/lib/Makefile b/lib/Makefile
index dd36f25..3a9f304 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -8,6 +8,7 @@
 ifndef CONFIG_SPL_BUILD
 
 obj-$(CONFIG_EFI) += efi/
+obj-$(CONFIG_EFI_LOADER) += efi_loader/
 obj-$(CONFIG_RSA) += rsa/
 obj-$(CONFIG_LZMA) += lzma/
 obj-$(CONFIG_LZO) += lzo/
diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
new file mode 100644
index 000..6da1c7f
--- /dev/null
+++ b/lib/efi_loader/Kconfig
@@ -0,0 +1,9 @@
+config EFI_LOADER
+   bool "Support running EFI Applications in U-Boot"
+   depends on ARM64 || ARM
+   default y
+   help
+ Select this option if you want to run EFI applications (like grub2)
+ on top of U-Boot. If this option is enabled, U-Boot will expose EFI
+ interfaces to a loaded EFI application, enabling it to reuse U-Boot's
+ device drivers.
diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile
new file mode 100644
index 000..28725a2
--- /dev/null
+++ b/lib/efi_loader/Makefile
@@ -0,0 +1,12 @@
+#
+# (C) Copyright 2016 Alexander Graf
+#
+#  SPDX-License-Identifier: GPL-2.0+
+#
+
+# This file only gets included with CONFIG_EFI_LOADER set, so all
+# object inclusion implicitly depends on it
+
+obj-y += efi_image_loader.o efi_boottime.o efi_runtime.o efi_console.o
+obj-y += efi_memory.o
+obj-$(CONFIG_PARTITIONS) += efi_disk.o
-- 
2.6.2

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


[U-Boot] [PATCH 08/16] efi_loader: Add "bootefi" command

2016-02-01 Thread Alexander Graf
In order to execute an EFI application, we need to bridge the gap between
U-Boot's notion of executing images and EFI's notion of doing the same.

The best path forward IMHO here is to stick completely to the way U-Boot
deals with payloads. You manually load them using whatever method to RAM
and then have a simple boot command to execute them. So in our case, you
would do

  # load mmc 0:1 $loadaddr grub.efi
  # bootefi $loadaddr

which then gets you into a grub shell. Fdt information known to U-boot
via the fdt addr command is also passed to the EFI payload.

Signed-off-by: Alexander Graf 
Reviewed-by: Simon Glass 

---

v1 -> v2:

  - Move to GPLv2+

v2 -> v3:

  - Move to new cmd directory
  - Add kconfig option
  - Fix comment style
  - Add help text
  - s/-1/-ENOENT
  - Move obj list to lib

XXX bootefi: make dtb conf table more explicit
---
 cmd/Kconfig   |   7 +++
 cmd/Makefile  |   1 +
 cmd/bootefi.c | 167 ++
 3 files changed, 175 insertions(+)
 create mode 100644 cmd/bootefi.c

diff --git a/cmd/Kconfig b/cmd/Kconfig
index 2ed0263..7cdff04 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -148,6 +148,13 @@ config CMD_BOOTM
help
  Boot an application image from the memory.
 
+config CMD_BOOTEFI
+   bool "bootefi"
+   depends on EFI_LOADER
+   default y
+   help
+ Boot an EFI image from memory.
+
 config CMD_ELF
bool "bootelf, bootvx"
default y
diff --git a/cmd/Makefile b/cmd/Makefile
index 03f7e0a..7604621 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -21,6 +21,7 @@ obj-$(CONFIG_CMD_SOURCE) += source.o
 obj-$(CONFIG_CMD_BDI) += bdinfo.o
 obj-$(CONFIG_CMD_BEDBUG) += bedbug.o
 obj-$(CONFIG_CMD_BMP) += bmp.o
+obj-$(CONFIG_CMD_BOOTEFI) += bootefi.o
 obj-$(CONFIG_CMD_BOOTMENU) += bootmenu.o
 obj-$(CONFIG_CMD_BOOTLDR) += bootldr.o
 obj-$(CONFIG_CMD_BOOTSTAGE) += bootstage.o
diff --git a/cmd/bootefi.c b/cmd/bootefi.c
new file mode 100644
index 000..e3e51d4
--- /dev/null
+++ b/cmd/bootefi.c
@@ -0,0 +1,167 @@
+/*
+ *  EFI application loader
+ *
+ *  Copyright (c) 2016 Alexander Graf
+ *
+ *  SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/*
+ * When booting using the "bootefi" command, we don't know which
+ * physical device the file came from. So we create a pseudo-device
+ * called "bootefi" with the device path /bootefi.
+ *
+ * In addition to the originating device we also declare the file path
+ * of "bootefi" based loads to be /bootefi.
+ */
+static struct efi_device_path_file_path bootefi_dummy_path[] = {
+   {
+   .dp.type = DEVICE_PATH_TYPE_MEDIA_DEVICE,
+   .dp.sub_type = DEVICE_PATH_SUB_TYPE_FILE_PATH,
+   .dp.length = sizeof(bootefi_dummy_path[0]),
+   .str = { 'b','o','o','t','e','f','i' },
+   }, {
+   .dp.type = DEVICE_PATH_TYPE_END,
+   .dp.sub_type = DEVICE_PATH_SUB_TYPE_END,
+   .dp.length = sizeof(bootefi_dummy_path[0]),
+   }
+};
+
+static efi_status_t bootefi_open_dp(void *handle, efi_guid_t *protocol,
+   void **protocol_interface, void *agent_handle,
+   void *controller_handle, uint32_t attributes)
+{
+   *protocol_interface = bootefi_dummy_path;
+   return EFI_SUCCESS;
+}
+
+/* The EFI loaded_image interface for the image executed via "bootefi" */
+static struct efi_loaded_image loaded_image_info = {
+   .device_handle = bootefi_dummy_path,
+   .file_path = bootefi_dummy_path,
+};
+
+/* The EFI object struct for the image executed via "bootefi" */
+static struct efi_object loaded_image_info_obj = {
+   .handle = &loaded_image_info,
+   .protocols = {
+   {
+   /*
+* When asking for the loaded_image interface, just
+* return handle which points to loaded_image_info
+*/
+   .guid = &efi_guid_loaded_image,
+   .open = &efi_return_handle,
+   },
+   {
+   /*
+* When asking for the device path interface, return
+* bootefi_dummy_path
+*/
+   .guid = &efi_guid_device_path,
+   .open = &bootefi_open_dp,
+   },
+   },
+};
+
+/* The EFI object struct for the device the "bootefi" image was loaded from */
+static struct efi_object bootefi_device_obj = {
+   .handle = bootefi_dummy_path,
+   .protocols = {
+   {
+   /* When asking for the device path interface, return
+* bootefi_dummy_path */
+   .guid = &efi_guid_device_path,
+   .open = &bootefi_open_dp,
+   }
+   },
+};
+
+/*
+ * Load an EFI payload into a newly allocated piece of memory, reg

[U-Boot] [PATCH 01/16] disk/part.c: Expose list of available block drivers

2016-02-01 Thread Alexander Graf
We have a pretty nice and generic interface to ask for a specific block
device. However, that one is still based around the magic notion that
we know the driver name.

In order to be able to write fully generic disk access code, expose the
currently internal list to other source files so that they can scan through
all available block drivers.

Signed-off-by: Alexander Graf 
---
 disk/part.c| 7 +--
 include/part.h | 8 
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/disk/part.c b/disk/part.c
index 1935b28..d265c2b 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -20,13 +20,8 @@
 #define PRINTF(fmt,args...)
 #endif
 
-struct block_drvr {
-   char *name;
-   block_dev_desc_t* (*get_dev)(int dev);
-   int (*select_hwpart)(int dev_num, int hwpart);
-};
 
-static const struct block_drvr block_drvr[] = {
+const struct block_drvr block_drvr[] = {
 #if defined(CONFIG_CMD_IDE)
{ .name = "ide", .get_dev = ide_get_dev, },
 #endif
diff --git a/include/part.h b/include/part.h
index dc23949..6e6205b 100644
--- a/include/part.h
+++ b/include/part.h
@@ -42,6 +42,12 @@ struct block_dev_desc {
void*priv;  /* driver private struct pointer */
 };
 
+struct block_drvr {
+   char *name;
+   block_dev_desc_t* (*get_dev)(int dev);
+   int (*select_hwpart)(int dev_num, int hwpart);
+};
+
 #define BLOCK_CNT(size, block_dev_desc) (PAD_COUNT(size, 
block_dev_desc->blksz))
 #define PAD_TO_BLOCKSIZE(size, block_dev_desc) \
(PAD_SIZE(size, block_dev_desc->blksz))
@@ -123,6 +129,8 @@ int get_device(const char *ifname, const char *dev_str,
 int get_device_and_partition(const char *ifname, const char *dev_part_str,
 block_dev_desc_t **dev_desc,
 disk_partition_t *info, int allow_whole_dev);
+
+extern const struct block_drvr block_drvr[];
 #else
 static inline block_dev_desc_t *get_dev(const char *ifname, int dev)
 { return NULL; }
-- 
2.6.2

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


[U-Boot] [PATCH 03/16] efi_loader: Add PE image loader

2016-02-01 Thread Alexander Graf
EFI uses the PE binary format for its application images. Add support to EFI PE
binaries as well as all necessary bits for the "EFI image loader" interfaces.

Signed-off-by: Alexander Graf 

---

v1 -> v2:

  - move memory allocation to separate patch
  - limit 32/64 to hosts that support it
  - check 32bit optional nt header magic
  - switch to GPL2+

v2 -> v3:

  - use efi_alloc
  - add EFIAPI to function prototypes
  - remove unused macros
  - reorder header inclusion
  - split relocation code into function
  - flush cache after loading
---
 include/efi_loader.h  |  20 +++
 include/pe.h  | 263 ++
 lib/efi_loader/efi_image_loader.c | 182 ++
 3 files changed, 465 insertions(+)
 create mode 100644 include/efi_loader.h
 create mode 100644 include/pe.h
 create mode 100644 lib/efi_loader/efi_image_loader.c

diff --git a/include/efi_loader.h b/include/efi_loader.h
new file mode 100644
index 000..5618185
--- /dev/null
+++ b/include/efi_loader.h
@@ -0,0 +1,20 @@
+/*
+ *  EFI application loader
+ *
+ *  Copyright (c) 2016 Alexander Graf
+ *
+ *  SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+
+extern const efi_guid_t efi_guid_device_path;
+extern const efi_guid_t efi_guid_loaded_image;
+
+efi_status_t efi_return_handle(void *handle,
+   efi_guid_t *protocol, void **protocol_interface,
+   void *agent_handle, void *controller_handle,
+   uint32_t attributes);
+void *efi_load_pe(void *efi, struct efi_loaded_image *loaded_image_info);
diff --git a/include/pe.h b/include/pe.h
new file mode 100644
index 000..6379ae1
--- /dev/null
+++ b/include/pe.h
@@ -0,0 +1,263 @@
+/*
+ *  Portable Executable binary format structures
+ *
+ *  Copyright (c) 2016 Alexander Graf
+ *
+ *  Based on wine code
+ *
+ *  SPDX-License-Identifier: GPL-2.0+
+ */
+
+#ifndef _PE_H
+#define _PE_H
+
+typedef struct _IMAGE_DOS_HEADER {
+   uint16_t e_magic;  /* 00: MZ Header signature */
+   uint16_t e_cblp;   /* 02: Bytes on last page of file */
+   uint16_t e_cp; /* 04: Pages in file */
+   uint16_t e_crlc;   /* 06: Relocations */
+   uint16_t e_cparhdr;/* 08: Size of header in paragraphs */
+   uint16_t e_minalloc;   /* 0a: Minimum extra paragraphs needed */
+   uint16_t e_maxalloc;   /* 0c: Maximum extra paragraphs needed */
+   uint16_t e_ss; /* 0e: Initial (relative) SS value */
+   uint16_t e_sp; /* 10: Initial SP value */
+   uint16_t e_csum;   /* 12: Checksum */
+   uint16_t e_ip; /* 14: Initial IP value */
+   uint16_t e_cs; /* 16: Initial (relative) CS value */
+   uint16_t e_lfarlc; /* 18: File address of relocation table */
+   uint16_t e_ovno;   /* 1a: Overlay number */
+   uint16_t e_res[4]; /* 1c: Reserved words */
+   uint16_t e_oemid;  /* 24: OEM identifier (for e_oeminfo) */
+   uint16_t e_oeminfo;/* 26: OEM information; e_oemid specific */
+   uint16_t e_res2[10];   /* 28: Reserved words */
+   uint32_t e_lfanew; /* 3c: Offset to extended header */
+} IMAGE_DOS_HEADER, *PIMAGE_DOS_HEADER;
+
+#define IMAGE_DOS_SIGNATURE0x5A4D /* MZ   */
+#define IMAGE_NT_SIGNATURE 0x4550 /* PE00 */
+
+#define IMAGE_FILE_MACHINE_ARM 0x01c0
+#define IMAGE_FILE_MACHINE_THUMB   0x01c2
+#define IMAGE_FILE_MACHINE_ARMNT   0x01c4
+#define IMAGE_FILE_MACHINE_AMD64   0x8664
+#define IMAGE_FILE_MACHINE_ARM64   0xaa64
+#define IMAGE_NT_OPTIONAL_HDR32_MAGIC  0x10b
+#define IMAGE_NT_OPTIONAL_HDR64_MAGIC  0x20b
+#define IMAGE_SUBSYSTEM_EFI_APPLICATION10
+
+typedef struct _IMAGE_FILE_HEADER {
+   uint16_t  Machine;
+   uint16_t  NumberOfSections;
+   uint32_t TimeDateStamp;
+   uint32_t PointerToSymbolTable;
+   uint32_t NumberOfSymbols;
+   uint16_t  SizeOfOptionalHeader;
+   uint16_t  Characteristics;
+} IMAGE_FILE_HEADER, *PIMAGE_FILE_HEADER;
+
+typedef struct _IMAGE_DATA_DIRECTORY {
+   uint32_t VirtualAddress;
+   uint32_t Size;
+} IMAGE_DATA_DIRECTORY, *PIMAGE_DATA_DIRECTORY;
+
+#define IMAGE_NUMBEROF_DIRECTORY_ENTRIES 16
+
+typedef struct _IMAGE_OPTIONAL_HEADER64 {
+   uint16_t  Magic; /* 0x20b */
+   uint8_t MajorLinkerVersion;
+   uint8_t MinorLinkerVersion;
+   uint32_t SizeOfCode;
+   uint32_t SizeOfInitializedData;
+   uint32_t SizeOfUninitializedData;
+   uint32_t AddressOfEntryPoint;
+   uint32_t BaseOfCode;
+   uint64_t ImageBase;
+   uint32_t SectionAlignment;
+   uint32_t FileAlignment;
+   uint16_t MajorOperatingSystemVersion;
+   uint16_t MinorOperatingSystemVersion;
+   uint16_t MajorImageVersion;
+   uint16_t MinorImageVersion;
+   uint16_t MajorSubsystemVersion;
+   uint16_t MinorSubsystemVersion;
+   uint32_t Win32VersionValue;
+   uint32_t 

[U-Boot] [PATCH 06/16] efi_loader: Add runtime services

2016-02-01 Thread Alexander Graf
After booting has finished, EFI allows firmware to still interact with the OS
using the "runtime services". These callbacks live in a separate address space,
since they are available long after U-Boot has been overwritten by the OS.

This patch adds enough framework for arbitrary code inside of U-Boot to become
a runtime service with the right section attributes set. For now, we don't make
use of it yet though.

We could maybe in the future map U-boot environment variables to EFI variables
here.

Signed-off-by: Alexander Graf 

---

v1 -> v2:

  - Fix runtime service sections
  - Add runtime detach
  - Enable runtime relocations
  - Add get_time
  - Fix relocation
  - Fix 32bit
  - Add am335x support
  - Move section definition to header
  - Add systab to runtime section
  - Add self-relocation hook table
  - Fix self-relocation
  - Relocate efi_runtime section early during bootup
  - Fix return values for a number of callbacks to be more UEFI compliant
  - Move to GPLv2+

v2 -> v3:

  - Patch reset to NULL
  - Add EFIAPI to function prototypes
  - Document header
  - Add dm.h include
  - Remove non-dm rtc support
  - Return DEVICE_ERROR in rtc path
---
 arch/arm/config.mk|   4 +
 arch/arm/cpu/armv8/u-boot.lds |  16 +++
 arch/arm/cpu/u-boot.lds   |  30 +
 arch/arm/lib/sections.c   |   4 +
 board/ti/am335x/u-boot.lds|  30 +
 common/board_r.c  |   4 +
 include/efi_loader.h  |  17 +++
 lib/efi_loader/efi_boottime.c |   6 +-
 lib/efi_loader/efi_runtime.c  | 290 ++
 9 files changed, 398 insertions(+), 3 deletions(-)
 create mode 100644 lib/efi_loader/efi_runtime.c

diff --git a/arch/arm/config.mk b/arch/arm/config.mk
index a3e14a8..99c5187 100644
--- a/arch/arm/config.mk
+++ b/arch/arm/config.mk
@@ -121,6 +121,10 @@ ifdef CONFIG_OF_EMBED
 OBJCOPYFLAGS += -j .dtb.init.rodata
 endif
 
+ifdef CONFIG_EFI_LOADER
+OBJCOPYFLAGS += -j .efi_runtime -j .efi_runtime_rel
+endif
+
 ifneq ($(CONFIG_IMX_CONFIG),)
 ifdef CONFIG_SPL
 ifndef CONFIG_SPL_BUILD
diff --git a/arch/arm/cpu/armv8/u-boot.lds b/arch/arm/cpu/armv8/u-boot.lds
index 4c1..fd15ad5 100644
--- a/arch/arm/cpu/armv8/u-boot.lds
+++ b/arch/arm/cpu/armv8/u-boot.lds
@@ -42,6 +42,22 @@ SECTIONS
 
. = ALIGN(8);
 
+   .efi_runtime : {
+__efi_runtime_start = .;
+   *(efi_runtime_text)
+   *(efi_runtime_data)
+__efi_runtime_stop = .;
+   }
+
+   .efi_runtime_rel : {
+__efi_runtime_rel_start = .;
+   *(.relaefi_runtime_text)
+   *(.relaefi_runtime_data)
+__efi_runtime_rel_stop = .;
+   }
+
+   . = ALIGN(8);
+
.image_copy_end :
{
*(.__image_copy_end)
diff --git a/arch/arm/cpu/u-boot.lds b/arch/arm/cpu/u-boot.lds
index d48a905..596a17d 100644
--- a/arch/arm/cpu/u-boot.lds
+++ b/arch/arm/cpu/u-boot.lds
@@ -89,6 +89,36 @@ SECTIONS
 
. = ALIGN(4);
 
+   .__efi_runtime_start : {
+   *(.__efi_runtime_start)
+   }
+
+   .efi_runtime : {
+   *(efi_runtime_text)
+   *(efi_runtime_data)
+   }
+
+   .__efi_runtime_stop : {
+   *(.__efi_runtime_stop)
+   }
+
+   .efi_runtime_rel_start :
+   {
+   *(.__efi_runtime_rel_start)
+   }
+
+   .efi_runtime_rel : {
+   *(.relefi_runtime_text)
+   *(.relefi_runtime_data)
+   }
+
+   .efi_runtime_rel_stop :
+   {
+   *(.__efi_runtime_rel_stop)
+   }
+
+   . = ALIGN(4);
+
.image_copy_end :
{
*(.__image_copy_end)
diff --git a/arch/arm/lib/sections.c b/arch/arm/lib/sections.c
index a1205c3..6a94522 100644
--- a/arch/arm/lib/sections.c
+++ b/arch/arm/lib/sections.c
@@ -27,4 +27,8 @@ char __rel_dyn_start[0] 
__attribute__((section(".__rel_dyn_start")));
 char __rel_dyn_end[0] __attribute__((section(".__rel_dyn_end")));
 char __secure_start[0] __attribute__((section(".__secure_start")));
 char __secure_end[0] __attribute__((section(".__secure_end")));
+char __efi_runtime_start[0] __attribute__((section(".__efi_runtime_start")));
+char __efi_runtime_stop[0] __attribute__((section(".__efi_runtime_stop")));
+char __efi_runtime_rel_start[0] 
__attribute__((section(".__efi_runtime_rel_start")));
+char __efi_runtime_rel_stop[0] 
__attribute__((section(".__efi_runtime_rel_stop")));
 char _end[0] __attribute__((section(".__end")));
diff --git a/board/ti/am335x/u-boot.lds b/board/ti/am335x/u-boot.lds
index 78f294a..a56cc82 100644
--- a/board/ti/am335x/u-boot.lds
+++ b/board/ti/am335x/u-boot.lds
@@ -59,6 +59,36 @@ SECTIONS
 
. = ALIGN(4);
 
+   .__efi_runtime_start : {
+   *(.__efi_runtime_start)
+   }
+
+   .efi_runtime : {
+   *(efi_runtime_text)
+   *(efi_runtime_data)
+   }
+
+   .__efi_runtime_stop : {
+   *(.__efi_runtime_stop

[U-Boot] [PATCH 07/16] efi_loader: Add disk interfaces

2016-02-01 Thread Alexander Graf
A EFI applications usually want to access storage devices to load data from.

This patch adds support for EFI disk interfaces. It loops through all block
storage interfaces known to U-Boot and creates an EFI object for each existing
one. EFI applications can then through these objects call U-Boot's read and
write functions.

Signed-off-by: Alexander Graf 
Reviewed-by: Simon Glass 

---

v1 -> v2:

  - Move to block_drvr array
  - Move to GPLv2+
  - Fix header order
  - Document efi block object struct
  - Use calloc rather than malloc & memset

v2 -> v3:

  - Adapt to newer u-boot block API
  - Add EFIAPI to function prototypes
  - Document header
  - Check for DEV_TYPE_UNKNOWN
  - Document 16byte limit for dp string
---
 include/efi_loader.h  |   2 +
 lib/efi_loader/efi_disk.c | 218 ++
 2 files changed, 220 insertions(+)
 create mode 100644 lib/efi_loader/efi_disk.c

diff --git a/include/efi_loader.h b/include/efi_loader.h
index 640e703..91ab6cb 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -86,6 +86,8 @@ struct efi_object {
 /* This list contains all UEFI objects we know of */
 extern struct list_head efi_obj_list;
 
+/* Called by bootefi to make all disk storage accessible as EFI objects */
+int efi_disk_register(void);
 /*
  * Stub implementation for a protocol opener that just returns the handle as
  * interface
diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c
new file mode 100644
index 000..f93fcb2
--- /dev/null
+++ b/lib/efi_loader/efi_disk.c
@@ -0,0 +1,218 @@
+/*
+ *  EFI application disk support
+ *
+ *  Copyright (c) 2016 Alexander Graf
+ *
+ *  SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static const efi_guid_t efi_block_io_guid = BLOCK_IO_GUID;
+
+struct efi_disk_obj {
+   /* Generic EFI object parent class data */
+   struct efi_object parent;
+   /* EFI Interface callback struct for block I/O */
+   struct efi_block_io ops;
+   /* U-Boot ifname for block device */
+   const char *ifname;
+   /* U-Boot dev_index for block device */
+   int dev_index;
+   /* EFI Interface Media descriptor struct, referenced by ops */
+   struct efi_block_io_media media;
+   /* EFI device path to this block device */
+   struct efi_device_path_file_path *dp;
+};
+
+static void ascii2unicode(u16 *unicode, char *ascii)
+{
+   while (*ascii)
+   *(unicode++) = *(ascii++);
+}
+
+static efi_status_t efi_disk_open_block(void *handle, efi_guid_t *protocol,
+   void **protocol_interface, void *agent_handle,
+   void *controller_handle, uint32_t attributes)
+{
+   struct efi_disk_obj *diskobj = handle;
+
+   *protocol_interface = &diskobj->ops;
+
+   return EFI_SUCCESS;
+}
+
+static efi_status_t efi_disk_open_dp(void *handle, efi_guid_t *protocol,
+   void **protocol_interface, void *agent_handle,
+   void *controller_handle, uint32_t attributes)
+{
+   struct efi_disk_obj *diskobj = handle;
+
+   *protocol_interface = diskobj->dp;
+
+   return EFI_SUCCESS;
+}
+
+static efi_status_t EFIAPI efi_disk_reset(struct efi_block_io *this,
+   char extended_verification)
+{
+   EFI_ENTRY("%p, %x", this, extended_verification);
+   return EFI_EXIT(EFI_DEVICE_ERROR);
+}
+
+enum efi_disk_direction {
+   EFI_DISK_READ,
+   EFI_DISK_WRITE,
+};
+
+static efi_status_t EFIAPI efi_disk_rw_blocks(struct efi_block_io *this,
+   u32 media_id, u64 lba, unsigned long buffer_size,
+   void *buffer, enum efi_disk_direction direction)
+{
+   struct efi_disk_obj *diskobj;
+   struct block_dev_desc *desc;
+   int blksz;
+   int blocks;
+   unsigned long n;
+
+   EFI_ENTRY("%p, %x, %"PRIx64", %lx, %p", this, media_id, lba,
+ buffer_size, buffer);
+
+   diskobj = container_of(this, struct efi_disk_obj, ops);
+   if (!(desc = get_dev(diskobj->ifname, diskobj->dev_index)))
+   return EFI_EXIT(EFI_DEVICE_ERROR);
+   blksz = desc->blksz;
+   blocks = buffer_size / blksz;
+
+#ifdef DEBUG_EFI
+   printf("EFI: %s:%d blocks=%x lba=%"PRIx64" blksz=%x dir=%d\n", __func__,
+  __LINE__, blocks, lba, blksz, direction);
+#endif
+
+   /* We only support full block access */
+   if (buffer_size & (blksz - 1))
+   return EFI_EXIT(EFI_DEVICE_ERROR);
+
+   if (direction == EFI_DISK_READ)
+   n = desc->block_read(desc, lba, blocks, buffer);
+   else
+   n = desc->block_write(desc, lba, blocks, buffer);
+
+   /* We don't do interrupts, so check for timers cooperatively */
+   efi_timer_check();
+
+#ifdef DEBUG_EFI
+   printf("EFI: %s:%d n=%lx blocks=%x\n", __func__, __LINE__, n, blocks);
+#endif
+   if (n != blocks)
+   return

[U-Boot] [PATCH 02/16] include/efi_api.h: Add more detailed API definitions

2016-02-01 Thread Alexander Graf
The EFI API header is great, but missing a good chunk of function prototype,
GUID defines and enum declarations.

This patch extends it to cover more of the EFI API. It's still not 100%
complete, but sufficient enough for our EFI payload interface.

Signed-off-by: Alexander Graf 

---

v2 -> v3:

  - Add EFIAPI to notify_function
  - Add access denied code
---
 include/efi.h |   1 +
 include/efi_api.h | 198 --
 2 files changed, 162 insertions(+), 37 deletions(-)

diff --git a/include/efi.h b/include/efi.h
index fcafda0..cce7020 100644
--- a/include/efi.h
+++ b/include/efi.h
@@ -38,6 +38,7 @@ struct efi_device_path;
 #define EFI_WRITE_PROTECTED(8 | (1UL << (BITS_PER_LONG - 1)))
 #define EFI_OUT_OF_RESOURCES   (9 | (1UL << (BITS_PER_LONG - 1)))
 #define EFI_NOT_FOUND  (14 | (1UL << (BITS_PER_LONG - 1)))
+#define EFI_ACCESS_DENIED  (15 | (1UL << (BITS_PER_LONG - 1)))
 #define EFI_SECURITY_VIOLATION (26 | (1UL << (BITS_PER_LONG - 1)))
 
 typedef unsigned long efi_status_t;
diff --git a/include/efi_api.h b/include/efi_api.h
index 4fd17d6..03f6687 100644
--- a/include/efi_api.h
+++ b/include/efi_api.h
@@ -17,11 +17,18 @@
 
 #include 
 
+/* Types and defines for EFI CreateEvent */
+enum efi_event_type {
+   EFI_TIMER_STOP = 0,
+   EFI_TIMER_PERIODIC = 1,
+   EFI_TIMER_RELATIVE = 2
+};
+
 /* EFI Boot Services table */
 struct efi_boot_services {
struct efi_table_hdr hdr;
-   void *raise_tpl;
-   void *restore_tpl;
+   efi_status_t (EFIAPI *raise_tpl)(unsigned long new_tpl);
+   void (EFIAPI *restore_tpl)(unsigned long old_tpl);
 
efi_status_t (EFIAPI *allocate_pages)(int, int, unsigned long,
  efi_physical_addr_t *);
@@ -32,21 +39,33 @@ struct efi_boot_services {
efi_status_t (EFIAPI *allocate_pool)(int, unsigned long, void **);
efi_status_t (EFIAPI *free_pool)(void *);
 
-   void *create_event;
-   void *set_timer;
-   efi_status_t(EFIAPI *wait_for_event)(unsigned long number_of_events,
-void *event, unsigned long *index);
-   void *signal_event;
-   void *close_event;
-   void *check_event;
-
-   void *install_protocol_interface;
-   void *reinstall_protocol_interface;
-   void *uninstall_protocol_interface;
+   efi_status_t (EFIAPI *create_event)(enum efi_event_type type,
+   unsigned long notify_tpl,
+   void (EFIAPI *notify_function) (void *event,
+   void *context),
+   void *notify_context, void **event);
+   efi_status_t (EFIAPI *set_timer)(void *event, int type,
+   uint64_t trigger_time);
+   efi_status_t (EFIAPI *wait_for_event)(unsigned long number_of_events,
+   void *event, unsigned long *index);
+   efi_status_t (EFIAPI *signal_event)(void *event);
+   efi_status_t (EFIAPI *close_event)(void *event);
+   efi_status_t (EFIAPI *check_event)(void *event);
+
+   efi_status_t (EFIAPI *install_protocol_interface)(
+   void **handle, efi_guid_t *protocol,
+   int protocol_interface_type, void *protocol_interface);
+   efi_status_t (EFIAPI *reinstall_protocol_interface)(
+   void *handle, efi_guid_t *protocol,
+   void *old_interface, void *new_interface);
+   efi_status_t (EFIAPI *uninstall_protocol_interface)(void *handle,
+   efi_guid_t *protocol, void *protocol_interface);
efi_status_t (EFIAPI *handle_protocol)(efi_handle_t, efi_guid_t *,
   void **);
void *reserved;
-   void *register_protocol_notify;
+   efi_status_t (EFIAPI *register_protocol_notify)(
+   efi_guid_t *protocol, void *event,
+   void **registration);
efi_status_t (EFIAPI *locate_handle)(
enum efi_locate_search_type search_type,
efi_guid_t *protocol, void *search_key,
@@ -54,7 +73,8 @@ struct efi_boot_services {
efi_status_t (EFIAPI *locate_device_path)(efi_guid_t *protocol,
struct efi_device_path **device_path,
efi_handle_t *device);
-   void *install_configuration_table;
+   efi_status_t (EFIAPI *install_configuration_table)(
+   efi_guid_t *guid, void *table);
 
efi_status_t (EFIAPI *load_image)(bool boot_policiy,
efi_handle_t parent_image,
@@ -66,17 +86,20 @@ struct efi_boot_services {
efi_status_t (EFIAPI *exit)(efi_handle_t handle,
efi_status_t exit_status,
unsigned long exitdata_size, s16 *exitdata);
-   void *unload_image;
+   efi_sta

[U-Boot] [PATCH 05/16] efi_loader: Add console interface

2016-02-01 Thread Alexander Graf
One of the basic EFI interfaces is the console interface. Using it an EFI
application can interface with the user. This patch implements an EFI console
interface using getc() and putc().

Today, we only implement text based consoles. We also convert the EFI Unicode
characters to UTF-8 on the fly, hoping that everyone managed to jump on the
train by now.

Signed-off-by: Alexander Graf 
Reviewed-by: Simon Glass 

---

v1 -> v2:

  - Move to GPLv2+

v2 -> v3:

  - Add EFIAPI to function prototypes
---
 include/efi_loader.h |   5 +
 lib/efi_loader/efi_console.c | 360 +++
 2 files changed, 365 insertions(+)
 create mode 100644 lib/efi_loader/efi_console.c

diff --git a/include/efi_loader.h b/include/efi_loader.h
index a7f033e..46cd714 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -31,6 +31,11 @@
 
 extern struct efi_system_table systab;
 
+extern const struct efi_simple_text_output_protocol efi_con_out;
+extern const struct efi_simple_input_interface efi_con_in;
+extern const struct efi_console_control_protocol efi_console_control;
+
+extern const efi_guid_t efi_guid_console_control;
 extern const efi_guid_t efi_guid_device_path;
 extern const efi_guid_t efi_guid_loaded_image;
 
diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c
new file mode 100644
index 000..5110c0a
--- /dev/null
+++ b/lib/efi_loader/efi_console.c
@@ -0,0 +1,360 @@
+/*
+ *  EFI application console interface
+ *
+ *  Copyright (c) 2016 Alexander Graf
+ *
+ *  SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include 
+#include 
+
+/* If we can't determine the console size, default to 80x24 */
+static int console_columns = 80;
+static int console_rows = 24;
+static bool console_size_queried;
+
+const efi_guid_t efi_guid_console_control = CONSOLE_CONTROL_GUID;
+
+#define cESC '\x1b'
+#define ESC "\x1b"
+
+static efi_status_t EFIAPI efi_cin_get_mode(
+   struct efi_console_control_protocol *this,
+   int *mode, char *uga_exists, char *std_in_locked)
+{
+   EFI_ENTRY("%p, %p, %p, %p", this, mode, uga_exists, std_in_locked);
+
+   if (mode)
+   *mode = EFI_CONSOLE_MODE_TEXT;
+   if (uga_exists)
+   *uga_exists = 0;
+   if (std_in_locked)
+   *std_in_locked = 0;
+
+   return EFI_EXIT(EFI_SUCCESS);
+}
+
+static efi_status_t EFIAPI efi_cin_set_mode(
+   struct efi_console_control_protocol *this, int mode)
+{
+   EFI_ENTRY("%p, %d", this, mode);
+   return EFI_EXIT(EFI_UNSUPPORTED);
+}
+
+static efi_status_t EFIAPI efi_cin_lock_std_in(
+   struct efi_console_control_protocol *this,
+   uint16_t *password)
+{
+   EFI_ENTRY("%p, %p", this, password);
+   return EFI_EXIT(EFI_UNSUPPORTED);
+}
+
+const struct efi_console_control_protocol efi_console_control = {
+   .get_mode = efi_cin_get_mode,
+   .set_mode = efi_cin_set_mode,
+   .lock_std_in = efi_cin_lock_std_in,
+};
+
+static struct simple_text_output_mode efi_con_mode = {
+   .max_mode = 0,
+   .mode = 0,
+   .attribute = 0,
+   .cursor_column = 0,
+   .cursor_row = 0,
+   .cursor_visible = 1,
+};
+
+static int term_read_reply(int *n, int maxnum, char end_char)
+{
+   char c;
+   int i = 0;
+
+   c = getc();
+   if (c != cESC)
+   return -1;
+   c = getc();
+   if (c != '[')
+   return -1;
+
+   n[0] = 0;
+   while (1) {
+   c = getc();
+   if (c == ';') {
+   i++;
+   if (i >= maxnum)
+   return -1;
+   n[i] = 0;
+   continue;
+   } else if (c == end_char) {
+   break;
+   } else if (c > '9' || c < '0') {
+   return -1;
+   }
+
+   /* Read one more decimal position */
+   n[i] *= 10;
+   n[i] += c - '0';
+   }
+
+   return 0;
+}
+
+static efi_status_t EFIAPI efi_cout_reset(
+   struct efi_simple_text_output_protocol *this,
+   char extended_verification)
+{
+   EFI_ENTRY("%p, %d", this, extended_verification);
+   return EFI_EXIT(EFI_UNSUPPORTED);
+}
+
+static void print_unicode_in_utf8(u16 c)
+{
+   char utf8[4] = { 0 };
+   char *b = utf8;
+
+   if (c < 0x80) {
+   *(b++) = c;
+   } else if (c < 0x800) {
+   *(b++) = 192 + c / 64;
+   *(b++) = 128 + c % 64;
+   } else {
+   *(b++) = 224 + c / 4096;
+   *(b++) = 128 + c / 64 % 64;
+   *(b++) = 128 + c % 64;
+   }
+
+   puts(utf8);
+}
+
+static efi_status_t EFIAPI efi_cout_output_string(
+   struct efi_simple_text_output_protocol *this,
+   const unsigned short *string)
+{

[U-Boot] [PATCH 00/16] EFI payload / application support v3

2016-02-01 Thread Alexander Graf
This is my (now quite late) Christmas present for my openSUSE friends :).

U-Boot is a great project for embedded devices. However, convincing
everyone involved that only for "a few oddball ARM devices" we need to
support different configuration formats from grub2 when all other platforms
(PPC, System Z, x86) are standardized on a single format is a nightmare.

So we started to explore alternatives. At first, people tried to get
grub2 running using the u-boot api interface. However, FWIW that one
doesn't support relocations, so you need to know where to link grub2 to
at compile time. It also seems to be broken more often than not. And on
top of it all, it's a one-off interface, so yet another thing to maintain.

That led to a nifty idea. What if we can just implement the EFI application
protocol on top of U-Boot? Then we could compile a single grub2 binary for
uEFI based systems and U-Boot based systems and as soon as that one's loaded,
everything looks and feels (almost) the same.

This patch set is the result of pursuing this endeavor.

  - I am successfully able to run grub2 and Linux EFI binaries with this code.
  - When enabled, the resulting U-Boot binary only grows by ~10kb,
so it's very light weight.
  - It works on 32bit ARM and AArch64. 
  - All storage devices are directly accessible
  - No EFI variables
  - Removable media booting (search for /efi/boot/boota{a64,arm}.efi)
  - Everything in place for runtime service support

Of course, there are still a few things one could do on top:

  - Improve disk media detection (don't scan, use what information we have)
  - Add EFI variable support using NVRAM
  - Add GFX support
  - Make EFI Shell work ;)
  - Network device support
  - Support for payload exit

But so far, I'm very happy with the state of the patches. They completely
eliminate potential arguments against U-Boot internally and give users the
chance to run with the same level of comfort on all firmware types.

Version 3 was successfully tested to boot grub2 and Linux from there on a
HiKey (AArch64, dcache disabled) and on a BeagleBone Black.

If you read this far and want to try out the patches, feel free to grab
the source from git at:

  https://github.com/agraf/u-boot efi-v3

v1 -> v2:
  - move memory allocation to separate patch
  - limit 32/64 to hosts that support it
  - check 32bit optional nt header magic
  - switch to GPLv2+
  - Fix typo s/does now/does not/
  - Add #ifdefs around header to allow inclusion when efi_loader is disabled
  - Add stub efi_restore_gd() function when efi_loader is disabled
  - Disable debug
  - Mark runtime region as such
  - Fix up memory map
  - Allow efi_restore_gd to be called before first efi entry
  - Add 32bit arm cache workaround
  - Move memory map to separate patch
  - Change BTS version to 2.5
  - Fix return values for a few callbacks to more EFI compliant ones
  - Change vendor to "Das U-Boot"
  - Add warning when truncating timer trigger
  - Add runtime detach
  - Enable runtime relocations
  - Add get_time
  - Fix relocation
  - Fix 32bit
  - Add am335x support
  - Move section definition to header
  - Add systab to runtime section
  - Add self-relocation hook table
  - Relocate efi_runtime section early during bootup
  - Fix return values for a number of callbacks to be more UEFI compliant
  - Move to block_drvr array
  - Fix header order
  - Document efi block object struct
  - Use calloc rather than malloc & memset
  - Default to y
  - New patches: 
- disk/part.c: Expose list of available block drivers
- arm64: Allow exceptions to return
- arm64: Allow EFI payload code to take exceptions
- efi_loader: Add DCACHE_OFF support for arm64
- efi_loader: Add distro boot script for removable media

v2 -> v3:

  - Add EFIAPI to notify_function
  - Add access denied code
  - use efi_alloc
  - add EFIAPI to function prototypes
  - remove unused macros
  - reorder header inclusion
  - split relocation code into function
  - flush cache after loading
  - Use external efi_memory helpers
  - Add EFIAPI to function prototypes
  - Initialize event timer to -1ULL to prevent early firing
  - Document header
  - Move obj list to lib
  - Remove implicit guid table
  - Add guid compare function
  - Fix return values
  - Implement efi_wait_for_event
  - Add EFIAPI to function prototypes
  - Patch reset to NULL
  - Add EFIAPI to function prototypes
  - Document header
  - Add dm.h include
  - Remove non-dm rtc support
  - Return DEVICE_ERROR in rtc path
  - Adapt to newer u-boot block API
  - Add EFIAPI to function prototypes
  - Document header
  - Check for DEV_TYPE_UNKNOWN
  - Document 16byte limit for dp string
  - Move to new cmd directory
  - Add kconfig option
  - Fix comment style
  - Add help text
  - s/-1/-ENOENT
  - Move obj list to lib
  - Rewrite memory allocation and map
  - Document header
  - Add memory file
  - New files:
- README patch
- MAINTAINERS patch


Alex


Alexander Graf (16):
  disk/part.c: Expose list 

[U-Boot] [PATCH 04/16] efi_loader: Add boot time services

2016-02-01 Thread Alexander Graf
When an EFI application runs, it has access to a few descriptor and callback
tables to instruct the EFI compliant firmware to do things for it. The bulk
of those interfaces are "boot time services". They handle all object management,
and memory allocation.

This patch adds support for the boot time services and also exposes a system
table, which is the point of entry descriptor table for EFI payloads.

Signed-off-by: Alexander Graf 
Reviewed-by: Simon Glass 

---

v1 -> v2:

  - Fix typo s/does now/does not/
  - Add #ifdefs around header to allow inclusion when efi_loader is disabled
  - Add stub efi_restore_gd() function when efi_loader is disabled
  - Disable debug
  - Mark runtime region as such
  - Fix up memory map
  - Allow efi_restore_gd to be called before first efi entry
  - Add 32bit arm cache workaround
  - Move memory map to separate patch
  - Change BTS version to 2.5
  - Fix return values for a few callbacks to more EFI compliant ones
  - Change vendor to "Das U-Boot"
  - Add warning when truncating timer trigger
  - Move to GPLv2+

v2 -> v3:

  - Use external efi_memory helpers
  - Add EFIAPI to function prototypes
  - Initialize event timer to -1ULL to prevent early firing
  - Document header
  - Move obj list to lib
  - Remove implicit guid table
  - Add guid compare function
  - Fix return values
  - Implement efi_wait_for_event
  - Implement efi_install_configuration_table
---
 include/efi_loader.h  |  84 +
 lib/efi_loader/efi_boottime.c | 781 ++
 2 files changed, 865 insertions(+)
 create mode 100644 lib/efi_loader/efi_boottime.c

diff --git a/include/efi_loader.h b/include/efi_loader.h
index 5618185..a7f033e 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -6,15 +6,99 @@
  *  SPDX-License-Identifier: GPL-2.0+
  */
 
+#include 
 #include 
 #include 
+
+#ifdef CONFIG_EFI_LOADER
+
 #include 
 
+/* #define DEBUG_EFI */
+
+#ifdef DEBUG_EFI
+#define EFI_ENTRY(format, ...) do { \
+   efi_restore_gd(); \
+   printf("EFI: Entry %s(" format ")\n", __func__, ##__VA_ARGS__); \
+   } while(0)
+#else
+#define EFI_ENTRY(format, ...) do { \
+   efi_restore_gd(); \
+   } while(0)
+#endif
+
+#define EFI_EXIT(ret) efi_exit_func(ret);
+
+extern struct efi_system_table systab;
+
 extern const efi_guid_t efi_guid_device_path;
 extern const efi_guid_t efi_guid_loaded_image;
 
+/*
+ * While UEFI objects can have callbacks, you can also call functions on
+ * protocols (classes) themselves. This struct maps a protocol GUID to its
+ * interface (usually a struct with callback functions).
+ */
+struct efi_class_map {
+   const efi_guid_t *guid;
+   const void *interface;
+};
+
+/*
+ * When the UEFI payload wants to open a protocol on an object to get its
+ * interface (usually a struct with callback functions), this struct maps the
+ * protocol GUID to the respective protocol handler open function for that
+ * object protocol combination.
+ */
+struct efi_handler {
+   const efi_guid_t *guid;
+   efi_status_t (EFIAPI *open)(void *handle,
+   efi_guid_t *protocol, void **protocol_interface,
+   void *agent_handle, void *controller_handle,
+   uint32_t attributes);
+};
+
+/*
+ * UEFI has a poor man's OO model where one "object" can be polimorphic and 
have
+ * multiple different protocols (classes) attached to it.
+ *
+ * This struct is the parent struct for all of our actual implementation 
objects
+ * that can include it to make themselves an EFI object
+ */
+struct efi_object {
+   /* Every UEFI object is part of a global object list */
+   struct list_head link;
+   /* We support up to 4 "protocols" an object can be accessed through */
+   struct efi_handler protocols[4];
+   /* The object spawner can either use this for data or as identifier */
+   void *handle;
+};
+
+/* This list contains all UEFI objects we know of */
+extern struct list_head efi_obj_list;
+
+/*
+ * Stub implementation for a protocol opener that just returns the handle as
+ * interface
+ */
 efi_status_t efi_return_handle(void *handle,
efi_guid_t *protocol, void **protocol_interface,
void *agent_handle, void *controller_handle,
uint32_t attributes);
+/* Called from places to check whether a timer expired */
+void efi_timer_check(void);
+/* PE loader implementation */
 void *efi_load_pe(void *efi, struct efi_loaded_image *loaded_image_info);
+/* Called once to store the pristine gd pointer */
+void efi_save_gd(void);
+/* Called from EFI_ENTRY on callback entry to put gd into the gd register */
+void efi_restore_gd(void);
+/* Called from EFI_EXIT on callback exit to restore the gd register */
+efi_status_t efi_exit_func(efi_status_t ret);
+
+#else /* defined(EFI_LOADER) */
+
+/* No loader configured, stub out EFI_ENTRY */
+static inline void efi_restore_gd(void) { }
+
+#endif
diff --git a/lib/efi_loader/efi_

[U-Boot] Please pull u-boot-fsl-qoriq master

2016-02-01 Thread york sun
Tom,

The following changes since commit 8cdae1dacde7dbe74d53a8ac1a05761a53c4f191:

  video: Correct 'tor' typo in comment (2016-01-30 10:58:47 +0100)

are available in the git repository at:

  git://git.denx.de/u-boot-fsl-qoriq.git master

for you to fetch changes up to 7711cc0a0648e215571b1d1768381963d92a1d97:

  arm8: ls2080: Move the core errata defines out of board specific file
(2016-02-01 13:59:55 -0800)


Alison Wang (1):
  armv7: ls102xa: Increase the supported kernel size

Ashish kumar (2):
  armv8: ls2080a: Implement workaround for core errata 829520, 833471
  arm8: ls2080: Move the core errata defines out of board specific file

Prabhakar Kushwaha (3):
  board: ls2085aqds: Update kernel_size env variable
  driver: net: fsl-mc: Memset dprc_cfg before configuring
  driver: net: fsl-mc: Update print to reflect correct string

Qianyu Gong (1):
  armv8/ls1043aqds: fix DSPI/QSPI node in dts file

 arch/arm/cpu/armv8/start.S|   19 +
 arch/arm/dts/fsl-ls1043a-qds.dtsi |   46 +
 arch/arm/include/asm/arch-fsl-layerscape/config.h |6 +++
 drivers/net/fsl-mc/mc.c   |3 +-
 include/configs/ls1021aqds.h  |1 +
 include/configs/ls1021atwr.h  |1 +
 include/configs/ls2080a_common.h  |3 --
 include/configs/ls2080aqds.h  |2 +-
 8 files changed, 76 insertions(+), 5 deletions(-)

Thanks.

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


[U-Boot] [RESEND PATCH v3 5/5] drivers: at91: clean up peripheral clock code

2016-02-01 Thread Wenyou Yang
Due to introducing the new peripheral clock handle functions,
use these functions to reduce the duplicated code.

Signed-off-by: Wenyou Yang 
Tested-by: Heiko Schocher 
---

Changes in v3: None
Changes in v2: None

 drivers/net/at91_emac.c   |9 -
 drivers/usb/host/ehci-atmel.c |8 
 drivers/usb/host/ohci-at91.c  |   20 
 3 files changed, 8 insertions(+), 29 deletions(-)

diff --git a/drivers/net/at91_emac.c b/drivers/net/at91_emac.c
index 2659592..178dfaa 100644
--- a/drivers/net/at91_emac.c
+++ b/drivers/net/at91_emac.c
@@ -12,7 +12,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -321,7 +320,6 @@ static int at91emac_init(struct eth_device *netdev, bd_t 
*bd)
emac_device *dev;
at91_emac_t *emac;
at91_pio_t *pio = (at91_pio_t *) ATMEL_BASE_PIO;
-   at91_pmc_t *pmc = (at91_pmc_t *) ATMEL_BASE_PMC;
 
emac = (at91_emac_t *) netdev->iobase;
dev = (emac_device *) netdev->priv;
@@ -347,7 +345,8 @@ static int at91emac_init(struct eth_device *netdev, bd_t 
*bd)
writel(value, &pio->piob.pdr);
writel(value, &pio->piob.bsr);
 
-   writel(1 << ATMEL_ID_EMAC, &pmc->pcer);
+   at91_periph_clk_enable(ATMEL_ID_EMAC);
+
writel(readl(&emac->ctl) | AT91_EMAC_CTL_CSR, &emac->ctl);
 
/* Init Ethernet buffers */
@@ -452,10 +451,10 @@ static int at91emac_recv(struct eth_device *netdev)
 static int at91emac_write_hwaddr(struct eth_device *netdev)
 {
at91_emac_t *emac;
-   at91_pmc_t *pmc = (at91_pmc_t *) ATMEL_BASE_PMC;
emac = (at91_emac_t *) netdev->iobase;
 
-   writel(1 << ATMEL_ID_EMAC, &pmc->pcer);
+   at91_periph_clk_enable(ATMEL_ID_EMAC);
+
debug_cond(DEBUG_AT91EMAC,
"init MAC-ADDR %02x:%02x:%02x:%02x:%02x:%02x\n",
netdev->enetaddr[5], netdev->enetaddr[4], netdev->enetaddr[3],
diff --git a/drivers/usb/host/ehci-atmel.c b/drivers/usb/host/ehci-atmel.c
index 9a8f004..a33fb49 100644
--- a/drivers/usb/host/ehci-atmel.c
+++ b/drivers/usb/host/ehci-atmel.c
@@ -40,11 +40,7 @@ int ehci_hcd_init(int index, enum usb_init_type init,
}
 
/* Enable USB Host clock */
-#ifdef CPU_HAS_PCR
at91_periph_clk_enable(ATMEL_ID_UHPHS);
-#else
-   writel(1 << ATMEL_ID_UHPHS, &pmc->pcer);
-#endif
 
*hccr = (struct ehci_hccr *)ATMEL_BASE_EHCI;
*hcor = (struct ehci_hcor *)((uint32_t)*hccr +
@@ -59,11 +55,7 @@ int ehci_hcd_stop(int index)
ulong start_time, tmp_time;
 
/* Disable USB Host Clock */
-#ifdef CPU_HAS_PCR
at91_periph_clk_disable(ATMEL_ID_UHPHS);
-#else
-   writel(1 << ATMEL_ID_UHPHS, &pmc->pcdr);
-#endif
 
start_time = get_timer(0);
/* Disable UTMI PLL */
diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index 820e2e5..da85111 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -37,17 +37,11 @@ int usb_cpu_init(void)
writel(AT91_PMC_USBS_USB_UPLL | AT91_PMC_USBDIV_10, &pmc->usb);
 #endif
 
-   /* Enable USB host clock. */
-#ifdef CPU_HAS_PCR
at91_periph_clk_enable(ATMEL_ID_UHP);
-#else
-   writel(1 << ATMEL_ID_UHP, &pmc->pcer);
-#endif
 
+   at91_system_clk_enable(ATMEL_PMC_UHP);
 #if defined(CONFIG_AT91SAM9261) || defined(CONFIG_AT91SAM9G10)
-   writel(ATMEL_PMC_UHP | AT91_PMC_HCK0, &pmc->scer);
-#else
-   writel(ATMEL_PMC_UHP, &pmc->scer);
+   at91_system_clk_enable(AT91_PMC_HCK0);
 #endif
 
return 0;
@@ -57,17 +51,11 @@ int usb_cpu_stop(void)
 {
at91_pmc_t *pmc = (at91_pmc_t *)ATMEL_BASE_PMC;
 
-   /* Disable USB host clock. */
-#ifdef CPU_HAS_PCR
at91_periph_clk_disable(ATMEL_ID_UHP);
-#else
-   writel(1 << ATMEL_ID_UHP, &pmc->pcdr);
-#endif
 
+   at91_system_clk_disable(ATMEL_PMC_UHP);
 #if defined(CONFIG_AT91SAM9261) || defined(CONFIG_AT91SAM9G10)
-   writel(ATMEL_PMC_UHP | AT91_PMC_HCK0, &pmc->scdr);
-#else
-   writel(ATMEL_PMC_UHP, &pmc->scdr);
+   at91_system_clk_disable(AT91_PMC_HCK0);
 #endif
 
 #ifdef CONFIG_USB_ATMEL_CLK_SEL_PLLB
-- 
1.7.9.5

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


[U-Boot] [RESEND PATCH v3 2/5] ARM: at91: clock: add a new file to handle clock

2016-02-01 Thread Wenyou Yang
To reduce the duplicated code, add a new file to accommodate
the peripheral's and system's clock handle code, shared with
the SoCs with different ARM core.

Signed-off-by: Wenyou Yang 
Tested-by: Heiko Schocher 
---

Changes in v3:
 - fix incorrectly used the indicator '&' to achieve the variable
   pointer of pmc->pcer and pmc->pcdr.

Changes in v2: None

 arch/arm/mach-at91/Makefile   |1 +
 arch/arm/mach-at91/arm926ejs/clock.c  |7 
 arch/arm/mach-at91/armv7/clock.c  |   26 
 arch/arm/mach-at91/clock.c|   72 +
 arch/arm/mach-at91/include/mach/clk.h |2 +
 5 files changed, 75 insertions(+), 33 deletions(-)
 create mode 100644 arch/arm/mach-at91/clock.c

diff --git a/arch/arm/mach-at91/Makefile b/arch/arm/mach-at91/Makefile
index 5b89617..d071072 100644
--- a/arch/arm/mach-at91/Makefile
+++ b/arch/arm/mach-at91/Makefile
@@ -14,6 +14,7 @@ obj-$(CONFIG_SAMA5D4) += mpddrc.o spl_atmel.o matrix.o 
atmel_sfr.o
 obj-y += spl.o
 endif
 
+obj-y += clock.o
 obj-$(CONFIG_CPU_ARM920T)  += arm920t/
 obj-$(CONFIG_CPU_ARM926EJS)+= arm926ejs/
 obj-$(CONFIG_CPU_V7)   += armv7/
diff --git a/arch/arm/mach-at91/arm926ejs/clock.c 
b/arch/arm/mach-at91/arm926ejs/clock.c
index 8d6934e..c8b5e10 100644
--- a/arch/arm/mach-at91/arm926ejs/clock.c
+++ b/arch/arm/mach-at91/arm926ejs/clock.c
@@ -242,10 +242,3 @@ void at91_mck_init(u32 mckr)
while (!(readl(&pmc->sr) & AT91_PMC_MCKRDY))
;
 }
-
-void at91_periph_clk_enable(int id)
-{
-   struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
-
-   writel(1 << id, &pmc->pcer);
-}
diff --git a/arch/arm/mach-at91/armv7/clock.c b/arch/arm/mach-at91/armv7/clock.c
index 41dbf16..81e9f69 100644
--- a/arch/arm/mach-at91/armv7/clock.c
+++ b/arch/arm/mach-at91/armv7/clock.c
@@ -150,32 +150,6 @@ void at91_mck_init(u32 mckr)
;
 }
 
-void at91_periph_clk_enable(int id)
-{
-   struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
-   u32 regval;
-
-   if (id > AT91_PMC_PCR_PID_MASK)
-   return;
-
-   regval = AT91_PMC_PCR_EN | AT91_PMC_PCR_CMD_WRITE | id;
-
-   writel(regval, &pmc->pcr);
-}
-
-void at91_periph_clk_disable(int id)
-{
-   struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
-   u32 regval;
-
-   if (id > AT91_PMC_PCR_PID_MASK)
-   return;
-
-   regval = AT91_PMC_PCR_CMD_WRITE | id;
-
-   writel(regval, &pmc->pcr);
-}
-
 int at91_enable_periph_generated_clk(u32 id, u32 clk_source, u32 div)
 {
struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
diff --git a/arch/arm/mach-at91/clock.c b/arch/arm/mach-at91/clock.c
new file mode 100644
index 000..d1c4b76
--- /dev/null
+++ b/arch/arm/mach-at91/clock.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2015 Atmel Corporation
+ *   Wenyou Yang 
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+void at91_periph_clk_enable(int id)
+{
+   struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
+
+#ifdef CPU_HAS_PCR
+   u32 regval;
+   u32 div_value;
+
+   if (id > AT91_PMC_PCR_PID_MASK)
+   return;
+
+   writel(id, &pmc->pcr);
+
+   div_value = readl(&pmc->pcr) & AT91_PMC_PCR_DIV;
+
+   regval = AT91_PMC_PCR_EN | AT91_PMC_PCR_CMD_WRITE | id | div_value;
+
+   writel(regval, &pmc->pcr);
+#else
+   u32 mask = 0x01 << (id % 32);
+   void *addr = (id / 32)  ?  &pmc->pcer1 : &pmc->pcer;
+
+   writel(mask, addr);
+#endif
+}
+
+void at91_periph_clk_disable(int id)
+{
+   struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
+
+#ifdef CPU_HAS_PCR
+   u32 regval;
+
+   if (id > AT91_PMC_PCR_PID_MASK)
+   return;
+
+   regval = AT91_PMC_PCR_CMD_WRITE | id;
+
+   writel(regval, &pmc->pcr);
+#else
+   u32 mask = 0x01 << (id % 32);
+   void *addr = (id / 32)  ?  &pmc->pcdr1 : &pmc->pcdr;
+
+   writel(mask, addr);
+#endif
+}
+
+void at91_system_clk_enable(int sys_clk)
+{
+   struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
+
+   writel(sys_clk, &pmc->scer);
+}
+
+void at91_system_clk_disable(int sys_clk)
+{
+   struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
+
+   writel(sys_clk, &pmc->scdr);
+}
diff --git a/arch/arm/mach-at91/include/mach/clk.h 
b/arch/arm/mach-at91/include/mach/clk.h
index ad83927..bef4e1c 100644
--- a/arch/arm/mach-at91/include/mach/clk.h
+++ b/arch/arm/mach-at91/include/mach/clk.h
@@ -128,5 +128,7 @@ void at91_periph_clk_enable(int id);
 void at91_periph_clk_disable(int id);
 int at91_enable_periph_generated_clk(u32 id, u32 clk_source, u32 div);
 u32 at91_get_periph_generated_clk(u32 id);
+void at91_system_clk_enable(int sys_clk);
+void at91_system_clk_disable(int sys_clk);
 
 #endif /* __ASM_ARM_ARCH_CLK_H__ */
-- 
1.7.9.5

___
U-Boot mailing list
U-Boot@lists.denx.de
htt

[U-Boot] [RESEND PATCH v3 4/5] board: atmel: clean up peripheral clock code

2016-02-01 Thread Wenyou Yang
Due to introducing the new peripheral clock handle functions,
use these functions to reduce duplicated code.

Signed-off-by: Wenyou Yang 
Tested-by: Heiko Schocher 
---

Changes in v3: None
Changes in v2:
 - fix checkpatch warning.

 board/atmel/at91rm9200ek/at91rm9200ek.c |1 -
 board/atmel/at91rm9200ek/led.c  |5 +
 board/atmel/at91sam9260ek/at91sam9260ek.c   |   15 +--
 board/atmel/at91sam9261ek/at91sam9261ek.c   |8 ++--
 board/atmel/at91sam9261ek/led.c |6 ++
 board/atmel/at91sam9263ek/at91sam9263ek.c   |   23 +++
 board/atmel/at91sam9263ek/led.c |9 +++--
 board/atmel/at91sam9m10g45ek/at91sam9m10g45ek.c |   20 +---
 board/atmel/at91sam9m10g45ek/led.c  |7 ++-
 board/atmel/at91sam9n12ek/at91sam9n12ek.c   |6 ++
 board/atmel/at91sam9rlek/at91sam9rlek.c |   18 ++
 board/atmel/at91sam9rlek/led.c  |7 ++-
 board/atmel/at91sam9x5ek/at91sam9x5ek.c |   10 +++---
 board/atmel/sama5d2_xplained/sama5d2_xplained.c |1 -
 board/atmel/sama5d3_xplained/sama5d3_xplained.c |5 ++---
 board/atmel/sama5d3xek/sama5d3xek.c |5 ++---
 board/atmel/sama5d4_xplained/sama5d4_xplained.c |5 ++---
 board/atmel/sama5d4ek/sama5d4ek.c   |5 ++---
 board/bluewater/snapper9260/snapper9260.c   |   15 +--
 board/calao/usb_a9263/usb_a9263.c   |   11 ---
 board/egnite/ethernut5/ethernut5.c  |   20 
 board/esd/meesc/meesc.c |   15 ++-
 board/mini-box/picosam9g45/led.c|7 ++-
 board/mini-box/picosam9g45/picosam9g45.c|   17 -
 board/ronetix/pm9261/led.c  |7 ++-
 board/ronetix/pm9261/pm9261.c   |   22 ++
 board/ronetix/pm9263/led.c  |7 ++-
 board/ronetix/pm9263/pm9263.c   |   19 +--
 board/ronetix/pm9g45/pm9g45.c   |   20 ++--
 board/siemens/corvus/board.c|6 ++
 board/siemens/smartweb/smartweb.c   |3 +--
 board/siemens/taurus/taurus.c   |3 +--
 32 files changed, 102 insertions(+), 226 deletions(-)

diff --git a/board/atmel/at91rm9200ek/at91rm9200ek.c 
b/board/atmel/at91rm9200ek/at91rm9200ek.c
index 64ab572..4ca8106 100644
--- a/board/atmel/at91rm9200ek/at91rm9200ek.c
+++ b/board/atmel/at91rm9200ek/at91rm9200ek.c
@@ -14,7 +14,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 
diff --git a/board/atmel/at91rm9200ek/led.c b/board/atmel/at91rm9200ek/led.c
index 6761b14..8b62035 100644
--- a/board/atmel/at91rm9200ek/led.c
+++ b/board/atmel/at91rm9200ek/led.c
@@ -12,7 +12,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 
@@ -59,11 +58,9 @@ void red_led_off(void)
 
 void coloured_LED_init (void)
 {
-   at91_pmc_t *pmc = (at91_pmc_t *)ATMEL_BASE_PMC;
at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
 
-   /* Enable PIOB clock */
-   writel(1 << ATMEL_ID_PIOB, &pmc->pcer);
+   at91_periph_clk_enable(ATMEL_ID_PIOB);
 
/* Disable peripherals on LEDs */
writel(GREEN_LED | YELLOW_LED | RED_LED, &pio->piob.per);
diff --git a/board/atmel/at91sam9260ek/at91sam9260ek.c 
b/board/atmel/at91sam9260ek/at91sam9260ek.c
index 7f14af1..98193bf 100644
--- a/board/atmel/at91sam9260ek/at91sam9260ek.c
+++ b/board/atmel/at91sam9260ek/at91sam9260ek.c
@@ -11,7 +11,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 
@@ -70,11 +70,9 @@ static void at91sam9260ek_nand_hw_init(void)
 #ifdef CONFIG_MACB
 static void at91sam9260ek_macb_hw_init(void)
 {
-   struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
struct at91_port *pioa = (struct at91_port *)ATMEL_BASE_PIOA;
 
-   /* Enable EMAC clock */
-   writel(1 << ATMEL_ID_EMAC0, &pmc->pcer);
+   at91_periph_clk_enable(ATMEL_ID_EMAC0);
 
/*
 * Disable pull-up on:
@@ -122,12 +120,9 @@ int board_mmc_init(bd_t *bd)
 
 int board_early_init_f(void)
 {
-   struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
-
-   /* Enable clocks for all PIOs */
-   writel((1 << ATMEL_ID_PIOA) | (1 << ATMEL_ID_PIOB) |
-   (1 << ATMEL_ID_PIOC),
-   &pmc->pcer);
+   at91_periph_clk_enable(ATMEL_ID_PIOA);
+   at91_periph_clk_enable(ATMEL_ID_PIOB);
+   at91_periph_clk_enable(ATMEL_ID_PIOC);
 
return 0;
 }
diff --git a/board/atmel/at91sam9261ek/at91sam9261ek.c 
b/board/atmel/at91sam9261ek/at91sam9261ek.c
index 5250474..7b7cd2c 100644
--- a/board/atmel/at91sam9261ek/at91sam9261ek.c
+++ b/board/atmel/at91sam9261ek/at91sam9261ek.c
@@ -12,7 +12,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #incl

[U-Boot] [RESEND PATCH v3 1/5] ARM: at91: asm/at91_pmc.h: fix trival register offset

2016-02-01 Thread Wenyou Yang
Remove unnecessary #ifdef CPU_HAS_PCR.

Signed-off-by: Wenyou Yang 
Tested-by: Heiko Schocher 
Reviewed-by: Andreas Bießmann 
---

Changes in v3: None
Changes in v2: None

 arch/arm/mach-at91/include/mach/at91_pmc.h |8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-at91/include/mach/at91_pmc.h 
b/arch/arm/mach-at91/include/mach/at91_pmc.h
index 3f50f77..eb40194 100644
--- a/arch/arm/mach-at91/include/mach/at91_pmc.h
+++ b/arch/arm/mach-at91/include/mach/at91_pmc.h
@@ -51,19 +51,15 @@ typedef struct at91_pmc {
u32 imr;/* 0x6C Interrupt Mask Register */
u32 reserved4[4];
u32 pllicpr;/* 0x80 Change Pump Current Register (SAM9) */
-   u32 reserved5[21];
+   u32 reserved5[24];
u32 wpmr;   /* 0xE4 Write Protect Mode Register (CAP0) */
u32 wpsr;   /* 0xE8 Write Protect Status Register (CAP0) */
-#ifdef CPU_HAS_PCR
-   u32 reserved6[8];
+   u32 reserved6[5];
u32 pcer1;  /* 0x100 Periperial Clock Enable Register 1 */
u32 pcdr1;  /* 0x104 Periperial Clock Disable Register 1 */
u32 pcsr1;  /* 0x108 Periperial Clock Status Register 1 */
u32 pcr;/* 0x10c Periperial Control Register */
u32 ocr;/* 0x110 Oscillator Calibration Register */
-#else
-   u32 reserved8[5];
-#endif
 } at91_pmc_t;
 
 #endif /* end not assembly */
-- 
1.7.9.5

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


[U-Boot] [RESEND PATCH v3 0/5] ARM: at91: improve peripheral and system clock handle functions

2016-02-01 Thread Wenyou Yang
To reduce the duplicated code, rework the peripheral's and
system's clock handle functions, use these functions to replace
the clock handle code.

Changes in v3:
 - fix incorrectly used the indicator '&' to achieve the variable
   pointer of pmc->pcer and pmc->pcdr.

Changes in v2:
 - fix checkpatch warning.

Wenyou Yang (5):
  ARM: at91: asm/at91_pmc.h: fix trival register offset
  ARM: at91: clock: add a new file to handle clock
  ARM: cpu: at91: clean up peripheral clock code
  board: atmel: clean up peripheral clock code
  drivers: at91: clean up peripheral clock code

 arch/arm/mach-at91/Makefile|1 +
 arch/arm/mach-at91/arm920t/at91rm9200_devices.c|   13 +---
 arch/arm/mach-at91/arm920t/timer.c |4 +-
 arch/arm/mach-at91/arm926ejs/at91sam9260_devices.c |   36 +++---
 arch/arm/mach-at91/arm926ejs/at91sam9261_devices.c |   28 ++--
 arch/arm/mach-at91/arm926ejs/at91sam9263_devices.c |   37 +++---
 .../mach-at91/arm926ejs/at91sam9m10g45_devices.c   |   33 +++--
 arch/arm/mach-at91/arm926ejs/at91sam9n12_devices.c |   40 +++
 arch/arm/mach-at91/arm926ejs/at91sam9rl_devices.c  |   28 ++--
 arch/arm/mach-at91/arm926ejs/at91sam9x5_devices.c  |   38 +++
 arch/arm/mach-at91/arm926ejs/clock.c   |7 --
 arch/arm/mach-at91/arm926ejs/cpu.c |1 -
 arch/arm/mach-at91/arm926ejs/timer.c   |5 +-
 arch/arm/mach-at91/armv7/clock.c   |   26 ---
 arch/arm/mach-at91/armv7/cpu.c |1 -
 arch/arm/mach-at91/armv7/timer.c   |1 -
 arch/arm/mach-at91/clock.c |   72 
 arch/arm/mach-at91/include/mach/at91_pmc.h |8 +--
 arch/arm/mach-at91/include/mach/clk.h  |2 +
 arch/arm/mach-at91/phy.c   |1 -
 arch/arm/mach-at91/sdram.c |1 -
 board/atmel/at91rm9200ek/at91rm9200ek.c|1 -
 board/atmel/at91rm9200ek/led.c |5 +-
 board/atmel/at91sam9260ek/at91sam9260ek.c  |   15 ++--
 board/atmel/at91sam9261ek/at91sam9261ek.c  |8 +--
 board/atmel/at91sam9261ek/led.c|6 +-
 board/atmel/at91sam9263ek/at91sam9263ek.c  |   23 ++-
 board/atmel/at91sam9263ek/led.c|9 +--
 board/atmel/at91sam9m10g45ek/at91sam9m10g45ek.c|   20 ++
 board/atmel/at91sam9m10g45ek/led.c |7 +-
 board/atmel/at91sam9n12ek/at91sam9n12ek.c  |6 +-
 board/atmel/at91sam9rlek/at91sam9rlek.c|   18 ++---
 board/atmel/at91sam9rlek/led.c |7 +-
 board/atmel/at91sam9x5ek/at91sam9x5ek.c|   10 +--
 board/atmel/sama5d2_xplained/sama5d2_xplained.c|1 -
 board/atmel/sama5d3_xplained/sama5d3_xplained.c|5 +-
 board/atmel/sama5d3xek/sama5d3xek.c|5 +-
 board/atmel/sama5d4_xplained/sama5d4_xplained.c|5 +-
 board/atmel/sama5d4ek/sama5d4ek.c  |5 +-
 board/bluewater/snapper9260/snapper9260.c  |   15 ++--
 board/calao/usb_a9263/usb_a9263.c  |   11 ++-
 board/egnite/ethernut5/ethernut5.c |   20 +++---
 board/esd/meesc/meesc.c|   15 ++--
 board/mini-box/picosam9g45/led.c   |7 +-
 board/mini-box/picosam9g45/picosam9g45.c   |   17 ++---
 board/ronetix/pm9261/led.c |7 +-
 board/ronetix/pm9261/pm9261.c  |   22 ++
 board/ronetix/pm9263/led.c |7 +-
 board/ronetix/pm9263/pm9263.c  |   19 ++
 board/ronetix/pm9g45/pm9g45.c  |   20 ++
 board/siemens/corvus/board.c   |6 +-
 board/siemens/smartweb/smartweb.c  |3 +-
 board/siemens/taurus/taurus.c  |3 +-
 drivers/net/at91_emac.c|9 ++-
 drivers/usb/host/ehci-atmel.c  |8 ---
 drivers/usb/host/ohci-at91.c   |   20 ++
 56 files changed, 252 insertions(+), 496 deletions(-)
 create mode 100644 arch/arm/mach-at91/clock.c

-- 
1.7.9.5

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


[U-Boot] [RESEND PATCH v3 3/5] ARM: cpu: at91: clean up peripheral clock code

2016-02-01 Thread Wenyou Yang
Due to introducing the new peripheral clock handle functions,
use these functions to clean up the duplicated code.

Meanwhile, remove unneeded header file include, at91_pmc.h.

Signed-off-by: Wenyou Yang 
Tested-by: Heiko Schocher 
Reviewed-by: Andreas Bießmann 
---

Changes in v3: None
Changes in v2: None

 arch/arm/mach-at91/arm920t/at91rm9200_devices.c|   13 ++-
 arch/arm/mach-at91/arm920t/timer.c |4 +-
 arch/arm/mach-at91/arm926ejs/at91sam9260_devices.c |   36 +-
 arch/arm/mach-at91/arm926ejs/at91sam9261_devices.c |   28 --
 arch/arm/mach-at91/arm926ejs/at91sam9263_devices.c |   37 +-
 .../mach-at91/arm926ejs/at91sam9m10g45_devices.c   |   33 
 arch/arm/mach-at91/arm926ejs/at91sam9n12_devices.c |   40 +---
 arch/arm/mach-at91/arm926ejs/at91sam9rl_devices.c  |   28 --
 arch/arm/mach-at91/arm926ejs/at91sam9x5_devices.c  |   38 +--
 arch/arm/mach-at91/arm926ejs/cpu.c |1 -
 arch/arm/mach-at91/arm926ejs/timer.c   |5 +--
 arch/arm/mach-at91/armv7/cpu.c |1 -
 arch/arm/mach-at91/armv7/timer.c   |1 -
 arch/arm/mach-at91/phy.c   |1 -
 arch/arm/mach-at91/sdram.c |1 -
 15 files changed, 65 insertions(+), 202 deletions(-)

diff --git a/arch/arm/mach-at91/arm920t/at91rm9200_devices.c 
b/arch/arm/mach-at91/arm920t/at91rm9200_devices.c
index fc54327..a340122 100644
--- a/arch/arm/mach-at91/arm920t/at91rm9200_devices.c
+++ b/arch/arm/mach-at91/arm920t/at91rm9200_devices.c
@@ -14,7 +14,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 
 /*
@@ -34,29 +33,23 @@
 
 void at91_serial0_hw_init(void)
 {
-   at91_pmc_t  *pmc= (at91_pmc_t *)ATMEL_BASE_PMC;
-
at91_set_a_periph(AT91_PIO_PORTA, 17, 1);   /* TXD0 */
at91_set_a_periph(AT91_PIO_PORTA, 18, PUP); /* RXD0 */
-   writel(1 << ATMEL_ID_USART0, &pmc->pcer);
+   at91_periph_clk_enable(ATMEL_ID_USART0);
 }
 
 void at91_serial1_hw_init(void)
 {
-   at91_pmc_t  *pmc= (at91_pmc_t *)ATMEL_BASE_PMC;
-
at91_set_a_periph(AT91_PIO_PORTB, 20, PUP); /* RXD1 */
at91_set_a_periph(AT91_PIO_PORTB, 21, 1);   /* TXD1 */
-   writel(1 << ATMEL_ID_USART1, &pmc->pcer);
+   at91_periph_clk_enable(ATMEL_ID_USART1);
 }
 
 void at91_serial2_hw_init(void)
 {
-   at91_pmc_t  *pmc= (at91_pmc_t *)ATMEL_BASE_PMC;
-
at91_set_a_periph(AT91_PIO_PORTA, 22, PUP); /* RXD2 */
at91_set_a_periph(AT91_PIO_PORTA, 23, 1);   /* TXD2 */
-   writel(1 << ATMEL_ID_USART2, &pmc->pcer);
+   at91_periph_clk_enable(ATMEL_ID_USART2);
 }
 
 void at91_seriald_hw_init(void)
diff --git a/arch/arm/mach-at91/arm920t/timer.c 
b/arch/arm/mach-at91/arm920t/timer.c
index 6aa2994..3190961 100644
--- a/arch/arm/mach-at91/arm920t/timer.c
+++ b/arch/arm/mach-at91/arm920t/timer.c
@@ -19,7 +19,6 @@
 #include 
 #include 
 #include 
-#include 
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -31,8 +30,7 @@ int timer_init(void)
at91_tc_t *tc = (at91_tc_t *) ATMEL_BASE_TC;
at91_pmc_t *pmc = (at91_pmc_t *) ATMEL_BASE_PMC;
 
-   /* enables TC1.0 clock */
-   writel(1 << ATMEL_ID_TC0, &pmc->pcer);  /* enable clock */
+   at91_periph_clk_enable(ATMEL_ID_TC0);
 
writel(0, &tc->bcr);
writel(AT91_TC_BMR_TC0XC0S_NONE | AT91_TC_BMR_TC1XC1S_NONE |
diff --git a/arch/arm/mach-at91/arm926ejs/at91sam9260_devices.c 
b/arch/arm/mach-at91/arm926ejs/at91sam9260_devices.c
index 5e0c0f5..912a966 100644
--- a/arch/arm/mach-at91/arm926ejs/at91sam9260_devices.c
+++ b/arch/arm/mach-at91/arm926ejs/at91sam9260_devices.c
@@ -11,8 +11,8 @@
 #include 
 #include 
 #include 
-#include 
 #include 
+#include 
 #include 
 
 /*
@@ -32,51 +32,40 @@
 
 void at91_serial0_hw_init(void)
 {
-   at91_pmc_t  *pmc= (at91_pmc_t *) ATMEL_BASE_PMC;
-
at91_set_a_periph(AT91_PIO_PORTB, 4, 1);/* TXD0 */
at91_set_a_periph(AT91_PIO_PORTB, 5, PUP);  /* RXD0 */
-   writel(1 << ATMEL_ID_USART0, &pmc->pcer);
+   at91_periph_clk_enable(ATMEL_ID_USART0);
 }
 
 void at91_serial1_hw_init(void)
 {
-   at91_pmc_t  *pmc= (at91_pmc_t *) ATMEL_BASE_PMC;
-
at91_set_a_periph(AT91_PIO_PORTB, 6, 1);/* TXD1 */
at91_set_a_periph(AT91_PIO_PORTB, 7, PUP);  /* RXD1 */
-   writel(1 << ATMEL_ID_USART1, &pmc->pcer);
+   at91_periph_clk_enable(ATMEL_ID_USART1);
 }
 
 void at91_serial2_hw_init(void)
 {
-   at91_pmc_t  *pmc= (at91_pmc_t *) ATMEL_BASE_PMC;
-
at91_set_a_periph(AT91_PIO_PORTB, 8, 1);/* TXD2 */
at91_set_a_periph(AT91_PIO_PORTB, 9, PUP);  /* RXD2 */
-   writel(1 << ATMEL_ID_USART2, &pmc->pcer);
+   at91_periph_clk_enable(ATMEL_ID_USART2);
 }
 
 vo

Re: [U-Boot] [PATCH 00/23] x86: Convert to use DM PCI APIs completely

2016-02-01 Thread Bin Meng
Hi Simon,

On Tue, Feb 2, 2016 at 12:19 AM, Simon Glass  wrote:
> Hi Bin,
>
> On 1 February 2016 at 02:40, Bin Meng  wrote:
>> There are still some codes that use the legacy PCI APIs to access
>> the configuration space registers. This series converts those codes
>> to completely use DM PCI APIs.
>>
>> This includes adding several new ops to the PCH uclass driver, and
>> some clean up to the SPI/GPIO/IRQ drivers.
>>
>> Tested on QEMU and Crown Bay. This series is available in pci-working
>> branch of u-boot-x86 repo.
>
> Looks great! This is a big step forward.
>
> I've tested it on minnowmax and will test on link in the next day or so.
>
> Here are a few things that I think can still be cleaned up:
> - void pci_assign_irqs(int bus, int device, u8 irq[4]) should use a
> struct udevice

I guess no, unless we expand struct udevice to include interrupt
routing information? But that's not generic across architectures. I am
not sure how.

> - pci_x86_read/write_config() move into drivers/pci/pci_x86.c (needs
> ivybridge fix which I'll look at)

Yep. I wanted to do this when reviewing one of previous patches.

> - disable DM_PCI_COMPAT for x86

Looks e1000 and pch_gbe (Crown Bay) ethernet drivers are still using
legacy PCI APIs. e1000 might need quite amount of work as it is being
widely used on lots of boards. I can update pch_gbe driver later.

> - use the PCI mmio access method instead of I/O once it becomes possible

Yep.

> - moving vesa video to driver model (UCLASS_VIDEO)

I was not following the dm video changes recently, but I guess yes.

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


Re: [U-Boot] [PATCH v3 0/7] fdt: Replace u-boot-dtb.bin with u-boot.bin

2016-02-01 Thread Tom Rini
On Mon, Feb 01, 2016 at 04:00:30PM -0700, Stephen Warren wrote:
> On 01/31/2016 06:10 PM, Simon Glass wrote:
> >At present u-boot.bin holds the plain U-Boot binary without the device tree.
> >This is somewhat annoying since you need either u-boot.bin or u-boot-dtb.bin
> >depending on whether device tree is used.
> >
> >This series adjusts the build such that u-boot.bin includes a device tree if
> >enabled, and the plain binary is in u-boot-nodtb.bin. For now u-boot-dtb.bin
> >remains the same.
> >
> >This should be acceptable since:
> >
> >- without OF_CONTROL, u-boot.bin still does not include a device tree
> >- with OF_CONTROL, u-boot-dtb.bin does not change
> >
> >The main impact is to build systems which are set up to use u-boot.bin as
> >the output file and then add a device tree. These will have to change to use
> >u-boot-nodtb.bin instead.
> >
> >The original decision to use a separate u-boot-dtb.bin was aimed at allowing
> >any device tree file to be concatenated to the u-boot.bin image after the
> >build. However this no-longer seems so important. More important is the
> >convenience of using the same output file regardless of the setting for
> >OF_CONTROL.
> 
> The series,
> Tested-by: Stephen Warren  
> (Both out T124-and-before and T210-and-later flashing processes
> still seem to work OK with the new file naming etc.)
> 
> Patches 1-3,
> Reviewed-by: Stephen Warren 

I've pushed this since I want -rc1 to have it (so everyone sees it and
adjusts now on a clean tag) and the feedback seems like minor updates
that we can do after the fact.  Thanks!

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v3 6/7] Makefile: Make u-boot.img the same as u-boot-dtb.img

2016-02-01 Thread Tom Rini
On Mon, Feb 01, 2016 at 03:54:52PM -0700, Stephen Warren wrote:

> On 01/31/2016 06:10 PM, Simon Glass wrote:
> >Create u-boot.img even when OF_CONTROL is enabled, so that this file can be
> >used in both cases.
> 
> Here also I wonder if it would be better to copy either
> u-boot-dtb.img or u-boot-nodtb.img to u-boot.img, to avoid running
> mkimage again?

Sounds like a good clean-up.

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PULL] u-boot-mips/master

2016-02-01 Thread Tom Rini
On Mon, Feb 01, 2016 at 10:53:29PM +0100, Daniel Schwierzeck wrote:

> Hi Tom,
> 
> please pull some small MIPS updates and the initial Microchip PIC32
> support. Thanks!
> 
> 
> The following changes since commit 8cdae1dacde7dbe74d53a8ac1a05761a53c4f191:
> 
>   video: Correct 'tor' typo in comment (2016-01-30 10:58:47 +0100)
> 
> are available in the git repository at:
> 
>   git://git.denx.de/u-boot-mips.git master
> 
> for you to fetch changes up to 7d514a7407756d96996960c2ae539a4b464c65bc:
> 
>   board: Enable ethernet, tftpboot support to pic32mzdask board.
> (2016-02-01 22:14:02 +0100)
> 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [U-Boot, v3, 6/7] Makefile: Make u-boot.img the same as u-boot-dtb.img

2016-02-01 Thread Tom Rini
On Sun, Jan 31, 2016 at 06:10:54PM -0700, Simon Glass wrote:

> Create u-boot.img even when OF_CONTROL is enabled, so that this file can be
> used in both cases.
> 
> Signed-off-by: Simon Glass 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [U-Boot, v3, 7/7] Makefile: Drop unnecessary -dtb suffixes

2016-02-01 Thread Tom Rini
On Sun, Jan 31, 2016 at 06:10:55PM -0700, Simon Glass wrote:

> When OF_CONTROL is enabled, u-boot-dtb.* files are the same as u-boot.*
> files. So we can use the latter for simplicity.
> 
> Signed-off-by: Simon Glass 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [U-Boot, v3, 1/7] tegra: Clarify generation of -nodtb file with OF_CONTROL

2016-02-01 Thread Tom Rini
On Sun, Jan 31, 2016 at 06:10:49PM -0700, Simon Glass wrote:

> Fix the ALL-y logic in the Makefile so that is clear that we always want
> the -nodtb file.
> 
> Signed-off-by: Simon Glass 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [U-Boot, v3, 4/7] tegra: Always build a boot image with the same filename

2016-02-01 Thread Tom Rini
On Sun, Jan 31, 2016 at 06:10:52PM -0700, Simon Glass wrote:

> Adjust the Makefile to build u-boot-tegra.bin which contains a device tree
> if OF_SEPARATE is enabled, and does not if not. This mirrors U-Boot's new
> approach of using u-boot.bin to handle both cases.
> 
> Signed-off-by: Simon Glass 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [U-Boot,v3,5/7] socfpga: Simplify Makefile filenames

2016-02-01 Thread Tom Rini
On Sun, Jan 31, 2016 at 06:10:53PM -0700, Simon Glass wrote:

> We don't need the -dtb suffix anymore, so drop it.
> 
> Signed-off-by: Simon Glass 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [U-Boot, v3, 3/7] fdt: Build an SPL binary without device tree

2016-02-01 Thread Tom Rini
On Sun, Jan 31, 2016 at 06:10:51PM -0700, Simon Glass wrote:

> At present u-boot-spl.bin holds the plain SPL binary without the device
> tree. This is somewhat annoying since you need either u-boot-spl.bin or
> u-boot-spl-dtb.bin depending on whether device tree is used.
> 
> Adjust the build such that u-boot-spl.bin includes a device tree
> (if enabled), and the plain binary is in u-boot-spl-nodtb.bin. For now
> u-boot-spl-dtb.bin remains the same.
> 
> Signed-off-by: Simon Glass 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [U-Boot, v3, 2/7] fdt: Build a U-Boot binary without device tree

2016-02-01 Thread Tom Rini
On Sun, Jan 31, 2016 at 06:10:50PM -0700, Simon Glass wrote:

> At present u-boot.bin holds the plain U-Boot binary without the device tree.
> This is somewhat annoying since you need either u-boot.bin or u-boot-dtb.bin
> depending on whether device tree is used.
> 
> Adjust the build such that u-boot.bin includes a device tree (if enabled),
> and the plain binary is in u-boot-nodtb.bin. For now u-boot-dtb.bin remains
> the same.
> 
> This should be acceptable since:
> 
> - without OF_CONTROL, u-boot.bin still does not include a device tree
> - with OF_CONTROL, u-boot-dtb.bin does not change
> 
> The main impact is build systems which are set up to use u-boot.bin as
> the output file and then add a device tree. These will have to change to use
> u-boot-nodtb.bin instead.
> 
> Adjust tegra rules so it continues to produce the correct files.
> 
> Signed-off-by: Simon Glass 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [U-Boot, v3, 1/7] tegra: Clarify generation of -nodtb file with OF_CONTROL

2016-02-01 Thread Tom Rini
On Sun, Jan 31, 2016 at 06:10:49PM -0700, Simon Glass wrote:

> Fix the ALL-y logic in the Makefile so that is clear that we always want
> the -nodtb file.
> 
> Signed-off-by: Simon Glass 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] .travis.yml: rework according to new travis-ci infra

2016-02-01 Thread Tom Rini
On Mon, Jan 25, 2016 at 08:22:41PM +0100, Roger Meier wrote:

> - install using addons.apt
> - remove MAKEALL
> - split mpc85xx boards
> - remove TEST_CONFIG_CMD, just info
> - fetch mips toolchain via buildman
> - remove --list-error-boards param
> - conditional script
> - use TOOLCHAIN instead of INSTALL_TOOLCHAIN
> - add aarch64
> - enable notifications via email
> 
> Signed-off-by: Roger Meier 
> Cc: Wolfgang Denk 
> Cc: Heiko Schocher 
> Cc: Tom Rini 
> Cc: Daniel Schwierzeck 
> Cc: Andreas Färber 
> Tested-by: Daniel Schwierzeck 
> Acked-by: Heiko Schocher 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] mmc: add missing prototype for mmc_get_env_dev

2016-02-01 Thread Tom Rini
On Tue, Jan 26, 2016 at 04:20:38PM +0100, Clemens Gruber wrote:

> This is a follow-up patch to e92029c0f4 and adds a prototype for
> the weak mmc_get_env_dev function.
> 
> Cc: Tom Rini 
> Cc: Stephen Warren 
> 
> Signed-off-by: Clemens Gruber 
> Reviewed-by: Tom Rini 
> Reviewed-by: Peng Fan 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] mailmap: fix Ricardo's entry

2016-02-01 Thread Tom Rini
On Fri, Jan 29, 2016 at 11:42:53AM +0900, Masahiro Yamada wrote:

> Commit df48b23428e9 (".mailmap: Add all the mail alias for Ricardo
> Ribalda") assigned two different proper names for the email address
> "ricardo.riba...@uam.es".  This is a completely wrong usage as the
> mailmap feature exists for coalescing together commits by the same
> person whose name is sometimes spelled differently.
> 
> Signed-off-by: Masahiro Yamada 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] malloc: work around some memalign fragmentation issues

2016-02-01 Thread Tom Rini
On Mon, Jan 25, 2016 at 02:03:42PM -0700, Stephen Warren wrote:

> From: Stephen Warren 
> 
> Use of memalign can trigger fragmentation issues such as:
> 
> // Internally, this needs to find a free block quite bit larger than s.
> // Once the free region is found, any unaligned "padding" immediately
> // before and after the block is marked free, so that the allocation
> // takes only s bytes (plus malloc header overhead).
> p = memalign(a, s);
> // If there's little fragmentation so far, this allocation is likely
> // located immediately after p.
> p2 = malloc(x);
> free(p);
> // In theory, this should return the same value for p. However, the hole
> // left by the free() call is only s in size (plus malloc header overhead)
> // whereas memalign searches for a larger block in order to guarantee it
> // can adjust the returned pointer to the alignment requirements. Hence,
> // the pointer returned, if any, won't be p. If there's little or no space
> // left after p2, this allocation will fail.
> p = memalign(a, s);
> 
> In practice, this issue occurs when running the "dfu" command repeatedly
> on NVIDIA Tegra boards, since DFU allocates a large 32M data buffer, and
> then initializes the USB controller. If this is the first time USB has
> been used in the U-Boot session, this causes a probe of the USB driver,
> which causes various allocations, including a strdup() of a GPIO name
> when requesting the VBUS GPIO. When DFU is torn down, the USB driver
> is left probed, and hence its memory is left allocated. If "dfu" is
> executed again, allocation of the 32M data buffer fails as described
> above.
> 
> In practice, there is a memory hole exactly large enough to hold the 32M
> data buffer than DFU needs. However, memalign() can't know that in a
> general way. Given that, it's particularly annoying that the allocation
> fails!
> 
> The issue is that memalign() tries to allocate something larger to
> guarantee the ability to align the returned pointer. This patch modifies
> memalign() so that if the "general case" over-sized allocation fails,
> another allocation is attempted, of the exact size the user desired. If
> that allocation just happens to be aligned in the way the user wants,
> (and in the case described above, it will be, since the free memory
> region is located where a previous identical allocation was located),
> the pointer can be returned.
> 
> This patch is somewhat related to 806bd245b1ab "dfu: don't keep
> freeing/reallocating". That patch worked around the issue by removing
> repeated free/memalign within a single execution of "dfu". However,
> the same technique can't be applied across multiple invocations, since
> there's no reason to keep the DFU buffer allocated while DFU isn't
> running. This patch addresses the root-cause a bit more directly.
> 
> This problem highlights some of the disadvantages of dynamic allocation
> and deferred probing of devices.
> 
> This patch isn't checkpatch-clean, since it conforms to the existing
> coding style in dlmalloc.c, which is different to the rest of U-Boot.
> 
> Signed-off-by: Stephen Warren 
> Reviewed-by: Tom Rini 
> Acked-by: Lukasz Majewski 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 04/14] efi_loader: Add boot time services

2016-02-01 Thread Alexander Graf



On 01/20/2016 01:16 AM, Leif Lindholm wrote:

On Fri, Jan 15, 2016 at 06:06:10AM +0100, Alexander Graf wrote:

When an EFI application runs, it has access to a few descriptor and callback
tables to instruct the EFI compliant firmware to do things for it. The bulk
of those interfaces are "boot time services". They handle all object management,
and memory allocation.

This patch adds support for the boot time services and also exposes a system
table, which is the point of entry descriptor table for EFI payloads.

Signed-off-by: Alexander Graf 

---

v1 -> v2:

   - Fix typo s/does now/does not/
   - Add #ifdefs around header to allow inclusion when efi_loader is disabled
   - Add stub efi_restore_gd() function when efi_loader is disabled
   - Disable debug
   - Mark runtime region as such
   - Fix up memory map
   - Allow efi_restore_gd to be called before first efi entry
   - Add 32bit arm cache workaround
   - Move memory map to separate patch
   - Change BTS version to 2.5
   - Fix return values for a few callbacks to more EFI compliant ones
   - Change vendor to "Das U-Boot"
   - Add warning when truncating timer trigger
   - Move to GPLv2+
---
  include/efi_loader.h  |  51 +++
  lib/efi_loader/efi_boottime.c | 761 ++
  2 files changed, 812 insertions(+)
  create mode 100644 lib/efi_loader/efi_boottime.c

diff --git a/include/efi_loader.h b/include/efi_loader.h
index bf77573..391459e 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -6,18 +6,69 @@
   *  SPDX-License-Identifier: GPL-2.0+
   */
  
+#include 

  #include 
  #include 
+
+#ifdef CONFIG_EFI_LOADER
+
  #include 
  
+/* #define DEBUG_EFI */

+
+#ifdef DEBUG_EFI
+#define EFI_ENTRY(format, ...) do { \
+   efi_restore_gd(); \
+   printf("EFI: Entry %s(" format ")\n", __func__, ##__VA_ARGS__); \
+   } while(0)
+#else
+#define EFI_ENTRY(format, ...) do { \
+   efi_restore_gd(); \
+   } while(0)
+#endif
+
+#define EFI_EXIT(ret) efi_exit_func(ret);
+
+extern struct efi_system_table systab;
+
  extern const efi_guid_t efi_guid_device_path;
  extern const efi_guid_t efi_guid_loaded_image;
  
+struct efi_class_map {

+   const efi_guid_t *guid;
+   const void *interface;
+};
+
+struct efi_handler {
+   const efi_guid_t *guid;
+   efi_status_t (EFIAPI *open)(void *handle,
+   efi_guid_t *protocol, void **protocol_interface,
+   void *agent_handle, void *controller_handle,
+   uint32_t attributes);
+};
+
+struct efi_object {
+   struct list_head link;
+   struct efi_handler protocols[4];
+   void *handle;
+};
+extern struct list_head efi_obj_list;
+
  efi_status_t efi_return_handle(void *handle,
efi_guid_t *protocol, void **protocol_interface,
void *agent_handle, void *controller_handle,
uint32_t attributes);
+void efi_timer_check(void);
  void *efi_load_pe(void *efi, struct efi_loaded_image *loaded_image_info);
+void efi_save_gd(void);
+void efi_restore_gd(void);
+efi_status_t efi_exit_func(efi_status_t ret);
  
  #define EFI_LOADER_POOL_SIZE (128 * 1024 * 1024)

  void *efi_loader_alloc(uint64_t len);
+
+#else /* defined(EFI_LOADER) */
+
+static inline void efi_restore_gd(void) { }
+
+#endif
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
new file mode 100644
index 000..5756c9c
--- /dev/null
+++ b/lib/efi_loader/efi_boottime.c
@@ -0,0 +1,761 @@
+/*
+ *  EFI application boot time services
+ *
+ *  Copyright (c) 2016 Alexander Graf
+ *
+ *  SPDX-License-Identifier: GPL-2.0+
+ */
+
+/* #define DEBUG_EFI */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
+
+/*
+ * If we're running on nasty systems (32bit ARM booting into non-EFI Linux)
+ * we need to do trickery with caches. Since we don't want to break the EFI
+ * aware boot path, only apply hacks when loading exiting directly (breaking
+ * direct Linux EFI booting along the way - oh well).
+ */
+static bool efi_is_direct_boot = true;
+
+/*
+ * EFI can pass arbitrary additional "tables" containing vendor specific
+ * information to the payload. One such table is the FDT table which contains
+ * a pointer to a flattened device tree blob.
+ *
+ * In most cases we want to pass an FDT to the payload, so reserve one slot of
+ * config table space for it. The pointer gets populated by do_bootefi_exec().
+ */
+static struct efi_configuration_table efi_conf_table[] = {
+   {
+   .guid = EFI_FDT_GUID,
+   },
+};
+
+/*
+ * The "gd" pointer lives in a register on ARM and AArch64 that we declare
+ * fixed when compiling U-Boot. However, the payload does not know about that
+ * restriction so we need to manually swap its and our view of that register on
+ * EFI callback entry/exit.
+ */
+static volatile void *efi_gd, *app_gd;
+
+/* Called from do_bootefi_exec() */
+v

Re: [U-Boot] [PATCH 14/14] efi_loader: Add distro boot script for removable media

2016-02-01 Thread Alexander Graf



On 01/31/2016 04:24 PM, Simon Glass wrote:

Hi Alexander,

On 14 January 2016 at 22:06, Alexander Graf  wrote:

UEFI defines a simple boot protocol for removable media. There we should look
at the EFI (first GPT FAT) partition and search for /efi/boot/bootXXX.efi with
XXX being different between different platforms (x86, x64, arm, aa64, ...).

This patch implements a simple version of that protocol for the default distro
boot script. With this we can automatically boot from valid UEFI enabled
removable media.

Because from all I could see U-Boot by default doesn't deliver device tree
blobs with its firmware, we also need to load the dtb from somewhere. Traverse
the same EFI partition for an fdt file that fits our current board so that
an OS receives a valid device tree when booted automatically.

Signed-off-by: Alexander Graf 
---
  include/config_distro_bootcmd.h | 47 -
  1 file changed, 46 insertions(+), 1 deletion(-)

Reviewed-by: Simon Glass 

Will this work OK with FITs?


Uh, why would it not work ok with FITs?


Also, can you add an entry to MAINTAINERS?


Sure :)

Btw, in your move of all cmd files into their own directory you forgot 
to update the MAINTAINERS file ;)



Alex

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


Re: [U-Boot] [PATCH 09/14] efi_loader: Implement memory allocation and map

2016-02-01 Thread Alexander Graf



On 01/31/2016 04:23 PM, Simon Glass wrote:

Hi Alexander,

On 14 January 2016 at 22:06, Alexander Graf  wrote:

Due to popular request, this is a separate patch implementing all of the memory
allocation and memory mapping bits.

We assume we always have a linear RAM map. At TOM U-Boot resides. Inside of
U-Boot there is the runtime region that we need to explicitly expose via the
EFI memory map. Below U-Boot, we reserve 128MB of RAM for LOADER_DATA.

Signed-off-by: Alexander Graf 
---
  lib/efi_loader/efi_boottime.c | 99 ++-
  lib/efi_loader/efi_image_loader.c | 28 ++-
  2 files changed, 123 insertions(+), 4 deletions(-)

diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index 45217ef..ff3f969 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -98,6 +98,8 @@ static void efi_restore_tpl(unsigned long old_tpl)
  static void *efi_alloc(uint64_t len, int memory_type)
  {
 switch (memory_type) {
+   case EFI_LOADER_DATA:
+   return efi_loader_alloc(len);
 default:
 return malloc(len);
 }
@@ -143,16 +145,109 @@ static efi_status_t efi_free_pages(uint64_t memory, 
unsigned long pages)
 return EFI_EXIT(EFI_SUCCESS);
  }

-/* Will be implemented in a later patch */
+/*
+ * Returns the EFI memory map. In our case, this looks pretty simple:
+ *
+ *  TOM
+ * ||
+ * |Second half of U-Boot   |

What does 'second half' mean?


It means that there's one big chunk of "U-Boot" with the RTS sitting in 
the middle, dividing it into 2 halves :).


I hope my new memory allocation code makes this more obvious.




+ * ||   &__efi_runtime_stop
+ * ||
+ * |EFI Runtime Services|
+ * ||   &__efi_runtime_start
+ * ||
+ * |First half of U-Boot|
+ * ||   start of EFI loader allocation space
+ * ||
+ * |  Free RAM  |
+ * ||   CONFIG_SYS_SDRAM_BASE
+ *
+ * All pointers are extended to live on a 4k boundary. After exiting the boot
+ * services, only the EFI Runtime Services chunk of memory stays alive.
+ */
  static efi_status_t efi_get_memory_map(unsigned long *memory_map_size,
struct efi_mem_desc *memory_map,
unsigned long *map_key,
unsigned long *descriptor_size,
uint32_t *descriptor_version)
  {
+   struct efi_mem_desc efi_memory_map[] = {
+   {
+   /* RAM before U-Boot */
+   .type = EFI_CONVENTIONAL_MEMORY,
+   .attribute = 1 << EFI_MEMORY_WB_SHIFT,
+   },
+   {
+   /* First half of U-Boot */
+   .type = EFI_LOADER_DATA,
+   .attribute = 1 << EFI_MEMORY_WB_SHIFT,
+   },
+   {
+   /* EFI Runtime Services */
+   .type = EFI_RUNTIME_SERVICES_CODE,
+   .attribute = (1 << EFI_MEMORY_WB_SHIFT) |
+(1ULL << EFI_MEMORY_RUNTIME_SHIFT),
+   },
+   {
+   /* Second half of U-Boot */
+   .type = EFI_LOADER_DATA,
+   .attribute = 1 << EFI_MEMORY_WB_SHIFT,
+   },
+   };
+   ulong runtime_start, runtime_end, runtime_len_pages, runtime_len;
+
 EFI_ENTRY("%p, %p, %p, %p, %p", memory_map_size, memory_map, map_key,
   descriptor_size, descriptor_version);
-   return EFI_EXIT(EFI_UNSUPPORTED);
+
+   runtime_start = (ulong)&__efi_runtime_start & ~0xfffULL;
+   runtime_end = ((ulong)&__efi_runtime_stop + 0xfff) & ~0xfffULL;
+   runtime_len_pages = (runtime_end - runtime_start) >> 12;
+   runtime_len = runtime_len_pages << 12;
+
+   /* Fill in where normal RAM is (up to U-Boot's top of stack) */
+   efi_memory_map[0].num_pages = gd->start_addr_sp >> 12;
+#ifdef CONFIG_SYS_SDRAM_BASE

If not defined, what happens?


The new code uses gd->bd->bi_dram.




+   efi_memory_map[0].physical_start = CONFIG_SYS_SDRAM_BASE;
+   efi_memory_map[0].virtual_start = CONFIG_SYS_SDRAM_BASE;
+   efi_memory_map[0].num_pages -= CONFIG_SYS_SDRAM_BASE >> 12;
+#endif
+
+   /* Give us some space for the stack */
+   efi_memory_map[0].num_pages -= (16 * 1024 * 1024) >> 12;
+
+   /* Reserve the EFI loader pool */
+   efi_memory_map[0].num_pages -= EFI_LOADER_POOL_SIZE >> 12;
+
+   /* Cut out the runtime services */
+   efi_memory_map[2].physical_start = runtime_start;
+   efi_memory_map[2].virtual_start = efi_memory_map[2].physical_start

Re: [U-Boot] [PATCH v2 00/23] dm: tegra: Convert tegra20 and tegra124 video drivers to driver model

2016-02-01 Thread Stephen Warren

On 02/01/2016 05:28 PM, Simon Glass wrote:

Hi Stephen,

On 1 February 2016 at 17:17, Stephen Warren  wrote:

On 02/01/2016 05:05 PM, Simon Glass wrote:


Hi Stephen,

On 1 February 2016 at 17:00, Stephen Warren  wrote:


On 01/30/2016 04:37 PM, Simon Glass wrote:



This series moves these two drivers over to use driver model for video.

This involves the following steps:
- Sync up some device tree files with Linux
- Implement a proper PWM driver
- Clean up and unify the driver code
- Modify the existing drivers to work with driver model

The tegra20 display driver uses device tree bindings invented in 2011
before
Linux had this or anyone was able to agree a standard. It seems possible
to
move it to the new bindings (like tegra124) except for the issue of time
delays between stages. It isn't clear how this should work, and Linux
implements this by including all LCD definitions in the kernel source
code,
and not using any delays. This causes strange display artifacts on the
display when starting up, but perhaps is harmless to the display. Future
work will sync up the device tree more for seaboard, and thus tidy this
up
for nvidia boards.

A bug in the keyboard driver is also fixed by this series. The series is
tested on seaboard and nyan-big, the two boards I have which support a
display.

This series is available at u-boot-dm/tegra-working.




This changes the name of the output device from "lcd" to "vidconsole".
Anyone who doesn't reset their environment to default when switching to
this
new U-Boot will lose their display output because of this. Is there any
way
to maintain compatibility?



I could not think of one other than an egregious hack. It will
certainly bite someone. Perhaps a hack that detects 'lcd' in the
stdout env variable and prints a warning would be useful?



Can't the two drivers just respond to the same device name. Presumably a
build would only have one or the other compiled in?


I don't want to use 'lcd' for 'vidconsole' since 'vidconsole' is
supposed to work for both LCD and video devices. The idea is to merge
them. The only way I could think of to make it work was hack in
stdio.c to automatically change 'lcd' to vidconsole. I was not brave
enough to attempt that, but it might work. What do you think?


That sounds like it should work. Isn't that simply:

#if SOMETHING
if (!strcmp(foo, "lcd"))
foo = "vidconsole";
#endif


Or perhaps we can add a hook in the board-specific initialization code which
re-writes the environment after loading it?

Printing a message would be useful if the user has a serial console plugged
in, which will not always be the case. It is not possible on Paz00 (likely
the most widely used T20 device) for example without taking the case apart
and soldering to a very tiny connector; I expect almost nobody has done
that.


Is that the shield thing? I'd really like to attempt that solder if
there are instructions somewhere.


It's the Toshiba AC100 laptop. There's some information at 
https://ac100.grandou.net/doku.php (and numerous other places if you 
search Google for the model number.)

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


Re: [U-Boot] [PATCH 07/14] efi_loader: Add disk interfaces

2016-02-01 Thread Alexander Graf



On 01/31/2016 04:23 PM, Simon Glass wrote:

On 14 January 2016 at 22:06, Alexander Graf  wrote:

A EFI applications usually want to access storage devices to load data from.

This patch adds support for EFI disk interfaces. It loops through all block
storage interfaces known to U-Boot and creates an EFI object for each existing
one. EFI applications can then through these objects call U-Boot's read and
write functions.

Signed-off-by: Alexander Graf 
Reviewed-by: Simon Glass 

---

v1 -> v2:

   - Move to block_drvr array
   - Move to GPLv2+
   - Fix header order
   - Document efi block object struct
   - Use calloc rather than malloc & memset
---
  include/efi_loader.h  |   1 +
  lib/efi_loader/efi_disk.c | 218 ++
  2 files changed, 219 insertions(+)
  create mode 100644 lib/efi_loader/efi_disk.c

diff --git a/include/efi_loader.h b/include/efi_loader.h
index 0f821ff..9d6c322 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -63,6 +63,7 @@ struct efi_object {
  };
  extern struct list_head efi_obj_list;

+int efi_disk_register(void);
  efi_status_t efi_return_handle(void *handle,
 efi_guid_t *protocol, void **protocol_interface,
 void *agent_handle, void *controller_handle,
diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c
new file mode 100644
index 000..c589604
--- /dev/null
+++ b/lib/efi_loader/efi_disk.c
@@ -0,0 +1,218 @@
+/*
+ *  EFI application disk support
+ *
+ *  Copyright (c) 2016 Alexander Graf
+ *
+ *  SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static const efi_guid_t efi_block_io_guid = BLOCK_IO_GUID;
+
+struct efi_disk_obj {
+   /* Generic EFI object parent class data */
+   struct efi_object parent;
+   /* EFI Interface callback struct for block I/O */
+   struct efi_block_io ops;
+   /* U-Boot ifname for block device */
+   const char *ifname;
+   /* U-Boot dev_index for block device */
+   int dev_index;
+   /* EFI Interface Media descriptor struct, referenced by ops */
+   struct efi_block_io_media media;
+   /* EFI device path to this block device */
+   struct efi_device_path_file_path *dp;
+};
+
+static void ascii2unicode(u16 *unicode, char *ascii)
+{
+   while (*ascii)
+   *(unicode++) = *(ascii++);
+}
+
+static efi_status_t efi_disk_open_block(void *handle, efi_guid_t *protocol,
+   void **protocol_interface, void *agent_handle,
+   void *controller_handle, uint32_t attributes)
+{
+   struct efi_disk_obj *diskobj = handle;
+
+   *protocol_interface = &diskobj->ops;
+
+   return EFI_SUCCESS;
+}
+
+static efi_status_t efi_disk_open_dp(void *handle, efi_guid_t *protocol,
+   void **protocol_interface, void *agent_handle,
+   void *controller_handle, uint32_t attributes)
+{
+   struct efi_disk_obj *diskobj = handle;
+
+   *protocol_interface = diskobj->dp;
+
+   return EFI_SUCCESS;
+}
+
+static efi_status_t efi_disk_reset(struct efi_block_io *this,
+   char extended_verification)
+{
+   EFI_ENTRY("%p, %x", this, extended_verification);
+   return EFI_EXIT(EFI_DEVICE_ERROR);
+}
+
+enum efi_disk_direction {
+   EFI_DISK_READ,
+   EFI_DISK_WRITE,
+};
+
+static efi_status_t efi_disk_rw_blocks(struct efi_block_io *this,
+   u32 media_id, u64 lba, unsigned long buffer_size,
+   void *buffer, enum efi_disk_direction direction)
+{
+   struct efi_disk_obj *diskobj;
+   struct block_dev_desc *desc;
+   int blksz;
+   int blocks;
+   unsigned long n;
+
+   EFI_ENTRY("%p, %x, %"PRIx64", %lx, %p", this, media_id, lba,
+ buffer_size, buffer);
+
+   diskobj = container_of(this, struct efi_disk_obj, ops);
+   if (!(desc = get_dev(diskobj->ifname, diskobj->dev_index)))
+   return EFI_EXIT(EFI_DEVICE_ERROR);
+   blksz = desc->blksz;
+   blocks = buffer_size / blksz;
+
+#ifdef DEBUG_EFI
+   printf("EFI: %s:%d blocks=%x lba=%"PRIx64" blksz=%x dir=%d\n", __func__,
+  __LINE__, blocks, lba, blksz, direction);
+#endif
+
+   /* We only support full block access */
+   if (buffer_size & (blksz - 1))
+   return EFI_EXIT(EFI_DEVICE_ERROR);
+
+   if (direction == EFI_DISK_READ)
+   n = desc->block_read(desc->dev, lba, blocks, buffer);

Shouldn't this be s/desc->dev/desc/?


+   else
+   n = desc->block_write(desc->dev, lba, blocks, buffer);

Same here.


+
+   /* We don't do interrupts, so check for timers cooperatively */
+   efi_timer_check();
+
+#ifdef DEBUG_EFI
+   printf("EFI: %s:%d n=%lx blocks=%x\n", __func__, __LINE__, n, blocks);
+#endif
+   if (n != blocks)
+   return EFI_EXIT(EFI_DEVICE_ERROR);
+
+   return EFI_EXIT(EFI_SUCCE

Re: [U-Boot] [PATCH 00/14] EFI payload / application support v2

2016-02-01 Thread Simon Glass
Hi Alex,

On 1 February 2016 at 17:16, Alexander Graf  wrote:
>
>
>
> On 02/02/2016 01:02 AM, Simon Glass wrote:
>>
>> Hi Alex,
>>
>> On 1 February 2016 at 14:38, Alexander Graf  wrote:
>>
>> For now I've had a play with Minnowboard, which is x86. The main thing
>> I noticed is that the API function implements should have EFIAPI on
>> them also.
>
>
> Yes :). I didn't expect anyone to actually care about running this on x86
> which is the only architecture that has different calling conventions for
> EFI. I'm very pleasantly surprised that you are interested and since you
> already have a patch to add them, I guess you can as well just post that
> once the base support is in :).

 OK. I suppose because EFIAPI is empty on ARM it doesn't matter. But
 strictly speaking the declaration should match the implementation.
>>>
>>>
>>> Yeah, I just didn't want to implement something I wouldn't test :).
>>
>> OK. You could add a regparm(0) or something like that to be sure it is
>> working. Or just bring in that part of my patch. But I'm OK if you'd
>> rather I send a follow-up.
>
>
>
> My AArch64 compiler isn't really happy about that:
>
> include/efi_loader.h:67:4: warning: 'regparm' attribute directive ignored 
> [-Wattributes]
>
> But I've fixed up everything I could find manually and just leave the 
> remaining 1 or 2 occurrences to you :)

Sounds good, thanks.

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


Re: [U-Boot] [PATCH v2 00/23] dm: tegra: Convert tegra20 and tegra124 video drivers to driver model

2016-02-01 Thread Simon Glass
Hi Stephen,

On 1 February 2016 at 17:17, Stephen Warren  wrote:
> On 02/01/2016 05:05 PM, Simon Glass wrote:
>>
>> Hi Stephen,
>>
>> On 1 February 2016 at 17:00, Stephen Warren  wrote:
>>>
>>> On 01/30/2016 04:37 PM, Simon Glass wrote:


 This series moves these two drivers over to use driver model for video.

 This involves the following steps:
 - Sync up some device tree files with Linux
 - Implement a proper PWM driver
 - Clean up and unify the driver code
 - Modify the existing drivers to work with driver model

 The tegra20 display driver uses device tree bindings invented in 2011
 before
 Linux had this or anyone was able to agree a standard. It seems possible
 to
 move it to the new bindings (like tegra124) except for the issue of time
 delays between stages. It isn't clear how this should work, and Linux
 implements this by including all LCD definitions in the kernel source
 code,
 and not using any delays. This causes strange display artifacts on the
 display when starting up, but perhaps is harmless to the display. Future
 work will sync up the device tree more for seaboard, and thus tidy this
 up
 for nvidia boards.

 A bug in the keyboard driver is also fixed by this series. The series is
 tested on seaboard and nyan-big, the two boards I have which support a
 display.

 This series is available at u-boot-dm/tegra-working.
>>>
>>>
>>>
>>> This changes the name of the output device from "lcd" to "vidconsole".
>>> Anyone who doesn't reset their environment to default when switching to
>>> this
>>> new U-Boot will lose their display output because of this. Is there any
>>> way
>>> to maintain compatibility?
>>
>>
>> I could not think of one other than an egregious hack. It will
>> certainly bite someone. Perhaps a hack that detects 'lcd' in the
>> stdout env variable and prints a warning would be useful?
>
>
> Can't the two drivers just respond to the same device name. Presumably a
> build would only have one or the other compiled in?

I don't want to use 'lcd' for 'vidconsole' since 'vidconsole' is
supposed to work for both LCD and video devices. The idea is to merge
them. The only way I could think of to make it work was hack in
stdio.c to automatically change 'lcd' to vidconsole. I was not brave
enough to attempt that, but it might work. What do you think?

>
> Or perhaps we can add a hook in the board-specific initialization code which
> re-writes the environment after loading it?
>
> Printing a message would be useful if the user has a serial console plugged
> in, which will not always be the case. It is not possible on Paz00 (likely
> the most widely used T20 device) for example without taking the case apart
> and soldering to a very tiny connector; I expect almost nobody has done
> that.

Is that the shield thing? I'd really like to attempt that solder if
there are instructions somewhere.

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


Re: [U-Boot] [PATCH v2 00/23] dm: tegra: Convert tegra20 and tegra124 video drivers to driver model

2016-02-01 Thread Stephen Warren

On 02/01/2016 05:05 PM, Simon Glass wrote:

Hi Stephen,

On 1 February 2016 at 17:00, Stephen Warren  wrote:

On 01/30/2016 04:37 PM, Simon Glass wrote:


This series moves these two drivers over to use driver model for video.

This involves the following steps:
- Sync up some device tree files with Linux
- Implement a proper PWM driver
- Clean up and unify the driver code
- Modify the existing drivers to work with driver model

The tegra20 display driver uses device tree bindings invented in 2011
before
Linux had this or anyone was able to agree a standard. It seems possible
to
move it to the new bindings (like tegra124) except for the issue of time
delays between stages. It isn't clear how this should work, and Linux
implements this by including all LCD definitions in the kernel source
code,
and not using any delays. This causes strange display artifacts on the
display when starting up, but perhaps is harmless to the display. Future
work will sync up the device tree more for seaboard, and thus tidy this up
for nvidia boards.

A bug in the keyboard driver is also fixed by this series. The series is
tested on seaboard and nyan-big, the two boards I have which support a
display.

This series is available at u-boot-dm/tegra-working.



This changes the name of the output device from "lcd" to "vidconsole".
Anyone who doesn't reset their environment to default when switching to this
new U-Boot will lose their display output because of this. Is there any way
to maintain compatibility?


I could not think of one other than an egregious hack. It will
certainly bite someone. Perhaps a hack that detects 'lcd' in the
stdout env variable and prints a warning would be useful?


Can't the two drivers just respond to the same device name. Presumably a 
build would only have one or the other compiled in?


Or perhaps we can add a hook in the board-specific initialization code 
which re-writes the environment after loading it?


Printing a message would be useful if the user has a serial console 
plugged in, which will not always be the case. It is not possible on 
Paz00 (likely the most widely used T20 device) for example without 
taking the case apart and soldering to a very tiny connector; I expect 
almost nobody has done that.

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


Re: [U-Boot] [PATCH 00/14] EFI payload / application support v2

2016-02-01 Thread Alexander Graf



On 02/02/2016 01:02 AM, Simon Glass wrote:

Hi Alex,

On 1 February 2016 at 14:38, Alexander Graf  wrote:


For now I've had a play with Minnowboard, which is x86. The main thing
I noticed is that the API function implements should have EFIAPI on
them also.


Yes :). I didn't expect anyone to actually care about running this on x86
which is the only architecture that has different calling conventions for
EFI. I'm very pleasantly surprised that you are interested and since you
already have a patch to add them, I guess you can as well just post that
once the base support is in :).

OK. I suppose because EFIAPI is empty on ARM it doesn't matter. But
strictly speaking the declaration should match the implementation.


Yeah, I just didn't want to implement something I wouldn't test :).

OK. You could add a regparm(0) or something like that to be sure it is
working. Or just bring in that part of my patch. But I'm OK if you'd
rather I send a follow-up.



My AArch64 compiler isn't really happy about that:

include/efi_loader.h:67:4: warning: 'regparm' attribute directive 
ignored [-Wattributes]


But I've fixed up everything I could find manually and just leave the 
remaining 1 or 2 occurrences to you :)



Alex

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


Re: [U-Boot] [PATCH] exynos: Set CNTFRQ

2016-02-01 Thread Simon Glass
+Minkyu

On 1 February 2016 at 13:41, Alexander Graf  wrote:
> Commit 73a1cb27 moved the check whether we should set the architected
> timer frequency from CONFIG_SYS_CLK_FREQ to CONFIG_TIMER_CLK_FREQ, but
> did not update all users of it.
>
> The one where I (finally) realized why KVM didn't work is the Arndale
> board, so this patch adds the respective define to it.
>
> Signed-off-by: Alexander Graf 
> Fixes: 73a1cb27
> ---
>  include/configs/exynos-common.h | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/include/configs/exynos-common.h b/include/configs/exynos-common.h
> index 852829c..c4e731f 100644
> --- a/include/configs/exynos-common.h
> +++ b/include/configs/exynos-common.h
> @@ -31,6 +31,7 @@
>
>  /* input clock of PLL: 24MHz input clock */
>  #define CONFIG_SYS_CLK_FREQ2400
> +#define CONFIG_TIMER_CLK_FREQ  2400
>
>  #define CONFIG_SETUP_MEMORY_TAGS
>  #define CONFIG_CMDLINE_TAG
> --
> 2.6.2
>
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v3 0/7] fdt: Replace u-boot-dtb.bin with u-boot.bin

2016-02-01 Thread Simon Glass
Hi Albert,

On 1 February 2016 at 00:31, Albert ARIBAUD  wrote:
> Hello Simon,
>
> Nitpicking:
>
> On Sun, 31 Jan 2016 18:10:48 -0700, Simon Glass 
> wrote:
>
>> The original decision to use a separate u-boot-dtb.bin was aimed at allowing
>> any device tree file to be concatenated to the u-boot.bin image after the
>> build. However this no-longer seems so important. More important is the
>> convenience of using the same output file regardless of the setting for
>> OF_CONTROL.
>
> Maybe explain in a few words why concatenating the DT no long seems
> important, so that readers who were intending to concatenate get a hint
> on what option they should follow instead?

I'm not sure what to say here. If people want to concatenate in a
build system, then they can use u-boot-nodtb.bin for that. Everything
should then work as expected.

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


Re: [U-Boot] [PATCH v2 00/23] dm: tegra: Convert tegra20 and tegra124 video drivers to driver model

2016-02-01 Thread Simon Glass
Hi Stephen,

On 1 February 2016 at 17:00, Stephen Warren  wrote:
> On 01/30/2016 04:37 PM, Simon Glass wrote:
>>
>> This series moves these two drivers over to use driver model for video.
>>
>> This involves the following steps:
>> - Sync up some device tree files with Linux
>> - Implement a proper PWM driver
>> - Clean up and unify the driver code
>> - Modify the existing drivers to work with driver model
>>
>> The tegra20 display driver uses device tree bindings invented in 2011
>> before
>> Linux had this or anyone was able to agree a standard. It seems possible
>> to
>> move it to the new bindings (like tegra124) except for the issue of time
>> delays between stages. It isn't clear how this should work, and Linux
>> implements this by including all LCD definitions in the kernel source
>> code,
>> and not using any delays. This causes strange display artifacts on the
>> display when starting up, but perhaps is harmless to the display. Future
>> work will sync up the device tree more for seaboard, and thus tidy this up
>> for nvidia boards.
>>
>> A bug in the keyboard driver is also fixed by this series. The series is
>> tested on seaboard and nyan-big, the two boards I have which support a
>> display.
>>
>> This series is available at u-boot-dm/tegra-working.
>
>
> This changes the name of the output device from "lcd" to "vidconsole".
> Anyone who doesn't reset their environment to default when switching to this
> new U-Boot will lose their display output because of this. Is there any way
> to maintain compatibility?

I could not think of one other than an egregious hack. It will
certainly bite someone. Perhaps a hack that detects 'lcd' in the
stdout env variable and prints a warning would be useful?

>
> Aside from that, I don't see any issues on Springbank (Seaboard), Harmony,
> Ventana, Paz00, or p2371-2180, so the series,
> Tested-by: Stephen Warren 

Thanks very much for testing all those,.

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


Re: [U-Boot] [PATCH v1 1/2] Revert "powerpc: mpc85xx: remove P2020DS board support"

2016-02-01 Thread Simon Glass
Hi York,

On 1 February 2016 at 12:37, york sun  wrote:
> On 01/31/2016 07:40 AM, Simon Glass wrote:
>> Hi,
>>
>> On 31 January 2016 at 07:19, Bin Meng  wrote:
>>> Hi York,
>>>
>>> On Sun, Jan 31, 2016 at 6:03 AM, York Sun  wrote:
 This reverts commit 168dcc6cef7a0e13bc52fc8fa8de2866cf4033dc.
 Align with changes since P2020DS was removed, including adding
 these macros to defconfig

 CONFIG_SYS_NS16550
 CONFIG_CMD_NET
 CONFIG_NETDEVICES
 CONFIG_E1000
 CONFIG_CMD_DHCP

 Remove macros and include from board header file, including
 CONFIG_E1000
 CONFIG_MTD_NAND_VERIFY_WRITE
 CONFIG_SYS_NS16550
 config_cmd_default.h
 CONFIG_CMD_ELF
 CONFIG_CMD_SETEXPR
 CONFIG_CMD_NET

>>>
>>> While we bring this board back, I believe we should add driver model
>>> support this this board as well, at least NS16550.
>>
>> Yes, since today is the day we are supposed to have all serial drivers
>> converted over.
>>
>> Other things that could perhaps be converted, and would give PPC a
>> better start on driver model: i2c, mmc, usb, Ethernet, PCI :-)
>>
>
> I will take this chance to convert P2020DS to use DM. Need some guidance here.
> For NS16550, it needs the clock. To keep it simple, let's presume platform 
> data
> is used. My trouble is the clock is not unknown at compiling time. It needs to
> be updated by checking the board/soc configuration after power up. The clock 
> is
> only available after get_clocks() is called in init_sequance. Is there a way I
> can update the clocks before the driver is initialized?
>
> York

See this commit:

858530a8 dm: tegra: Enable driver model for serial

It sets up its own clock.

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


Re: [U-Boot] [PATCH V2] fdt: introduce fdtdec_get_child_count

2016-02-01 Thread Simon Glass
On 31 January 2016 at 22:31, Peng Fan  wrote:
> Introduce fdtdec_get_child_count for get the number of subnodes
> of one parent node.
>
> Signed-off-by: Peng Fan 
> Cc: Simon Glass 
> ---
>
> V2:
>  correct spell error.
>  renamed to fdtdec_get_child_count, move code to lib/fdtdec.c and add
>  prototype in include/fdtdec.h
>
>  include/fdtdec.h |  9 +
>  lib/fdtdec.c | 11 +++
>  2 files changed, 20 insertions(+)

Acked-by: Simon Glass 
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 2/2] pinctrl: imx: Support i.MX7D

2016-02-01 Thread Simon Glass
Hi Peng,

On 31 January 2016 at 22:38, Peng Fan  wrote:
> Introudce i.MX7 pinctrl driver support.
> For now only i.MX7D supported.
> There are two iomux controllers in i.MX7D, iomuxc and iomuxc_lpsr.
> To iomuxc_lpsr, ZERO_OFFSET_VALID is set, means offset of mux_reg
> and conf_reg can begin at 0.
>
> Signed-off-by: Peng Fan 
> Cc: Simon Glass 
> Cc: Stefano Babic 
> Cc: Fabio Estevam 
> ---
>  drivers/pinctrl/nxp/Kconfig|  8 
>  drivers/pinctrl/nxp/Makefile   |  1 +
>  drivers/pinctrl/nxp/pinctrl-imx7.c | 42 
> ++
>  3 files changed, 51 insertions(+)
>  create mode 100644 drivers/pinctrl/nxp/pinctrl-imx7.c

Reviewed-by: Simon Glass 

>
> diff --git a/drivers/pinctrl/nxp/Kconfig b/drivers/pinctrl/nxp/Kconfig
> index 2032588..a251d54 100644
> --- a/drivers/pinctrl/nxp/Kconfig
> +++ b/drivers/pinctrl/nxp/Kconfig
> @@ -8,3 +8,11 @@ config PINCTRL_IMX6
> select PINCTRL_IMX
> help
>   Say Y here to enable the imx6ul pinctrl driver
> +
> +config PINCTRL_IMX7
> +   bool "IMX7 pinctrl driver"
> +   depends on ARCH_MX7
> +   select DEVRES
> +   select PINCTRL_IMX
> +   help
> + Say Y here to enable the imx6ul pinctrl driver

Please add some help!

> diff --git a/drivers/pinctrl/nxp/Makefile b/drivers/pinctrl/nxp/Makefile
> index 7fd9850..0ee7f2f 100644
> --- a/drivers/pinctrl/nxp/Makefile
> +++ b/drivers/pinctrl/nxp/Makefile
> @@ -1,2 +1,3 @@
>  obj-$(CONFIG_PINCTRL_IMX)  += pinctrl-imx.o
>  obj-$(CONFIG_PINCTRL_IMX6) += pinctrl-imx6.o
> +obj-$(CONFIG_PINCTRL_IMX7) += pinctrl-imx7.o
> diff --git a/drivers/pinctrl/nxp/pinctrl-imx7.c 
> b/drivers/pinctrl/nxp/pinctrl-imx7.c
> new file mode 100644
> index 000..150ccf9
> --- /dev/null
> +++ b/drivers/pinctrl/nxp/pinctrl-imx7.c
> @@ -0,0 +1,42 @@
> +
> +/*
> + * Copyright (C) 2016 Peng Fan 
> + *
> + * SPDX-License-Identifier:GPL-2.0+
> + */
> +
> +#include 
> +#include 
> +
> +#include "pinctrl-imx.h"
> +
> +static struct imx_pinctrl_soc_info imx7_pinctrl_soc_info;
> +
> +static struct imx_pinctrl_soc_info imx7_lpsr_pinctrl_soc_info = {
> +   .flags = ZERO_OFFSET_VALID,
> +};
> +
> +static int imx7_pinctrl_probe(struct udevice *dev)
> +{
> +   struct imx_pinctrl_soc_info *info =
> +   (struct imx_pinctrl_soc_info *)dev_get_driver_data(dev);

I think this should be platform data.

> +
> +   return imx_pinctrl_probe(dev, info);
> +}
> +
> +static const struct udevice_id imx7_pinctrl_match[] = {
> +   { .compatible = "fsl,imx7d-iomuxc", .data = 
> (ulong)&imx7_pinctrl_soc_info },
> +   { .compatible = "fsl,imx7d-iomuxc-lpsr", .data = 
> (ulong)&imx7_lpsr_pinctrl_soc_info },
> +   { /* sentinel */ }
> +};
> +
> +U_BOOT_DRIVER(imx7_pinctrl) = {
> +   .name = "imx7-pinctrl",
> +   .id = UCLASS_PINCTRL,
> +   .of_match = of_match_ptr(imx7_pinctrl_match),
> +   .probe = imx7_pinctrl_probe,
> +   .remove = imx_pinctrl_remove,
> +   .priv_auto_alloc_size = sizeof(struct imx_pinctrl_priv),
> +   .ops = &imx_pinctrl_ops,
> +   .flags = DM_FLAG_PRE_RELOC,
> +};
> --
> 2.6.2
>

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


Re: [U-Boot] [PATCH] patman: fix series-notes handling for buildman

2016-02-01 Thread Simon Glass
Hi Albert,

On 31 January 2016 at 09:51, Albert ARIBAUD  wrote:
> Hello Simon,
>
> On Thu, 19 Nov 2015 20:29:11 -0700, Simon Glass 
> wrote:
>> Hi Albert,
>>
>> On 13 November 2015 at 19:35, Simon Glass  wrote:
>> > On 9 November 2015 at 14:36, Albert ARIBAUD  
>> > wrote:
>> >> Hello Simon,
>> >>
>> >> On Mon, 9 Nov 2015 12:24:55 -0800, Simon Glass  wrote:
>> >>> On 9 November 2015 at 06:19, Albert ARIBAUD  
>> >>> wrote:
>> >>> > A patman series with a 'Series-notes' section causes
>> >>> > buildman to crash with:
>> >>> >
>> >>> > self.series.notes += self.section
>> >>> > TypeError: cannot concatenate 'str' and 'list' objects
>> >>> >
>> >>> > Fix by initializing series.notes as a one-element array
>> >>> > rathen than a scalar.
>> >>> >
>> >>> > Signed-off-by: Albert ARIBAUD 
>> >>> > ---
>> >>> >
>> >>> >  tools/patman/series.py | 2 +-
>> >>> >  1 file changed, 1 insertion(+), 1 deletion(-)
>> >>>
>> >>> Acked-by: Simon Glass 
>> >>
>> >> Note: just spotted a typo, 'rathen' instead of 'rather'. If this patch
>> >> gets applied, please fix that on-the-fly.
>> >>
>> >> Amicalement,
>> >> --
>> >> Albert.
>> >
>> > Fixed typo and
>> >
>> > Applied to u-boot-dm, thanks!
>>
>> Hmm, actually I've had to drop this as it breaks 'Series-version'.
>> That currently does not expect a list.
>
> Hmm, I can't reproduce this here. How do you trigger the Series-version
> break?

I created a commit with a Series-version: in it. Then, running patman
gives a run-time error because it is expecting a single value, not an
array.

>
>> I wonder if Series-notes needs a special case, instead?
>>
>> Regards,
>> Simon
>
> Amicalement,
> --
> Albert.


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


Re: [U-Boot] [PATCH 1/2] pinctrl: imx: Introduce pinctrl driver for i.MX6

2016-02-01 Thread Simon Glass
Hi Peng,

On 31 January 2016 at 22:38, Peng Fan  wrote:
> Introduce pinctrl for i.MX6
> 1. pinctrl-imx.c is for common usage. It's used by i.MX6/7.
> 2. Add PINCTRL_IMX PINCTRL_IMX6 Kconfig entry.
> 3. To the pinctrl_ops implementation, only set_state is implemented.
>To i.MX6/7, the pinctrl dts entry is as following:
> &iomuxc {
> pinctrl-names = "default";
>
> pinctrl_csi1: csi1grp {
> fsl,pins = <
> MX6UL_PAD_CSI_MCLK__CSI_MCLK0x1b088
> MX6UL_PAD_CSI_PIXCLK__CSI_PIXCLK0x1b088
> MX6UL_PAD_CSI_VSYNC__CSI_VSYNC  0x1b088
> >;
> };
>
> [.]
> };
>   there is no property named function or groups. So pinctrl_generic_set_state
>   can not be used here.
> 5. This driver is a simple implementation for i.mx iomux controller,
>only parse the fsl,pins property and write value to registers.
> 6. With DEBUG enabled, we can see log when "i2c bus 0":
>"
>set_state_simple op missing
>imx_pinctrl_set_state: i2c1grp
>mux_reg 0x14c, conf_reg 0x3bc, input_reg 0x5d8, mux_mode 0x0, input_val 
> 0x1, config_val 0x407f
>write mux: offset 0x14c val 0x10
>select_input: offset 0x5d8 val 0x1
>write config: offset 0x3bc val 0x7f
>mux_reg 0x148, conf_reg 0x3b8, input_reg 0x5d4, mux_mode 0x0, input_val 
> 0x1, config_val 0x407f
>write mux: offset 0x148 val 0x10
>select_input: offset 0x5d4 val 0x1
>write config: offset 0x3b8 val 0x7f
>"
>this means imx6 pinctrl driver works as expected.
>
> Signed-off-by: Peng Fan 
> Cc: Simon Glass 
> Cc: Stefano Babic 
> Cc: Fabio Estevam 
> ---
>  drivers/pinctrl/Kconfig|   1 +
>  drivers/pinctrl/Makefile   |   1 +
>  drivers/pinctrl/nxp/Kconfig|  10 ++
>  drivers/pinctrl/nxp/Makefile   |   2 +
>  drivers/pinctrl/nxp/pinctrl-imx.c  | 224 
> +
>  drivers/pinctrl/nxp/pinctrl-imx.h  |  59 ++
>  drivers/pinctrl/nxp/pinctrl-imx6.c |  41 +++
>  7 files changed, 338 insertions(+)
>  create mode 100644 drivers/pinctrl/nxp/Kconfig
>  create mode 100644 drivers/pinctrl/nxp/Makefile
>  create mode 100644 drivers/pinctrl/nxp/pinctrl-imx.c
>  create mode 100644 drivers/pinctrl/nxp/pinctrl-imx.h
>  create mode 100644 drivers/pinctrl/nxp/pinctrl-imx6.c
>

Reviewed-by: Simon Glass 

Some questions and comments below.

> diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig
> index 57e6142..9fd8f62 100644
> --- a/drivers/pinctrl/Kconfig
> +++ b/drivers/pinctrl/Kconfig
> @@ -133,6 +133,7 @@ config PINCTRL_SANDBOX
>
>  endif
>
> +source "drivers/pinctrl/nxp/Kconfig"
>  source "drivers/pinctrl/uniphier/Kconfig"
>
>  endmenu
> diff --git a/drivers/pinctrl/Makefile b/drivers/pinctrl/Makefile
> index 70d25dc..dcd20bf 100644
> --- a/drivers/pinctrl/Makefile
> +++ b/drivers/pinctrl/Makefile
> @@ -5,6 +5,7 @@
>  obj-y  += pinctrl-uclass.o
>  obj-$(CONFIG_$(SPL_)PINCTRL_GENERIC)   += pinctrl-generic.o
>
> +obj-y  += nxp/
>  obj-$(CONFIG_ARCH_ROCKCHIP) += rockchip/
>  obj-$(CONFIG_PINCTRL_SANDBOX)  += pinctrl-sandbox.o
>
> diff --git a/drivers/pinctrl/nxp/Kconfig b/drivers/pinctrl/nxp/Kconfig
> new file mode 100644
> index 000..2032588
> --- /dev/null
> +++ b/drivers/pinctrl/nxp/Kconfig
> @@ -0,0 +1,10 @@
> +config PINCTRL_IMX
> +   bool
> +
> +config PINCTRL_IMX6
> +   bool "IMX6 pinctrl driver"
> +   depends on ARCH_MX6
> +   select DEVRES
> +   select PINCTRL_IMX
> +   help
> + Say Y here to enable the imx6ul pinctrl driver

Please can you add a few more details? What features does it support?
What SoCs use it?

> diff --git a/drivers/pinctrl/nxp/Makefile b/drivers/pinctrl/nxp/Makefile
> new file mode 100644
> index 000..7fd9850
> --- /dev/null
> +++ b/drivers/pinctrl/nxp/Makefile
> @@ -0,0 +1,2 @@
> +obj-$(CONFIG_PINCTRL_IMX)  += pinctrl-imx.o
> +obj-$(CONFIG_PINCTRL_IMX6) += pinctrl-imx6.o
> diff --git a/drivers/pinctrl/nxp/pinctrl-imx.c 
> b/drivers/pinctrl/nxp/pinctrl-imx.c
> new file mode 100644
> index 000..09ffb1b
> --- /dev/null
> +++ b/drivers/pinctrl/nxp/pinctrl-imx.c
> @@ -0,0 +1,224 @@
> +/*
> + * Copyright (C) 2016 Peng Fan 
> + *
> + * SPDX-License-Identifier:GPL-2.0+
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include "pinctrl-imx.h"
> +
> +DECLARE_GLOBAL_DATA_PTR;
> +
> +static int imx_pinctrl_set_state(struct udevice *dev, struct udevice *config)
> +{
> +   struct imx_pinctrl_priv *priv = dev_get_priv(dev);
> +   struct imx_pinctrl_soc_info *info = priv->info;
> +   int node = config->of_offset;
> +   const struct fdt_property *prop;
> +   unsigned int *pin_data;
> +   int npins, size, pin_size;
> +   int mux_reg, conf_reg, input_reg, input_val, mux_mode, config_val;
> +   int i, j = 0;
> +
> +   

Re: [U-Boot] [PATCH 04/14] efi_loader: Add boot time services

2016-02-01 Thread Alexander Graf



On 02/02/2016 12:54 AM, Simon Glass wrote:

Hi Alex,

On 1 February 2016 at 16:45, Alexander Graf  wrote:



On 01/31/2016 04:19 PM, Simon Glass wrote:

Hi Alexander,

On 14 January 2016 at 22:06, Alexander Graf  wrote:

When an EFI application runs, it has access to a few descriptor and callback
tables to instruct the EFI compliant firmware to do things for it. The bulk
of those interfaces are "boot time services". They handle all object management,
and memory allocation.

This patch adds support for the boot time services and also exposes a system
table, which is the point of entry descriptor table for EFI payloads.

Signed-off-by: Alexander Graf 

---

v1 -> v2:

- Fix typo s/does now/does not/
- Add #ifdefs around header to allow inclusion when efi_loader is disabled
- Add stub efi_restore_gd() function when efi_loader is disabled
- Disable debug
- Mark runtime region as such
- Fix up memory map
- Allow efi_restore_gd to be called before first efi entry
- Add 32bit arm cache workaround
- Move memory map to separate patch
- Change BTS version to 2.5
- Fix return values for a few callbacks to more EFI compliant ones
- Change vendor to "Das U-Boot"
- Add warning when truncating timer trigger
- Move to GPLv2+
---
   include/efi_loader.h  |  51 +++
   lib/efi_loader/efi_boottime.c | 761 
++
   2 files changed, 812 insertions(+)
   create mode 100644 lib/efi_loader/efi_boottime.c

Reviewed-by: Simon Glass 

But please see below.

Also, how does the timer get disabled? For me it seems to be enabled
on boot so it always calls the trigger function.


I think I see what you're running into. The ARM code runs set_timer as one of its 
first actions. On x86 it probably doesn't, so that's why you see the timer firing 
off, since it's initialized to 0 and now >= 0 always.

I'll change the initialization for timer_next to -1ULL. That way you should 
only get to see events when they're there.

OK. Or maybe you need a bool to track when it is not active?


Setting the value to -1ULL is almost the same, as it would only ever 
match if timer_get_us() returns exactly 0x.







diff --git a/include/efi_loader.h b/include/efi_loader.h
index bf77573..391459e 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -6,18 +6,69 @@
*  SPDX-License-Identifier: GPL-2.0+
*/

+#include 
   #include 
   #include 
+
+#ifdef CONFIG_EFI_LOADER
+
   #include 

+/* #define DEBUG_EFI */
+
+#ifdef DEBUG_EFI
+#define EFI_ENTRY(format, ...) do { \
+   efi_restore_gd(); \
+   printf("EFI: Entry %s(" format ")\n", __func__, ##__VA_ARGS__); \
+   } while(0)
+#else
+#define EFI_ENTRY(format, ...) do { \
+   efi_restore_gd(); \
+   } while(0)
+#endif
+
+#define EFI_EXIT(ret) efi_exit_func(ret);
+
+extern struct efi_system_table systab;
+
   extern const efi_guid_t efi_guid_device_path;
   extern const efi_guid_t efi_guid_loaded_image;

+struct efi_class_map {
+   const efi_guid_t *guid;
+   const void *interface;
+};
+
+struct efi_handler {
+   const efi_guid_t *guid;
+   efi_status_t (EFIAPI *open)(void *handle,
+   efi_guid_t *protocol, void **protocol_interface,
+   void *agent_handle, void *controller_handle,
+   uint32_t attributes);

Can we add a name in here? It would be good to name each of these
things so that we can print it out for debugging, etc.

Same also for efi_object. The guids are an unfortunate but effective
obfuscation for people trying to figure out what is going on. I think
we should try to keep things human-friendly.


While I agree, I'm not sure this is the correct layer to do this in. As soon as 
the open callback gets called, you should be able to see which function this 
is, no?

Do you have any concrete case where the current debugging wasn't enough?

In my case I was trying to work out whether the call was getting
through, and where it was ending up. It was really hard to know
whether something was just not getting through. Putting a name in the
dispatching helped a lot with that. It's all very well to send a
message when you have arrived, but it's more useful I think to send a
message when you leave :-)


I can see why it would help for that specific case, but I'd really put 
this into the "apply locally, debug, throw away" patch category. I'm 
sure once we have the support going well on x86, there won't be any need 
to dig out names from the dispatcher.



Alex

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


  1   2   3   >