Re: [U-Boot] [PATCH 2/2] ventana: Add Gateworks Ventana family support

2014-02-05 Thread Tim Harvey
On Mon, Feb 3, 2014 at 9:39 AM, Stefano Babic  wrote:
> Hi Tim,
>
> On 01/02/2014 20:49, Tim Harvey wrote:
>> Gateworks Ventana is a product family based on the i.MX6.  This
>> patch adds support for all boards in the Ventana family. Where
>> possible, data from the boards EEPROM is used to determine various
>> details about the board at runtime.
>>
>> Signed-off-by: Tim Harvey 
>> ---
>>  board/gateworks/gw_ventana/Makefile |   10 +
>>  board/gateworks/gw_ventana/README   |   56 ++
>>  board/gateworks/gw_ventana/clocks.cfg   |   42 +
>>  board/gateworks/gw_ventana/gsc.c|  129 +++
>>  board/gateworks/gw_ventana/gsc.h|9 +
>>  board/gateworks/gw_ventana/gw_ventana.c | 1200 
>> +++
>>  board/gateworks/gw_ventana/gw_ventana.cfg   |   42 +
>>  board/gateworks/gw_ventana/ventana_eeprom.h |  103 +++
>>  boards.cfg  |5 +
>>  include/configs/gw_ventana.h|  418 ++
>>  10 files changed, 2014 insertions(+)
>>  create mode 100644 board/gateworks/gw_ventana/Makefile
>>  create mode 100644 board/gateworks/gw_ventana/README
>>  create mode 100644 board/gateworks/gw_ventana/clocks.cfg
>>  create mode 100644 board/gateworks/gw_ventana/gsc.c
>>  create mode 100644 board/gateworks/gw_ventana/gsc.h
>>  create mode 100644 board/gateworks/gw_ventana/gw_ventana.c
>>  create mode 100644 board/gateworks/gw_ventana/gw_ventana.cfg
>>  create mode 100644 board/gateworks/gw_ventana/ventana_eeprom.h
>>  create mode 100644 include/configs/gw_ventana.h
>>
>> diff --git a/board/gateworks/gw_ventana/Makefile 
>> b/board/gateworks/gw_ventana/Makefile
>> new file mode 100644
>> index 000..e8dab89
>> --- /dev/null
>> +++ b/board/gateworks/gw_ventana/Makefile
>> @@ -0,0 +1,10 @@
>> +#
>> +# Copyright (C) 2012-2013, Guennadi Liakhovetski 
>> +# (C) Copyright 2012-2013 Freescale Semiconductor, Inc.
>> +# Copyright (C) 2013, Gateworks Corporation
>> +#
>> +# SPDX-License-Identifier:  GPL-2.0+
>> +#
>> +
>> +obj-y  := gw_ventana.o gsc.o
>> +
>> diff --git a/board/gateworks/gw_ventana/README 
>> b/board/gateworks/gw_ventana/README
>> new file mode 100644
>> index 000..f744a4a
>> --- /dev/null
>> +++ b/board/gateworks/gw_ventana/README
>> @@ -0,0 +1,56 @@
>> +U-Boot for the Gateworks Ventana Product Family boards
>> +
>> +This file contains information for the port of U-Boot to the Gateworks
>> +Ventana Product family boards.
>> +
>> +1. Boot source, boot from NAND
>> +--
>> +
>> +The i.MX6 BOOT ROM expects some structures that provide details of NAND 
>> layout
>> +and bad block information (referred to as 'bootstreams') which are 
>> replicated
>> +multiple times in NAND. The number of replications is configurable through
>> +board strapping options and eFUSE settings.  The Freescale 'kobs-ng'
>> +application from the Freescale LTIB BSP, which runs under Linux, must be 
>> used
>> +to program the bootstream in order to setup the replicated headers 
>> correctly.
>> +
>> +The Gateworks Ventana boards with NAND flash have been factory programmed
>> +such that their eFUSE settings expect 2 copies of the boostream (this is
>> +specified by providing kobs-ng with the --search_exponent=1 argument). Once 
>> in
>> +Linux with MTD support for the NAND on /dev/mtd0 you can program the 
>> boostream
>> +with:
>> +
>> +kobs-ng init -v -x --search_exponent=1 u-boot.imx
>> +
>> +The kobs-ng application users an imximage (u-boot.imx) which contains the
> ^-- spelling, uses

will fix

>
>> +Image Vector Table (IVT) and Device Configuration Data (DCD) structures that
>> +the i.MX6 BOOT ROM requires to boot.  The kobs-ng adds the Firmware
>> +Configuration Block (FCB) and Discovered Bad Block Table (DBBT).
>> +
>> +This information is taken from:
>> +  http://trac.gateworks.com/wiki/ventana/bootloader#NANDFLASH
>> +
>> +More details about the i.MX6 BOOT ROM can be found at:
>> +  http://cache.freescale.com/files/32bit/doc/ref_manual/IMX6DQRM.pdf
>
> Why cache.freescale ? I think you can simply write that more information
> are in the User Manual. Freescale moves sometimes the location of the
> documentation.

will replace with:

More details about the i.MX6 BOOT ROM can be found in the IMX6
reference manuals.

>
>> diff --git a/board/gateworks/gw_ventana/gsc.c 
>> b/board/gateworks/gw_ventana/gsc.c
>> new file mode 100644
>> index 000..72eec38
>> --- /dev/null
>> +++ b/board/gateworks/gw_ventana/gsc.c
>> @@ -0,0 +1,129 @@
>> +/*
>> + * Copyright (C) 2013 Gateworks Corporation
>> + *
>> + * Author: Tim Harvey 
>> + *
>> + * SPDX-License-Identifier: GPL-2.0+
>> + */
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +
>> +/*
>> + * The Gateworks System Controller will fail to ACK a master transaction if
>> + * it is busy, which can occur during its 1HZ timer tick while reading 
>> ADC's.
>> + * When this does occur, it will never be busy long enough to f

[U-Boot] u-boot compile error: Source object has EABI version 5, but target has EABI version 0

2014-02-05 Thread Abdullah YILDIZ
When I try to compile u-boot I get the following error:


The error is explained in this link:

http://www.denx.de/wiki/DULG/SourceObjectHasEABIVersion4ButTargetHasEABIVersion0

It works for another toolchain. However, I want to learn that if there is a way 
to compile it with the current toolchain as explained in the link above.

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


[U-Boot] enabling post for arm in uboot

2014-02-05 Thread shobin b
Hi,

   I have tried to build u-boot for iris board(toradex) with POST enabled,
but its showing some compilation errors as,


i=aapcs-linux -mno-thumb-interwork -march=armv5 -Werror -Wall
-Wstrict-prototypes -fno-stack-protector   -o tftp.o tftp.c -c
/home/shobin/toradex/gcc-linaro-arm-linux-gnueabihf-2012.09-20120921_linux/bin/arm-linux-gnueabihf-ld
 -r -o libnet.o  bootp.o eth.o net.o tftp.o
make[1]: Leaving directory `/home/shobin/iris/u-boot-toradex/net'
make -C post/
make[1]: Entering directory `/home/shobin/iris/u-boot-toradex/post'
make[1]: Leaving directory `/home/shobin/iris/u-boot-toradex/post'
make[1]: Entering directory `/home/shobin/iris/u-boot-toradex/post'
/home/shobin/toradex/gcc-linaro-arm-linux-gnueabihf-2012.09-20120921_linux/bin/arm-linux-gnueabihf-gcc
 -g  -O2   -fno-common -ffixed-r8 -msoft-float  -D__KERNEL__
-DCONFIG_SYS_TEXT_BASE=0x00108000
-I/home/shobin/iris/u-boot-toradex/include -fno-builtin -ffreestanding
-nostdinc -isystem
/home/shobin/toradex/gcc-linaro-arm-linux-gnueabihf-2012.09-20120921_linux/bin/../lib/gcc/arm-linux-gnueabihf/4.7.2/include
-pipe  -DCONFIG_ARM -D__ARM__ -marm  -mabi=aapcs-linux -mno-thumb-interwork
-march=armv5 -Werror -Wall -Wstrict-prototypes -fno-stack-protector   -o
post.o post.c -c
post.c: In function 'post_log':
post.c:403:7: error: variable 'i' set but not used
[-Werror=unused-but-set-variable]
post.c: In function 'post_time_ms':
post.c:494:2: error: #warning "Not implemented yet" [-Werror=cpp]
cc1: all warnings being treated as errors
make[1]: *** [post.o] Error 1
make[1]: Leaving directory `/home/shobin/iris/u-boot-toradex/post'
make: *** [post/libpost.o] Error 2

please help me.


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


Re: [U-Boot] enabling post for arm in uboot

2014-02-05 Thread Michael Trimarchi
Hi Shobin

On Wed, Feb 5, 2014 at 8:46 AM, shobin b  wrote:
> Hi,
>
>I have tried to build u-boot for iris board(toradex) with POST enabled,
> but its showing some compilation errors as,
>
>
> i=aapcs-linux -mno-thumb-interwork -march=armv5 -Werror -Wall
> -Wstrict-prototypes -fno-stack-protector   -o tftp.o tftp.c -c
> /home/shobin/toradex/gcc-linaro-arm-linux-gnueabihf-2012.09-20120921_linux/bin/arm-linux-gnueabihf-ld
>  -r -o libnet.o  bootp.o eth.o net.o tftp.o
> make[1]: Leaving directory `/home/shobin/iris/u-boot-toradex/net'
> make -C post/
> make[1]: Entering directory `/home/shobin/iris/u-boot-toradex/post'
> make[1]: Leaving directory `/home/shobin/iris/u-boot-toradex/post'
> make[1]: Entering directory `/home/shobin/iris/u-boot-toradex/post'
> /home/shobin/toradex/gcc-linaro-arm-linux-gnueabihf-2012.09-20120921_linux/bin/arm-linux-gnueabihf-gcc
>  -g  -O2   -fno-common -ffixed-r8 -msoft-float  -D__KERNEL__
> -DCONFIG_SYS_TEXT_BASE=0x00108000
> -I/home/shobin/iris/u-boot-toradex/include -fno-builtin -ffreestanding
> -nostdinc -isystem
> /home/shobin/toradex/gcc-linaro-arm-linux-gnueabihf-2012.09-20120921_linux/bin/../lib/gcc/arm-linux-gnueabihf/4.7.2/include
> -pipe  -DCONFIG_ARM -D__ARM__ -marm  -mabi=aapcs-linux -mno-thumb-interwork
> -march=armv5 -Werror -Wall -Wstrict-prototypes -fno-stack-protector   -o
> post.o post.c -c
> post.c: In function 'post_log':
> post.c:403:7: error: variable 'i' set but not used
> [-Werror=unused-but-set-variable]
> post.c: In function 'post_time_ms':
> post.c:494:2: error: #warning "Not implemented yet" [-Werror=cpp]
> cc1: all warnings being treated as errors
> make[1]: *** [post.o] Error 1
> make[1]: Leaving directory `/home/shobin/iris/u-boot-toradex/post'
> make: *** [post/libpost.o] Error 2
>
> please help me.

I would like to help you but I don't have time.
Is it better that your company pay someone that do this work for you?
You are sending this email since 2 months now.

Michael

>
>
> regards,
> shobin.b
>
> ___
> U-Boot mailing list
> U-Boot@lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot
>
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 0/6] usb:samsung: Exynos4 SoC USB code improvements

2014-02-05 Thread Lukasz Majewski
This patch series comprises several improvements for Exynos4 USB code.

The most notable is transmission speed improvement (measured on Trats):
>From 9.51 MiB/s up to 27 MiB/s

This is due to UDC driver optimizations.

Also a code cleanup for THOR gadget has been included.

Lukasz Majewski (6):
  usb:gadget:ums: Replace malloc calls with memalign to fix cache
buffer alignment
  usb:udc:samsung: Remove redundant cache operation from Samsung UDC
driver
  usb:udc:samsung: Allow burst transfers for non EP0 endpints
  usb:udc:samsung: Zero copy approach for data passed to Samsung's UDC
driver
  usb:gadget:f_thor: Allocate request up to THOR_PACKET_SIZE not
ep->maxpacket
  usb:gadget:f_thor: cosmetic: Remove debug memset

 drivers/usb/gadget/f_mass_storage.c   |4 +-
 drivers/usb/gadget/f_thor.c   |4 +-
 drivers/usb/gadget/s3c_udc_otg.c  |   19 +++
 drivers/usb/gadget/s3c_udc_otg_xfer_dma.c |   87 -
 include/usb/s3c_udc.h |5 +-
 5 files changed, 49 insertions(+), 70 deletions(-)

-- 
1.7.10.4

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


[U-Boot] [PATCH v2 2/6] usb:udc:samsung: Remove redundant cache operation from Samsung UDC driver

2014-02-05 Thread Lukasz Majewski
A set of cache operations (both invalidation and flush) were redundant
in the S3C HS OTG Samsung driver:

1. s3c_udc_ep0_zlp - to transmit EP0's ZLP packets one don't need to flush
the cache (since it is the zero length transmission)

2. s3c_udc_pre_setup and s3c_ep0_complete_out - cache invalidation is not
needed when the buffer for OUT EP0 transmission is setup, since no data
has yet arrived.

Cache cleanups presented above don't contribute much to transmission speed
up, hence shall be regarded as cosmetic changes.

3. setdma_rx - here the s3c UDC driver's internal buffers were invalidated.
This call is not needed anymore since we reuse the buffers passed from
gadgets. This is a key contribution to transmission speed improvement.


Test condition
- test HW + measurement: Trats - Exynos4210 rev.1
- test HW Trats2 - Exynos4412 rev.1
400 MiB compressed rootfs image download with `thor 0 mmc 0`

Measurements:

Base values (without improvement):
Transmission speed: 9.51 MiB/s

After the change:
Transmission speed: 10.15 MiB/s

Signed-off-by: Lukasz Majewski 
Cc: Marek Vasut 

---
Changes for v2:
- Remove Change-Id:
- More verbose commit message
- Remove superficial cache invalidation at s3c_ep0_complete_out() function
---
 drivers/usb/gadget/s3c_udc_otg_xfer_dma.c |   17 -
 1 file changed, 17 deletions(-)

diff --git a/drivers/usb/gadget/s3c_udc_otg_xfer_dma.c 
b/drivers/usb/gadget/s3c_udc_otg_xfer_dma.c
index 1cbf8f6..cbc8734 100644
--- a/drivers/usb/gadget/s3c_udc_otg_xfer_dma.c
+++ b/drivers/usb/gadget/s3c_udc_otg_xfer_dma.c
@@ -29,10 +29,6 @@ static inline void s3c_udc_ep0_zlp(struct s3c_udc *dev)
 {
u32 ep_ctrl;
 
-   flush_dcache_range((unsigned long) usb_ctrl_dma_addr,
-  (unsigned long) usb_ctrl_dma_addr
-  + DMA_BUFFER_SIZE);
-
writel(usb_ctrl_dma_addr, ®->in_endp[EP0_CON].diepdma);
writel(DIEPT_SIZ_PKT_CNT(1), ®->in_endp[EP0_CON].dieptsiz);
 
@@ -52,10 +48,6 @@ void s3c_udc_pre_setup(void)
debug_cond(DEBUG_IN_EP,
   "%s : Prepare Setup packets.\n", __func__);
 
-   invalidate_dcache_range((unsigned long) usb_ctrl_dma_addr,
-   (unsigned long) usb_ctrl_dma_addr
-   + DMA_BUFFER_SIZE);
-
writel(DOEPT_SIZ_PKT_CNT(1) | sizeof(struct usb_ctrlrequest),
   ®->out_endp[EP0_CON].doeptsiz);
writel(usb_ctrl_dma_addr, ®->out_endp[EP0_CON].doepdma);
@@ -82,10 +74,6 @@ static inline void s3c_ep0_complete_out(void)
debug_cond(DEBUG_IN_EP,
"%s : Prepare Complete Out packet.\n", __func__);
 
-   invalidate_dcache_range((unsigned long) usb_ctrl_dma_addr,
-   (unsigned long) usb_ctrl_dma_addr
-   + DMA_BUFFER_SIZE);
-
writel(DOEPT_SIZ_PKT_CNT(1) | sizeof(struct usb_ctrlrequest),
   ®->out_endp[EP0_CON].doeptsiz);
writel(usb_ctrl_dma_addr, ®->out_endp[EP0_CON].doepdma);
@@ -115,11 +103,6 @@ static int setdma_rx(struct s3c_ep *ep, struct s3c_request 
*req)
ep->len = length;
ep->dma_buf = buf;
 
-   invalidate_dcache_range((unsigned long) ep->dev->dma_buf[ep_num],
-   (unsigned long) ep->dev->dma_buf[ep_num]
-   + ROUND(ep->ep.maxpacket,
-   CONFIG_SYS_CACHELINE_SIZE));
-
if (length == 0)
pktcnt = 1;
else
-- 
1.7.10.4

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


[U-Boot] [PATCH v2 1/6] usb:gadget:ums: Replace malloc calls with memalign to fix cache buffer alignment

2014-02-05 Thread Lukasz Majewski
Calls to malloc() have been replaced by memalign. It now provides proper
buffer alignment.

Signed-off-by: Lukasz Majewski 
Cc: Marek Vasut 

---
Changes for v2:
- Remove Change-Id.
---
 drivers/usb/gadget/f_mass_storage.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/f_mass_storage.c 
b/drivers/usb/gadget/f_mass_storage.c
index b1fe8bd..f896169 100644
--- a/drivers/usb/gadget/f_mass_storage.c
+++ b/drivers/usb/gadget/f_mass_storage.c
@@ -2515,7 +2515,7 @@ static struct fsg_common *fsg_common_init(struct 
fsg_common *common,
 buffhds_first_it:
bh->inreq_busy = 0;
bh->outreq_busy = 0;
-   bh->buf = kmalloc(FSG_BUFLEN, GFP_KERNEL);
+   bh->buf = memalign(CONFIG_SYS_CACHELINE_SIZE, FSG_BUFLEN);
if (unlikely(!bh->buf)) {
rc = -ENOMEM;
goto error_release;
@@ -2622,7 +2622,7 @@ usb_copy_descriptors(struct usb_descriptor_header **src)
bytes += (*tmp)->bLength;
bytes += (n_desc + 1) * sizeof(*tmp);
 
-   mem = kmalloc(bytes, GFP_KERNEL);
+   mem = memalign(CONFIG_SYS_CACHELINE_SIZE, bytes);
if (!mem)
return NULL;
 
-- 
1.7.10.4

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


[U-Boot] [PATCH v2 5/6] usb:gadget:f_thor: Allocate request up to THOR_PACKET_SIZE not ep->maxpacket

2014-02-05 Thread Lukasz Majewski
Now it is possible to allocate static request - which receives data from
the host (OUT transaction) to the size of THOR packet.

Signed-off-by: Lukasz Majewski 
Cc: Marek Vasut 

---
Changes for v2:
- Remove Change-Id:
---
 drivers/usb/gadget/f_thor.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/f_thor.c b/drivers/usb/gadget/f_thor.c
index c4c9909..780729a 100644
--- a/drivers/usb/gadget/f_thor.c
+++ b/drivers/usb/gadget/f_thor.c
@@ -614,7 +614,7 @@ static struct usb_request *thor_start_ep(struct usb_ep *ep)
 {
struct usb_request *req;
 
-   req = alloc_ep_req(ep, ep->maxpacket);
+   req = alloc_ep_req(ep, THOR_PACKET_SIZE);
debug("%s: ep:%p req:%p\n", __func__, ep, req);
 
if (!req)
-- 
1.7.10.4

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


[U-Boot] [PATCH v2 3/6] usb:udc:samsung: Allow burst transfers for non EP0 endpints

2014-02-05 Thread Lukasz Majewski
This patch removed obscure restriction on the HW setting of DMA transfers.
Before this change each transaction sent up to 512 bytes (with packet count
equal to 1) for non EP0 transfer.

Now it is possible to setup DMA transaction up to DMA_BUFFER_SIZE.

Test condition
- test HW + measurement: Trats - Exynos4210 rev.1
- test HW Trats2 - Exynos4412 rev.1
400 MiB compressed rootfs image download with `thor 0 mmc 0`

Measurement:
Transmission speed: 20.74 MiB/s

Signed-off-by: Lukasz Majewski 
Cc: Marek Vasut 

---
Changes for v2:
- Remove Change-Id:
---
 drivers/usb/gadget/s3c_udc_otg_xfer_dma.c |7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/gadget/s3c_udc_otg_xfer_dma.c 
b/drivers/usb/gadget/s3c_udc_otg_xfer_dma.c
index cbc8734..7c7176b 100644
--- a/drivers/usb/gadget/s3c_udc_otg_xfer_dma.c
+++ b/drivers/usb/gadget/s3c_udc_otg_xfer_dma.c
@@ -97,18 +97,17 @@ static int setdma_rx(struct s3c_ep *ep, struct s3c_request 
*req)
u32 ep_num = ep_index(ep);
 
buf = req->req.buf + req->req.actual;
-
-   length = min(req->req.length - req->req.actual, (int)ep->ep.maxpacket);
+   length = min(req->req.length - req->req.actual,
+ep_num ? DMA_BUFFER_SIZE : ep->ep.maxpacket);
 
ep->len = length;
ep->dma_buf = buf;
 
-   if (length == 0)
+   if (ep_num == EP0_CON || length == 0)
pktcnt = 1;
else
pktcnt = (length - 1)/(ep->ep.maxpacket) + 1;
 
-   pktcnt = 1;
ctrl =  readl(®->out_endp[ep_num].doepctl);
 
writel(the_controller->dma_addr[ep_index(ep)+1],
-- 
1.7.10.4

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


[U-Boot] [PATCH v2 6/6] usb:gadget:f_thor: cosmetic: Remove debug memset

2014-02-05 Thread Lukasz Majewski
Apparently debug memset (with a 0x55 value) has been overlooked in the
f_thor code.

Signed-off-by: Lukasz Majewski 
Cc: Marek Vasut 

---
Changes for v2:
- Remove Change-id:
---
 drivers/usb/gadget/f_thor.c |2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/usb/gadget/f_thor.c b/drivers/usb/gadget/f_thor.c
index 780729a..f5c0224 100644
--- a/drivers/usb/gadget/f_thor.c
+++ b/drivers/usb/gadget/f_thor.c
@@ -623,8 +623,6 @@ static struct usb_request *thor_start_ep(struct usb_ep *ep)
memset(req->buf, 0, req->length);
req->complete = thor_rx_tx_complete;
 
-   memset(req->buf, 0x55, req->length);
-
return req;
 }
 
-- 
1.7.10.4

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


[U-Boot] [PATCH v2 4/6] usb:udc:samsung: Zero copy approach for data passed to Samsung's UDC driver

2014-02-05 Thread Lukasz Majewski
The Samsung's UDC driver is not anymore copying data from USB requests to
aligned internal buffers. Now it works directly in data allocated in the
upper layers like UMS, DFU, THOR.

This change is possible since those gadgets now must take care to allocate
buffers aligned to cache line (CONFIG_SYS_CACHELINE_SIZE).

This can be achieved by using DEFINE_CACHE_ALIGN_BUFFER() or
ALLOC_CACHE_ALIGN_BUFFER() macros. Those take care to allocate buffer
aligned to cache line in both starting address and its size.
Sometimes it is enough to just use memalign() with size being a
multiplication of cache line size.

Test condition
- test HW + measurement: Trats - Exynos4210 rev.1
- test HW Trats2 - Exynos4412 rev.1
400 MiB compressed rootfs image download with `thor 0 mmc 0`

Measurement:
Transmission speed: 27.04 MiB/s

Signed-off-by: Lukasz Majewski 
Cc: Marek Vasut 

---
Changes for v2:
- Remove Change-Id:
- More verbose commit message
- Add comment explaining the need for proper buffer alignment
---
 drivers/usb/gadget/s3c_udc_otg.c  |   19 +
 drivers/usb/gadget/s3c_udc_otg_xfer_dma.c |   63 +++--
 include/usb/s3c_udc.h |5 +--
 3 files changed, 43 insertions(+), 44 deletions(-)

diff --git a/drivers/usb/gadget/s3c_udc_otg.c b/drivers/usb/gadget/s3c_udc_otg.c
index ba17a04..63d4487 100644
--- a/drivers/usb/gadget/s3c_udc_otg.c
+++ b/drivers/usb/gadget/s3c_udc_otg.c
@@ -843,7 +843,7 @@ static struct s3c_udc memory = {
 int s3c_udc_probe(struct s3c_plat_otg_data *pdata)
 {
struct s3c_udc *dev = &memory;
-   int retval = 0, i;
+   int retval = 0;
 
debug("%s: %p\n", __func__, pdata);
 
@@ -864,16 +864,15 @@ int s3c_udc_probe(struct s3c_plat_otg_data *pdata)
 
the_controller = dev;
 
-   for (i = 0; i < S3C_MAX_ENDPOINTS+1; i++) {
-   dev->dma_buf[i] = memalign(CONFIG_SYS_CACHELINE_SIZE,
-  DMA_BUFFER_SIZE);
-   dev->dma_addr[i] = (dma_addr_t) dev->dma_buf[i];
-   invalidate_dcache_range((unsigned long) dev->dma_buf[i],
-   (unsigned long) (dev->dma_buf[i]
-+ DMA_BUFFER_SIZE));
+   usb_ctrl = memalign(CONFIG_SYS_CACHELINE_SIZE,
+   ROUND(sizeof(struct usb_ctrlrequest),
+ CONFIG_SYS_CACHELINE_SIZE));
+   if (!usb_ctrl) {
+   error("No memory available for UDC!\n");
+   return -ENOMEM;
}
-   usb_ctrl = dev->dma_buf[0];
-   usb_ctrl_dma_addr = dev->dma_addr[0];
+
+   usb_ctrl_dma_addr = (dma_addr_t) usb_ctrl;
 
udc_reinit(dev);
 
diff --git a/drivers/usb/gadget/s3c_udc_otg_xfer_dma.c 
b/drivers/usb/gadget/s3c_udc_otg_xfer_dma.c
index 7c7176b..06dfeed 100644
--- a/drivers/usb/gadget/s3c_udc_otg_xfer_dma.c
+++ b/drivers/usb/gadget/s3c_udc_otg_xfer_dma.c
@@ -110,8 +110,7 @@ static int setdma_rx(struct s3c_ep *ep, struct s3c_request 
*req)
 
ctrl =  readl(®->out_endp[ep_num].doepctl);
 
-   writel(the_controller->dma_addr[ep_index(ep)+1],
-  ®->out_endp[ep_num].doepdma);
+   writel((unsigned int) ep->dma_buf, ®->out_endp[ep_num].doepdma);
writel(DOEPT_SIZ_PKT_CNT(pktcnt) | DOEPT_SIZ_XFER_SIZE(length),
   ®->out_endp[ep_num].doeptsiz);
writel(DEPCTL_EPENA|DEPCTL_CNAK|ctrl, ®->out_endp[ep_num].doepctl);
@@ -134,7 +133,6 @@ int setdma_tx(struct s3c_ep *ep, struct s3c_request *req)
u32 *buf, ctrl = 0;
u32 length, pktcnt;
u32 ep_num = ep_index(ep);
-   u32 *p = the_controller->dma_buf[ep_index(ep)+1];
 
buf = req->req.buf + req->req.actual;
length = req->req.length - req->req.actual;
@@ -144,10 +142,10 @@ int setdma_tx(struct s3c_ep *ep, struct s3c_request *req)
 
ep->len = length;
ep->dma_buf = buf;
-   memcpy(p, ep->dma_buf, length);
 
-   flush_dcache_range((unsigned long) p ,
-  (unsigned long) p + DMA_BUFFER_SIZE);
+   flush_dcache_range((unsigned long) ep->dma_buf,
+  (unsigned long) ep->dma_buf +
+  ROUND(ep->len, CONFIG_SYS_CACHELINE_SIZE));
 
if (length == 0)
pktcnt = 1;
@@ -160,8 +158,7 @@ int setdma_tx(struct s3c_ep *ep, struct s3c_request *req)
while (readl(®->grstctl) & TX_FIFO_FLUSH)
;
 
-   writel(the_controller->dma_addr[ep_index(ep)+1],
-  ®->in_endp[ep_num].diepdma);
+   writel((unsigned long) ep->dma_buf, ®->in_endp[ep_num].diepdma);
writel(DIEPT_SIZ_PKT_CNT(pktcnt) | DIEPT_SIZ_XFER_SIZE(length),
   ®->in_endp[ep_num].dieptsiz);
 
@@ -194,7 +191,6 @@ static void complete_rx(struct s3c_udc *dev, u8 ep_num)
struct s3c_ep *ep = &dev->ep[ep_num];
struct s3c_request *req = NULL;
u32 ep_tsr = 0, xfer_size = 0, is_short = 0;
-   u32 *p

Re: [U-Boot] [PATCH V3 2/3] ARM: tegra: rework boot scripts

2014-02-05 Thread Andreas Färber
Am 04.02.2014 23:59, schrieb Stephen Warren:
> From: Stephen Warren 
> 
> Update the common Tegra boot scripts in the default environment to
> 
> a) Make use of the new "exists" shell command to avoid some error
>messges.

"messages"; and "exists" became "test -e"

> 
> b) Allow booting using the sysboot command and extlinux.conf. This
>allows easy creation of boot menus, and provides a simple interface
>for distros to parameterize/configure the boot process.
> 
> Signed-off-by: Stephen Warren 
> ---
> v3: s/exists/test -e/ in shell commands.
> v2: No change.
> ---
>  include/configs/tegra-common-post.h | 39 
> -
>  1 file changed, 30 insertions(+), 9 deletions(-)
> 
> diff --git a/include/configs/tegra-common-post.h 
> b/include/configs/tegra-common-post.h
> index e1a3bbc62636..5acbdc3a1890 100644
> --- a/include/configs/tegra-common-post.h
> +++ b/include/configs/tegra-common-post.h
> @@ -69,20 +69,41 @@
>  #define BOOTCMDS_COMMON \
>   "rootpart=1\0" \
>   \
> + "do_script_boot=" \
> + "load ${devtype} ${devnum}:${rootpart} "  \
> + "${scriptaddr} ${prefix}${script}; "  \
> + "source ${scriptaddr}\0"  \
> + \
>   "script_boot="\
> - "if load ${devtype} ${devnum}:${rootpart} "   \
> - "${scriptaddr} ${prefix}${script}; then " \
> - "echo ${script} found! Executing ...;"\
> - "source ${scriptaddr};"   \
> - "fi;\0"   \
> + "for script in ${boot_scripts}; do "  \
> + "if test -e ${devtype} ${devnum}:${rootpart} "\
> + "${prefix}${script}; then "   \
> + "echo Found U-Boot script "   \
> + "${prefix}${script}; "\
> + "run do_script_boot;" \
> + "echo SCRIPT FAILED; continuing...; " \

This is not going to work, "continuing..." would be treated as command.

> + "fi; "\
> + "done\0"  \
> + \
> + "do_sysboot_boot="\
> + "sysboot ${devtype} ${devnum}:${rootpart} any "   \
> + "${scriptaddr} ${prefix}extlinux.conf\0"  \
> + \
> + "sysboot_boot="   \
> + "if test -e ${devtype} ${devnum}:${rootpart} "\
> + "${prefix}extlinux.conf; then "   \
> + "echo Found extlinux config " \
> + "${prefix}extlinux.conf; "\
> + "run do_sysboot_boot;"\
> + "echo SCRIPT FAILED; continuing...; " \

Dito. Also note that there's no space before either echo.

Cheers,
Andreas

> + "fi\0"\
>   \
>   "scan_boot="  \
>   "echo Scanning ${devtype} ${devnum}...; " \
>   "for prefix in ${boot_prefixes}; do " \
> - "for script in ${boot_scripts}; do "  \
> - "run script_boot; "   \
> - "done; "  \
> - "done;\0" \
> + "run script_boot; "   \
> + "run sysboot_boot; "  \
> + "done\0"  \
>   \
>   "boot_targets=" \
>   BOOT_TARGETS_MMC " " \

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] ARM: imx6: fix wrong fec clk

2014-02-05 Thread Markus Niebel
From: Markus Niebel 

imx_get_fecclk() returns enet_ref instead of ipg.
Since the clock is used to calculate the prescaler
for the MDIO interface wrong values can be calculated.

Tested on a custom MX6S board with 100MBit interface

Signed-off-by: Markus Niebel 
---
 arch/arm/cpu/armv7/mx6/clock.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/cpu/armv7/mx6/clock.c b/arch/arm/cpu/armv7/mx6/clock.c
index 5617a41..5cc25d1 100644
--- a/arch/arm/cpu/armv7/mx6/clock.c
+++ b/arch/arm/cpu/armv7/mx6/clock.c
@@ -409,7 +409,7 @@ u32 imx_get_uartclk(void)
 
 u32 imx_get_fecclk(void)
 {
-   return decode_pll(PLL_ENET, MXC_HCLK);
+   return mxc_get_clock(MXC_IPG_CLK);
 }
 
 int enable_sata_clock(void)
-- 
1.7.9.5

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


[U-Boot] [PATCH] NET: fec_mxc: fix MDIO clock prescaler calculation

2014-02-05 Thread Markus Niebel
From: Markus Niebel 

The prescaler value for MDC is calculated wrong for
MX6S. Implement the same logic as linux here which handles
ENET_MAC different then original FEC.

Tested on a custom board with i.MX6S and 100MBit PHY

Signed-off-by: Markus Niebel 
---
 drivers/net/fec_mxc.c |8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
index 3b2b995..4cefda4 100644
--- a/drivers/net/fec_mxc.c
+++ b/drivers/net/fec_mxc.c
@@ -128,8 +128,12 @@ static void fec_mii_setspeed(struct ethernet_regs *eth)
 * Set MII_SPEED = (1/(mii_speed * 2)) * System Clock
 * and do not drop the Preamble.
 */
-   writelimx_get_fecclk() / 100) + 2) / 5) << 1,
-   ð->mii_speed);
+   register u32 speed = DIV_ROUND_UP(imx_get_fecclk(), 500);
+#ifdef FEC_QUIRK_ENET_MAC
+   speed--;
+#endif
+   speed <<= 1;
+   writel(speed, ð->mii_speed);
debug("%s: mii_speed %08x\n", __func__, readl(ð->mii_speed));
 }
 
-- 
1.7.9.5

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


Re: [U-Boot] u-boot compile error: Source object has EABI version 5, but target has EABI version 0

2014-02-05 Thread Wolfgang Denk
Dear Abdullah,

In message <1391536944.55409.yahoomail...@web140303.mail.bf1.yahoo.com> you 
wrote:
> 
> When I try to compile u-boot I get the following error:
> 
> The error is explained in this link:
> 
> http://www.denx.de/wiki/DULG/SourceObjectHasEABIVersion4ButTargetHasEABIVersion0
> 
> It works for another toolchain. However, I want to learn that if
> there is a way to compile it with the current toolchain as explained
> in the link above.

EABI has become the default configuration for ARM systems many, many
years ago.  If you still have such an ancient tool chain that does not
support it, it definitely makes no sense trying to use that for any
recent version of U-Boot.  All such efforts are simply wasted.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
Our business is run on trust.  We trust you will pay in advance.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2 06/12] USB: gadget: added a saner gadget downloader registration API

2014-02-05 Thread Mateusz Zalega
On 02/05/14 08:13, Marek Vasut wrote:
> On Tuesday, February 04, 2014 at 06:02:38 PM, Mateusz Zalega wrote:
>> Preprocessor definitions and hardcoded implementation selection in
>> g_dnl core were replaced by a linker list made of (usb_function_name,
>> bind_callback) pairs.
>>
>> Signed-off-by: Mateusz Zalega 
>> Cc: Lukasz Majewski 
>> Cc: Marek Vasut 
> 
> [...]
> 
>> +
>> +/* export dfu_add to g_dnl.o */
>> +ll_entry_declare(struct g_dnl_bind_callback, dfu_bind_callback,
>> +g_dnl_bind_callbacks) = { .usb_function_name = "usb_dnl_dfu",
>> +  .fptr = dfu_add };
> 
> 
> from linker-lists.h quote:
> 
> 104  * ll_entry_declare() - Declare linker-generated array entry
> [...]
> 110  * This macro declares a variable that is placed into a linker-generated
> 111  * array. This is a basic building block for more advanced use of linker-
> 112  * generated arrays. The user is expected to build their own macro wrapper
> 113  * around this one.
> 
> Can you follow this advice and build a macro for declaring these USB devices ?
> btw would you mind fixing the example for ll_entry_declare() in 
> linker-lists.h ? 
> It has four params in the example for some reason (it's a remnant from 
> rework).

Yup

> [...]
> 
>> +static inline struct g_dnl_bind_callback * g_dnl_first_bind_callback(void)
>> +{
>> +return ll_entry_start(struct g_dnl_bind_callback,
>> +g_dnl_bind_callbacks);
>> +}
>> +
>> +static inline struct g_dnl_bind_callback * g_dnl_last_bind_callback(void)
>> +{
>> +return ll_entry_end(struct g_dnl_bind_callback,
>> +g_dnl_bind_callbacks);
>> +}
>> +
> 
> Are these two new functions called from multiple places at all? If not, just 
> inline these ll_foo() calls and be done with it. FYI you can also make macros 
> for these to avoid having to type all these args all around and duplicating 
> the 
> code.

Macros or static inlines, it's all the same, there's no point in
changing that. The symbols aren't visible outside this compilation unit
and function calls are, well, inlined.

>>  static int g_dnl_do_config(struct usb_configuration *c)
>>  {
>>  const char *s = c->cdev->driver->name;
>> -int ret = -1;
>>
>>  debug("%s: configuration: 0x%p composite dev: 0x%p\n",
>> -  __func__, c, c->cdev);
>> -
>> +__func__, c, c->cdev);
>>  printf("GADGET DRIVER: %s\n", s);
>> -if (!strcmp(s, "usb_dnl_dfu"))
>> -ret = dfu_add(c);
>> -else if (!strcmp(s, "usb_dnl_ums"))
>> -ret = fsg_add(c);
>> -else if (!strcmp(s, "usb_dnl_thor"))
>> -ret = thor_add(c);
>> -
>> -return ret;
>> +
>> +struct g_dnl_bind_callback *callback = g_dnl_first_bind_callback();
>> +for (; callback != g_dnl_last_bind_callback(); ++callback)
> 
> callback++ , this is not C++ where the order might matter. Nonetheless, you 
> do 

It doesn't matter anyway and can't be supported on Coding Style grounds,
don't bug me.

> want to use ll_entry_count() and ll_entry_get() with an iterator variable 

I don't think using ll_entry_get() in this way is possible with current
implementation of linker lists. Moreover, there's plenty of code doing
just the same already accepted to U-Boot.

> instead to make sure you don't step onto a corrupted field and crash in some 
> weird way.

Linker would have to split sections to make this sort of thing possible.
Won't happen.

>> +if (!strcmp(s, callback->usb_function_name))
>> +return callback->fptr(c);
>> +return -ENODEV;
>>  }
>>
>>  static int g_dnl_config_register(struct usb_composite_dev *cdev)
>> @@ -203,12 +210,12 @@ static int g_dnl_bind(struct usb_composite_dev *cdev)
>>  device_desc.bcdDevice = cpu_to_le16(gcnum);
>>  else {
>>  debug("%s: controller '%s' not recognized\n",
>> -shortname, gadget->name);
>> +__func__, gadget->name);
>>  device_desc.bcdDevice = __constant_cpu_to_le16(0x);
>>  }
>>
>> -debug("%s: calling usb_gadget_connect for "
>> -"controller '%s'\n", shortname, gadget->name);
>> +debug("%s: calling usb_gadget_connect for controller '%s'\n",
>> +__func__, gadget->name);
> 
> Please split all these cleanups into a separate patch.

Right, I'll post v3.

> [...]
> 

Regards,

-- 
Mateusz Zalega
Samsung R&D Institute Poland
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2 6/8] cmd_mmc.c: Add 'partconf' command to mmc

2014-02-05 Thread Tom Rini
On Tue, Feb 04, 2014 at 09:58:06AM +0900, Jaehoon Chung wrote:
> On 01/31/2014 06:31 AM, Tom Rini wrote:
> > Add a partconf sub-command to the mmc command to allow for setting
> > the boot_ack, boot_partition and partition_access fields of
> > PARTITION_CONFIG (formerly BOOT_CONFIG, EXT_CSD[179]).  Part of this
> > requires changing the check for 'part' from an strncmp to a strcmp, like
> > the rest of the sub-commands.
[snip]
> > @@ -451,6 +477,8 @@ U_BOOT_CMD(
> > " - Enable boot_part for booting and disable access to boot_part\n"
> > "mmc bootpart-resize   \n"
> > " - Change sizes of boot and RPMB partitions of specified device\n"
> > +   "mmc partconf dev boot_ack boot_partition partition_access\n"
> 
> How about using bracket("< >") for more readable?
> mmc partconf

Except for bootpart-resize the rest of the mmc commands (and most in
general) don't use "< >" around required parameters unless it's part of
some sub-choices (such as spl export  ...).

> Anyway, looks good to me.

Thanks!

-- 
Tom


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


[U-Boot] [PATCH] board: Add support for B&R T-Series Motherboard

2014-02-05 Thread Hannes Petermaier
Adds support for Bernecker & Rainer Industrieelektronik GmbH T-Series
Motherboard, using TI's AM3352 SoC.

Most of code is derived from TI's AM335x_EVM

Signed-off-by: Hannes Petermaier 
---
 board/BuR/bur_tseries/Makefile   |   13 +
 board/BuR/bur_tseries/board.c|  333 +
 board/BuR/bur_tseries/board.h|   18 ++
 board/BuR/bur_tseries/mux.c  |  224 +
 board/BuR/bur_tseries/u-boot.lds |  101 
 include/configs/bur_tseries.h|  512 ++
 6 files changed, 1201 insertions(+)
 create mode 100644 board/BuR/bur_tseries/Makefile
 create mode 100644 board/BuR/bur_tseries/board.c
 create mode 100644 board/BuR/bur_tseries/board.h
 create mode 100644 board/BuR/bur_tseries/mux.c
 create mode 100644 board/BuR/bur_tseries/u-boot.lds
 create mode 100644 include/configs/bur_tseries.h

diff --git a/board/BuR/bur_tseries/Makefile b/board/BuR/bur_tseries/Makefile
new file mode 100644
index 000..af45c2c
--- /dev/null
+++ b/board/BuR/bur_tseries/Makefile
@@ -0,0 +1,13 @@
+#
+# Makefile
+#
+# Copyright (C) 2013 Hannes Petermaier 
+# Bernecker & Rainer Industrieelektronik GmbH - http://www.br-automation.com
+#
+# SPDX-License-Identifier: GPL-2.0+
+#
+
+ifeq ($(CONFIG_SPL_BUILD)$(CONFIG_NOR_BOOT),y)
+obj-y  := mux.o
+endif
+obj-y  += board.o
diff --git a/board/BuR/bur_tseries/board.c b/board/BuR/bur_tseries/board.c
new file mode 100644
index 000..46ccc92
--- /dev/null
+++ b/board/BuR/bur_tseries/board.c
@@ -0,0 +1,333 @@
+/*
+ * board.c
+ *
+ * Board functions for B&R LEIT Board
+ *
+ * Copyright (C) 2013 Hannes Petermaier 
+ * Bernecker & Rainer Industrieelektronik GmbH - http://www.br-automation.com
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ *
+ * 04.02.2014  hpm very first board support for T-SERIES,
+ * based on board/ti/am335x/board.c
+ */
+
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "board.h"
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE;
+
+/* --*/
+/* -- defines for GPIO -- */
+#defineETHLED_ORANGE   (96+16) /* GPIO3_16 */
+#defineREPSWITCH   (0+20)  /* GPIO0_20 */
+
+
+#if defined(CONFIG_SPL_BUILD)
+/* TODO: check ram-timing ! */
+static const struct ddr_data ddr3_data = {
+   .datardsratio0 = MT41K256M16HA125E_RD_DQS,
+   .datawdsratio0 = MT41K256M16HA125E_WR_DQS,
+   .datafwsratio0 = MT41K256M16HA125E_PHY_FIFO_WE,
+   .datawrsratio0 = MT41K256M16HA125E_PHY_WR_DATA,
+};
+
+static const struct cmd_control ddr3_cmd_ctrl_data = {
+   .cmd0csratio = MT41K256M16HA125E_RATIO,
+   .cmd0iclkout = MT41K256M16HA125E_INVERT_CLKOUT,
+
+   .cmd1csratio = MT41K256M16HA125E_RATIO,
+   .cmd1iclkout = MT41K256M16HA125E_INVERT_CLKOUT,
+
+   .cmd2csratio = MT41K256M16HA125E_RATIO,
+   .cmd2iclkout = MT41K256M16HA125E_INVERT_CLKOUT,
+};
+
+static struct emif_regs ddr3_emif_reg_data = {
+   .sdram_config = MT41K256M16HA125E_EMIF_SDCFG,
+   .ref_ctrl = MT41K256M16HA125E_EMIF_SDREF,
+   .sdram_tim1 = MT41K256M16HA125E_EMIF_TIM1,
+   .sdram_tim2 = MT41K256M16HA125E_EMIF_TIM2,
+   .sdram_tim3 = MT41K256M16HA125E_EMIF_TIM3,
+   .zq_config = MT41K256M16HA125E_ZQ_CFG,
+   .emif_ddr_phy_ctlr_1 = MT41K256M16HA125E_EMIF_READ_LATENCY,
+};
+const struct ctrl_ioregs ddr3_ioregs = {
+   .cm0ioctl = MT41K256M16HA125E_IOCTRL_VALUE,
+   .cm1ioctl = MT41K256M16HA125E_IOCTRL_VALUE,
+   .cm2ioctl = MT41K256M16HA125E_IOCTRL_VALUE,
+   .dt0ioctl = MT41K256M16HA125E_IOCTRL_VALUE,
+   .dt1ioctl = MT41K256M16HA125E_IOCTRL_VALUE,
+};
+
+static void blink(unsigned char blinks, unsigned int intervall)
+{
+   gpio_direction_output(ETHLED_ORANGE, 0);
+   int val = 0;
+
+   do {
+   val ^= 0x01;
+   gpio_set_value(ETHLED_ORANGE, val);
+   mdelay(intervall);
+   } while (blinks--);
+
+   gpio_set_value(ETHLED_ORANGE, 0);
+}
+#ifdef CONFIG_SPL_OS_BOOT
+/*
+ * called from spl_nand.c
+ * return 0 for loading linux, return 1 for loading u-boot
+ */
+int spl_start_uboot(void)
+{
+   if (0 == gpio_get_value(REPSWITCH)) {
+   blink(5, 125);
+   mdelay(1000);
+   printf("SPL: entering u-boot instead kernel image.\n");
+   return 1;
+   }
+   return 0;
+}
+#endif /* CONFIG_SPL_OS_BOOT */
+
+#define OSC(V_OSCK/100)
+const struct dpll_params dpll_ddr3 = {
+   400, OSC-1, 1, -1, -1, -1, -1};
+
+void am33xx_spl_board_init(void)
+{
+   int mpu_vdd;
+   int usb_cur_lim;
+
+   /* setup I2C */
+   enable_i2c0_pin_mux();
+   i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED, CONFIG_SYS_OMA

Re: [U-Boot] NAND bad block table

2014-02-05 Thread Michal Simek
On 02/04/2014 09:46 PM, Scott Wood wrote:
> On Tue, 2014-02-04 at 13:43 +0100, Michal Simek wrote:
>> Hi Scott and others,
>>
>> I have a question regarding BBT position and number of blocks allocated
>> for BBT.
>>
>> Did you face the issue with last 4 blocks broken in any NAND flash
>> device since the default option in Linux/u-boot BBM is last 4 blocks?
>>
>> It doesn't mean that if the last 4 blocks are broken than the NAND flash
>> device is broken too.
>> Also I haven't seen any common binding for Linux kernel to change it.
>>
>> Has someone tried to improve this algorithm or process of storing BBT in a 
>> better way.
>> For example just look for BBT from the end till any limit?
> 
> I don't recall if I've ever tested it personally, but that sort of
> scanning is already there.  Have you seen a problem with it?

We have met with nand device which has broken last 4 blocks and
u-boot and linux just scan last 4 blocks by default.

In connection to Linux. Interesting is that there is no binding
for extending scan blocks and this has to be done through driver
properties.

Thanks,
Michal

-- 
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Microblaze cpu - http://www.monstr.eu/fdt/
Maintainer of Linux kernel - Xilinx Zynq ARM architecture
Microblaze U-BOOT custodian and responsible for u-boot arm zynq platform




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


[U-Boot] [PATCH v3 4/8] cmd_mmc.c: Add 'partconf' command to mmc

2014-02-05 Thread Tom Rini
Add a partconf sub-command to the mmc command to allow for setting
the boot_ack, boot_partition and partition_access fields of
PARTITION_CONFIG (formerly BOOT_CONFIG, EXT_CSD[179]).  Part of this
requires changing the check for 'part' from an strncmp to a strcmp, like
the rest of the sub-commands.

Cc: Andy Fleming 
Cc: Pantelis Antoniou 
Acked-by: Jaehoon Chung 
Signed-off-by: Tom Rini 
---
 common/cmd_mmc.c  |   30 +-
 drivers/mmc/mmc.c |   21 +
 include/mmc.h |2 ++
 3 files changed, 52 insertions(+), 1 deletion(-)

diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c
index a322063..5842e85 100644
--- a/common/cmd_mmc.c
+++ b/common/cmd_mmc.c
@@ -195,7 +195,7 @@ static int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, 
char * const argv[])
return 1;
else
return 0;
-   } else if (strncmp(argv[1], "part", 4) == 0) {
+   } else if (strcmp(argv[1], "part") == 0) {
block_dev_desc_t *mmc_dev;
struct mmc *mmc;
 
@@ -311,7 +311,33 @@ static int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, 
char * const argv[])
 
/* acknowledge to be sent during boot operation */
return boot_part_access(mmc, 1, part_num, access);
+   } else if (strcmp(argv[1], "partconf") == 0) {
+   int dev;
+   struct mmc *mmc;
+   u8 ack, part_num, access;
+
+   if (argc == 6) {
+   dev = simple_strtoul(argv[2], NULL, 10);
+   ack = simple_strtoul(argv[3], NULL, 10);
+   part_num = simple_strtoul(argv[4], NULL, 10);
+   access = simple_strtoul(argv[5], NULL, 10);
+   } else {
+   return CMD_RET_USAGE;
+   }
+
+   mmc = find_mmc_device(dev);
+   if (!mmc) {
+   printf("no mmc device at slot %x\n", dev);
+   return 1;
+   }
 
+   if (IS_SD(mmc)) {
+   puts("PARTITION_CONFIG only exists on eMMC\n");
+   return 1;
+   }
+
+   /* acknowledge to be sent during boot operation */
+   return mmc_set_part_conf(mmc, ack, part_num, access);
} else if (strcmp(argv[1], "bootpart-resize") == 0) {
int dev;
struct mmc *mmc;
@@ -451,6 +477,8 @@ U_BOOT_CMD(
" - Enable boot_part for booting and disable access to boot_part\n"
"mmc bootpart-resize   \n"
" - Change sizes of boot and RPMB partitions of specified device\n"
+   "mmc partconf dev boot_ack boot_partition partition_access\n"
+   " - Change the bits of the PARTITION_CONFIG field of the specified 
device\n"
 #endif
"mmc setdsr - set DSR register value\n"
);
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index c6a1c23..1591fce 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -1505,4 +1505,25 @@ int mmc_boot_part_access(struct mmc *mmc, u8 ack, u8 
part_num, u8 access)
}
return 0;
 }
+
+/*
+ * Modify EXT_CSD[179] which is PARTITION_CONFIG (formerly BOOT_CONFIG)
+ * based on the passed in values for BOOT_ACK, BOOT_PARTITION_ENABLE and
+ * PARTITION_ACCESS.
+ *
+ * Returns 0 on success.
+ */
+int mmc_set_part_conf(struct mmc *mmc, u8 ack, u8 part_num, u8 access)
+{
+   int err;
+
+   err = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_PART_CONF,
+EXT_CSD_BOOT_ACK(ack) |
+EXT_CSD_BOOT_PART_NUM(part_num) |
+EXT_CSD_PARTITION_ACCESS(access));
+
+   if (err)
+   return err;
+   return 0;
+}
 #endif
diff --git a/include/mmc.h b/include/mmc.h
index e1060b9..7e026da 100644
--- a/include/mmc.h
+++ b/include/mmc.h
@@ -312,6 +312,8 @@ int mmc_boot_partition_size_change(struct mmc *mmc, 
unsigned long bootsize,
unsigned long rpmbsize);
 /* Function to send commands to open/close the specified boot partition */
 int mmc_boot_part_access(struct mmc *mmc, u8 ack, u8 part_num, u8 access);
+/* Function to modify the PARTITION_CONFIG field of EXT_CSD */
+int mmc_set_part_conf(struct mmc *mmc, u8 ack, u8 part_num, u8 access);
 
 /**
  * Start device initialization and return immediately; it does not block on
-- 
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/8] cmd_mmc.c: Change 'bootpart' code to match normal coding style

2014-02-05 Thread Tom Rini
Acked-by: Jaehoon Chung 
Signed-off-by: Tom Rini 
---
 common/cmd_mmc.c |   15 +++
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c
index da5fef9..e118252 100644
--- a/common/cmd_mmc.c
+++ b/common/cmd_mmc.c
@@ -314,11 +314,18 @@ static int do_mmcops(cmd_tbl_t *cmdtp, int flag, int 
argc, char * const argv[])
 
} else if (strcmp(argv[1], "bootpart") == 0) {
int dev;
-   dev = simple_strtoul(argv[2], NULL, 10);
+   struct *mmc;
+   u32 bootsize, rpmbsize;
 
-   u32 bootsize = simple_strtoul(argv[3], NULL, 10);
-   u32 rpmbsize = simple_strtoul(argv[4], NULL, 10);
-   struct mmc *mmc = find_mmc_device(dev);
+   if (argc == 5) {
+   dev = simple_strtoul(argv[2], NULL, 10);
+   bootsize = simple_strtoul(argv[3], NULL, 10);
+   rpmbsize = simple_strtoul(argv[4], NULL, 10);
+   } else {
+   return CMD_RET_USAGE;
+   }
+
+   mmc = find_mmc_device(dev);
if (!mmc) {
printf("no mmc device at slot %x\n", dev);
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 5/8] cmd_mmc.c: Add bootbus mmc sub-command

2014-02-05 Thread Tom Rini
Add a bootbus sub-command to the mmc command to allow for setting
the boot_bus_width, reset_boot_bus_width and boot_mode fields of
BOOT_BUS_WIDTH (EXT_CSD[177]).

Acked-by: Jaehoon Chung 
Signed-off-by: Tom Rini 
---
 common/cmd_mmc.c  |   29 +
 drivers/mmc/mmc.c |   21 +
 include/mmc.h |5 +
 3 files changed, 55 insertions(+)

diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c
index 5842e85..a028149 100644
--- a/common/cmd_mmc.c
+++ b/common/cmd_mmc.c
@@ -338,6 +338,33 @@ static int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, 
char * const argv[])
 
/* acknowledge to be sent during boot operation */
return mmc_set_part_conf(mmc, ack, part_num, access);
+   } else if (strcmp(argv[1], "bootbus") == 0) {
+   int dev;
+   struct mmc *mmc;
+   u8 width, reset, mode;
+
+   if (argc == 6) {
+   dev = simple_strtoul(argv[2], NULL, 10);
+   width = simple_strtoul(argv[3], NULL, 10);
+   reset = simple_strtoul(argv[4], NULL, 10);
+   mode = simple_strtoul(argv[5], NULL, 10);
+   } else {
+   return CMD_RET_USAGE;
+   }
+
+   mmc = find_mmc_device(dev);
+   if (!mmc) {
+   printf("no mmc device at slot %x\n", dev);
+   return 1;
+   }
+
+   if (IS_SD(mmc)) {
+   puts("BOOT_BUS_WIDTH only exists on eMMC\n");
+   return 1;
+   }
+
+   /* acknowledge to be sent during boot operation */
+   return mmc_set_boot_bus_width(mmc, width, reset, mode);
} else if (strcmp(argv[1], "bootpart-resize") == 0) {
int dev;
struct mmc *mmc;
@@ -475,6 +502,8 @@ U_BOOT_CMD(
" - Enable boot_part for booting and enable R/W access of boot_part\n"
"mmc close  \n"
" - Enable boot_part for booting and disable access to boot_part\n"
+   "mmc bootbus dev boot_bus_width reset_boot_bus_width boot_mode\n"
+   " - Set the BOOT_BUS_WIDTH field of the specified device\n"
"mmc bootpart-resize   \n"
" - Change sizes of boot and RPMB partitions of specified device\n"
"mmc partconf dev boot_ack boot_partition partition_access\n"
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 1591fce..fc1c1dc 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -1507,6 +1507,27 @@ int mmc_boot_part_access(struct mmc *mmc, u8 ack, u8 
part_num, u8 access)
 }
 
 /*
+ * Modify EXT_CSD[177] which is BOOT_BUS_WIDTH
+ * based on the passed in values for BOOT_BUS_WIDTH, RESET_BOOT_BUS_WIDTH
+ * and BOOT_MODE.
+ *
+ * Returns 0 on success.
+ */
+int mmc_set_boot_bus_width(struct mmc *mmc, u8 width, u8 reset, u8 mode)
+{
+   int err;
+
+   err = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_BOOT_BUS_WIDTH,
+EXT_CSD_BOOT_BUS_WIDTH_MODE(mode) |
+EXT_CSD_BOOT_BUS_WIDTH_RESET(reset) |
+EXT_CSD_BOOT_BUS_WIDTH_WIDTH(width));
+
+   if (err)
+   return err;
+   return 0;
+}
+
+/*
  * Modify EXT_CSD[179] which is PARTITION_CONFIG (formerly BOOT_CONFIG)
  * based on the passed in values for BOOT_ACK, BOOT_PARTITION_ENABLE and
  * PARTITION_ACCESS.
diff --git a/include/mmc.h b/include/mmc.h
index 7e026da..3594286 100644
--- a/include/mmc.h
+++ b/include/mmc.h
@@ -187,6 +187,9 @@
 #define EXT_CSD_BOOT_PART_NUM(x)   (x << 3)
 #define EXT_CSD_PARTITION_ACCESS(x)(x << 0)
 
+#define EXT_CSD_BOOT_BUS_WIDTH_MODE(x) (x << 3)
+#define EXT_CSD_BOOT_BUS_WIDTH_RESET(x)(x << 2)
+#define EXT_CSD_BOOT_BUS_WIDTH_WIDTH(x)(x)
 
 #define R1_ILLEGAL_COMMAND (1 << 22)
 #define R1_APP_CMD (1 << 5)
@@ -314,6 +317,8 @@ int mmc_boot_partition_size_change(struct mmc *mmc, 
unsigned long bootsize,
 int mmc_boot_part_access(struct mmc *mmc, u8 ack, u8 part_num, u8 access);
 /* Function to modify the PARTITION_CONFIG field of EXT_CSD */
 int mmc_set_part_conf(struct mmc *mmc, u8 ack, u8 part_num, u8 access);
+/* Function to modify the BOOT_BUS_WIDTH field of EXT_CSD */
+int mmc_set_boot_bus_width(struct mmc *mmc, u8 width, u8 reset, u8 mode);
 
 /**
  * Start device initialization and return immediately; it does not block on
-- 
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/8] SPL: Add CONFIG_SUPPORT_EMMC_BOOT support to CONFIG_SPL_FRAMEWORK

2014-02-05 Thread Tom Rini
We use the switch CONFIG_SUPPORT_EMMC_BOOT today to enable some
additional features of the eMMC boot partitions.  Add support for being
told that we have booted from one of these partitions to the spl
framework and implement this on TI OMAP/related.

Cc: Pantelis Antoniou 
Signed-off-by: Tom Rini 
---
Changes in v3:
- Rework eMMC boot detect logic for TI platforms, in the eMMC boot case
  we rely on non-FAT/RAW values being in bootmode.
---
 arch/arm/cpu/armv7/omap-common/boot-common.c |   13 -
 common/spl/spl_mmc.c |   24 
 include/spl.h|1 +
 3 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/arch/arm/cpu/armv7/omap-common/boot-common.c 
b/arch/arm/cpu/armv7/omap-common/boot-common.c
index 69fff32..52e0f4a 100644
--- a/arch/arm/cpu/armv7/omap-common/boot-common.c
+++ b/arch/arm/cpu/armv7/omap-common/boot-common.c
@@ -66,7 +66,18 @@ u32 spl_boot_device(void)
 
 u32 spl_boot_mode(void)
 {
-   return gd->arch.omap_boot_params.omap_bootmode;
+   u32 val = gd->arch.omap_boot_params.omap_bootmode;
+
+   if (val == MMCSD_MODE_RAW)
+   return MMCSD_MODE_RAW;
+   else if (val == MMCSD_MODE_FAT)
+   return MMCSD_MODE_FAT;
+   else
+#ifdef CONFIG_SUPPORT_EMMC_BOOT
+   return MMCSD_MODE_EMMCBOOT;
+#else
+   return MMCSD_MODE_UNDEFINED;
+#endif
 }
 
 void spl_board_init(void)
diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c
index 13fbff0..fa6f891 100644
--- a/common/spl/spl_mmc.c
+++ b/common/spl/spl_mmc.c
@@ -111,6 +111,30 @@ void spl_mmc_load_image(void)
CONFIG_SYS_MMC_SD_FAT_BOOT_PARTITION,
CONFIG_SPL_FAT_LOAD_PAYLOAD_NAME);
 #endif
+#ifdef CONFIG_SUPPORT_EMMC_BOOT
+   } else if (boot_mode == MMCSD_MODE_EMMCBOOT) {
+   /*
+* We need to check what the partition is configured to.
+* 1 and 2 match up to boot0 / boot1 and 7 is user data
+* which is the first physical partition (0).
+*/
+   int part = (mmc->part_config >> 3) & PART_ACCESS_MASK;
+
+   if (part == 7)
+   part = 0;
+
+   if (mmc_switch_part(0, part)) {
+#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
+   puts("MMC partition switch failed\n");
+#endif
+   hang();
+   }
+#ifdef CONFIG_SPL_OS_BOOT
+   if (spl_start_uboot() || mmc_load_image_raw_os(mmc))
+#endif
+   err = mmc_load_image_raw(mmc,
+   CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR);
+#endif
} else {
 #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
puts("spl: wrong MMC boot mode\n");
diff --git a/include/spl.h b/include/spl.h
index 5e24856..dad00c0 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -16,6 +16,7 @@
 #define MMCSD_MODE_UNDEFINED   0
 #define MMCSD_MODE_RAW 1
 #define MMCSD_MODE_FAT 2
+#define MMCSD_MODE_EMMCBOOT3
 
 struct spl_image_info {
const char *name;
-- 
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 7/8] omap5_uevm: Add CONFIG_SUPPORT_EMMC_BOOT, document usage

2014-02-05 Thread Tom Rini
Add a README to the board which lists the commands required to enable
booting from the eMMC boot partitions found on the board.

Signed-off-by: Tom Rini 
---
 board/ti/omap5_uevm/README   |   25 +
 include/configs/omap5_uevm.h |1 +
 2 files changed, 26 insertions(+)
 create mode 100644 board/ti/omap5_uevm/README

diff --git a/board/ti/omap5_uevm/README b/board/ti/omap5_uevm/README
new file mode 100644
index 000..970e2ec
--- /dev/null
+++ b/board/ti/omap5_uevm/README
@@ -0,0 +1,25 @@
+Summary
+===
+
+This document covers various features of the 'omap5_uevm' build and some
+related uses.
+
+eMMC boot partition use
+===
+
+It is possible, depending on SYSBOOT configuration to boot from the eMMC
+boot partitions using (name depending on documentation referenced)
+Alternative Boot operation mode or Boot Sequence Option 1/2.  In this
+example we load MLO and u-boot.img from the build into DDR and then use
+'mmc bootbus' to set the required rate (see TRM) and 'mmc partconfig' to
+set boot0 as the boot device.
+U-Boot # setenv autoload no
+U-Boot # usb start
+U-Boot # dhcp
+U-Boot # mmc dev 1 1
+U-Boot # tftp ${loadaddr} omap5uevm/MLO
+U-Boot # mmc write ${loadaddr} 0 100
+U-Boot # tftp ${loadaddr} omap5uevm/u-boot.img
+U-Boot # mmc write ${loadaddr} 300 400
+U-Boot # mmc bootbus 1 2 0 2
+U-Boot # mmc partconf 1 1 1 0
diff --git a/include/configs/omap5_uevm.h b/include/configs/omap5_uevm.h
index 76c5106..3df502e 100644
--- a/include/configs/omap5_uevm.h
+++ b/include/configs/omap5_uevm.h
@@ -37,6 +37,7 @@
 #define CONFIG_PARTITION_UUIDS
 #define CONFIG_CMD_PART
 #define CONFIG_HSMMC2_8BIT
+#define CONFIG_SUPPORT_EMMC_BOOT
 
 /* Required support for the TCA642X GPIO we have on the uEVM */
 #define CONFIG_TCA642X
-- 
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/8] cmd_mmc.c: Rename 'bootpart' to 'bootpart-resize'

2014-02-05 Thread Tom Rini
Rename 'bootpart' to 'bootpart-resize' to better reflect what this
command is for.

Acked-by: Jaehoon Chung 
Signed-off-by: Tom Rini 
---
 common/cmd_mmc.c |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c
index e118252..a322063 100644
--- a/common/cmd_mmc.c
+++ b/common/cmd_mmc.c
@@ -312,9 +312,9 @@ static int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, 
char * const argv[])
/* acknowledge to be sent during boot operation */
return boot_part_access(mmc, 1, part_num, access);
 
-   } else if (strcmp(argv[1], "bootpart") == 0) {
+   } else if (strcmp(argv[1], "bootpart-resize") == 0) {
int dev;
-   struct *mmc;
+   struct mmc *mmc;
u32 bootsize, rpmbsize;
 
if (argc == 5) {
@@ -449,8 +449,8 @@ U_BOOT_CMD(
" - Enable boot_part for booting and enable R/W access of boot_part\n"
"mmc close  \n"
" - Enable boot_part for booting and disable access to boot_part\n"
-   "mmc bootpart   \n"
-   " - change sizes of boot and RPMB partitions of specified device\n"
+   "mmc bootpart-resize   \n"
+   " - Change sizes of boot and RPMB partitions of specified device\n"
 #endif
"mmc setdsr - set DSR register value\n"
);
-- 
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 8/8] dra7xx_evm: Add CONFIG_SUPPORT_EMMC_BOOT, document usage

2014-02-05 Thread Tom Rini
Add a README to the board which lists the commands required to enable
booting from the eMMC boot partitions found on the board.

Cc: Lokesh Vutla 
Signed-off-by: Tom Rini 
---
 board/ti/dra7xx/README   |   25 +
 include/configs/dra7xx_evm.h |2 ++
 2 files changed, 27 insertions(+)
 create mode 100644 board/ti/dra7xx/README

diff --git a/board/ti/dra7xx/README b/board/ti/dra7xx/README
new file mode 100644
index 000..2fdaeac
--- /dev/null
+++ b/board/ti/dra7xx/README
@@ -0,0 +1,25 @@
+Summary
+===
+
+This document covers various features of the 'dra7xx_evm' build and some
+related uses.
+
+eMMC boot partition use
+===
+
+It is possible, depending on SYSBOOT configuration to boot from the eMMC
+boot partitions using (name depending on documentation referenced)
+Alternative Boot operation mode or Boot Sequence Option 1/2.  In this
+example we load MLO and u-boot.img from the build into DDR and then use
+'mmc bootbus' to set the required rate (see TRM) and 'mmc partconfig' to
+set boot0 as the boot device.
+U-Boot # setenv autoload no
+U-Boot # usb start
+U-Boot # dhcp
+U-Boot # mmc dev 1 1
+U-Boot # tftp ${loadaddr} dra7xx/MLO
+U-Boot # mmc write ${loadaddr} 0 100
+U-Boot # tftp ${loadaddr} dra7xx/u-boot.img
+U-Boot # mmc write ${loadaddr} 300 400
+U-Boot # mmc bootbus 1 2 0 2
+U-Boot # mmc partconf 1 1 1 0
diff --git a/include/configs/dra7xx_evm.h b/include/configs/dra7xx_evm.h
index f210ed8..3c53f0a 100644
--- a/include/configs/dra7xx_evm.h
+++ b/include/configs/dra7xx_evm.h
@@ -73,6 +73,8 @@
 #define CONFIG_SPL_SPI_CS  0
 #define CONFIG_SYS_SPI_U_BOOT_OFFS 0x2
 
+#define CONFIG_SUPPORT_EMMC_BOOT
+
 /* USB xHCI HOST */
 #define CONFIG_CMD_USB
 #define CONFIG_USB_HOST
-- 
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 6/8] cmd_mmc.c: Drop open/close mmc sub-commands

2014-02-05 Thread Tom Rini
The open and close mmc sub-commands implement a hard-coded set of values
specific to the SMDK5250 platform.  Remove these commands as what they
did can be done instead with a series of mmc dev / bootpart / bootbus
commands instead now.

Cc: Amar 
Cc: Minkyu Kang 
Acked-by: Jaehoon Chung 
Signed-off-by: Tom Rini 
---
 common/cmd_mmc.c  |   72 -
 drivers/mmc/mmc.c |   65 ---
 include/mmc.h |2 --
 3 files changed, 139 deletions(-)

diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c
index a028149..2d51927 100644
--- a/common/cmd_mmc.c
+++ b/common/cmd_mmc.c
@@ -131,36 +131,6 @@ U_BOOT_CMD(
"- display info of the current MMC device"
 );
 
-#ifdef CONFIG_SUPPORT_EMMC_BOOT
-static int boot_part_access(struct mmc *mmc, u8 ack, u8 part_num, u8 access)
-{
-   int err;
-   err = mmc_boot_part_access(mmc, ack, part_num, access);
-
-   if ((err == 0) && (access != 0)) {
-   printf("\t\t\t!!!Notice!!!\n");
-
-   printf("!You must close EMMC boot Partition");
-   printf("after all images are written\n");
-
-   printf("!EMMC boot partition has continuity");
-   printf("at image writing time.\n");
-
-   printf("!So, do not close the boot partition");
-   printf("before all images are written.\n");
-   return 0;
-   } else if ((err == 0) && (access == 0))
-   return 0;
-   else if ((err != 0) && (access != 0)) {
-   printf("EMMC boot partition-%d OPEN Failed.\n", part_num);
-   return 1;
-   } else {
-   printf("EMMC boot partition-%d CLOSE Failed.\n", part_num);
-   return 1;
-   }
-}
-#endif
-
 static int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
enum mmc_state state;
@@ -273,44 +243,6 @@ static int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, 
char * const argv[])
 
return 0;
 #ifdef CONFIG_SUPPORT_EMMC_BOOT
-   } else if ((strcmp(argv[1], "open") == 0) ||
-   (strcmp(argv[1], "close") == 0)) {
-   int dev;
-   struct mmc *mmc;
-   u8 part_num, access = 0;
-
-   if (argc == 4) {
-   dev = simple_strtoul(argv[2], NULL, 10);
-   part_num = simple_strtoul(argv[3], NULL, 10);
-   } else {
-   return CMD_RET_USAGE;
-   }
-
-   mmc = find_mmc_device(dev);
-   if (!mmc) {
-   printf("no mmc device at slot %x\n", dev);
-   return 1;
-   }
-
-   if (IS_SD(mmc)) {
-   printf("SD device cannot be opened/closed\n");
-   return 1;
-   }
-
-   if ((part_num <= 0) || (part_num > MMC_NUM_BOOT_PARTITION)) {
-   printf("Invalid boot partition number:\n");
-   printf("Boot partition number cannot be <= 0\n");
-   printf("EMMC44 supports only 2 boot partitions\n");
-   return 1;
-   }
-
-   if (strcmp(argv[1], "open") == 0)
-   access = part_num; /* enable R/W access to boot part*/
-   else
-   access = 0; /* No access to boot partition */
-
-   /* acknowledge to be sent during boot operation */
-   return boot_part_access(mmc, 1, part_num, access);
} else if (strcmp(argv[1], "partconf") == 0) {
int dev;
struct mmc *mmc;
@@ -498,10 +430,6 @@ U_BOOT_CMD(
"mmc dev [dev] [part] - show or set current mmc device [partition]\n"
"mmc list - lists available devices\n"
 #ifdef CONFIG_SUPPORT_EMMC_BOOT
-   "mmc open  \n"
-   " - Enable boot_part for booting and enable R/W access of boot_part\n"
-   "mmc close  \n"
-   " - Enable boot_part for booting and disable access to boot_part\n"
"mmc bootbus dev boot_bus_width reset_boot_bus_width boot_mode\n"
" - Set the BOOT_BUS_WIDTH field of the specified device\n"
"mmc bootpart-resize   \n"
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index fc1c1dc..3a57ab8 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -1442,71 +1442,6 @@ int mmc_boot_partition_size_change(struct mmc *mmc, 
unsigned long bootsize,
 }
 
 /*
- * This function shall form and send the commands to open / close the
- * boot partition specified by user.
- *
- * Input Parameters:
- * ack: 0x0 - No boot acknowledge sent (default)
- * 0x1 - Boot acknowledge sent during boot operation
- * part_num: User selects boot data that will be sent to master
- * 0x0 - Device not boot enabled (default)
- * 0x1 - Boot partition 1 enabled for boot
- * 0x2 - Boot partition 2 enabled for boot
- * access: User selec

Re: [U-Boot] [PATCH V3 2/3] ARM: tegra: rework boot scripts

2014-02-05 Thread Stephen Warren
On 02/05/2014 02:16 AM, Andreas Färber wrote:
> Am 04.02.2014 23:59, schrieb Stephen Warren:
>> From: Stephen Warren 
>>
>> Update the common Tegra boot scripts in the default environment to
>>
>> a) Make use of the new "exists" shell command to avoid some error
>>messges.
>>
>> b) Allow booting using the sysboot command and extlinux.conf. This
>>allows easy creation of boot menus, and provides a simple interface
>>for distros to parameterize/configure the boot process.

>> diff --git a/include/configs/tegra-common-post.h 
>> b/include/configs/tegra-common-post.h

>>  "script_boot="\
>> -"if load ${devtype} ${devnum}:${rootpart} "   \
>> -"${scriptaddr} ${prefix}${script}; then " \
>> -"echo ${script} found! Executing ...;"\
>> -"source ${scriptaddr};"   \
>> -"fi;\0"   \
>> +"for script in ${boot_scripts}; do "  \
>> +"if test -e ${devtype} ${devnum}:${rootpart} "\
>> +"${prefix}${script}; then "   \
>> +"echo Found U-Boot script "   \
>> +"${prefix}${script}; "\
>> +"run do_script_boot;" \
>> +"echo SCRIPT FAILED; continuing...; " \
> 
> This is not going to work, "continuing..." would be treated as command.

But I tested it:-)

It seems that U-Boot just ignores the unknown command (well, it prints
an error that I didn't notice) and continues on. So, it kinda works but
certainly doesn't do what's intended;-)

Thanks for pointing out the issues. I'll also have to revise the
Raspberry Pi patches that have the same issue.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH V4 2/3] ARM: tegra: rework boot scripts

2014-02-05 Thread Stephen Warren
From: Stephen Warren 

Update the common Tegra boot scripts in the default environment to

a) Make use of the new "test -e" shell command to avoid some error
   messages.

b) Allow booting using the sysboot command and extlinux.conf. This
   allows easy creation of boot menus, and provides a simple interface
   for distros to parameterize/configure the boot process.

Signed-off-by: Stephen Warren 
---
v4:
* Prioritize extlinux.conf over boot.scr.uimg when searching; it makes
  sense to use the cross-distro/-bootloader (hopeful) standard first.
* Replace ; in the middle of echo'd text in boot scripts.
* Add missing space between commands in boot scripts.
* s/exists/test -e/ in commmit description.
v3: s/exists/test -e/ in shell commands.
v2: No change.
---
 include/configs/tegra-common-post.h | 39 -
 1 file changed, 30 insertions(+), 9 deletions(-)

diff --git a/include/configs/tegra-common-post.h 
b/include/configs/tegra-common-post.h
index e1a3bbc62636..3bf55ce428f2 100644
--- a/include/configs/tegra-common-post.h
+++ b/include/configs/tegra-common-post.h
@@ -69,20 +69,41 @@
 #define BOOTCMDS_COMMON \
"rootpart=1\0" \
\
+   "do_script_boot=" \
+   "load ${devtype} ${devnum}:${rootpart} "  \
+   "${scriptaddr} ${prefix}${script}; "  \
+   "source ${scriptaddr}\0"  \
+   \
"script_boot="\
-   "if load ${devtype} ${devnum}:${rootpart} "   \
-   "${scriptaddr} ${prefix}${script}; then " \
-   "echo ${script} found! Executing ...;"\
-   "source ${scriptaddr};"   \
-   "fi;\0"   \
+   "for script in ${boot_scripts}; do "  \
+   "if test -e ${devtype} ${devnum}:${rootpart} "\
+   "${prefix}${script}; then "   \
+   "echo Found U-Boot script "   \
+   "${prefix}${script}; "\
+   "run do_script_boot; "\
+   "echo SCRIPT FAILED: continuing...; " \
+   "fi; "\
+   "done\0"  \
+   \
+   "do_sysboot_boot="\
+   "sysboot ${devtype} ${devnum}:${rootpart} any "   \
+   "${scriptaddr} ${prefix}extlinux.conf\0"  \
+   \
+   "sysboot_boot="   \
+   "if test -e ${devtype} ${devnum}:${rootpart} "\
+   "${prefix}extlinux.conf; then "   \
+   "echo Found extlinux config " \
+   "${prefix}extlinux.conf; "\
+   "run do_sysboot_boot; "   \
+   "echo SCRIPT FAILED: continuing...; " \
+   "fi\0"\
\
"scan_boot="  \
"echo Scanning ${devtype} ${devnum}...; " \
"for prefix in ${boot_prefixes}; do " \
-   "for script in ${boot_scripts}; do "  \
-   "run script_boot; "   \
-   "done; "  \
-   "done;\0" \
+   "run sysboot_boot; "  \
+   "run script_boot; "   \
+   "done\0"  \
\
"boot_targets=" \
BOOT_TARGETS_MMC " " \
-- 
1.8.1.5

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


[U-Boot] [PATCH V4 1/3] ARM: tegra: convert tegra to use distro defaults

2014-02-05 Thread Stephen Warren
From: Stephen Warren 

Modify all Tegra boards to include the "distro defaults" header, so that
all the config options distros expect are enabled. Remove any #defines
that enable the same options from the Tegra files.

Signed-off-by: Stephen Warren 
---
v4: No change.
v3: No change.
v2: No change.

Note: These patches depend on:
a) The very latest u-boot/master, in particular "config:
   add config_distro_defaults.h".
b) The very latest u-boot-tegra/next.

I suggest rebasing u-boot-tegra/next on top of u-boot/master before applying
this series.
---
 include/configs/tegra-common.h | 20 
 1 file changed, 4 insertions(+), 16 deletions(-)

diff --git a/include/configs/tegra-common.h b/include/configs/tegra-common.h
index 522cd4133d77..bbe417a13ec7 100644
--- a/include/configs/tegra-common.h
+++ b/include/configs/tegra-common.h
@@ -29,7 +29,6 @@
 #define CONFIG_DISPLAY_BOARDINFO
 
 #define CONFIG_CMDLINE_TAG /* enable passing of ATAGs */
-#define CONFIG_OF_LIBFDT   /* enable passing of devicetree */
 
 /* Environment */
 #define CONFIG_ENV_VARS_UBOOT_CONFIG
@@ -69,33 +68,20 @@
 #undef CONFIG_CMD_NET  /* network support */
 
 /* turn on command-line edit/hist/auto */
-#define CONFIG_CMDLINE_EDITING
 #define CONFIG_COMMAND_HISTORY
-#define CONFIG_AUTO_COMPLETE
 
 /* turn on commonly used storage-related commands */
-
-#define CONFIG_DOS_PARTITION
-#define CONFIG_EFI_PARTITION
 #define CONFIG_PARTITION_UUIDS
-#define CONFIG_FS_EXT4
-#define CONFIG_FS_FAT
-#define CONFIG_CMD_EXT2
-#define CONFIG_CMD_FAT
-#define CONFIG_CMD_FS_GENERIC
 #define CONFIG_CMD_PART
 
 #define CONFIG_SYS_NO_FLASH
 
 #define CONFIG_CONSOLE_MUX
 #define CONFIG_SYS_CONSOLE_IS_IN_ENV
-#define CONFIG_BOOTDELAY   2   /* -1 to disable auto boot */
 
 /*
  * Miscellaneous configurable options
  */
-#define CONFIG_SYS_LONGHELP/* undef to save memory */
-#define CONFIG_SYS_HUSH_PARSER /* use "hush" command parser */
 #define CONFIG_SYS_PROMPT  V_PROMPT
 /*
  * Increasing the size of the IO buffer as default nfsargs size is more
@@ -133,8 +119,6 @@
 #define CONFIG_TEGRA_GPIO
 #define CONFIG_CMD_GPIO
 #define CONFIG_CMD_ENTERRCM
-#define CONFIG_CMD_BOOTZ
-#define CONFIG_SUPPORT_RAW_INITRD
 
 /* Defines for SPL */
 #define CONFIG_SPL
@@ -157,4 +141,8 @@
 #define CONFIG_BOUNCE_BUFFER
 #define CONFIG_CRC32_VERIFY
 
+#ifndef CONFIG_SPL_BUILD
+#include 
+#endif
+
 #endif /* _TEGRA_COMMON_H_ */
-- 
1.8.1.5

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


[U-Boot] [PATCH V4 3/3] ARM: tegra: implement bootcmd_pxe

2014-02-05 Thread Stephen Warren
From: Stephen Warren 

This retrieves a PXE config file over the network, and executes it. This
allows an extlinux config file  to be retrieved over the network and
executed, whereas the existing bootcmd_dhcp retrieves a U-Boot script.

Signed-off-by: Stephen Warren 
---
v4: No change.
v3: No change.
v2: No change.
---
 include/configs/tegra-common-post.h | 18 +-
 include/configs/tegra114-common.h   |  4 
 include/configs/tegra20-common.h|  4 
 include/configs/tegra30-common.h|  4 
 4 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/include/configs/tegra-common-post.h 
b/include/configs/tegra-common-post.h
index 3bf55ce428f2..76dad4e88cd9 100644
--- a/include/configs/tegra-common-post.h
+++ b/include/configs/tegra-common-post.h
@@ -66,6 +66,20 @@
 #define BOOT_TARGETS_DHCP ""
 #endif
 
+#if defined(CONFIG_CMD_DHCP) && defined(CONFIG_CMD_PXE)
+#define BOOTCMDS_PXE \
+   "bootcmd_pxe=" \
+   BOOTCMD_INIT_USB \
+   "dhcp; " \
+   "if pxe get; then " \
+   "pxe boot; " \
+   "fi\0"
+#define BOOT_TARGETS_PXE "pxe"
+#else
+#define BOOTCMDS_PXE ""
+#define BOOT_TARGETS_PXE ""
+#endif
+
 #define BOOTCMDS_COMMON \
"rootpart=1\0" \
\
@@ -108,6 +122,7 @@
"boot_targets=" \
BOOT_TARGETS_MMC " " \
BOOT_TARGETS_USB " " \
+   BOOT_TARGETS_PXE " " \
BOOT_TARGETS_DHCP " " \
"\0" \
\
@@ -117,7 +132,8 @@
\
BOOTCMDS_MMC \
BOOTCMDS_USB \
-   BOOTCMDS_DHCP
+   BOOTCMDS_DHCP \
+   BOOTCMDS_PXE
 
 #define CONFIG_BOOTCOMMAND \
"set usb_need_init; " \
diff --git a/include/configs/tegra114-common.h 
b/include/configs/tegra114-common.h
index 1bf5af5b3830..bff5447fe421 100644
--- a/include/configs/tegra114-common.h
+++ b/include/configs/tegra114-common.h
@@ -46,6 +46,9 @@
  * scriptaddr can be pretty much anywhere that doesn't conflict with something
  *   else. Put it above BOOTMAPSZ to eliminate conflicts.
  *
+ * pxefile_addr_r can be pretty much anywhere that doesn't conflict with
+ *   something else. Put it above BOOTMAPSZ to eliminate conflicts.
+ *
  * kernel_addr_r must be within the first 128M of RAM in order for the
  *   kernel's CONFIG_AUTO_ZRELADDR option to work. Since the kernel will
  *   decompress itself to 0x8000 after the start of RAM, kernel_addr_r
@@ -63,6 +66,7 @@
  */
 #define MEM_LAYOUT_ENV_SETTINGS \
"scriptaddr=0x9000\0" \
+   "pxefile_addr_r=0x9010\0" \
"kernel_addr_r=0x8100\0" \
"fdt_addr_r=0x8200\0" \
"ramdisk_addr_r=0x8210\0"
diff --git a/include/configs/tegra20-common.h b/include/configs/tegra20-common.h
index d2c45321b46a..933130a405da 100644
--- a/include/configs/tegra20-common.h
+++ b/include/configs/tegra20-common.h
@@ -44,6 +44,9 @@
  * scriptaddr can be pretty much anywhere that doesn't conflict with something
  *   else. Put it above BOOTMAPSZ to eliminate conflicts.
  *
+ * pxefile_addr_r can be pretty much anywhere that doesn't conflict with
+ *   something else. Put it above BOOTMAPSZ to eliminate conflicts.
+ *
  * kernel_addr_r must be within the first 128M of RAM in order for the
  *   kernel's CONFIG_AUTO_ZRELADDR option to work. Since the kernel will
  *   decompress itself to 0x8000 after the start of RAM, kernel_addr_r
@@ -61,6 +64,7 @@
  */
 #define MEM_LAYOUT_ENV_SETTINGS \
"scriptaddr=0x1000\0" \
+   "pxefile_addr_r=0x1010\0" \
"kernel_addr_r=0x0100\0" \
"fdt_addr_r=0x0200\0" \
"ramdisk_addr_r=0x0210\0"
diff --git a/include/configs/tegra30-common.h b/include/configs/tegra30-common.h
index edb930e032bc..4b6f8d128e63 100644
--- a/include/configs/tegra30-common.h
+++ b/include/configs/tegra30-common.h
@@ -43,6 +43,9 @@
  * scriptaddr can be pretty much anywhere that doesn't conflict with something
  *   else. Put it above BOOTMAPSZ to eliminate conflicts.
  *
+ * pxefile_addr_r can be pretty much anywhere that doesn't conflict with
+ *   something else. Put it above BOOTMAPSZ to eliminate conflicts.
+ *
  * kernel_addr_r must be within the first 128M of RAM in order for the
  *   kernel's CONFIG_AUTO_ZRELADDR option to work. Since the kernel will
  *   decompress itself to 0x8000 after the start of RAM, kernel_addr_r
@@ -60,6 +63,7 @@
  */
 #define MEM_LAYOUT_ENV_SETTINGS \
"scriptaddr=0x9000\0" \
+   "pxefile_addr_r=0x9010\0" \
"kernel_addr_r=0x8100\0" \
"fdt_addr_r=0x8200\0" \
"ramdisk_addr_r=0x8210\0"
-- 
1.8.1.5

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


Re: [U-Boot] [PATCH v2] board: Add support for B&R T-Series Motherboard

2014-02-05 Thread Wolfgang Denk
Dear Hannes,

In message <1391606231-24963-1-git-send-email-oe5...@oevsv.at> you wrote:
> Adds support for Bernecker & Rainer Industrieelektronik GmbH T-Series
> Motherboard, using TI's AM3352 SoC.
> 
> Most of code is derived from TI's AM335x_EVM
> 
> Signed-off-by: Hannes Petermaier 
> Cc: tr...@ti.com
> ---
> Changes for v2:
>- added T-Series to boards.cfg (forgotten before)
> 
>  board/BuR/bur_tseries/Makefile   |   13 +
>  board/BuR/bur_tseries/board.c|  333 +
>  board/BuR/bur_tseries/board.h|   18 ++
>  board/BuR/bur_tseries/mux.c  |  224 +
>  board/BuR/bur_tseries/u-boot.lds |  101 
>  boards.cfg   |3 +
>  include/configs/bur_tseries.h|  512 
> ++

This is soemwhat redundant naming - you have the vendor name already
encoded in the vendor directory, so it is not necessary to repeat it
in the board directory name.

I think it would be better to have:

board/BuR/tseries/*


> +++ b/board/BuR/bur_tseries/board.c
...
> + * 04.02.2014hpm very first board support for T-SERIES,
> + *   based on board/ti/am335x/board.c

Please do not add any such changelog information to the source code.
We use git to track code modifications, which is much more powerful.

> +/* 
> --*/
> +/* -- defines for GPIO -- */
> +#define  ETHLED_ORANGE   (96+16) /* GPIO3_16 */
> +#define  REPSWITCH   (0+20)  /* GPIO0_20 */

Should these not rather go to the board config header file?

> diff --git a/board/BuR/bur_tseries/u-boot.lds 
> b/board/BuR/bur_tseries/u-boot.lds
> new file mode 100644
> index 000..76db891
> --- /dev/null
> +++ b/board/BuR/bur_tseries/u-boot.lds

Are you sure you need a board specific linker script?  Why?

> diff --git a/include/configs/bur_tseries.h b/include/configs/bur_tseries.h
> new file mode 100644
> index 000..a5e6dbc
> --- /dev/null
> +++ b/include/configs/bur_tseries.h
> @@ -0,0 +1,512 @@
...
> +/*#define DEBUG */
...
> +#if _HPMTEST
> +#define CONFIG_SILENT_CONSOLE
> +#define CONFIG_SILENT_U_BOOT_ONLY
> +#define CONFIG_SILENT_CONSOLE_UPDATE_ON_SET
> +#define CONFIG_SYS_DEVICE_NULLDEV
> +#endif /* _HPMTEST */

Please remove such dead code.

> +#define CONFIG_ENV_VARS_UBOOT_CONFIG /* Strongly encouraged */

Really?  What exactly do you use these for?


Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
Success is  not  the  opposite  of  failure.  Failure  is  the  vital
ingredient in the recipe for success.  - Mario Cortes
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] board: Add support for B&R KWB Motherboard

2014-02-05 Thread Tom Rini
On Wed, Feb 05, 2014 at 04:47:04PM +0100, Hannes Petermaier wrote:

> Adds support for Bernecker & Rainer Industrieelektronik GmbH KWB
> Motherboard, using TI's AM3352 SoC.
> 
> Most of code is derived from TI's AM335x_EVM
> 
> Signed-off-by: Hannes Petermaier 
> Cc: tr...@ti.com
> ---
>  board/BuR/bur_kwb/Makefile   |   16 ++
>  board/BuR/bur_kwb/am335xScreen.c |  548 
> ++
>  board/BuR/bur_kwb/am335xScreen.h |   45 

Minor nit, this should be am335x_screen.[ch]

> +ifeq ($(CONFIG_SPL_BUILD),y)
> +obj-y:= mux.o
> +endif
> +ifeq ($(CONFIG_SYS_SCREEN),y)
> +obj-y   += am335xScreen.o
> +endif
> +obj-y+= board.o

obj-$(CONFIG_SPL_BUILD) +=
obj-$(CONFIG_SYS_SCREEN) +=

> diff --git a/board/BuR/bur_kwb/am335xScreen.c 
> b/board/BuR/bur_kwb/am335xScreen.c
[snip]
> +#if defined(CONFIG_SYS_SCREEN) && !defined(CONFIG_SPL_BUILD)

You shouldn't need this.  It'll be discarded if unused.

> +
> +#define DEBUG
> +#ifdef DEBUG
> +#define DBG(...) printf(__VA_ARGS__)
> +#else
> +#define DBG(...)
> +#endif /* DEBUG */

We provide debug(...) already.

> +#define  SCREEN_HMAX 1366
> +#define  SCREEN_VMAX 768

For consistency, please '#define' globally, thanks.

> +static const unsigned char char_tab2[257*8] = {

A comment about what this is please.

> +static void setPix(struct screen_typ *pscr,
> + unsigned int x, unsigned int y, unsigned int color)
> +{
> + unsigned int addroffset = 0;
> +
> + /* braces not for function, only for better reading by human :-) */
> + addroffset = y * (pscr->resx*4) + (x*4);
> + *(unsigned int *)(pscr->pfb+addroffset) = (color & 0x00FF);
> +}
> +static void outch(struct screen_typ *pscr,

Newline after functions, fix globally.  Also set_pix(), etc, also fix
globally.

> +++ b/board/BuR/bur_kwb/board.c
[snip]
> + if (i2c_probe(TPS65217_CHIP_PM)) {
> + printf("PMIC (0x%02x) not found! skip further initalization.\n",
> +TPS65217_CHIP_PM);

You should be able to do this with puts() since it's all constants.

> + /*
> +  * Increase USB current limit to 1300mA or 1800mA and set
> +  * the MPU voltage controller as needed.
> +  */
> + if (dpll_mpu_opp100.m == MPUPLL_M_1000) {
> + usb_cur_lim = TPS65217_USB_INPUT_CUR_LIMIT_1800MA;
> + mpu_vdd = TPS65217_DCDC_VOLT_SEL_1325MV;
> + } else {
> + usb_cur_lim = TPS65217_USB_INPUT_CUR_LIMIT_1300MA;
> + mpu_vdd = TPS65217_DCDC_VOLT_SEL_1275MV;
> + }

Since you've got a tps65217 (like beaglebone) you can drop the tps65250
include earlier in the file.

> +++ b/board/BuR/bur_kwb/u-boot.lds

Since you don't support NOR, you should be able to use the generic
linker script.

> +++ b/include/configs/bur_kwb.h
[snip]
> +#include 
> +/* 
> -*/
> +/* -- undefinig unused features --  
> */
> +/* prior defined from config_defaults.h */
> +#undef   CONFIG_BOOTM_LINUX
> +#undef   CONFIG_BOOTM_NETBSD
> +#undef   CONFIG_BOOTM_PLAN9
> +#undef   CONFIG_BOOTM_RTEMS
> +#undef   CONFIG_GZIP
> +#undef   CONFIG_ZLIB

Space not tab please.

> +#define CONFIG_SYS_NO_FLASH

Duplicate.

> +/* MMC/SD IP block */
> +#if defined(CONFIG_EMMC_BOOT)

So, CONFIG_EMMC_BOOT is used in am335x_evm.h since we have to support
building for a few different variants.  In this case it looks like you
can just drop setting EMMC_BOOT in boards.cfg and then simplify a lot of
the logic in the config file too.

> + #define CONFIG_MMC
> + #define CONFIG_GENERIC_MMC
> + #define CONFIG_OMAP_HSMMC
> + #define CONFIG_CMD_MMC
> + #define CONFIG_SUPPORT_EMMC_BOOT

So, are you making use of 'mmc open' / 'mmc close' on this platform to
work with the eMMC boot partitions today?

> +/*
> + * Our platforms make use of SPL to initalize the hardware (primarily
> + * memory) enough for full U-Boot to be loaded.  We also support Falcon
> + * Mode so that the Linux kernel can be booted directly from SPL
> + * instead, if desired.  We make use of the general SPL framework found
> + * under common/spl/.  Given our generally common memory map, we set a
> + * number of related defaults and sizes here.
> + */
> +#define CONFIG_SPL
> +#define CONFIG_SPL_FRAMEWORK
> +#undef CONFIG_SPL_OS_BOOT

Just don't set CONFIG_SPL_OS_BOOT, and drop the function from board.c
that you've got too.

> +#define CONFIG_SYS_NS16550_COM1  0x44e09000  /* Base EVM has 
> UART0 */
> +#define CONFIG_SYS_NS16550_COM2  0x48022000  /* UART1 */
> +#define CONFIG_SYS_NS16550_COM3  0x48024000  /* UART2 */
> +#define CONFIG_SYS_NS16550_COM4  0x481a6000  /* UART3 */
> +#define CONFIG_SYS_NS16550_COM5  0x481a8000  /* UART4 */
> +#define CONFIG_SYS_NS16550_COM6  0x481aa000  

Re: [U-Boot] [PATCH] board: Add support for B&R KWB Motherboard

2014-02-05 Thread Wolfgang Denk
Dear Hannes,

In message <1391615224-26493-1-git-send-email-oe5...@oevsv.at> you wrote:
> Adds support for Bernecker & Rainer Industrieelektronik GmbH KWB
> Motherboard, using TI's AM3352 SoC.
> 
> Most of code is derived from TI's AM335x_EVM
> 
> Signed-off-by: Hannes Petermaier 
> Cc: tr...@ti.com
> ---
>  board/BuR/bur_kwb/Makefile   |   16 ++
>  board/BuR/bur_kwb/am335xScreen.c |  548 
> ++
>  board/BuR/bur_kwb/am335xScreen.h |   45 
>  board/BuR/bur_kwb/board.c|  522 
>  board/BuR/bur_kwb/board.h|   18 ++
>  board/BuR/bur_kwb/mux.c  |  213 +++
>  board/BuR/bur_kwb/u-boot.lds |  101 +++

See previous comments.  Repeating the "bur_" part in the board
directory name is redundant; I recommend to drop that.


> + * History
> + * ===
> + * 17.12.2013hpm created

Please drop this.  Please fix globally.

> +#define DEBUG
> +#ifdef DEBUG
> +#define DBG(...) printf(__VA_ARGS__)
> +#else
> +#define DBG(...)
> +#endif /* DEBUG */

We already have debug(); please use existing standard facilities.

> + if ('\r' == *str) {
...
> + } else if ('\n' == *str) {

Please avoid this reversed notation style.  Please fix globally.

...
> +}
> +int drawrecticle(unsigned int x, unsigned int y,
> +  unsigned int w, unsigned int h, unsigned int color)
> +{

CodingStyle says: "In source files, separate functions with one blank
line."  Please fix globally.

> + setPix(&screen, j, i, color);

We do not allow CamelCase identifiers.  Please fix globally.

> +int prints(const char *fmt, ...)
...
> +int printsxy(unsigned int x, unsigned int y, const char *fmt, ...)
etc.

BTW - are you not reinventing the wheel here?  What about functions
like video_drawstring(), video_putchar(), ... ?

> index 000..5a1b15f
> --- /dev/null
> +++ b/board/BuR/bur_kwb/board.c
> @@ -0,0 +1,522 @@

Pretty significant parts of this file appear to be identical to code
in board/BuR/bur_tseries/board.c as added by your earlier patch.
Please factor out such common code into a common/ directory so it can
be shared across boards.

> + * History
> + * ===
> + * xx.10.2013hpm - created, adopted from ti_am335x_evm
> + * 06.12.2013hpm - setting MPU_PLL to 600 MHz (as required for
> + * industrial)
> + *   - implemented simple boot-mode detection
> + *   - reduced resetpulse for USB2SD controller
> + * from 5ms to 1ms
> + * 10.12.2013hpm - switch OFF LCD-Screen within SPL-Stage
> + * (due to invalid 3V3 pullup resistor)
> + *   - powerUP 3V3 via I2C-Resetcontroller within SPL-Stage
> + * 16.12.2013hpm - V1.10: changed bootaddr of VxWorks from
> + * 0x8200 to 0x8010
> + * 24.12.2013hpm - V1.11: added LCD-support
> + * 30.01.2014hpm - V2.00: ported to new U-Boot (2014) sources

As mentioned before: please drop globally!


> + printf("echo setting PMIC Register in the RTC.\n");
> + *(unsigned int *)0x44e3e098 = 0x1f010;
> + printf("read back PMIC Register: 0x%08x\n",
> +*(unsigned int *)0x44e3e098);
> +
> + year = *(unsigned int *)0x44e3e014;
> + mon = *(unsigned int *)0x44e3e010;
> + d   = *(unsigned int *)0x44e3e00C;
> + h   = *(unsigned int *)0x44e3e008;
> + min = *(unsigned int *)0x44e3e004;

Please use proper I/O accessors to access hardware registers, and
declare a proper C struct to describe the register layout.  Please fix
globally.

> +static struct cpsw_slave_data cpsw_slaves[] = {
> + {
> + .slave_reg_ofs  = 0x208,
> + .sliver_reg_ofs = 0xd80,
...
> + .slave_reg_ofs  = 0x308,
> + .sliver_reg_ofs = 0xdc0,

Would it make sense to provide symboolic names for such magic numbers?

And how about some comments to explain the actual settings?


> diff --git a/board/BuR/bur_kwb/board.h b/board/BuR/bur_kwb/board.h
> new file mode 100644
> index 000..def41aa
> --- /dev/null
> +++ b/board/BuR/bur_kwb/board.h
> @@ -0,0 +1,18 @@
> +/*
> + * board.h
> + *
> + * BUR-KWB boards information header
> + *
> + * Copyright (C) 2013, Bernecker & Rainer Industrieelektronik GmbH -
> + * http://www.br-automation.com
> + *
> + * SPDX-License-Identifier:  GPL-2.0+
> + */
> +
> +#ifndef _BOARD_H_
> +#define _BOARD_H_
> +
> +void enable_uart0_pin_mux(void);
> +void enable_i2c0_pin_mux(void);
> +void enable_board_pin_mux(void);

This file appears to be identical to board/BuR/bur_tseries/board.h as
added by your earlier patch.  Please use a common header file instead.


> diff --git a/board/BuR/bur_kwb/mux.c b/board/BuR/bur_kwb/mux.c
> new file mode 100644
> index 000..da4b9f3
> --

Re: [U-Boot] [PATCH v2 06/12] USB: gadget: added a saner gadget downloader registration API

2014-02-05 Thread Marek Vasut
On Wednesday, February 05, 2014 at 01:40:27 PM, Mateusz Zalega wrote:

[...]

> > Are these two new functions called from multiple places at all? If not,
> > just inline these ll_foo() calls and be done with it. FYI you can also
> > make macros for these to avoid having to type all these args all around
> > and duplicating the code.
> 
> Macros or static inlines, it's all the same

NAK, what you say is seriously wrong, you should know that by now!

Macros do not do any kind of typechecking, functions do typechecking.
Macros are expanded in place during preprocessing, functions are (usually) 
single-instance.

etc.

> there's no point in
> changing that. The symbols aren't visible outside this compilation unit
> and function calls are, well, inlined.

It's pointless to have them pulled out so explicitly. Or would you prefer to 
have each function encapsulated in another function ? This doesn't make does 
now, does it ?

What I would like to do is for you to follow the advice in linker_lists.h and 
produce a small shim over these crude linker lists prototypes there, so that 
the 
users here in the g_* world don't have to type the whole linker list macros 
with 
all the arguments, which do not ever change for this g_* . Does it make sense 
please?

> >>  static int g_dnl_do_config(struct usb_configuration *c)
> >>  {
> >>  
> >>const char *s = c->cdev->driver->name;
> >> 
> >> -  int ret = -1;
> >> 
> >>debug("%s: configuration: 0x%p composite dev: 0x%p\n",
> >> 
> >> -__func__, c, c->cdev);
> >> -
> >> +  __func__, c, c->cdev);
> >> 
> >>printf("GADGET DRIVER: %s\n", s);
> >> 
> >> -  if (!strcmp(s, "usb_dnl_dfu"))
> >> -  ret = dfu_add(c);
> >> -  else if (!strcmp(s, "usb_dnl_ums"))
> >> -  ret = fsg_add(c);
> >> -  else if (!strcmp(s, "usb_dnl_thor"))
> >> -  ret = thor_add(c);
> >> -
> >> -  return ret;
> >> +
> >> +  struct g_dnl_bind_callback *callback = g_dnl_first_bind_callback();
> >> +  for (; callback != g_dnl_last_bind_callback(); ++callback)
> > 
> > callback++ , this is not C++ where the order might matter. Nonetheless,
> > you do
> 
> It doesn't matter anyway and can't be supported on Coding Style grounds,
> don't bug me.

Can be done on purely statistical grounds, try this:

$ git grep 'for.*(.* *++[:alnum:]\+ *)' | wc -l
13
$ git grep 'for.*(.* *[:alnum:]\+++ *)' | wc -l
183

Please fix, thank you.

> > want to use ll_entry_count() and ll_entry_get() with an iterator variable
> 
> I don't think using ll_entry_get() in this way is possible with current
> implementation of linker lists. Moreover, there's plenty of code doing
> just the same already accepted to U-Boot.

Ah meh, sorry. Seems like someone was messing with the linkerlists and 
misdesigned it. Dang.

> > instead to make sure you don't step onto a corrupted field and crash in
> > some weird way.
> 
> Linker would have to split sections to make this sort of thing possible.
> Won't happen.

Can you please elaborate ?
[...]
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] NAND bad block table

2014-02-05 Thread Scott Wood
On Wed, 2014-02-05 at 15:16 +0100, Michal Simek wrote:
> On 02/04/2014 09:46 PM, Scott Wood wrote:
> > On Tue, 2014-02-04 at 13:43 +0100, Michal Simek wrote:
> >> Hi Scott and others,
> >>
> >> I have a question regarding BBT position and number of blocks allocated
> >> for BBT.
> >>
> >> Did you face the issue with last 4 blocks broken in any NAND flash
> >> device since the default option in Linux/u-boot BBM is last 4 blocks?
> >>
> >> It doesn't mean that if the last 4 blocks are broken than the NAND flash
> >> device is broken too.
> >> Also I haven't seen any common binding for Linux kernel to change it.
> >>
> >> Has someone tried to improve this algorithm or process of storing BBT in a 
> >> better way.
> >> For example just look for BBT from the end till any limit?
> > 
> > I don't recall if I've ever tested it personally, but that sort of
> > scanning is already there.  Have you seen a problem with it?
> 
> We have met with nand device which has broken last 4 blocks and
> u-boot and linux just scan last 4 blocks by default.
> 
> In connection to Linux. Interesting is that there is no binding
> for extending scan blocks and this has to be done through driver
> properties.

Could you be more specific about what sort of "driver property" you're
talking about?  AFAICT from glancing at the code, searching is the
default unless the controller driver specifies NAND_BBT_ABSPAGE.

In any case, this code comes straight from Linux, so you'll probably
find people more familiar with this code on linux-mtd.

-Scott


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


[U-Boot] [RFC PATCH 1/1] Read mmc device memory capacity from EXT_CSD if memory is addressed by sector

2014-02-05 Thread Frank Bormann

Hello Everyone,

I believe, there is a bug in the mmc driver code pertaining to how u-boot 
detects memory size of an mmc device. However, I am not 100% sure, my solution 
conforms to the JEDEC standard. So I am putting it up for discussion.


Previously, sector count indicated by mmc devices in the EXT_CSD
would only be used in u-boot if the size indicated is greater than
2 GB. This seems to be incorrect. I am working with a 4 GB Micron
eMMC device that after partition configuration and setting the
user data area to enhanced mode has a remaining capacity of less
than 2 GB for the user data area. JESD84-B50 explicitly states in
6.2.4 that for these devices SEC_CNT from the EXT_CSD is still
valid even if the memory size for that device has dropped below
2 GB by the partition configuration applied. The access mode bits
from the OCR register seem to provide a better way to decide
whether to use the CSD-based C_SIZE & C_MULT or the EXT_CSD-based
SEC_CNT information when determining the device's capacity.

In particular, this fixes a bug where u-boot SPL would assign 0 to
mmc->block_dev.lba later on in the mmc_startup() function and
subsequently fail to load u-boot from that mmc due to the original
C_SIZE & C_MULT code assigning a 4 TB size to mmc->capacity, that
incorrect capacity never being overwritten by the SEC_CNT capacity
calculation (due to its size being less than 2 GB) and then finally
lldiv(mmc->capacity, mmc->read_bl_len) exceeding the 32-bit result
data type of mmc->block_dev.lba.

Signed-off-by: Frank Bormann 
---
 drivers/mmc/mmc.c |   10 +-
 include/mmc.h |1 +
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index c6a1c23..c5d1efc 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -935,19 +935,19 @@ static int mmc_startup(struct mmc *mmc)
if (!IS_SD(mmc) && (mmc->version >= MMC_VERSION_4)) {
/* check  ext_csd version and capacity */
err = mmc_send_ext_csd(mmc, ext_csd);
-   if (!err && (ext_csd[EXT_CSD_REV] >= 2)) {
+   if (!err && (ext_csd[EXT_CSD_REV] >= 2) &&
+   (mmc->ocr & OCR_ACCESS_MODE) == OCR_ACCESS_BY_SECTOR) {
/*
 * According to the JEDEC Standard, the value of
-* ext_csd's capacity is valid if the value is more
-* than 2GB
+* ext_csd's capacity is valid if the device addresses
+* its memory by sector
 */
capacity = ext_csd[EXT_CSD_SEC_CNT] << 0
| ext_csd[EXT_CSD_SEC_CNT + 1] << 8
| ext_csd[EXT_CSD_SEC_CNT + 2] << 16
| ext_csd[EXT_CSD_SEC_CNT + 3] << 24;
capacity *= MMC_MAX_BLOCK_LEN;
-   if ((capacity >> 20) > 2 * 1024)
-   mmc->capacity_user = capacity;
+   mmc->capacity_user = capacity;
}

switch (ext_csd[EXT_CSD_REV]) {
diff --git a/include/mmc.h b/include/mmc.h
index e1060b9..816b580 100644
--- a/include/mmc.h
+++ b/include/mmc.h
@@ -104,6 +104,7 @@
 #define OCR_HCS0x4000
 #define OCR_VOLTAGE_MASK   0x007FFF80
 #define OCR_ACCESS_MODE0x6000
+#define OCR_ACCESS_BY_SECTOR   (1 << 30)

 #define SECURE_ERASE   0x8000
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] powerpc/t104xrdb, t1040qds : Update FMAN microcode NOR address

2014-02-05 Thread York Sun
On 02/04/2014 10:12 PM, Priyanka Jain wrote:
> FMAN microcode image address range on NOR flash changed from
> (0xeff0 to 0xebf1) to (0xeff1 to 0xeff1)
> 
> The change has been done
> - to support FMAN microcode flashing via promjet mechanism as
>  promjet uses address based on offsets. Based on this
>  address of FMAN microcode flash on promjet flash should be 0x0
>  But 0x0 offset is already use for rcw on promjet flash.
>  To take care of  this limitation FMAN microcode address has been
>  changed. Now, FMAN microcode address on promjet flash is 0x1
> 
> - FMAN microcode is of size 64KB so it will fit into
>  0xeff1 to 0xeff1.
> 

NACK.

The tool is not broken. I have made a configuration to use PROMJET to download
all images successfully.

York


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


Re: [U-Boot] [PATCH v2 2/3] dts: move device tree sources to arch/$(ARCH)/dts/

2014-02-05 Thread Simon Glass
Hi Masahiro,

On 4 February 2014 02:38, Masahiro Yamada  wrote:
> Unlike Linux Kernel, U-Boot historically had *.dts files under
> board/$(VENDOR)/dts/ and *.dtsi files under arch/$(ARCH)/dts/.
>
> I think arch/$(ARCH)/dts dicretory is a better location
> to store both *.dts and *.dtsi files.
>
> For example, before this commit, board/xilinx/dts directory
> had both MicroBlaze dts (microblaze-generic.dts) and
> ARM dts (zynq-*.dts), which are totally unrelated.
>
> This commit moves *.dts to arch/$(ARCH)/dts/ directories,
> allowing us to describe nicely mutiple DTBs generation in the next commit.

What is the motivation for this? I worry that we might end up with a
lot of files in one directory. One benefit of the current approach is
that .dts files are split up by vendor. Even if we put the SoC .dtsi
files in arch/arm, perhaps there is a benefit in leaving the board
.dts files in board/?

I don't have strong feelings, just questing this...

Regards,
Simon

>
> Signed-off-by: Masahiro Yamada 
> ---
>
> Changes in v2:
>   - Newly added
>
>  {board/samsung => arch/arm}/dts/exynos5250-arndale.dts | 0
>  {board/samsung => arch/arm}/dts/exynos5250-smdk5250.dts| 0
>  {board/samsung => arch/arm}/dts/exynos5250-snow.dts| 0
>  {board/samsung => arch/arm}/dts/exynos5420-smdk5420.dts| 0
>  {board/nvidia => arch/arm}/dts/tegra114-dalmore.dts| 0
>  {board/toradex => arch/arm}/dts/tegra20-colibri_t20_iris.dts   | 0
>  {board/nvidia => arch/arm}/dts/tegra20-harmony.dts | 0
>  {board/avionic-design => arch/arm}/dts/tegra20-medcom-wide.dts | 0
>  {board/compal => arch/arm}/dts/tegra20-paz00.dts   | 0
>  {board/avionic-design => arch/arm}/dts/tegra20-plutux.dts  | 0
>  {board/nvidia => arch/arm}/dts/tegra20-seaboard.dts| 0
>  {board/avionic-design => arch/arm}/dts/tegra20-tamonten.dtsi   | 0
>  {board/avionic-design => arch/arm}/dts/tegra20-tec.dts | 0
>  {board/compulab => arch/arm}/dts/tegra20-trimslice.dts | 0
>  {board/nvidia => arch/arm}/dts/tegra20-ventana.dts | 0
>  {board/nvidia => arch/arm}/dts/tegra20-whistler.dts| 0
>  {board/nvidia => arch/arm}/dts/tegra30-beaver.dts  | 0
>  {board/nvidia => arch/arm}/dts/tegra30-cardhu.dts  | 0
>  {board/avionic-design => arch/arm}/dts/tegra30-tamonten.dtsi   | 0
>  {board/avionic-design => arch/arm}/dts/tegra30-tec-ng.dts  | 0
>  {board/xilinx => arch/arm}/dts/zynq-microzed.dts   | 0
>  {board/xilinx => arch/arm}/dts/zynq-zc702.dts  | 0
>  {board/xilinx => arch/arm}/dts/zynq-zc706.dts  | 0
>  {board/xilinx => arch/arm}/dts/zynq-zc770-xm010.dts| 0
>  {board/xilinx => arch/arm}/dts/zynq-zc770-xm012.dts| 0
>  {board/xilinx => arch/arm}/dts/zynq-zc770-xm013.dts| 0
>  {board/xilinx => arch/arm}/dts/zynq-zed.dts| 0
>  {board/xilinx => arch/microblaze}/dts/microblaze-generic.dts   | 0
>  {board/chromebook-x86 => arch/x86}/dts/alex.dts| 0
>  {board/chromebook-x86 => arch/x86}/dts/link.dts| 0
>  dts/Makefile   | 4 ++--
>  scripts/Makefile.lib   | 1 -
>  32 files changed, 2 insertions(+), 3 deletions(-)
>  rename {board/samsung => arch/arm}/dts/exynos5250-arndale.dts (100%)
>  rename {board/samsung => arch/arm}/dts/exynos5250-smdk5250.dts (100%)
>  rename {board/samsung => arch/arm}/dts/exynos5250-snow.dts (100%)
>  rename {board/samsung => arch/arm}/dts/exynos5420-smdk5420.dts (100%)
>  rename {board/nvidia => arch/arm}/dts/tegra114-dalmore.dts (100%)
>  rename {board/toradex => arch/arm}/dts/tegra20-colibri_t20_iris.dts (100%)
>  rename {board/nvidia => arch/arm}/dts/tegra20-harmony.dts (100%)
>  rename {board/avionic-design => arch/arm}/dts/tegra20-medcom-wide.dts (100%)
>  rename {board/compal => arch/arm}/dts/tegra20-paz00.dts (100%)
>  rename {board/avionic-design => arch/arm}/dts/tegra20-plutux.dts (100%)
>  rename {board/nvidia => arch/arm}/dts/tegra20-seaboard.dts (100%)
>  rename {board/avionic-design => arch/arm}/dts/tegra20-tamonten.dtsi (100%)
>  rename {board/avionic-design => arch/arm}/dts/tegra20-tec.dts (100%)
>  rename {board/compulab => arch/arm}/dts/tegra20-trimslice.dts (100%)
>  rename {board/nvidia => arch/arm}/dts/tegra20-ventana.dts (100%)
>  rename {board/nvidia => arch/arm}/dts/tegra20-whistler.dts (100%)
>  rename {board/nvidia => arch/arm}/dts/tegra30-beaver.dts (100%)
>  rename {board/nvidia => arch/arm}/dts/tegra30-cardhu.dts (100%)
>  rename {board/avionic-design => arch/arm}/dts/tegra30-tamonten.dtsi (100%)
>  rename {board/avionic-design => arch/arm}/dts/tegra30-tec-ng.dts (100%)
>  rename {board/xilinx => arch/arm}/dts/zynq-microzed.dts (100%)
>  rename {board/xilinx => arch/arm}/dts/zynq-zc702.dts (100%)
>  rename {board/xilinx => arch/arm}/dts/zynq-zc706.dts (100%)
>  rename {boar

[U-Boot] [PATCH] common: Remove invalid endianess conversion

2014-02-05 Thread Christian Eggers
do_bootm_standanlone() calls ntohl(images->ep) which is obviously wrong
(find . -name '*.c' | xargs grep -n -- 'images->ep'). Without this
conversion the code works correctly at least on ARM9. Addtionally "appl"
must not be dereferenced with the "*" operator.

Signed-off-by: Christian Eggers 
---
 common/cmd_bootm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index a59ee95..c507e1d 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -514,8 +514,8 @@ static int do_bootm_standalone(int flag, int argc, char * 
const argv[],
setenv_hex("filesize", images->os.image_len);
return 0;
}
-   appl = (int (*)(int, char * const []))(ulong)ntohl(images->ep);
-   (*appl)(argc, argv);
+   appl = (int (*)(int, char * const []))images->ep;
+   (appl)(argc, argv);
return 0;
 }
 
-- 
1.8.4.5

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


Re: [U-Boot] [PATCH] common: Remove invalid endianess conversion

2014-02-05 Thread Wolfgang Denk
Dear Christian Eggers,

In message <1391633046-8878-1-git-send-email-cegg...@gmx.de> you wrote:
> do_bootm_standanlone() calls ntohl(images->ep) which is obviously wrong
> (find . -name '*.c' | xargs grep -n -- 'images->ep'). Without this
> conversion the code works correctly at least on ARM9. Addtionally "appl"
> must not be dereferenced with the "*" operator.

What makes you so sure that this is "obvious" ?  I think the image
header is actually supposed to be in network byte order...

> Signed-off-by: Christian Eggers 
> ---
>  common/cmd_bootm.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
> index a59ee95..c507e1d 100644
> --- a/common/cmd_bootm.c
> +++ b/common/cmd_bootm.c
> @@ -514,8 +514,8 @@ static int do_bootm_standalone(int flag, int argc, char * 
> const argv[],
>   setenv_hex("filesize", images->os.image_len);
>   return 0;
>   }
> - appl = (int (*)(int, char * const []))(ulong)ntohl(images->ep);
> - (*appl)(argc, argv);
> + appl = (int (*)(int, char * const []))images->ep;
> + (appl)(argc, argv);

You are also making another change here - which looks as obscure to me
as the first one.

Can you please provide a test case which is fixed by your
modification?

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
If you can't explain it to a six year old, you  don't  understand  it
yourself.   - Albert Einstein
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v3 0/2] IMX6: Add Gateworks Ventana support

2014-02-05 Thread Tim Harvey
Changes in v3:
  - update README fixing typo and removing Freescale document link
  - use debug() instead of printf()
  - be more explicit with hwmon error output and use macro for min/max percent
  - use #defines for GSC slave address and registers
  - remove extern from function prototype
  - moved gpio config into structure for better readability
  - use enum for eeprom bit configs and array to map to fdt property alias
  - add SATA regardless of cpu type
  - add FIT support regardless of flash type
  - display PMIC and device id in misc_init_r() instead of pmic driver

Changes in v2:
  - rebase on top of u-boot-imx
  - use switch..case for model specific init instead of strcmps
  - move checkboard to late init allowing i2c_setup to be moved to board_init()
eeprom reading to be done after relocation, and move eeprom struct from
data segment
  - move SPI/I2C init to board_init()
  - update README
  - remove unnecessary console overwrite function
  - fix multiline comment style and eliminate >80 char lines
  - eliminate unnecessary loop in board_mmc_init()
  - add missing copyright to clocks.cfg
  - avoid duplicating cfg files where no changes exist
  - added missing SPDX header to ventana_eeprom.h
  - use puts() instead of printf() for constant strings
  - remove messages regarding /dev/i2c-
  - use get_ram_size() for determing ram_size
  - cleanup gpio configuration using tables for baseboard pinmux combinations
  - remove phy init errata as it doesn't pertain to use case
(it is for 802.3az which IMX6 MAC does not support)
  - added pfuze100_pmic driver using PMIC API
  - moved GSC code (gsc command and i2c_read/i2c_write wrappers into own file)
  - allow user to quiet down some of the data displayed
  - remove display support for now - will revisit later
  - remove display of boot mode info - may revisit later
  - replace bitwise fields in eeprom structure with bit definitions

Tim Harvey (2):
  power: add PFUZE100 PMIC driver
  ventana: Add Gateworks Ventana family support

 board/gateworks/gw_ventana/Makefile |   10 +
 board/gateworks/gw_ventana/README   |   55 ++
 board/gateworks/gw_ventana/clocks.cfg   |   42 +
 board/gateworks/gw_ventana/gsc.c|  129 +++
 board/gateworks/gw_ventana/gsc.h|   30 +
 board/gateworks/gw_ventana/gw_ventana.c | 1240 +++
 board/gateworks/gw_ventana/gw_ventana.cfg   |   42 +
 board/gateworks/gw_ventana/ventana_eeprom.h |  106 +++
 boards.cfg  |5 +
 drivers/power/pmic/Makefile |1 +
 drivers/power/pmic/pmic_pfuze100.c  |   33 +
 include/configs/gw_ventana.h|  415 +
 include/power/pfuze100_pmic.h   |   96 +++
 13 files changed, 2204 insertions(+)
 create mode 100644 board/gateworks/gw_ventana/Makefile
 create mode 100644 board/gateworks/gw_ventana/README
 create mode 100644 board/gateworks/gw_ventana/clocks.cfg
 create mode 100644 board/gateworks/gw_ventana/gsc.c
 create mode 100644 board/gateworks/gw_ventana/gsc.h
 create mode 100644 board/gateworks/gw_ventana/gw_ventana.c
 create mode 100644 board/gateworks/gw_ventana/gw_ventana.cfg
 create mode 100644 board/gateworks/gw_ventana/ventana_eeprom.h
 create mode 100644 drivers/power/pmic/pmic_pfuze100.c
 create mode 100644 include/configs/gw_ventana.h
 create mode 100644 include/power/pfuze100_pmic.h

-- 
1.8.3.2

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


[U-Boot] [PATCH v3 1/2] power: add PFUZE100 PMIC driver

2014-02-05 Thread Tim Harvey
Signed-off-by: Tim Harvey 
Cc: Stefano Babic 
---
Changes in v2:
  - remove detect and device_id display from pmic_init()

 drivers/power/pmic/Makefile|  1 +
 drivers/power/pmic/pmic_pfuze100.c | 33 +
 include/power/pfuze100_pmic.h  | 96 ++
 3 files changed, 130 insertions(+)
 create mode 100644 drivers/power/pmic/pmic_pfuze100.c
 create mode 100644 include/power/pfuze100_pmic.h

diff --git a/drivers/power/pmic/Makefile b/drivers/power/pmic/Makefile
index 0b45ffa..4129bda 100644
--- a/drivers/power/pmic/Makefile
+++ b/drivers/power/pmic/Makefile
@@ -9,5 +9,6 @@ obj-$(CONFIG_POWER_MAX8998) += pmic_max8998.o
 obj-$(CONFIG_POWER_MAX8997) += pmic_max8997.o
 obj-$(CONFIG_POWER_MUIC_MAX8997) += muic_max8997.o
 obj-$(CONFIG_POWER_MAX77686) += pmic_max77686.o
+obj-$(CONFIG_POWER_PFUZE100) += pmic_pfuze100.o
 obj-$(CONFIG_POWER_TPS65217) += pmic_tps65217.o
 obj-$(CONFIG_POWER_TPS65910) += pmic_tps65910.o
diff --git a/drivers/power/pmic/pmic_pfuze100.c 
b/drivers/power/pmic/pmic_pfuze100.c
new file mode 100644
index 000..3962bb7
--- /dev/null
+++ b/drivers/power/pmic/pmic_pfuze100.c
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2014 Gateworks Corporation
+ * Tim Harvey 
+ *
+ * SPDX-License-Identifier:  GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+int pmic_init(unsigned char bus)
+{
+   static const char name[] = "PFUZE100_PMIC";
+   int ret;
+   struct pmic *p = pmic_alloc();
+
+   if (!p) {
+   printf("%s: POWER allocation error!\n", __func__);
+   return -ENOMEM;
+   }
+
+   p->name = name;
+   p->interface = PMIC_I2C;
+   p->number_of_regs = PMIC_NUM_OF_REGS;
+   p->hw.i2c.addr = CONFIG_POWER_PFUZE100_I2C_ADDR;
+   p->hw.i2c.tx_num = 1;
+   p->bus = bus;
+
+   return 0;
+}
diff --git a/include/power/pfuze100_pmic.h b/include/power/pfuze100_pmic.h
new file mode 100644
index 000..2a9032a
--- /dev/null
+++ b/include/power/pfuze100_pmic.h
@@ -0,0 +1,96 @@
+/*
+ *  Copyright (C) 2014 Gateworks Corporation
+ *  Tim Harvey 
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#ifndef __PFUZE100_PMIC_H_
+#define __PFUZE100_PMIC_H_
+
+/* PFUZE100 registers */
+enum {
+   PFUZE100_DEVICEID   = 0x00,
+   PFUZE100_REVID  = 0x03,
+   PFUZE100_FABID  = 0x04,
+
+   PFUZE100_SW1ABVOL   = 0x20,
+   PFUZE100_SW1CVOL= 0x2e,
+   PFUZE100_SW2VOL = 0x35,
+   PFUZE100_SW3AVOL= 0x3c,
+   PFUZE100_SW3BVOL= 0x43,
+   PFUZE100_SW4VOL = 0x4a,
+   PFUZE100_SWBSTCON1  = 0x66,
+   PFUZE100_VREFDDRCON = 0x6a,
+   PFUZE100_VSNVSVOL   = 0x6b,
+   PFUZE100_VGEN1VOL   = 0x6c,
+   PFUZE100_VGEN2VOL   = 0x6d,
+   PFUZE100_VGEN3VOL   = 0x6e,
+   PFUZE100_VGEN4VOL   = 0x6f,
+   PFUZE100_VGEN5VOL   = 0x70,
+   PFUZE100_VGEN6VOL   = 0x71,
+
+   PMIC_NUM_OF_REGS= 0x7f,
+};
+
+/*
+ * LDO Configuration
+ */
+
+/* VGEN1/2 Voltage Configuration */
+#define LDOA_0_80V 0
+#define LDOA_0_85V 1
+#define LDOA_0_90V 2
+#define LDOA_0_95V 3
+#define LDOA_1_00V 4
+#define LDOA_1_05V 5
+#define LDOA_1_10V 6
+#define LDOA_1_15V 7
+#define LDOA_1_20V 8
+#define LDOA_1_25V 9
+#define LDOA_1_30V 10
+#define LDOA_1_35V 11
+#define LDOA_1_40V 12
+#define LDOA_1_45V 13
+#define LDOA_1_50V 14
+#define LDOA_1_55V 15
+
+/* VGEN3/4/5/6 Voltage Configuration */
+#define LDOB_1_80V 0
+#define LDOB_1_90V 1
+#define LDOB_2_00V 2
+#define LDOB_2_10V 3
+#define LDOB_2_20V 4
+#define LDOB_2_30V 5
+#define LDOB_2_40V 6
+#define LDOB_2_50V 7
+#define LDOB_2_60V 8
+#define LDOB_2_70V 9
+#define LDOB_2_80V 10
+#define LDOB_2_90V 11
+#define LDOB_3_00V 12
+#define LDOB_3_10V 13
+#define LDOB_3_20V 14
+#define LDOB_3_30V 15
+
+#define LDO_VOL_MASK   0xf
+#define LDO_EN 4
+
+/*
+ * Boost Regulator
+ */
+
+/* SWBST Output Voltage */
+#define SWBST_5_00V0
+#define SWBST_5_05V1
+#define SWBST_5_10V2
+#define SWBST_5_15V3
+
+#define SWBST_VOL_MASK 0x3
+#define SWBST_MODE_MASK0x6
+#define SWBST_MODE_OFF (2 << 0)
+#define SWBST_MODE_PFM (2 << 1)
+#define SWBST_MODE_AUTO(2 << 2)
+#define SWBST_MODE_APS (2 << 3)
+
+#endif
-- 
1.8.3.2

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


[U-Boot] [PATCH v3 1/2] power: add PFUZE100 PMIC driver

2014-02-05 Thread Tim Harvey
Signed-off-by: Tim Harvey 
Cc: Stefano Babic  denx.de>
---
Changes in v2:
  - remove detect and device_id display from pmic_init()

 drivers/power/pmic/Makefile|  1 +
 drivers/power/pmic/pmic_pfuze100.c | 33 +
 include/power/pfuze100_pmic.h  | 96 ++
 3 files changed, 130 insertions(+)
 create mode 100644 drivers/power/pmic/pmic_pfuze100.c
 create mode 100644 include/power/pfuze100_pmic.h

diff --git a/drivers/power/pmic/Makefile b/drivers/power/pmic/Makefile
index 0b45ffa..4129bda 100644
--- a/drivers/power/pmic/Makefile
+++ b/drivers/power/pmic/Makefile
@@ -9,5 +9,6 @@ obj-$(CONFIG_POWER_MAX8998) += pmic_max8998.o
 obj-$(CONFIG_POWER_MAX8997) += pmic_max8997.o
 obj-$(CONFIG_POWER_MUIC_MAX8997) += muic_max8997.o
 obj-$(CONFIG_POWER_MAX77686) += pmic_max77686.o
+obj-$(CONFIG_POWER_PFUZE100) += pmic_pfuze100.o
 obj-$(CONFIG_POWER_TPS65217) += pmic_tps65217.o
 obj-$(CONFIG_POWER_TPS65910) += pmic_tps65910.o
diff --git a/drivers/power/pmic/pmic_pfuze100.c 
b/drivers/power/pmic/pmic_pfuze100.c
new file mode 100644
index 000..3962bb7
--- /dev/null
+++ b/drivers/power/pmic/pmic_pfuze100.c
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2014 Gateworks Corporation
+ * Tim Harvey 
+ *
+ * SPDX-License-Identifier:  GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+int pmic_init(unsigned char bus)
+{
+   static const char name[] = "PFUZE100_PMIC";
+   int ret;
+   struct pmic *p = pmic_alloc();
+
+   if (!p) {
+   printf("%s: POWER allocation error!\n", __func__);
+   return -ENOMEM;
+   }
+
+   p->name = name;
+   p->interface = PMIC_I2C;
+   p->number_of_regs = PMIC_NUM_OF_REGS;
+   p->hw.i2c.addr = CONFIG_POWER_PFUZE100_I2C_ADDR;
+   p->hw.i2c.tx_num = 1;
+   p->bus = bus;
+
+   return 0;
+}
diff --git a/include/power/pfuze100_pmic.h b/include/power/pfuze100_pmic.h
new file mode 100644
index 000..2a9032a
--- /dev/null
+++ b/include/power/pfuze100_pmic.h
@@ -0,0 +1,96 @@
+/*
+ *  Copyright (C) 2014 Gateworks Corporation
+ *  Tim Harvey 
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#ifndef __PFUZE100_PMIC_H_
+#define __PFUZE100_PMIC_H_
+
+/* PFUZE100 registers */
+enum {
+   PFUZE100_DEVICEID   = 0x00,
+   PFUZE100_REVID  = 0x03,
+   PFUZE100_FABID  = 0x04,
+
+   PFUZE100_SW1ABVOL   = 0x20,
+   PFUZE100_SW1CVOL= 0x2e,
+   PFUZE100_SW2VOL = 0x35,
+   PFUZE100_SW3AVOL= 0x3c,
+   PFUZE100_SW3BVOL= 0x43,
+   PFUZE100_SW4VOL = 0x4a,
+   PFUZE100_SWBSTCON1  = 0x66,
+   PFUZE100_VREFDDRCON = 0x6a,
+   PFUZE100_VSNVSVOL   = 0x6b,
+   PFUZE100_VGEN1VOL   = 0x6c,
+   PFUZE100_VGEN2VOL   = 0x6d,
+   PFUZE100_VGEN3VOL   = 0x6e,
+   PFUZE100_VGEN4VOL   = 0x6f,
+   PFUZE100_VGEN5VOL   = 0x70,
+   PFUZE100_VGEN6VOL   = 0x71,
+
+   PMIC_NUM_OF_REGS= 0x7f,
+};
+
+/*
+ * LDO Configuration
+ */
+
+/* VGEN1/2 Voltage Configuration */
+#define LDOA_0_80V 0
+#define LDOA_0_85V 1
+#define LDOA_0_90V 2
+#define LDOA_0_95V 3
+#define LDOA_1_00V 4
+#define LDOA_1_05V 5
+#define LDOA_1_10V 6
+#define LDOA_1_15V 7
+#define LDOA_1_20V 8
+#define LDOA_1_25V 9
+#define LDOA_1_30V 10
+#define LDOA_1_35V 11
+#define LDOA_1_40V 12
+#define LDOA_1_45V 13
+#define LDOA_1_50V 14
+#define LDOA_1_55V 15
+
+/* VGEN3/4/5/6 Voltage Configuration */
+#define LDOB_1_80V 0
+#define LDOB_1_90V 1
+#define LDOB_2_00V 2
+#define LDOB_2_10V 3
+#define LDOB_2_20V 4
+#define LDOB_2_30V 5
+#define LDOB_2_40V 6
+#define LDOB_2_50V 7
+#define LDOB_2_60V 8
+#define LDOB_2_70V 9
+#define LDOB_2_80V 10
+#define LDOB_2_90V 11
+#define LDOB_3_00V 12
+#define LDOB_3_10V 13
+#define LDOB_3_20V 14
+#define LDOB_3_30V 15
+
+#define LDO_VOL_MASK   0xf
+#define LDO_EN 4
+
+/*
+ * Boost Regulator
+ */
+
+/* SWBST Output Voltage */
+#define SWBST_5_00V0
+#define SWBST_5_05V1
+#define SWBST_5_10V2
+#define SWBST_5_15V3
+
+#define SWBST_VOL_MASK 0x3
+#define SWBST_MODE_MASK0x6
+#define SWBST_MODE_OFF (2 << 0)
+#define SWBST_MODE_PFM (2 << 1)
+#define SWBST_MODE_AUTO(2 << 2)
+#define SWBST_MODE_APS (2 << 3)
+
+#endif
-- 
1.8.3.2

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


Re: [U-Boot] [PATCH v3 2/2] ventana: Add Gateworks Ventana family support

2014-02-05 Thread Wolfgang Denk
Dear Tim Harvey,

In message <1391642553-25778-1-git-send-email-thar...@gateworks.com> you wrote:
> Gateworks Ventana is a product family based on the i.MX6.  This
> patch adds support for all boards in the Ventana family. Where
> possible, data from the boards EEPROM is used to determine various
> details about the board at runtime.
...
> +#define MINMAX(n, percent)   n*(1.0-percent/100), n*(1.0+percent/100)

U-Boot is integer arithmetics only.  You must not use any FP
calculations in the code.


> +/*
> + * Hardware Monitor
> + */
> +#define GSC_HWMON_TEMP   0x00
> +#define GSC_HWMON_VIN0x02
> +#define GSC_HWMON_VDD_3P30x05
> +#define GSC_HWMON_VBATT  0x08
> +#define GSC_HWMON_VDD_5P00x0b
> +#define GSC_HWMON_VDD_CORE   0x0e
> +#define GSC_HWMON_VDD_HIGH   0x14
> +#define GSC_HWMON_VDD_DDR0x17
> +#define GSC_HWMON_VDD_SOC0x11
> +#define GSC_HWMON_VDD_1P80x1d
> +#define GSC_HWMON_VDD_2P50x23
> +#define GSC_HWMON_VDD_1P00x20

I'd really like to see a C struct here to describe the register
layout...


> diff --git a/include/configs/gw_ventana.h b/include/configs/gw_ventana.h
> new file mode 100644
> index 000..1a18d93
...
> +  #define CONFIG_SPI_FLASH_WINBOND_ERASESIZE 64*1024  /* 4,32,64K for 
> W26Q256 */


This causes a checkpatch error:

ERROR: Macros with complex values should be enclosed in parenthesis

Please fix!

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
The use of anthropomorphic terminology when  dealing  with  computing
systems is a symptom of professional immaturity.   -- Edsger Dijkstra
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v3 2/2] ventana: Add Gateworks Ventana family support

2014-02-05 Thread Tim Harvey
On Wed, Feb 5, 2014 at 3:43 PM, Wolfgang Denk  wrote:
>
> Dear Tim Harvey,
>
> In message <1391642553-25778-1-git-send-email-thar...@gateworks.com> you 
> wrote:
> > Gateworks Ventana is a product family based on the i.MX6.  This
> > patch adds support for all boards in the Ventana family. Where
> > possible, data from the boards EEPROM is used to determine various
> > details about the board at runtime.
> ...
> > +#define MINMAX(n, percent)   n*(1.0-percent/100), n*(1.0+percent/100)
>
> U-Boot is integer arithmetics only.  You must not use any FP
> calculations in the code.

ok

>
>
> > +/*
> > + * Hardware Monitor
> > + */
> > +#define GSC_HWMON_TEMP   0x00
> > +#define GSC_HWMON_VIN0x02
> > +#define GSC_HWMON_VDD_3P30x05
> > +#define GSC_HWMON_VBATT  0x08
> > +#define GSC_HWMON_VDD_5P00x0b
> > +#define GSC_HWMON_VDD_CORE   0x0e
> > +#define GSC_HWMON_VDD_HIGH   0x14
> > +#define GSC_HWMON_VDD_DDR0x17
> > +#define GSC_HWMON_VDD_SOC0x11
> > +#define GSC_HWMON_VDD_1P80x1d
> > +#define GSC_HWMON_VDD_2P50x23
> > +#define GSC_HWMON_VDD_1P00x20
>
> I'd really like to see a C struct here to describe the register
> layout...

you mean enum right?

I see that some include/power/*.h use enums for regs, others use
#defines.  I would agree that enums save some text at least and seem
preferable.

>
>
> > diff --git a/include/configs/gw_ventana.h b/include/configs/gw_ventana.h
> > new file mode 100644
> > index 000..1a18d93
> ...
> > +  #define CONFIG_SPI_FLASH_WINBOND_ERASESIZE 64*1024  /* 4,32,64K for 
> > W26Q256 */
>
>
> This causes a checkpatch error:
>
> ERROR: Macros with complex values should be enclosed in parenthesis
>
> Please fix!

what args do you run checkpatch.pl with?  The default args does not
check COMPLEX_MACRO it would seem which is why I missed that.

Thanks,

Tim

>
> Best regards,
>
> Wolfgang Denk
>
> --
> DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
> The use of anthropomorphic terminology when  dealing  with  computing
> systems is a symptom of professional immaturity.   -- Edsger Dijkstra
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] serial: s5p: set automatically clears after resetting Rx FIFO

2014-02-05 Thread Minkyu Kang
On 04/02/14 14:57, Inha Song wrote:
> This patch fix the u-boot shell problem on TRATS2 board.
>  - If hold the key while booting is in progress,
>white spaces are written in u-boot shell.
> 
> Set Automatically clears after resetting Rx FIFO.
> 
> Signed-off-by: Inha Song 
> Signed-off-by: Jaehoon Chung 
> ---
>  drivers/serial/serial_s5p.c |4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 

applied to u-boot-samsung

Thanks,
Minkyu Kang.

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


Re: [U-Boot] [PATCH v2 1/6] usb:gadget:ums: Replace malloc calls with memalign to fix cache buffer alignment

2014-02-05 Thread Marek Vasut
On Wednesday, February 05, 2014 at 10:10:41 AM, Lukasz Majewski wrote:
> Calls to malloc() have been replaced by memalign. It now provides proper
> buffer alignment.
> 
> Signed-off-by: Lukasz Majewski 
> Cc: Marek Vasut 
> 
> ---
> Changes for v2:
> - Remove Change-Id.
> ---
>  drivers/usb/gadget/f_mass_storage.c |4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/gadget/f_mass_storage.c
> b/drivers/usb/gadget/f_mass_storage.c index b1fe8bd..f896169 100644
> --- a/drivers/usb/gadget/f_mass_storage.c
> +++ b/drivers/usb/gadget/f_mass_storage.c
> @@ -2515,7 +2515,7 @@ static struct fsg_common *fsg_common_init(struct
> fsg_common *common, buffhds_first_it:
>   bh->inreq_busy = 0;
>   bh->outreq_busy = 0;
> - bh->buf = kmalloc(FSG_BUFLEN, GFP_KERNEL);
> + bh->buf = memalign(CONFIG_SYS_CACHELINE_SIZE, FSG_BUFLEN);
>   if (unlikely(!bh->buf)) {
>   rc = -ENOMEM;
>   goto error_release;
> @@ -2622,7 +2622,7 @@ usb_copy_descriptors(struct usb_descriptor_header
> **src) bytes += (*tmp)->bLength;
>   bytes += (n_desc + 1) * sizeof(*tmp);
> 
> - mem = kmalloc(bytes, GFP_KERNEL);
> + mem = memalign(CONFIG_SYS_CACHELINE_SIZE, bytes);

I wonder, does this align the begining of the buffer as well or only the size? 
Can we rely on the fact the begining is also cacheline-aligned ?

>   if (!mem)
>   return NULL;

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


Re: [U-Boot] [PATCH v2 0/6] usb:samsung: Exynos4 SoC USB code improvements

2014-02-05 Thread Marek Vasut
On Wednesday, February 05, 2014 at 10:10:40 AM, Lukasz Majewski wrote:
> This patch series comprises several improvements for Exynos4 USB code.
> 
> The most notable is transmission speed improvement (measured on Trats):
> From 9.51 MiB/s up to 27 MiB/s
> 
> This is due to UDC driver optimizations.
> 
> Also a code cleanup for THOR gadget has been included.
> 
> Lukasz Majewski (6):
>   usb:gadget:ums: Replace malloc calls with memalign to fix cache
> buffer alignment
>   usb:udc:samsung: Remove redundant cache operation from Samsung UDC
> driver
>   usb:udc:samsung: Allow burst transfers for non EP0 endpints
>   usb:udc:samsung: Zero copy approach for data passed to Samsung's UDC
> driver
>   usb:gadget:f_thor: Allocate request up to THOR_PACKET_SIZE not
> ep->maxpacket
>   usb:gadget:f_thor: cosmetic: Remove debug memset
> 
>  drivers/usb/gadget/f_mass_storage.c   |4 +-
>  drivers/usb/gadget/f_thor.c   |4 +-
>  drivers/usb/gadget/s3c_udc_otg.c  |   19 +++
>  drivers/usb/gadget/s3c_udc_otg_xfer_dma.c |   87
> - include/usb/s3c_udc.h | 
>   5 +-
>  5 files changed, 49 insertions(+), 70 deletions(-)

Applied all, but I'd like to know about the memalign() calls' precise alignment 
behavior -- that is, if the begining if cacheline aligned or if it's only the 
size or what -- see my rant /wrt patch #1 .

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


[U-Boot] [PATCH] usb: mv_udc: Rename to ci_udc

2014-02-05 Thread Marek Vasut
The mv_udc is not marvell-specific anymore. The mv_udc is used to drive
generic ChipIdea CI13xxx series OTG cores, so rename the driver to ci_udc
instead.

Signed-off-by: Marek Vasut 
Cc: Eric Nelson 
Cc: Stefano Babic 
---
 board/boundary/nitrogen6x/nitrogen6x.c|   2 +-
 drivers/serial/usbtty.h   |   4 +-
 drivers/usb/gadget/Makefile   |   2 +-
 drivers/usb/gadget/{mv_udc.c => ci_udc.c} | 178 +++---
 drivers/usb/gadget/{mv_udc.h => ci_udc.h} |  12 +-
 drivers/usb/gadget/gadget_chips.h |   8 +-
 include/configs/nitrogen6x.h  |   2 +-
 include/configs/sansa_fuze_plus.h |   2 +-
 include/configs/xfi3.h|   2 +-
 include/usb/{mv_udc.h => ci_udc.h}|   6 +-
 10 files changed, 109 insertions(+), 109 deletions(-)
 rename drivers/usb/gadget/{mv_udc.c => ci_udc.c} (79%)
 rename drivers/usb/gadget/{mv_udc.h => ci_udc.h} (94%)
 rename include/usb/{mv_udc.h => ci_udc.h} (73%)

diff --git a/board/boundary/nitrogen6x/nitrogen6x.c 
b/board/boundary/nitrogen6x/nitrogen6x.c
index 3f4cfa1..d9c05b0 100644
--- a/board/boundary/nitrogen6x/nitrogen6x.c
+++ b/board/boundary/nitrogen6x/nitrogen6x.c
@@ -389,7 +389,7 @@ int board_eth_init(bd_t *bis)
}
 #endif
 
-#ifdef CONFIG_MV_UDC
+#ifdef CONFIG_CI_UDC
/* For otg ethernet*/
usb_eth_initialize(bis);
 #endif
diff --git a/drivers/serial/usbtty.h b/drivers/serial/usbtty.h
index 819dec6..21a3ef4 100644
--- a/drivers/serial/usbtty.h
+++ b/drivers/serial/usbtty.h
@@ -20,8 +20,8 @@
 #include 
 #elif defined(CONFIG_DW_UDC)
 #include 
-#elif defined(CONFIG_MV_UDC)
-#include 
+#elif defined(CONFIG_CI_UDC)
+#include 
 #endif
 
 #include 
diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
index f13b172..804a2bd 100644
--- a/drivers/usb/gadget/Makefile
+++ b/drivers/usb/gadget/Makefile
@@ -21,7 +21,7 @@ endif
 ifdef CONFIG_USB_ETHER
 obj-y += ether.o
 obj-$(CONFIG_USB_ETH_RNDIS) += rndis.o
-obj-$(CONFIG_MV_UDC)   += mv_udc.o
+obj-$(CONFIG_CI_UDC)   += ci_udc.o
 obj-$(CONFIG_CPU_PXA25X) += pxa25x_udc.o
 else
 # Devices not related to the new gadget layer depend on CONFIG_USB_DEVICE
diff --git a/drivers/usb/gadget/mv_udc.c b/drivers/usb/gadget/ci_udc.c
similarity index 79%
rename from drivers/usb/gadget/mv_udc.c
rename to drivers/usb/gadget/ci_udc.c
index da41738..6c5ef4c 100644
--- a/drivers/usb/gadget/mv_udc.c
+++ b/drivers/usb/gadget/ci_udc.c
@@ -20,9 +20,9 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include "../host/ehci.h"
-#include "mv_udc.h"
+#include "ci_udc.h"
 
 /*
  * Check if the system has too long cachelines. If the cachelines are
@@ -70,85 +70,85 @@ static struct usb_endpoint_descriptor ep0_in_desc = {
.bmAttributes = USB_ENDPOINT_XFER_CONTROL,
 };
 
-static int mv_pullup(struct usb_gadget *gadget, int is_on);
-static int mv_ep_enable(struct usb_ep *ep,
+static int ci_pullup(struct usb_gadget *gadget, int is_on);
+static int ci_ep_enable(struct usb_ep *ep,
const struct usb_endpoint_descriptor *desc);
-static int mv_ep_disable(struct usb_ep *ep);
-static int mv_ep_queue(struct usb_ep *ep,
+static int ci_ep_disable(struct usb_ep *ep);
+static int ci_ep_queue(struct usb_ep *ep,
struct usb_request *req, gfp_t gfp_flags);
 static struct usb_request *
-mv_ep_alloc_request(struct usb_ep *ep, unsigned int gfp_flags);
-static void mv_ep_free_request(struct usb_ep *ep, struct usb_request *_req);
+ci_ep_alloc_request(struct usb_ep *ep, unsigned int gfp_flags);
+static void ci_ep_free_request(struct usb_ep *ep, struct usb_request *_req);
 
-static struct usb_gadget_ops mv_udc_ops = {
-   .pullup = mv_pullup,
+static struct usb_gadget_ops ci_udc_ops = {
+   .pullup = ci_pullup,
 };
 
-static struct usb_ep_ops mv_ep_ops = {
-   .enable = mv_ep_enable,
-   .disable= mv_ep_disable,
-   .queue  = mv_ep_queue,
-   .alloc_request  = mv_ep_alloc_request,
-   .free_request   = mv_ep_free_request,
+static struct usb_ep_ops ci_ep_ops = {
+   .enable = ci_ep_enable,
+   .disable= ci_ep_disable,
+   .queue  = ci_ep_queue,
+   .alloc_request  = ci_ep_alloc_request,
+   .free_request   = ci_ep_free_request,
 };
 
 /* Init values for USB endpoints. */
-static const struct usb_ep mv_ep_init[2] = {
+static const struct usb_ep ci_ep_init[2] = {
[0] = { /* EP 0 */
.maxpacket  = 64,
.name   = "ep0",
-   .ops= &mv_ep_ops,
+   .ops= &ci_ep_ops,
},
[1] = { /* EP 1..n */
.maxpacket  = 512,
.name   = "ep-",
-   .ops= &mv_ep_ops,
+   .ops= &ci_ep_ops,
},
 };
 
-static struct mv_drv controller = {
+static struct ci_drv controller = {
.gadget = {
-   .name   = "mv_udc",
-   .o

Re: [U-Boot] [PATCH] usb: mv_udc: Rename to ci_udc

2014-02-05 Thread Fabio Estevam
On Wed, Feb 5, 2014 at 11:49 PM, Marek Vasut  wrote:

> The mv_udc is not marvell-specific anymore. The mv_udc is used to drive
> generic ChipIdea CI13xxx series OTG cores, so rename the driver to ci_udc
> instead.
>
> Signed-off-by: Marek Vasut 
> Cc: Eric Nelson 
> Cc: Stefano Babic 

Yes, makes sense:

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


Re: [U-Boot] [PATCH RESEND] MMC: DWMMC: Correct the CLKDIV register value

2014-02-05 Thread Jaehoon Chung
Hi.

Right, It's reasonable. Looks good to me. 

Acked-by: Jaehoon Chung 

Best Regards,
Jaehoon Chung

On 02/05/2014 02:58 PM, Rajeshwari Birje wrote:
> Hi All,
> 
> CCing Jaehoon Chung.
> 
> Regards,
> Rajeshwari
> 
> On Wed, Feb 5, 2014 at 10:48 AM, Rajeshwari Shinde
>  wrote:
>> From: Rajeshwari S Shinde 
>>
>> This patch corrects the divider value written to CLKDIV register.
>> Since SDCLKIN is divided inside controller by the DIVRATIO value set
>> in the CLKSEL register, we need to use the same output clock value to
>> calculate the CLKDIV value.
>> as per user manual: cclk_in = SDCLKIN / (DIVRATIO + 1)
>>
>> Input parameter to mmc_clk is changed to dwmci_host, since
>> we need the same to read DWMCI_CLKSEL register.
>>
>> This improves the read timing values for channel 0 on SMDK5250
>> from 0.288sec to 0.144sec
>>
>> Signed-off-by: Rajeshwari S Shinde 
>> ---
>>  arch/arm/include/asm/arch-exynos/dwmmc.h |  4 
>>  drivers/mmc/dw_mmc.c |  2 +-
>>  drivers/mmc/exynos_dw_mmc.c  | 17 +++--
>>  include/dwmmc.h  |  2 +-
>>  4 files changed, 21 insertions(+), 4 deletions(-)
>>
>> diff --git a/arch/arm/include/asm/arch-exynos/dwmmc.h 
>> b/arch/arm/include/asm/arch-exynos/dwmmc.h
>> index 09d739d..a7ca12c 100644
>> --- a/arch/arm/include/asm/arch-exynos/dwmmc.h
>> +++ b/arch/arm/include/asm/arch-exynos/dwmmc.h
>> @@ -23,6 +23,10 @@
>>  #define MPSCTRL_ENCRYPTION (0x1<<1)
>>  #define MPSCTRL_VALID  (0x1<<0)
>>
>> +/* CLKSEL Register */
>> +#define DWMCI_DIVRATIO_BIT 24
>> +#define DWMCI_DIVRATIO_MASK0x7
>> +
>>  #ifdef CONFIG_OF_CONTROL
>>  int exynos_dwmmc_init(const void *blob);
>>  #endif
>> diff --git a/drivers/mmc/dw_mmc.c b/drivers/mmc/dw_mmc.c
>> index 4cec5aa..d45c15c 100644
>> --- a/drivers/mmc/dw_mmc.c
>> +++ b/drivers/mmc/dw_mmc.c
>> @@ -237,7 +237,7 @@ static int dwmci_setup_bus(struct dwmci_host *host, u32 
>> freq)
>>  * host->bus_hz should be set from user.
>>  */
>> if (host->get_mmc_clk)
>> -   sclk = host->get_mmc_clk(host->dev_index);
>> +   sclk = host->get_mmc_clk(host);
>> else if (host->bus_hz)
>> sclk = host->bus_hz;
>> else {
>> diff --git a/drivers/mmc/exynos_dw_mmc.c b/drivers/mmc/exynos_dw_mmc.c
>> index b3e5c5e..de8cdcc 100644
>> --- a/drivers/mmc/exynos_dw_mmc.c
>> +++ b/drivers/mmc/exynos_dw_mmc.c
>> @@ -29,9 +29,22 @@ static void exynos_dwmci_clksel(struct dwmci_host *host)
>> dwmci_writel(host, DWMCI_CLKSEL, host->clksel_val);
>>  }
>>
>> -unsigned int exynos_dwmci_get_clk(int dev_index)
>> +unsigned int exynos_dwmci_get_clk(struct dwmci_host *host)
>>  {
>> -   return get_mmc_clk(dev_index);
>> +   unsigned long sclk;
>> +   int8_t clk_div;
>> +
>> +   /*
>> +* Since SDCLKIN is divided inside controller by the DIVRATIO
>> +* value set in the CLKSEL register, we need to use the same output
>> +* clock value to calculate the CLKDIV value.
>> +* as per user manual:cclk_in = SDCLKIN / (DIVRATIO + 1)
>> +*/
>> +   clk_div = ((dwmci_readl(host, DWMCI_CLKSEL) >> DWMCI_DIVRATIO_BIT)
>> +   & DWMCI_DIVRATIO_MASK) + 1;
>> +   sclk = get_mmc_clk(host->dev_index);
>> +
>> +   return sclk / clk_div;
>>  }
>>
>>  static void exynos_dwmci_board_init(struct dwmci_host *host)
>> diff --git a/include/dwmmc.h b/include/dwmmc.h
>> index a02dd67..b641558 100644
>> --- a/include/dwmmc.h
>> +++ b/include/dwmmc.h
>> @@ -142,7 +142,7 @@ struct dwmci_host {
>>
>> void (*clksel)(struct dwmci_host *host);
>> void (*board_init)(struct dwmci_host *host);
>> -   unsigned int (*get_mmc_clk)(int dev_index);
>> +   unsigned int (*get_mmc_clk)(struct dwmci_host *host);
>>  };
>>
>>  struct dwmci_idmac {
>> --
>> 1.7.12.4
>>
>> ___
>> U-Boot mailing list
>> U-Boot@lists.denx.de
>> http://lists.denx.de/mailman/listinfo/u-boot
> 
> 
> 

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


[U-Boot] [PULL] u-boot-pxa/master

2014-02-05 Thread Marek Vasut
The following changes since commit e97f9d817e600cd6f43d1d0da76f5787e33a5c56:

  Merge branch 'u-boot-ti/master' into 'u-boot-arm/master' (2014-01-29 14:07:50 
+0100)

are available in the git repository at:


  git://git.denx.de/u-boot-pxa.git master

for you to fetch changes up to f8d1086851409ee16344932ef367b8a05c365b09:

  ARM: serial: Remove the IXP UART driver (2014-02-06 02:51:52 +0100)


Marek Vasut (10):
  ARM: IXP: Remove actux1 board
  ARM: IXP: Remove actux2 board
  ARM: IXP: Remove actux3 board
  ARM: IXP: Remove actux4 board
  ARM: IXP: Remove dvl_host board
  ARM: IXP: Remove the IXP architecture support
  ARM: USB: Remove the IXP EHCI driver
  ARM: PCI: Remove the IXP PCI driver
  ARM: NET: Remove the IXP NPE ethernet driver
  ARM: serial: Remove the IXP UART driver

 MAKEALL   |2 -
 Makefile  |1 -
 README|1 -
 arch/arm/cpu/ixp/Makefile |   12 -
 arch/arm/cpu/ixp/config.mk|   16 -
 arch/arm/cpu/ixp/cpu.c|  100 ---
 arch/arm/cpu/ixp/interrupts.c |   66 --
 arch/arm/cpu/ixp/start.S  |  430 -
 arch/arm/cpu/ixp/timer.c  |  101 
 arch/arm/cpu/ixp/u-boot.lds   |   91 ---
 arch/arm/include/asm/arch-ixp/ixp425.h|  548 
-
 arch/arm/include/asm/arch-ixp/ixp425pci.h |  174 --
 arch/arm/include/asm/global_data.h|3 -
 board/actux1/Makefile |8 -
 board/actux1/actux1.c |  148 -
 board/actux1/actux1_hw.h  |   41 --
 board/actux1/u-boot.lds   |   99 ---
 board/actux2/Makefile |8 -
 board/actux2/actux2.c |  122 
 board/actux2/actux2_hw.h  |   43 --
 board/actux2/u-boot.lds   |   99 ---
 board/actux3/Makefile |8 -
 board/actux3/actux3.c |  149 -
 board/actux3/actux3_hw.h  |   44 --
 board/actux3/u-boot.lds   |   99 ---
 board/actux4/Makefile |8 -
 board/actux4/actux4.c |  129 
 board/actux4/actux4_hw.h  |   33 -
 board/dvlhost/Makefile|8 -
 board/dvlhost/dvlhost.c   |  112 
 board/dvlhost/dvlhost_hw.h|   31 -
 board/dvlhost/u-boot.lds  |   99 ---
 board/dvlhost/watchdog.c  |   27 -
 boards.cfg|8 -
 doc/README.scrapyard  |5 +
 doc/driver-model/UDM-pci.txt  |4 -
 doc/driver-model/UDM-serial.txt   |4 -
 drivers/i2c/soft_i2c.c|3 -
 drivers/net/npe/IxEthAcc.c|  237 
 drivers/net/npe/IxEthAccCommon.c  | 1025 
---
 drivers/net/npe/IxEthAccControlInterface.c|  509 

 drivers/net/npe/IxEthAccDataPlane.c   | 2459 
--
 drivers/net/npe/IxEthAccMac.c | 2617 
---
 drivers/net/npe/IxEthAccMii.c |  386 
 drivers/net/npe/IxEthDBAPI.c  |  424 -
 drivers/net/npe/IxEthDBAPISupport.c   |  651 

 drivers/net/npe/IxEthDBCore.c |  439 --
 drivers/net/npe/IxEthDBEvents.c   |  496 
---
 drivers/net/npe/IxEthDBFeatures.c |  638 

 drivers/net/npe/IxEthDBFirewall.c |  242 
 drivers/net/npe/IxEthDBHashtable.c|  618 
---
 drivers/net/npe/IxEthDBLearning.c |  125 
 drivers/net/npe/IxEthDBMem.c  |  625 
---
 drivers/net/npe/IxEthDBNPEAdaptor.c   |  695 
---

[U-Boot] [PATCH] i2c: i2c-mxs: Wait for I2C to empty queue

2014-02-05 Thread Marek Vasut
Make sure the I2C write queue is empty before leaving the mxs_i2c_write().
If we start and I2C write and only wait for ACK, the MXS I2C IP block may
enter next operation while still processing the write aftermath internally.
This will in turn disrupt one or more subsequent transfer(s).

A testcase for this issue is as such. This testcase is also interesting because
the first I2C_WRITE which becomes disruptive happens in the 'i2c read' command.
The 'i2c read' command first uses I2C_WRITE to send I2C address of the chip and
then uses I2C_READ to read data from the chip. After this command completes, the
'i2c probe' will use sequence of I2C_WRITE commands to probe the I2C bus. The
problem is that the first I2C_WRITE disrupted the I2C IP block operation and
this sideeffect propagates all the way to this next I2C_WRITE used by the 'i2c
probe' call. The result is the 'i2c probe' receives an ACK on I2C address 0x00,
even if this ACK was owned by the previous I2C_WRITE operation. Note that the
'i2c read' command must read from a valid I2C chip address.

Wrong:
> i2c probe
Valid chip addresses: 50 51
> i2c read 0x50 0x0.2 0x10 0x4200
> i2c probe
Valid chip addresses: 00 50 51

With this patch
> i2c probe
Valid chip addresses: 50 51
> i2c read 0x50 0x0.2 0x10 0x4200
> i2c probe
Valid chip addresses: 50 51

Signed-off-by: Marek Vasut 
Cc: Heiko Schocher 
Cc: Fabio Estevam 
---
 drivers/i2c/mxs_i2c.c | 39 ---
 1 file changed, 32 insertions(+), 7 deletions(-)

diff --git a/drivers/i2c/mxs_i2c.c b/drivers/i2c/mxs_i2c.c
index a298c95..de3b194 100644
--- a/drivers/i2c/mxs_i2c.c
+++ b/drivers/i2c/mxs_i2c.c
@@ -64,16 +64,17 @@ static void mxs_i2c_setup_read(uint8_t chip, int len)
writel(I2C_QUEUECTRL_QUEUE_RUN, &i2c_regs->hw_i2c_queuectrl_set);
 }
 
-static void mxs_i2c_write(uchar chip, uint addr, int alen,
+static int mxs_i2c_write(uchar chip, uint addr, int alen,
uchar *buf, int blen, int stop)
 {
struct mxs_i2c_regs *i2c_regs = (struct mxs_i2c_regs *)MXS_I2C0_BASE;
-   uint32_t data;
+   uint32_t data, tmp;
int i, remain, off;
+   int timeout = MXS_I2C_MAX_TIMEOUT;
 
if ((alen > 4) || (alen == 0)) {
debug("MXS I2C: Invalid address length\n");
-   return;
+   return -EINVAL;
}
 
if (stop)
@@ -106,6 +107,19 @@ static void mxs_i2c_write(uchar chip, uint addr, int alen,
writel(data >> remain, &i2c_regs->hw_i2c_data);
 
writel(I2C_QUEUECTRL_QUEUE_RUN, &i2c_regs->hw_i2c_queuectrl_set);
+
+   while (--timeout) {
+   tmp = readl(&i2c_regs->hw_i2c_queuestat);
+   if (tmp & I2C_QUEUESTAT_WR_QUEUE_EMPTY)
+   break;
+   }
+
+   if (!timeout) {
+   debug("MXS I2C: Failed transmitting data!\n");
+   return -EINVAL;
+   }
+
+   return 0;
 }
 
 static int mxs_i2c_wait_for_ack(void)
@@ -154,7 +168,12 @@ int i2c_read(uchar chip, uint addr, int alen, uchar 
*buffer, int len)
int ret;
int i;
 
-   mxs_i2c_write(chip, addr, alen, NULL, 0, 0);
+   ret = mxs_i2c_write(chip, addr, alen, NULL, 0, 0);
+   if (ret) {
+   debug("MXS I2C: Failed writing address\n");
+   return ret;
+   }
+
ret = mxs_i2c_wait_for_ack();
if (ret) {
debug("MXS I2C: Failed writing address\n");
@@ -193,7 +212,12 @@ int i2c_read(uchar chip, uint addr, int alen, uchar 
*buffer, int len)
 int i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len)
 {
int ret;
-   mxs_i2c_write(chip, addr, alen, buffer, len, 1);
+   ret = mxs_i2c_write(chip, addr, alen, buffer, len, 1);
+   if (ret) {
+   debug("MXS I2C: Failed writing address\n");
+   return ret;
+   }
+
ret = mxs_i2c_wait_for_ack();
if (ret)
debug("MXS I2C: Failed writing address\n");
@@ -204,8 +228,9 @@ int i2c_write(uchar chip, uint addr, int alen, uchar 
*buffer, int len)
 int i2c_probe(uchar chip)
 {
int ret;
-   mxs_i2c_write(chip, 0, 1, NULL, 0, 1);
-   ret = mxs_i2c_wait_for_ack();
+   ret = mxs_i2c_write(chip, 0, 1, NULL, 0, 1);
+   if (!ret)
+   ret = mxs_i2c_wait_for_ack();
mxs_i2c_reset();
return ret;
 }
-- 
1.8.5.3

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


Re: [U-Boot] [PATCH] usb: mv_udc: Rename to ci_udc

2014-02-05 Thread Eric Nelson

Hi Marek,

On 02/05/2014 06:49 PM, Marek Vasut wrote:

The mv_udc is not marvell-specific anymore. The mv_udc is used to drive
generic ChipIdea CI13xxx series OTG cores, so rename the driver to ci_udc
instead.



Sounds good.


Signed-off-by: Marek Vasut 
Cc: Eric Nelson 
Cc: Stefano Babic 
---
  board/boundary/nitrogen6x/nitrogen6x.c|   2 +-
  drivers/serial/usbtty.h   |   4 +-
  drivers/usb/gadget/Makefile   |   2 +-
  drivers/usb/gadget/{mv_udc.c => ci_udc.c} | 178 +++---
  drivers/usb/gadget/{mv_udc.h => ci_udc.h} |  12 +-
  drivers/usb/gadget/gadget_chips.h |   8 +-
  include/configs/nitrogen6x.h  |   2 +-
  include/configs/sansa_fuze_plus.h |   2 +-
  include/configs/xfi3.h|   2 +-
  include/usb/{mv_udc.h => ci_udc.h}|   6 +-
  10 files changed, 109 insertions(+), 109 deletions(-)
  rename drivers/usb/gadget/{mv_udc.c => ci_udc.c} (79%)
  rename drivers/usb/gadget/{mv_udc.h => ci_udc.h} (94%)
  rename include/usb/{mv_udc.h => ci_udc.h} (73%)

...
diff --git a/drivers/usb/gadget/mv_udc.c b/drivers/usb/gadget/ci_udc.c
similarity index 79%
rename from drivers/usb/gadget/mv_udc.c
rename to drivers/usb/gadget/ci_udc.c
index da41738..6c5ef4c 100644
--- a/drivers/usb/gadget/mv_udc.c
+++ b/drivers/usb/gadget/ci_udc.c


> ...
>

I think you missed the mvudc_probe() routine though:


@@ -673,23 +673,23 @@ static int mvudc_probe(void)


Aside from that...

Reviewed-by: Eric Nelson 


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


[U-Boot] [PATCH] ARM: bcm2835: fix mbox POWER_STATE_RESP_ON value

2014-02-05 Thread Stephen Warren
Typo: The correct value is 1 not 2.

Signed-off-by: Stephen Warren 
---
 arch/arm/include/asm/arch-bcm2835/mbox.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/include/asm/arch-bcm2835/mbox.h 
b/arch/arm/include/asm/arch-bcm2835/mbox.h
index 38cb42a..dded857 100644
--- a/arch/arm/include/asm/arch-bcm2835/mbox.h
+++ b/arch/arm/include/asm/arch-bcm2835/mbox.h
@@ -143,7 +143,7 @@ struct bcm2835_mbox_tag_get_arm_mem {
 #define BCM2835_MBOX_POWER_DEVID_SPI   7
 #define BCM2835_MBOX_POWER_DEVID_CCP2TX8
 
-#define BCM2835_MBOX_POWER_STATE_RESP_ON   (1 << 1)
+#define BCM2835_MBOX_POWER_STATE_RESP_ON   (1 << 0)
 /* Device doesn't exist */
 #define BCM2835_MBOX_POWER_STATE_RESP_NODEV(1 << 1)
 
-- 
1.8.3.2

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


[U-Boot] [PATCH] tools: mxsboot: Implement SPI SMEM block support

2014-02-05 Thread Marek Vasut
This patch adds support for augmenting the BootStream with the
SMEM block. For further details on the SMEM block, please refer
to i.MX28 datasheet section 12.10 .

NOTE: It is absolutely optional to augment BootStream with SMEM
  block. The SMEM block is only useful if you need to tweak
  SPI NOR clockspeed or place the u-boot.sb elsewhere than
  at block 1 of the SPI NOR (SMEM block resides in block 0).
  The i.MX28 will boot BootStream image placed at block 0 in
  SPI NOR directly.

Signed-off-by: Marek Vasut 
Cc: Stefano Babic 
---
 tools/mxsboot.c | 133 ++--
 1 file changed, 130 insertions(+), 3 deletions(-)

diff --git a/tools/mxsboot.c b/tools/mxsboot.c
index 90b2173..1575e8d 100644
--- a/tools/mxsboot.c
+++ b/tools/mxsboot.c
@@ -38,6 +38,14 @@ static uint32_t nand_erasesize = 128 * 1024;
 static uint32_t sd_sector = 2048;
 
 /*
+ * Layout for the SPI configuration block with the default settings
+ * in it. This is what the BootROM uses.
+ */
+static uint32_t spi_sector_size = 128;
+static uint32_t spi_image_offset = 64 * 1024;  /* Block 1 */
+static uint32_t spi_clock_idx = 8; /* BootROM's default clock */
+
+/*
  * Each of the U-Boot bootstreams is at maximum 1MB big.
  *
  * TWEAK this if, for some wild reason, you need to boot bigger image.
@@ -125,6 +133,49 @@ struct mx28_sd_config_block {
struct mx28_sd_drive_info   drv_info[1];
 };
 
+#define SSP_CLOCK_CONFIG_CLKSEL(n) ((n) << 0)
+#define SSP_CLOCK_CONFIG_IO_FRAC(n)((n) << 1)
+#define SSP_CLOCK_CONFIG_SSP_FRAC(n)   ((n) << 7)
+#define SSP_CLOCK_CONFIG_SSP_DIV(n)((n) << 16)
+#define SSP_CLOCK_CONFIG_SSP_RATE(n)   ((n) << 24)
+#define SSP_CLOCK_CONFIG(clksel, iofrac, sspfrac, sspdiv, ssprate) \
+   SSP_CLOCK_CONFIG_CLKSEL(clksel) |   \
+   SSP_CLOCK_CONFIG_IO_FRAC(iofrac) |  \
+   SSP_CLOCK_CONFIG_SSP_FRAC(sspfrac) |\
+   SSP_CLOCK_CONFIG_SSP_DIV(sspdiv) |  \
+   SSP_CLOCK_CONFIG_SSP_RATE(ssprate)
+
+#define SSP_BOOT_FLAG_DISABLE_FASTREAD (1 << 0)
+
+struct mx28_spi_config_block {
+   uint32_tsignature;
+   uint32_tboot_start_addr;
+   uint32_tsector_size;
+   uint32_tflags;
+   uint32_tclock_config_size;
+   uint32_tclock_config;
+};
+
+/* This is aligned with Table 12-27 in i.MX28 reference manual. */
+static const uint32_t mx28_spi_clock_config[] = {
+   0x, /* 0 ... invalid. */
+   SSP_CLOCK_CONFIG(1, 0, 0, 100, 0),  /* 1 ... 0.24 MHz */
+   SSP_CLOCK_CONFIG(1, 0, 0, 24, 0),   /* 2 ... 1 MHz */
+   SSP_CLOCK_CONFIG(1, 0, 0, 12, 0),   /* 3 ... 2 MHz */
+   SSP_CLOCK_CONFIG(1, 0, 0, 6, 0),/* 4 ... 4 MHz */
+   SSP_CLOCK_CONFIG(1, 0, 0, 4, 0),/* 5 ... 6 MHz */
+   SSP_CLOCK_CONFIG(0, 18, 6, 10, 0),  /* 6 ... 8 MHz */
+   SSP_CLOCK_CONFIG(0, 18, 6, 8, 0),   /* 7 ... 10 MHz */
+   SSP_CLOCK_CONFIG(1, 0, 0, 2, 0),/* 8 ... 12 MHz */
+   SSP_CLOCK_CONFIG(0, 18, 5, 6, 0),   /* 9 ... 16 MHz */
+   SSP_CLOCK_CONFIG(0, 18, 6, 4, 0),   /* 10 .. 20 MHz */
+   SSP_CLOCK_CONFIG(0, 18, 8, 2, 0),   /* 11 .. 30 MHz */
+   SSP_CLOCK_CONFIG(0, 18, 6, 2, 0),   /* 12 .. 40 MHz */
+   SSP_CLOCK_CONFIG(0, 18, 5, 2, 0),   /* 13 .. 48 MHz */
+   SSP_CLOCK_CONFIG(0, 21, 4, 2, 0),   /* 14 .. 51.4 MHz */
+   0x  /* 15 .. invalid. */
+};
+
 static inline uint32_t mx28_nand_ecc_size_in_bits(uint32_t ecc_strength)
 {
return ecc_strength * 13;
@@ -445,6 +496,7 @@ static void usage(void)
" type of image:\n"
" \"nand\" for NAND image\n"
" \"sd\" for SD image\n"
+   " \"spi\" for SPI NOR image\n"
"   input file, the u-boot.sb bootstream\n"
"  output file, the bootable image\n"
"\n");
@@ -456,6 +508,11 @@ static void usage(void)
"\n"
"For SD boot, these options are accepted:\n"
"  -p   Sector where the SGTL partition starts\n"
+   "\n"
+   "For SPI NOR boot, these options are accepted:\n"
+   "  -s SPI NOR sector size\n"
+   "  -i SPI NOR image offset (multiple of page size)\n"
+   "  -c Clock INDEX (see Table 12-27 in MX28 RM)\n"
);
 }
 
@@ -577,6 +634,54 @@ err0:
return ret;
 }
 
+static int mx28_create_spi_image(int infd, int outfd)
+{
+   int ret = -1;
+   uint32_t *buf;
+   int size;
+   off_t fsize;
+   ssize_t wr_size;
+   struct mx28

[U-Boot] [PATCH 1/4] aes: Fix kerneldoc for aes.h

2014-02-05 Thread Marek Vasut
Fix the function annotations in aes.h so they're compatible with kerneldoc.

Signed-off-by: Marek Vasut 
---
 include/aes.h | 22 --
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/include/aes.h b/include/aes.h
index ea06308..c70eda6 100644
--- a/include/aes.h
+++ b/include/aes.h
@@ -25,29 +25,31 @@ enum {
 };
 
 /**
+ * aes_expand_key() - Expand the AES key
+ *
  * Expand a key into a key schedule, which is then used for the other
  * operations.
  *
- * \param key  Key, of length AES_KEY_LENGTH bytes
- * \param expkey   Buffer to place expanded key, AES_EXPAND_KEY_LENGTH
+ * @keyKey, of length AES_KEY_LENGTH bytes
+ * @expkey Buffer to place expanded key, AES_EXPAND_KEY_LENGTH
  */
 void aes_expand_key(u8 *key, u8 *expkey);
 
 /**
- * Encrypt a single block of data
+ * aes_encrypt() - Encrypt single block of data with AES 128
  *
- * in  Input data
- * expkey  Expanded key to use for encryption (from aes_expand_key())
- * out Output data
+ * @in Input data
+ * @expkey Expanded key to use for encryption (from aes_expand_key())
+ * @outOutput data
  */
 void aes_encrypt(u8 *in, u8 *expkey, u8 *out);
 
 /**
- * Decrypt a single block of data
+ * aes_decrypt() - Decrypt single block of data with AES 128
  *
- * in  Input data
- * expkey  Expanded key to use for decryption (from aes_expand_key())
- * out Output data
+ * @in Input data
+ * @expkey Expanded key to use for decryption (from aes_expand_key())
+ * @outOutput data
  */
 void aes_decrypt(u8 *in, u8 *expkey, u8 *out);
 
-- 
1.8.5.3

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


[U-Boot] [PATCH 4/4] aes: Add 'aes' command to access AES-128-CBC

2014-02-05 Thread Marek Vasut
Add simple 'aes' command, which allows using the AES-128-CBC encryption
and decryption functions from U-Boot command line.

Signed-off-by: Marek Vasut 
---
 README   |  1 +
 common/Makefile  |  1 +
 common/cmd_aes.c | 89 
 3 files changed, 91 insertions(+)
 create mode 100644 common/cmd_aes.c

diff --git a/README b/README
index fe48ccd..770113d 100644
--- a/README
+++ b/README
@@ -895,6 +895,7 @@ The following options need to be configured:
The default command configuration includes all commands
except those marked below with a "*".
 
+   CONFIG_CMD_AESAES 128 CBC encrypt/decrypt
CONFIG_CMD_ASKENV   * ask for env variable
CONFIG_CMD_BDIbdinfo
CONFIG_CMD_BEDBUG   * Include BedBug Debugger
diff --git a/common/Makefile b/common/Makefile
index a83246e..2879304 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -48,6 +48,7 @@ obj-$(CONFIG_ENV_IS_IN_UBI) += env_ubi.o
 obj-$(CONFIG_ENV_IS_NOWHERE) += env_nowhere.o
 
 # command
+obj-$(CONFIG_CMD_AES) += cmd_aes.o
 obj-$(CONFIG_CMD_AMBAPP) += cmd_ambapp.o
 obj-$(CONFIG_SOURCE) += cmd_source.o
 obj-$(CONFIG_CMD_SOURCE) += cmd_source.o
diff --git a/common/cmd_aes.c b/common/cmd_aes.c
new file mode 100644
index 000..76da3ef
--- /dev/null
+++ b/common/cmd_aes.c
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2014 Marek Vasut 
+ *
+ * Command for en/de-crypting block of memory with AES-128-CBC cipher.
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
+
+/**
+ * do_aes() - Handle the "aes" command-line command
+ * @cmdtp: Command data struct pointer
+ * @flag:  Command flag
+ * @argc:  Command-line argument count
+ * @argv:  Array of command-line arguments
+ *
+ * Returns zero on success, CMD_RET_USAGE in case of misuse and negative
+ * on error.
+ */
+static int do_aes(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
+{
+   uint32_t key_addr, src_addr, dst_addr, len;
+   uint8_t *key_ptr, *src_ptr, *dst_ptr;
+   uint8_t key_exp[AES_EXPAND_KEY_LENGTH];
+   uint32_t aes_blocks;
+   int enc;
+
+   if (argc != 6)
+   return CMD_RET_USAGE;
+
+   if (!strncmp(argv[1], "enc", 3))
+   enc = 1;
+   else if (!strncmp(argv[1], "dec", 3))
+   enc = 0;
+   else
+   return CMD_RET_USAGE;
+
+   key_addr = simple_strtoul(argv[2], NULL, 16);
+   src_addr = simple_strtoul(argv[3], NULL, 16);
+   dst_addr = simple_strtoul(argv[4], NULL, 16);
+   len = simple_strtoul(argv[5], NULL, 16);
+
+   key_ptr = (uint8_t *)key_addr;
+   src_ptr = (uint8_t *)src_addr;
+   dst_ptr = (uint8_t *)dst_addr;
+
+   /* First we expand the key. */
+   aes_expand_key(key_ptr, key_exp);
+
+   /* Calculate the number of AES blocks to encrypt. */
+   aes_blocks = DIV_ROUND_UP(len, AES_KEY_LENGTH);
+
+   if (enc)
+   aes_cbc_encrypt_blocks(key_exp, src_ptr, dst_ptr, aes_blocks);
+   else
+   aes_cbc_decrypt_blocks(key_exp, src_ptr, dst_ptr, aes_blocks);
+
+   return 0;
+}
+
+/***/
+#ifdef CONFIG_SYS_LONGHELP
+static char aes_help_text[] =
+   "enc key src dst len - Encrypt block of data $len bytes long\n"
+   "  at address $src using a key at address\n"
+   "  $key and store the result at address\n"
+   "  $dst. The $len size must be multiple of\n"
+   "  16 bytes and $key must be 16 bytes long.\n"
+   "aes dec key src dst len - Decrypt block of data $len bytes long\n"
+   "  at address $src using a key at address\n"
+   "  $key and store the result at address\n"
+   "  $dst. The $len size must be multiple of\n"
+   "  16 bytes and $key must be 16 bytes long.";
+#endif
+
+U_BOOT_CMD(
+   aes, 6, 1, do_aes,
+   "AES 128 CBC encryption",
+   aes_help_text
+);
-- 
1.8.5.3

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


[U-Boot] [PATCH 2/4] aes: Move the AES-128-CBC encryption function to common code

2014-02-05 Thread Marek Vasut
Move the AES-128-CBC encryption function implemented in tegra20-common/crypto.c
into lib/aes.c . This is well re-usable common code. Moreover, clean the code up
a bit and fix the kerneldoc-style annotations.

Signed-off-by: Marek Vasut 
---
 arch/arm/cpu/tegra20-common/crypto.c | 72 +---
 include/aes.h| 10 +
 lib/aes.c| 59 +
 3 files changed, 71 insertions(+), 70 deletions(-)

diff --git a/arch/arm/cpu/tegra20-common/crypto.c 
b/arch/arm/cpu/tegra20-common/crypto.c
index 8209f76..b18e67c 100644
--- a/arch/arm/cpu/tegra20-common/crypto.c
+++ b/arch/arm/cpu/tegra20-common/crypto.c
@@ -19,74 +19,6 @@ enum security_op {
SECURITY_ENCRYPT= 1 << 1,   /* Encrypt the data */
 };
 
-static void debug_print_vector(char *name, u32 num_bytes, u8 *data)
-{
-   u32 i;
-
-   debug("%s [%d] @0x%08x", name, num_bytes, (u32)data);
-   for (i = 0; i < num_bytes; i++) {
-   if (i % 16 == 0)
-   debug(" = ");
-   debug("%02x", data[i]);
-   if ((i+1) % 16 != 0)
-   debug(" ");
-   }
-   debug("\n");
-}
-
-/**
- * Apply chain data to the destination using EOR
- *
- * Each array is of length AES_AES_KEY_LENGTH.
- *
- * \param cbc_chain_data   Chain data
- * \param src  Source data
- * \param dst  Destination data, which is modified here
- */
-static void apply_cbc_chain_data(u8 *cbc_chain_data, u8 *src, u8 *dst)
-{
-   int i;
-
-   for (i = 0; i < 16; i++)
-   *dst++ = *src++ ^ *cbc_chain_data++;
-}
-
-/**
- * Encrypt some data with AES.
- *
- * \param key_schedule Expanded key to use
- * \param src  Source data to encrypt
- * \param dst  Destination buffer
- * \param num_aes_blocks   Number of AES blocks to encrypt
- */
-static void encrypt_object(u8 *key_schedule, u8 *src, u8 *dst,
-  u32 num_aes_blocks)
-{
-   u8 tmp_data[AES_KEY_LENGTH];
-   u8 *cbc_chain_data;
-   u32 i;
-
-   cbc_chain_data = zero_key;  /* Convenient array of 0's for IV */
-
-   for (i = 0; i < num_aes_blocks; i++) {
-   debug("encrypt_object: block %d of %d\n", i, num_aes_blocks);
-   debug_print_vector("AES Src", AES_KEY_LENGTH, src);
-
-   /* Apply the chain data */
-   apply_cbc_chain_data(cbc_chain_data, src, tmp_data);
-   debug_print_vector("AES Xor", AES_KEY_LENGTH, tmp_data);
-
-   /* encrypt the AES block */
-   aes_encrypt(tmp_data, key_schedule, dst);
-   debug_print_vector("AES Dst", AES_KEY_LENGTH, dst);
-
-   /* Update pointers for next loop. */
-   cbc_chain_data = dst;
-   src += AES_KEY_LENGTH;
-   dst += AES_KEY_LENGTH;
-   }
-}
-
 /**
  * Shift a vector left by one bit
  *
@@ -129,7 +61,7 @@ static void sign_object(u8 *key, u8 *key_schedule, u8 *src, 
u8 *dst,
for (i = 0; i < AES_KEY_LENGTH; i++)
tmp_data[i] = 0;
 
-   encrypt_object(key_schedule, tmp_data, left, 1);
+   aes_cbc_encrypt_blocks(key_schedule, tmp_data, left, 1);
debug_print_vector("AES(key, nonce)", AES_KEY_LENGTH, left);
 
left_shift_vector(left, k1, sizeof(left));
@@ -193,7 +125,7 @@ static int encrypt_and_sign(u8 *key, enum security_op oper, 
u8 *src,
if (oper & SECURITY_ENCRYPT) {
/* Perform this in place, resulting in src being encrypted. */
debug("encrypt_and_sign: begin encryption\n");
-   encrypt_object(key_schedule, src, src, num_aes_blocks);
+   aes_cbc_encrypt_blocks(key_schedule, src, src, num_aes_blocks);
debug("encrypt_and_sign: end encryption\n");
}
 
diff --git a/include/aes.h b/include/aes.h
index c70eda6..d9bb387 100644
--- a/include/aes.h
+++ b/include/aes.h
@@ -53,4 +53,14 @@ void aes_encrypt(u8 *in, u8 *expkey, u8 *out);
  */
 void aes_decrypt(u8 *in, u8 *expkey, u8 *out);
 
+/**
+ * aes_cbc_encrypt_blocks() - Encrypt multiple blocks of data with AES CBC.
+ *
+ * @key_expExpanded key to use
+ * @srcSource data to encrypt
+ * @dstDestination buffer
+ * @num_aes_blocks Number of AES blocks to encrypt
+ */
+void aes_cbc_encrypt_blocks(u8 *key_exp, u8 *src, u8 *dst, u32 num_aes_blocks);
+
 #endif /* _AES_REF_H_ */
diff --git a/lib/aes.c b/lib/aes.c
index e996b27..4df5dae 100644
--- a/lib/aes.c
+++ b/lib/aes.c
@@ -580,3 +580,62 @@ void aes_decrypt(u8 *in, u8 *expkey, u8 *out)
 
memcpy(out, state, sizeof(state));
 }
+
+static void debug_print_vector(char *name, u32 num_bytes, u8 *data)
+{
+   u32 i;
+
+   debug("%s [%d] @0x%08x", name, num_bytes, (u32)data);
+   for (i = 0; i < num_bytes; i++) {
+   if (i % 16 ==

[U-Boot] [PATCH 3/4] aes: Implement AES-128-CBC decryption function

2014-02-05 Thread Marek Vasut
Implement a compatible AES-128-CBC decryption function as a counterpart
of the encryption function pulled from tegra20-common/crypto.c .

Signed-off-by: Marek Vasut 
---
 include/aes.h | 10 ++
 lib/aes.c | 28 
 2 files changed, 38 insertions(+)

diff --git a/include/aes.h b/include/aes.h
index d9bb387..4897e6f 100644
--- a/include/aes.h
+++ b/include/aes.h
@@ -63,4 +63,14 @@ void aes_decrypt(u8 *in, u8 *expkey, u8 *out);
  */
 void aes_cbc_encrypt_blocks(u8 *key_exp, u8 *src, u8 *dst, u32 num_aes_blocks);
 
+/**
+ * Decrypt multiple blocks of data with AES CBC.
+ *
+ * @key_expExpanded key to use
+ * @srcSource data to decrypt
+ * @dstDestination buffer
+ * @num_aes_blocks Number of AES blocks to decrypt
+ */
+void aes_cbc_decrypt_blocks(u8 *key_exp, u8 *src, u8 *dst, u32 num_aes_blocks);
+
 #endif /* _AES_REF_H_ */
diff --git a/lib/aes.c b/lib/aes.c
index 4df5dae..8b23e10 100644
--- a/lib/aes.c
+++ b/lib/aes.c
@@ -639,3 +639,31 @@ void aes_cbc_encrypt_blocks(u8 *key_exp, u8 *src, u8 *dst, 
u32 num_aes_blocks)
dst += AES_KEY_LENGTH;
}
 }
+
+void aes_cbc_decrypt_blocks(u8 *key_exp, u8 *src, u8 *dst, u32 num_aes_blocks)
+{
+   u8 tmp_data[AES_KEY_LENGTH], tmp_block[AES_KEY_LENGTH];
+   /* Convenient array of 0's for IV */
+   u8 cbc_chain_data[AES_KEY_LENGTH] = { 0 };
+   u32 i;
+
+   for (i = 0; i < num_aes_blocks; i++) {
+   debug("encrypt_object: block %d of %d\n", i, num_aes_blocks);
+   debug_print_vector("AES Src", AES_KEY_LENGTH, src);
+
+   memcpy(tmp_block, src, AES_KEY_LENGTH);
+
+   /* Decrypt the AES block */
+   aes_decrypt(src, key_exp, tmp_data);
+   debug_print_vector("AES Xor", AES_KEY_LENGTH, tmp_data);
+
+   /* Apply the chain data */
+   apply_cbc_chain_data(cbc_chain_data, tmp_data, dst);
+   debug_print_vector("AES Dst", AES_KEY_LENGTH, dst);
+
+   /* Update pointers for next loop. */
+   memcpy(cbc_chain_data, tmp_block, AES_KEY_LENGTH);
+   src += AES_KEY_LENGTH;
+   dst += AES_KEY_LENGTH;
+   }
+}
-- 
1.8.5.3

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


[U-Boot] [PATCH 3/3] env: Implement support for AES encryption into fw_* tools

2014-02-05 Thread Marek Vasut
Implement support for encrypting/decrypting the environment block
into the tools/env/fw_* tools. The cipher used is AES 128 CBC and
the implementation depends solely on components internal to U-Boot.

To allow building against the internal AES library, the library did
need minor adjustments to not include U-Boot's headers which are not
wanted to be included and define missing types.

Signed-off-by: Marek Vasut 
---
 include/aes.h   |   7 +++
 lib/aes.c   |   4 ++
 tools/env/Makefile  |   1 +
 tools/env/fw_env.c  | 129 +++-
 tools/env/fw_env_main.c |  17 +--
 5 files changed, 151 insertions(+), 7 deletions(-)

diff --git a/include/aes.h b/include/aes.h
index 4897e6f..891d833 100644
--- a/include/aes.h
+++ b/include/aes.h
@@ -8,6 +8,13 @@
 #ifndef _AES_REF_H_
 #define _AES_REF_H_
 
+#ifdef USE_HOSTCC
+/* Define compat stuff for use in fw_* tools. */
+typedef unsigned char u8;
+typedef unsigned int u32;
+#define debug(...) do {} while(0)
+#endif
+
 /*
  * AES encryption library, with small code size, supporting only 128-bit AES
  *
diff --git a/lib/aes.c b/lib/aes.c
index 8b23e10..aec2afa 100644
--- a/lib/aes.c
+++ b/lib/aes.c
@@ -22,7 +22,11 @@
  * REDISTRIBUTION OF THIS SOFTWARE.
 */
 
+#ifndef USE_HOSTCC
 #include 
+#else
+#include 
+#endif
 #include "aes.h"
 
 /* forward s-box */
diff --git a/tools/env/Makefile b/tools/env/Makefile
index 27892f7..ae19200 100644
--- a/tools/env/Makefile
+++ b/tools/env/Makefile
@@ -10,6 +10,7 @@ include $(TOPDIR)/config.mk
 HOSTSRCS := $(SRCTREE)/lib/crc32.c  fw_env.c  fw_env_main.c
 HOSTSRCS += $(SRCTREE)/lib/ctype.c $(SRCTREE)/lib/linux_string.c
 HOSTSRCS += $(SRCTREE)/common/env_attr.c $(SRCTREE)/common/env_flags.c
+HOSTSRCS += $(SRCTREE)/lib/aes.c
 HEADERS:= fw_env.h $(OBJTREE)/include/config.h
 
 # Compile for a hosted environment on the target
diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c
index 577ce2d..807ec1b 100644
--- a/tools/env/fw_env.c
+++ b/tools/env/fw_env.c
@@ -31,6 +31,10 @@
 
 #include "fw_env.h"
 
+#include 
+
+#define DIV_ROUND_UP(n,d)  (((n) + (d) - 1) / (d))
+
 #define WHITESPACE(c) ((c == '\t') || (c == ' '))
 
 #define min(x, y) ({   \
@@ -98,6 +102,11 @@ static struct environment environment = {
.flag_scheme = FLAG_NONE,
 };
 
+/* Is AES encryption used? */
+static int aes_flag = 0;
+static uint8_t aes_key[AES_KEY_LENGTH] = {0};
+static int env_aes_cbc_crypt(char *data, const int enc);
+
 static int HaveRedundEnv = 0;
 
 static unsigned char active_flag = 1;
@@ -120,6 +129,10 @@ static inline ulong getenvsize (void)
 
if (HaveRedundEnv)
rc -= sizeof (char);
+
+   if (aes_flag)
+   rc &= ~(AES_KEY_LENGTH - 1);
+
return rc;
 }
 
@@ -191,6 +204,36 @@ char *fw_getdefenv(char *name)
return NULL;
 }
 
+static int parse_aes_key(char *key)
+{
+   char tmp[5] = { '0', 'x', 0, 0, 0 };
+   unsigned long ul;
+   int i;
+
+   if (strnlen(key, 64) != 32) {
+   fprintf (stderr, "## Error: "
+   "`-a' option requires 16-byte AES key\n");
+   return -1;
+   }
+
+   for (i = 0; i < 16; i++) {
+   tmp[2] = key[0];
+   tmp[3] = key[1];
+   errno = 0;
+   ul = strtoul(tmp, NULL, 16);
+   if (errno) {
+   fprintf (stderr, "## Error: "
+   "`-a' option requires valid AES key\n");
+   return -1;
+   }
+   aes_key[i] = ul & 0xff;
+   key += 2;
+   }
+   aes_flag = 1;
+
+   return 0;
+}
+
 /*
  * Print the current definition of one, or more, or all
  * environment variables
@@ -201,6 +244,19 @@ int fw_printenv (int argc, char *argv[])
int i, n_flag;
int rc = 0;
 
+   if (argc >= 2 && strcmp (argv[1], "-a") == 0) {
+   if (argc < 3) {
+   fprintf (stderr, "## Error: "
+   "`-a' option requires AES key\n");
+   return -1;
+   }
+   rc = parse_aes_key(argv[2]);
+   if (rc)
+   return rc;
+   argv += 2;
+   argc -= 2;
+   }
+
if (fw_env_open())
return -1;
 
@@ -266,6 +322,16 @@ int fw_printenv (int argc, char *argv[])
 
 int fw_env_close(void)
 {
+   int ret;
+   if (aes_flag) {
+   ret = env_aes_cbc_crypt(environment.data, 1);
+   if (ret) {
+   fprintf(stderr,
+   "Error: can't encrypt env for flash\n");
+   return ret;
+   }
+   }
+
/*
 * Update CRC
 */
@@ -413,7 +479,7 @@ int fw_env_write(char *name, char *value)
  */
 int fw_setenv(int argc, char *argv[])
 {
-   int i;
+   int i, rc;
size_t len;
 

[U-Boot] [PATCH 1/3] env: Add env_export() wrapper

2014-02-05 Thread Marek Vasut
Implement env_export() wrapper, so that all implementers of saveenv() don't
have to call hexport_r(), crc32() etc. sequence . This trims down a bit of
code duplication.

Signed-off-by: Marek Vasut 
---
 common/env_common.c| 17 +
 common/env_dataflash.c | 17 ++---
 common/env_eeprom.c| 12 +++-
 common/env_fat.c   | 12 +++-
 common/env_flash.c | 21 ++---
 common/env_mmc.c   | 12 ++--
 common/env_nand.c  | 13 -
 common/env_nvram.c | 12 +++-
 common/env_onenand.c   | 13 -
 common/env_sf.c| 24 +++-
 common/env_ubi.c   | 27 ---
 include/environment.h  |  3 +++
 12 files changed, 66 insertions(+), 117 deletions(-)

diff --git a/common/env_common.c b/common/env_common.c
index c0bfc2f..fe35ff4 100644
--- a/common/env_common.c
+++ b/common/env_common.c
@@ -172,6 +172,23 @@ int env_import(const char *buf, int check)
return 0;
 }
 
+/* Emport the environment and generate CRC for it. */
+int env_export(env_t *env_out)
+{
+   char *res;
+   ssize_t len;
+
+   res = (char *)env_out->data;
+   len = hexport_r(&env_htab, '\0', 0, &res, ENV_SIZE, 0, NULL);
+   if (len < 0) {
+   error("Cannot export environment: errno = %d\n", errno);
+   return 1;
+   }
+   env_out->crc = crc32(0, env_out->data, ENV_SIZE);
+
+   return 0;
+}
+
 void env_relocate(void)
 {
 #if defined(CONFIG_NEEDS_MANUAL_RELOC)
diff --git a/common/env_dataflash.c b/common/env_dataflash.c
index b53b87e..034e323 100644
--- a/common/env_dataflash.c
+++ b/common/env_dataflash.c
@@ -56,17 +56,12 @@ void env_relocate_spec(void)
 
 int saveenv(void)
 {
-   env_t   env_new;
-   ssize_t len;
-   char*res;
-
-   res = (char *)&env_new.data;
-   len = hexport_r(&env_htab, '\0', 0, &res, ENV_SIZE, 0, NULL);
-   if (len < 0) {
-   error("Cannot export environment: errno = %d\n", errno);
-   return 1;
-   }
-   env_new.crc = crc32(0, env_new.data, ENV_SIZE);
+   env_t env_new;
+   int ret;
+
+   ret = env_export(&env_new);
+   if (ret)
+   return ret;
 
return write_dataflash(CONFIG_ENV_ADDR,
(unsigned long)&env_new,
diff --git a/common/env_eeprom.c b/common/env_eeprom.c
index 0db2bb6..490ac73 100644
--- a/common/env_eeprom.c
+++ b/common/env_eeprom.c
@@ -98,8 +98,6 @@ void env_relocate_spec(void)
 int saveenv(void)
 {
env_t   env_new;
-   ssize_t len;
-   char*res;
int rc;
unsigned int off= CONFIG_ENV_OFFSET;
 #ifdef CONFIG_ENV_OFFSET_REDUND
@@ -109,13 +107,9 @@ int saveenv(void)
 
BUG_ON(env_ptr != NULL);
 
-   res = (char *)&env_new.data;
-   len = hexport_r(&env_htab, '\0', 0, &res, ENV_SIZE, 0, NULL);
-   if (len < 0) {
-   error("Cannot export environment: errno = %d\n", errno);
-   return 1;
-   }
-   env_new.crc = crc32(0, env_new.data, ENV_SIZE);
+   rc = env_export(&env_new);
+   if (rc)
+   return rc;
 
 #ifdef CONFIG_ENV_OFFSET_REDUND
if (gd->env_valid == 1) {
diff --git a/common/env_fat.c b/common/env_fat.c
index 708fd13..aad0487 100644
--- a/common/env_fat.c
+++ b/common/env_fat.c
@@ -37,19 +37,14 @@ int env_init(void)
 int saveenv(void)
 {
env_t   env_new;
-   ssize_t len;
-   char*res;
block_dev_desc_t *dev_desc = NULL;
int dev = FAT_ENV_DEVICE;
int part = FAT_ENV_PART;
int err;
 
-   res = (char *)&env_new.data;
-   len = hexport_r(&env_htab, '\0', 0, &res, ENV_SIZE, 0, NULL);
-   if (len < 0) {
-   error("Cannot export environment: errno = %d\n", errno);
-   return 1;
-   }
+   err = env_export(&env_new);
+   if (err)
+   return err;
 
 #ifdef CONFIG_MMC
if (strcmp(FAT_ENV_INTERFACE, "mmc") == 0) {
@@ -79,7 +74,6 @@ int saveenv(void)
return 1;
}
 
-   env_new.crc = crc32(0, env_new.data, ENV_SIZE);
err = file_fat_write(FAT_ENV_FILE, (void *)&env_new, sizeof(env_t));
if (err == -1) {
printf("\n** Unable to write \"%s\" from %s%d:%d **\n",
diff --git a/common/env_flash.c b/common/env_flash.c
index 7d5a4cf..b3ad908 100644
--- a/common/env_flash.c
+++ b/common/env_flash.c
@@ -106,8 +106,7 @@ int env_init(void)
 int saveenv(void)
 {
env_t   env_new;
-   ssize_t len;
-   char*res, *saved_data = NULL;
+   char*saved_data = NULL;
charflag = OBSOLETE_FLAG, new_flag = ACTIVE_FLAG;
int rc = 1;
 #if CONFIG_ENV_SECT_SIZE > CONFIG_ENV_SIZE
@@ -125,13 +124,9 @@ int saveenv(void)
if (flash_sect_protect(0, (ulong)flash_addr_new, end_addr_new))
goto done;
 
-   res = (char *)&env_new.data;
-   len = hexport_r(&env_hta

[U-Boot] [PATCH 2/3] env: Implement support for encrypting environment

2014-02-05 Thread Marek Vasut
Add function which allows encrypting the whole environment block with
AES-128-CBC. The key for the environment is retrieved by env_aes_cbc_get_key()
function, which must be implemented on a per-board basis.

Signed-off-by: Marek Vasut 
---
 common/env_common.c   | 62 +++
 include/environment.h | 12 +-
 2 files changed, 73 insertions(+), 1 deletion(-)

diff --git a/common/env_common.c b/common/env_common.c
index fe35ff4..cd7b4cd 100644
--- a/common/env_common.c
+++ b/common/env_common.c
@@ -140,6 +140,52 @@ int set_default_vars(int nvars, char * const vars[])
H_NOCLEAR | H_INTERACTIVE, nvars, vars);
 }
 
+#ifdef CONFIG_ENV_AES
+#include 
+/**
+ * env_aes_cbc_get_key() - Get AES-128-CBC key for the environment
+ *
+ * This function shall return 16-byte array containing AES-128 key used
+ * to encrypt and decrypt the environment. This function must be overriden
+ * by the implementer as otherwise the environment encryption will not
+ * work.
+ */
+__weak uint8_t *env_aes_cbc_get_key(void)
+{
+   return NULL;
+}
+
+static int env_aes_cbc_crypt(env_t *env, const int enc)
+{
+   unsigned char *data = env->data;
+   uint8_t *key;
+   uint8_t key_exp[AES_EXPAND_KEY_LENGTH];
+   uint32_t aes_blocks;
+
+   key = env_aes_cbc_get_key();
+   if (!key)
+   return -EINVAL;
+
+   /* First we expand the key. */
+   aes_expand_key(key, key_exp);
+
+   /* Calculate the number of AES blocks to encrypt. */
+   aes_blocks = ENV_SIZE / AES_KEY_LENGTH;
+
+   if (enc)
+   aes_cbc_encrypt_blocks(key_exp, data, data, aes_blocks);
+   else
+   aes_cbc_decrypt_blocks(key_exp, data, data, aes_blocks);
+
+   return 0;
+}
+#else
+static inline int env_aes_cbc_crypt(env_t *env, const int enc)
+{
+   return 0;
+}
+#endif
+
 /*
  * Check if CRC is valid and (if yes) import the environment.
  * Note that "buf" may or may not be aligned.
@@ -147,6 +193,7 @@ int set_default_vars(int nvars, char * const vars[])
 int env_import(const char *buf, int check)
 {
env_t *ep = (env_t *)buf;
+   int ret;
 
if (check) {
uint32_t crc;
@@ -159,6 +206,14 @@ int env_import(const char *buf, int check)
}
}
 
+   /* Decrypt the env if desired. */
+   ret = env_aes_cbc_crypt(ep, 0);
+   if (ret) {
+   error("Failed to decrypt env!\n");
+   set_default_env("!import failed");
+   return ret;
+   }
+
if (himport_r(&env_htab, (char *)ep->data, ENV_SIZE, '\0', 0,
0, NULL)) {
gd->flags |= GD_FLG_ENV_READY;
@@ -177,6 +232,7 @@ int env_export(env_t *env_out)
 {
char *res;
ssize_t len;
+   int ret;
 
res = (char *)env_out->data;
len = hexport_r(&env_htab, '\0', 0, &res, ENV_SIZE, 0, NULL);
@@ -184,6 +240,12 @@ int env_export(env_t *env_out)
error("Cannot export environment: errno = %d\n", errno);
return 1;
}
+
+   /* Encrypt the env if desired. */
+   ret = env_aes_cbc_crypt(env_out, 1);
+   if (ret)
+   return ret;
+
env_out->crc = crc32(0, env_out->data, ENV_SIZE);
 
return 0;
diff --git a/include/environment.h b/include/environment.h
index f797595..08679ae 100644
--- a/include/environment.h
+++ b/include/environment.h
@@ -146,7 +146,12 @@ extern unsigned long nand_env_oob_offset;
 extern char *env_name_spec;
 #endif
 
+#ifdef CONFIG_ENV_AES
+/* Make sure the payload is multiple of AES block size */
+#define ENV_SIZE ((CONFIG_ENV_SIZE - ENV_HEADER_SIZE) & ~(16 - 1))
+#else
 #define ENV_SIZE (CONFIG_ENV_SIZE - ENV_HEADER_SIZE)
+#endif
 
 typedef struct environment_s {
uint32_tcrc;/* CRC32 over data bytes*/
@@ -154,7 +159,12 @@ typedef struct environment_s {
unsigned char   flags;  /* active/obsolete flags*/
 #endif
unsigned char   data[ENV_SIZE]; /* Environment data */
-} env_t;
+} env_t
+#ifdef CONFIG_ENV_AES
+/* Make sure the env is aligned to block size. */
+__attribute__((aligned(16)))
+#endif
+;
 
 #ifdef ENV_IS_EMBEDDED
 extern env_t environment;
-- 
1.8.5.3

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


[U-Boot] [PATCH 1/3] fit: Add support for SHA256 hash

2014-02-05 Thread Marek Vasut
This patch adds support for SHA-256 hash into the FIT image. The usage is
as with the other hashing algorithms:

"
hash@1 {
algo = "sha256";
};
"

Signed-off-by: Marek Vasut 
---
 common/image-fit.c |  5 +
 include/image.h| 15 ++-
 tools/Makefile |  2 ++
 3 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/common/image-fit.c b/common/image-fit.c
index cf4b67e..a7ecf8b 100644
--- a/common/image-fit.c
+++ b/common/image-fit.c
@@ -22,6 +22,7 @@ DECLARE_GLOBAL_DATA_PTR;
 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -882,6 +883,10 @@ int calculate_hash(const void *data, int data_len, const 
char *algo,
sha1_csum_wd((unsigned char *)data, data_len,
 (unsigned char *)value, CHUNKSZ_SHA1);
*value_len = 20;
+   } else if (IMAGE_ENABLE_SHA256 && strcmp(algo, "sha256") == 0) {
+   sha256_csum_wd((unsigned char *)data, data_len,
+(unsigned char *)value, CHUNKSZ_SHA256);
+   *value_len = 32;
} else if (IMAGE_ENABLE_MD5 && strcmp(algo, "md5") == 0) {
md5_wd((unsigned char *)data, data_len, value, CHUNKSZ_MD5);
*value_len = 16;
diff --git a/include/image.h b/include/image.h
index 7de2bb2..e5c76e7 100644
--- a/include/image.h
+++ b/include/image.h
@@ -57,13 +57,18 @@ struct lmb;
 #  ifdef CONFIG_SPL_SHA1_SUPPORT
 #   define IMAGE_ENABLE_SHA1   1
 #  endif
+#  ifdef CONFIG_SPL_SHA256_SUPPORT
+#   define IMAGE_ENABLE_SHA256 1
+#  endif
 # else
 #  define CONFIG_CRC32 /* FIT images need CRC32 support */
 #  define CONFIG_MD5   /* and MD5 */
 #  define CONFIG_SHA1  /* and SHA1 */
+#  define CONFIG_SHA256/* and SHA256 */
 #  define IMAGE_ENABLE_CRC32   1
 #  define IMAGE_ENABLE_MD5 1
 #  define IMAGE_ENABLE_SHA11
+#  define IMAGE_ENABLE_SHA256  1
 # endif
 
 #ifndef IMAGE_ENABLE_CRC32
@@ -78,6 +83,10 @@ struct lmb;
 #define IMAGE_ENABLE_SHA1  0
 #endif
 
+#ifndef IMAGE_ENABLE_SHA256
+#define IMAGE_ENABLE_SHA2560
+#endif
+
 #endif /* CONFIG_FIT */
 
 #ifdef CONFIG_SYS_BOOT_RAMDISK_HIGH
@@ -345,6 +354,10 @@ extern bootm_headers_t images;
 #define CHUNKSZ_SHA1 (64 * 1024)
 #endif
 
+#ifndef CHUNKSZ_SHA256
+#define CHUNKSZ_SHA256 (64 * 1024)
+#endif
+
 #define uimage_to_cpu(x)   be32_to_cpu(x)
 #define cpu_to_uimage(x)   cpu_to_be32(x)
 
@@ -691,7 +704,7 @@ int bootz_setup(ulong image, ulong *start, ulong *end);
 #define FIT_FDT_PROP   "fdt"
 #define FIT_DEFAULT_PROP   "default"
 
-#define FIT_MAX_HASH_LEN   20  /* max(crc32_len(4), sha1_len(20)) */
+#define FIT_MAX_HASH_LEN   32  /* max(crc32_len(4), sha1_len(20), 
sha256_len(32)) */
 
 /* cmdline argument format parsing */
 int fit_parse_conf(const char *spec, ulong addr_curr,
diff --git a/tools/Makefile b/tools/Makefile
index 328cea3..e025004 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -71,6 +71,7 @@ EXT_OBJ_FILES-y += common/image-sig.o
 EXT_OBJ_FILES-y += lib/crc32.o
 EXT_OBJ_FILES-y += lib/md5.o
 EXT_OBJ_FILES-y += lib/sha1.o
+EXT_OBJ_FILES-y += lib/sha256.o
 
 # Source files located in the tools directory
 NOPED_OBJ_FILES-y += aisimage.o
@@ -252,6 +253,7 @@ $(obj)mkimage$(SFX):$(obj)aisimage.o \
$(obj)os_support.o \
$(obj)pblimage.o \
$(obj)sha1.o \
+   $(obj)sha256.o \
$(obj)ublimage.o \
$(LIBFDT_OBJS) \
$(RSA_OBJS)
-- 
1.8.5.3

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


[U-Boot] [PATCH 2/3] fit: rsa: Add groundwork to support other hashes

2014-02-05 Thread Marek Vasut
Separate out the SHA1 code from the rsa-sign.c and rsa-verify.c .
Each file now has a function which does the correct hashing operation
instead of having the SHA-1 hashing operation hard-coded in the rest
of the code. This makes adding a new hashing operating much easier and
cleaner.

Signed-off-by: Marek Vasut 
---
 lib/rsa/rsa-sign.c   | 45 --
 lib/rsa/rsa-verify.c | 89 +++-
 2 files changed, 110 insertions(+), 24 deletions(-)

diff --git a/lib/rsa/rsa-sign.c b/lib/rsa/rsa-sign.c
index 549130e..4e11720 100644
--- a/lib/rsa/rsa-sign.c
+++ b/lib/rsa/rsa-sign.c
@@ -15,6 +15,11 @@
 #include 
 #include 
 
+enum rsa_hash_type {
+   RSA_HASH_SHA1,
+   RSA_HASH_UNKNOWN,
+};
+
 #if OPENSSL_VERSION_NUMBER >= 0x1000L
 #define HAVE_ERR_REMOVE_THREAD_STATE
 #endif
@@ -159,7 +164,19 @@ static void rsa_remove(void)
EVP_cleanup();
 }
 
-static int rsa_sign_with_key(RSA *rsa, const struct image_region region[],
+static const EVP_MD *rsa_sign_get_hash(enum rsa_hash_type hash)
+{
+   switch (hash) {
+   case RSA_HASH_SHA1:
+   return EVP_sha1();
+   default:/* This must never happen. */
+   rsa_err("Invalid hash type!\n");
+   exit(1);
+   };
+}
+
+static int rsa_sign_with_key(RSA *rsa, enum rsa_hash_type hash,
+   const struct image_region region[],
int region_count, uint8_t **sigp, uint *sig_size)
 {
EVP_PKEY *key;
@@ -192,7 +209,7 @@ static int rsa_sign_with_key(RSA *rsa, const struct 
image_region region[],
goto err_create;
}
EVP_MD_CTX_init(context);
-   if (!EVP_SignInit(context, EVP_sha1())) {
+   if (!EVP_SignInit(context, rsa_sign_get_hash(hash))) {
ret = rsa_err("Signer setup failed");
goto err_sign;
}
@@ -228,12 +245,34 @@ err_set:
return ret;
 }
 
+static enum rsa_hash_type rsa_get_sha_type(struct image_sign_info *info)
+{
+   char *pos;
+   unsigned int hash_str_len;
+
+   pos = strstr(info->algo->name, ",");
+   if (!pos)
+   return -EINVAL;
+
+   hash_str_len = pos - info->algo->name;
+
+   if (!strncmp(info->algo->name, "sha1", hash_str_len))
+   return RSA_HASH_SHA1;
+   else
+   return RSA_HASH_UNKNOWN;
+}
+
 int rsa_sign(struct image_sign_info *info,
 const struct image_region region[], int region_count,
 uint8_t **sigp, uint *sig_len)
 {
RSA *rsa;
int ret;
+   enum rsa_hash_type hash;
+
+   hash = rsa_get_sha_type(info);
+   if (hash == RSA_HASH_UNKNOWN)
+   return -EINVAL;
 
ret = rsa_init();
if (ret)
@@ -242,7 +281,7 @@ int rsa_sign(struct image_sign_info *info,
ret = rsa_get_priv_key(info->keydir, info->keyname, &rsa);
if (ret)
goto err_priv;
-   ret = rsa_sign_with_key(rsa, region, region_count, sigp, sig_len);
+   ret = rsa_sign_with_key(rsa, hash, region, region_count, sigp, sig_len);
if (ret)
goto err_sign;
 
diff --git a/lib/rsa/rsa-verify.c b/lib/rsa/rsa-verify.c
index 02cc4e3..9617f8d 100644
--- a/lib/rsa/rsa-verify.c
+++ b/lib/rsa/rsa-verify.c
@@ -6,6 +6,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -209,10 +210,9 @@ static int pow_mod(const struct rsa_public_key *key, 
uint32_t *inout)
 }
 
 static int rsa_verify_key(const struct rsa_public_key *key, const uint8_t *sig,
-   const uint32_t sig_len, const uint8_t *hash)
+   const uint32_t sig_len, const uint8_t *hash,
+   const uint8_t *padding, int pad_len)
 {
-   const uint8_t *padding;
-   int pad_len;
int ret;
 
if (!key || !sig || !hash)
@@ -238,10 +238,6 @@ static int rsa_verify_key(const struct rsa_public_key 
*key, const uint8_t *sig,
if (ret)
return ret;
 
-   /* Determine padding to use depending on the signature type. */
-   padding = padding_sha1_rsa2048;
-   pad_len = RSA2048_BYTES - SHA1_SUM_LEN;
-
/* Check pkcs1.5 padding bytes. */
if (memcmp(buf, padding, pad_len)) {
debug("In RSAVerify(): Padding check failed!\n");
@@ -266,7 +262,8 @@ static void rsa_convert_big_endian(uint32_t *dst, const 
uint32_t *src, int len)
 }
 
 static int rsa_verify_with_keynode(struct image_sign_info *info,
-   const void *hash, uint8_t *sig, uint sig_len, int node)
+   const void *hash, uint8_t *sig, uint sig_len, int node,
+   const uint8_t *padding, int pad_len)
 {
const void *blob = info->fdt_blob;
struct rsa_public_key key;
@@ -309,7 +306,7 @@ static int rsa_verify_with_keynode(struct image_sign_info 
*info,
}
 
debug("key length %d\n", key.len);
-   ret = rsa_verify_key(&key, sig, sig_len, hash);
+   ret = rsa_verify_key(&key, sig, sig_len,

[U-Boot] [PATCH 3/3] fit: rsa: Add support for SHA256 hash

2014-02-05 Thread Marek Vasut
Add support for "sha256,rsa2048" signature. This patch utilises the previously
laid groundwork for adding other hashes.

Signed-off-by: Marek Vasut 
---
 common/image-sig.c   |  8 +++-
 lib/rsa/rsa-sign.c   |  5 +
 lib/rsa/rsa-verify.c | 58 
 3 files changed, 70 insertions(+), 1 deletion(-)

diff --git a/common/image-sig.c b/common/image-sig.c
index 973b06d..c3d63bc 100644
--- a/common/image-sig.c
+++ b/common/image-sig.c
@@ -23,7 +23,13 @@ struct image_sig_algo image_sig_algos[] = {
rsa_sign,
rsa_add_verify_data,
rsa_verify,
-   }
+   },
+   {
+   "sha256,rsa2048",
+   rsa_sign,
+   rsa_add_verify_data,
+   rsa_verify,
+   },
 };
 
 struct image_sig_algo *image_get_sig_algo(const char *name)
diff --git a/lib/rsa/rsa-sign.c b/lib/rsa/rsa-sign.c
index 4e11720..f1167b1 100644
--- a/lib/rsa/rsa-sign.c
+++ b/lib/rsa/rsa-sign.c
@@ -17,6 +17,7 @@
 
 enum rsa_hash_type {
RSA_HASH_SHA1,
+   RSA_HASH_SHA256,
RSA_HASH_UNKNOWN,
 };
 
@@ -169,6 +170,8 @@ static const EVP_MD *rsa_sign_get_hash(enum rsa_hash_type 
hash)
switch (hash) {
case RSA_HASH_SHA1:
return EVP_sha1();
+   case RSA_HASH_SHA256:
+   return EVP_sha256();
default:/* This must never happen. */
rsa_err("Invalid hash type!\n");
exit(1);
@@ -258,6 +261,8 @@ static enum rsa_hash_type rsa_get_sha_type(struct 
image_sign_info *info)
 
if (!strncmp(info->algo->name, "sha1", hash_str_len))
return RSA_HASH_SHA1;
+   else if (!strncmp(info->algo->name, "sha256", hash_str_len))
+   return RSA_HASH_SHA256;
else
return RSA_HASH_UNKNOWN;
 }
diff --git a/lib/rsa/rsa-verify.c b/lib/rsa/rsa-verify.c
index 9617f8d..67fb882 100644
--- a/lib/rsa/rsa-verify.c
+++ b/lib/rsa/rsa-verify.c
@@ -9,6 +9,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -70,6 +71,37 @@ static const uint8_t padding_sha1_rsa2048[RSA2048_BYTES - 
SHA1_SUM_LEN] = {
0x05, 0x00, 0x04, 0x14
 };
 
+static const uint8_t padding_sha256_rsa2048[RSA2048_BYTES - SHA256_SUM_LEN] = {
+   0x00, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+   0xff, 0xff, 0xff, 0xff, 0x00, 0x30, 0x31, 0x30,
+   0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65,
+   0x03, 0x04, 0x02, 0x01, 0x05, 0x00, 0x04, 0x20,
+};
+
 /**
  * subtract_modulus() - subtract modulus from the given value
  *
@@ -337,6 +369,28 @@ rsa_compute_hash_sha1(const struct image_region region[], 
int region_count,
return 0;
 }
 
+static int
+rsa_compute_hash_sha256(const struct image_region region[], int region_count,
+uint8_t **out_hash)
+{
+   sha256_context ctx;
+   int i;
+   uint8_t *hash;
+
+   hash = calloc(1, SHA256_SUM_LEN);
+   if (!hash)
+   return -ENOMEM;
+
+   sha256_starts(&ctx);
+   for (i = 0; i < region_count; i++)
+   sha256_update(&ctx, region[i].data, region[i].size);
+   sha256_finish(&ctx, hash);
+
+   *out_hash = hash;
+
+   return 0;
+}
+
 static int rsa_compute_hash(struct image_sign_info *info,
   const struct image_region region[], int region_count,
   uint8_t **out_hash, const uint8_t **padding,
@@ -349,6 +403,10 @@ static int rsa_compute_hash(struct image_sign_info *info,
pad = padding_sha1_rsa2048;
len = RSA2048_BYTES - SHA1_SUM_LEN;

[U-Boot] [PATCH V2] usb: mv_udc: Rename to ci_udc

2014-02-05 Thread Marek Vasut
The mv_udc is not marvell-specific anymore. The mv_udc is used to drive
generic ChipIdea CI13xxx series OTG cores, so rename the driver to ci_udc
instead.

Signed-off-by: Marek Vasut 
Cc: Eric Nelson 
Cc: Stefano Babic 
---
 board/boundary/nitrogen6x/nitrogen6x.c|   2 +-
 drivers/serial/usbtty.h   |   4 +-
 drivers/usb/gadget/Makefile   |   2 +-
 drivers/usb/gadget/{mv_udc.c => ci_udc.c} | 182 +++---
 drivers/usb/gadget/{mv_udc.h => ci_udc.h} |  12 +-
 drivers/usb/gadget/gadget_chips.h |   8 +-
 include/configs/nitrogen6x.h  |   2 +-
 include/configs/sansa_fuze_plus.h |   2 +-
 include/configs/xfi3.h|   2 +-
 include/usb/{mv_udc.h => ci_udc.h}|   6 +-
 10 files changed, 111 insertions(+), 111 deletions(-)
 rename drivers/usb/gadget/{mv_udc.c => ci_udc.c} (79%)
 rename drivers/usb/gadget/{mv_udc.h => ci_udc.h} (94%)
 rename include/usb/{mv_udc.h => ci_udc.h} (73%)

V2: Rename mvudc_probe() to ci_udc_probe()

diff --git a/board/boundary/nitrogen6x/nitrogen6x.c 
b/board/boundary/nitrogen6x/nitrogen6x.c
index 3f4cfa1..d9c05b0 100644
--- a/board/boundary/nitrogen6x/nitrogen6x.c
+++ b/board/boundary/nitrogen6x/nitrogen6x.c
@@ -389,7 +389,7 @@ int board_eth_init(bd_t *bis)
}
 #endif
 
-#ifdef CONFIG_MV_UDC
+#ifdef CONFIG_CI_UDC
/* For otg ethernet*/
usb_eth_initialize(bis);
 #endif
diff --git a/drivers/serial/usbtty.h b/drivers/serial/usbtty.h
index 819dec6..21a3ef4 100644
--- a/drivers/serial/usbtty.h
+++ b/drivers/serial/usbtty.h
@@ -20,8 +20,8 @@
 #include 
 #elif defined(CONFIG_DW_UDC)
 #include 
-#elif defined(CONFIG_MV_UDC)
-#include 
+#elif defined(CONFIG_CI_UDC)
+#include 
 #endif
 
 #include 
diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
index f13b172..804a2bd 100644
--- a/drivers/usb/gadget/Makefile
+++ b/drivers/usb/gadget/Makefile
@@ -21,7 +21,7 @@ endif
 ifdef CONFIG_USB_ETHER
 obj-y += ether.o
 obj-$(CONFIG_USB_ETH_RNDIS) += rndis.o
-obj-$(CONFIG_MV_UDC)   += mv_udc.o
+obj-$(CONFIG_CI_UDC)   += ci_udc.o
 obj-$(CONFIG_CPU_PXA25X) += pxa25x_udc.o
 else
 # Devices not related to the new gadget layer depend on CONFIG_USB_DEVICE
diff --git a/drivers/usb/gadget/mv_udc.c b/drivers/usb/gadget/ci_udc.c
similarity index 79%
rename from drivers/usb/gadget/mv_udc.c
rename to drivers/usb/gadget/ci_udc.c
index da41738..14b1e9b 100644
--- a/drivers/usb/gadget/mv_udc.c
+++ b/drivers/usb/gadget/ci_udc.c
@@ -20,9 +20,9 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include "../host/ehci.h"
-#include "mv_udc.h"
+#include "ci_udc.h"
 
 /*
  * Check if the system has too long cachelines. If the cachelines are
@@ -70,85 +70,85 @@ static struct usb_endpoint_descriptor ep0_in_desc = {
.bmAttributes = USB_ENDPOINT_XFER_CONTROL,
 };
 
-static int mv_pullup(struct usb_gadget *gadget, int is_on);
-static int mv_ep_enable(struct usb_ep *ep,
+static int ci_pullup(struct usb_gadget *gadget, int is_on);
+static int ci_ep_enable(struct usb_ep *ep,
const struct usb_endpoint_descriptor *desc);
-static int mv_ep_disable(struct usb_ep *ep);
-static int mv_ep_queue(struct usb_ep *ep,
+static int ci_ep_disable(struct usb_ep *ep);
+static int ci_ep_queue(struct usb_ep *ep,
struct usb_request *req, gfp_t gfp_flags);
 static struct usb_request *
-mv_ep_alloc_request(struct usb_ep *ep, unsigned int gfp_flags);
-static void mv_ep_free_request(struct usb_ep *ep, struct usb_request *_req);
+ci_ep_alloc_request(struct usb_ep *ep, unsigned int gfp_flags);
+static void ci_ep_free_request(struct usb_ep *ep, struct usb_request *_req);
 
-static struct usb_gadget_ops mv_udc_ops = {
-   .pullup = mv_pullup,
+static struct usb_gadget_ops ci_udc_ops = {
+   .pullup = ci_pullup,
 };
 
-static struct usb_ep_ops mv_ep_ops = {
-   .enable = mv_ep_enable,
-   .disable= mv_ep_disable,
-   .queue  = mv_ep_queue,
-   .alloc_request  = mv_ep_alloc_request,
-   .free_request   = mv_ep_free_request,
+static struct usb_ep_ops ci_ep_ops = {
+   .enable = ci_ep_enable,
+   .disable= ci_ep_disable,
+   .queue  = ci_ep_queue,
+   .alloc_request  = ci_ep_alloc_request,
+   .free_request   = ci_ep_free_request,
 };
 
 /* Init values for USB endpoints. */
-static const struct usb_ep mv_ep_init[2] = {
+static const struct usb_ep ci_ep_init[2] = {
[0] = { /* EP 0 */
.maxpacket  = 64,
.name   = "ep0",
-   .ops= &mv_ep_ops,
+   .ops= &ci_ep_ops,
},
[1] = { /* EP 1..n */
.maxpacket  = 512,
.name   = "ep-",
-   .ops= &mv_ep_ops,
+   .ops= &ci_ep_ops,
},
 };
 
-static struct mv_drv controller = {
+static struct ci_drv controller = {
.gadget = {
- 

[U-Boot] [PULL] u-boot-usb/master

2014-02-05 Thread Marek Vasut
The following changes since commit e141652b9cd0cb4f899f7a0fd71c8a438300e365:

  config: Fix line lengths in include/config_distro_defaults.h (2014-02-05 
08:04:38 -0500)

are available in the git repository at:

  git://git.denx.de/u-boot-usb.git master

for you to fetch changes up to f016f8ca3d503af004a649de1c704d5ddf3def22:

  usb: mv_udc: Rename to ci_udc (2014-02-06 04:48:15 +0100)


Lukasz Majewski (6):
  usb:gadget:ums: Replace malloc calls with memalign to fix cache buffer 
alignment
  usb:udc:samsung: Remove redundant cache operation from Samsung UDC driver
  usb:udc:samsung: Allow burst transfers for non EP0 endpints
  usb:udc:samsung: Zero copy approach for data passed to Samsung's UDC 
driver
  usb:gadget:f_thor: Allocate request up to THOR_PACKET_SIZE not ep-
>maxpacket
  usb:gadget:f_thor: cosmetic: Remove debug memset

Marek Vasut (1):
  usb: mv_udc: Rename to ci_udc

 board/boundary/nitrogen6x/nitrogen6x.c|   2 +-
 drivers/serial/usbtty.h   |   4 +--
 drivers/usb/gadget/Makefile   |   2 +-
 drivers/usb/gadget/{mv_udc.c => ci_udc.c} | 182 

 drivers/usb/gadget/{mv_udc.h => ci_udc.h} |  12 +++
 drivers/usb/gadget/f_mass_storage.c   |   4 +--
 drivers/usb/gadget/f_thor.c   |   4 +--
 drivers/usb/gadget/gadget_chips.h |   8 ++---
 drivers/usb/gadget/s3c_udc_otg.c  |  19 +-
 drivers/usb/gadget/s3c_udc_otg_xfer_dma.c |  87 
+++---
 include/configs/nitrogen6x.h  |   2 +-
 include/configs/sansa_fuze_plus.h |   2 +-
 include/configs/xfi3.h|   2 +-
 include/usb/{mv_udc.h => ci_udc.h}|   6 ++--
 include/usb/s3c_udc.h |   5 +--
 15 files changed, 160 insertions(+), 181 deletions(-)
 rename drivers/usb/gadget/{mv_udc.c => ci_udc.c} (79%)
 rename drivers/usb/gadget/{mv_udc.h => ci_udc.h} (94%)
 rename include/usb/{mv_udc.h => ci_udc.h} (73%)
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] usb: mv_udc: Rename to ci_udc

2014-02-05 Thread Marek Vasut
On Thursday, February 06, 2014 at 04:11:05 AM, Eric Nelson wrote:
> Hi Marek,
> 
> On 02/05/2014 06:49 PM, Marek Vasut wrote:
> > The mv_udc is not marvell-specific anymore. The mv_udc is used to drive
> > generic ChipIdea CI13xxx series OTG cores, so rename the driver to ci_udc
> > instead.
> 
> Sounds good.
> 
> > Signed-off-by: Marek Vasut 
> > Cc: Eric Nelson 
> > Cc: Stefano Babic 
> > ---
> > 
> >   board/boundary/nitrogen6x/nitrogen6x.c|   2 +-
> >   drivers/serial/usbtty.h   |   4 +-
> >   drivers/usb/gadget/Makefile   |   2 +-
> >   drivers/usb/gadget/{mv_udc.c => ci_udc.c} | 178
> >   +++--- drivers/usb/gadget/{mv_udc.h =>
> >   ci_udc.h} |  12 +-
> >   drivers/usb/gadget/gadget_chips.h |   8 +-
> >   include/configs/nitrogen6x.h  |   2 +-
> >   include/configs/sansa_fuze_plus.h |   2 +-
> >   include/configs/xfi3.h|   2 +-
> >   include/usb/{mv_udc.h => ci_udc.h}|   6 +-
> >   10 files changed, 109 insertions(+), 109 deletions(-)
> >   rename drivers/usb/gadget/{mv_udc.c => ci_udc.c} (79%)
> >   rename drivers/usb/gadget/{mv_udc.h => ci_udc.h} (94%)
> >   rename include/usb/{mv_udc.h => ci_udc.h} (73%)
> > 
> > ...
> > diff --git a/drivers/usb/gadget/mv_udc.c b/drivers/usb/gadget/ci_udc.c
> > similarity index 79%
> > rename from drivers/usb/gadget/mv_udc.c
> > rename to drivers/usb/gadget/ci_udc.c
> > index da41738..6c5ef4c 100644
> > --- a/drivers/usb/gadget/mv_udc.c
> > +++ b/drivers/usb/gadget/ci_udc.c
> > 
>  > ...
> 
> I think you missed the mvudc_probe() routine though:
> > @@ -673,23 +673,23 @@ static int mvudc_probe(void)
> 
> Aside from that...
> 
> Reviewed-by: Eric Nelson 

Thanks, fixed in V2.

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


[U-Boot] [PATCH V2 3/4] ARM: rpi_b: load /uEnv.txt from MMC at startup

2014-02-05 Thread Stephen Warren
The Pi has no flash to store an environment in the usual fashion. However,
the user may wish to customize the environment. We know that the SD card
must be present, since that's where the boot ROM has loaded U-Boot from.
So, load uEnv.txt from there early during boot. This allows the user to
e.g. customize boot_targets, in order to automatically select network
boot.

Signed-off-by: Stephen Warren 
---
v2: No change.
---
 include/configs/rpi_b.h | 5 +
 1 file changed, 5 insertions(+)

diff --git a/include/configs/rpi_b.h b/include/configs/rpi_b.h
index 202c9c3..4b5a0c2 100644
--- a/include/configs/rpi_b.h
+++ b/include/configs/rpi_b.h
@@ -95,6 +95,11 @@
 #define CONFIG_SYS_LOAD_ADDR   0x100
 #define CONFIG_CONSOLE_MUX
 #define CONFIG_SYS_CONSOLE_IS_IN_ENV
+#define CONFIG_PREBOOT \
+   "if load mmc 0:1 ${loadaddr} /uEnv.txt; then " \
+   "env import -t ${loadaddr} ${filesize}; " \
+   "fi"
+
 /*
  * Memory layout for where various images get loaded by boot scripts:
  *
-- 
1.8.3.2

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


[U-Boot] [PATCH V2 2/4] ARM: rpi_b: convert to use distro defaults

2014-02-05 Thread Stephen Warren
Modify the rpi_b board to include the "distro defaults" header, so that
all the config options distros expect are enabled. Remove any #defines
that enable the same options from the rpi_b.h.

Signed-off-by: Stephen Warren 
---
v2: No change.

Patches 2/4 and 4/4 depend on various patches in u-boot/master, so that
will need to be merged into u-boot-arm/master if this series gets applied
there. In particular, "config: add config_distro_defaults.h" and various
patches before that are required.
---
 include/configs/rpi_b.h | 29 +
 1 file changed, 13 insertions(+), 16 deletions(-)

diff --git a/include/configs/rpi_b.h b/include/configs/rpi_b.h
index 976ceaa..202c9c3 100644
--- a/include/configs/rpi_b.h
+++ b/include/configs/rpi_b.h
@@ -147,37 +147,34 @@
 #define CONFIG_BOOTDELAY   2
 
 /* Shell */
-#define CONFIG_SYS_HUSH_PARSER
 #define CONFIG_SYS_MAXARGS 8
 #define CONFIG_SYS_PROMPT  "U-Boot> "
-#define CONFIG_SYS_LONGHELP
-#define CONFIG_CMDLINE_EDITING
 #define CONFIG_COMMAND_HISTORY
-#define CONFIG_AUTO_COMPLETE
 
 /* Commands */
 #include 
-#define CONFIG_CMD_BOOTZ
 #define CONFIG_CMD_GPIO
 #define CONFIG_CMD_MMC
-#define CONFIG_DOS_PARTITION
 #define CONFIG_PARTITION_UUIDS
 #define CONFIG_CMD_PART
-#define CONFIG_CMD_FS_GENERIC
-#define CONFIG_CMD_FAT
-#define CONFIG_CMD_EXT
-/* Some things don't make sense on this HW or yet */
-#undef CONFIG_CMD_FPGA
-#undef CONFIG_CMD_NET
-#undef CONFIG_CMD_NFS
-#undef CONFIG_CMD_SAVEENV
 
-/* Device tree support for bootm/bootz */
-#define CONFIG_OF_LIBFDT
+/* Device tree support */
 #define CONFIG_OF_BOARD_SETUP
 /* ATAGs support for bootm/bootz */
 #define CONFIG_SETUP_MEMORY_TAGS
 #define CONFIG_CMDLINE_TAG
 #define CONFIG_INITRD_TAG
 
+#include 
+
+/* Some things don't make sense on this HW or yet */
+#undef CONFIG_CMD_FPGA
+#undef CONFIG_CMD_NET
+#undef CONFIG_CMD_NFS
+#undef CONFIG_CMD_SAVEENV
+#undef CONFIG_CMD_DHCP
+#undef CONFIG_CMD_MII
+#undef CONFIG_CMD_NET
+#undef CONFIG_CMD_PING
+
 #endif
-- 
1.8.3.2

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


[U-Boot] [PATCH V2 4/4] ARM: rpi_b: rework boot scripts, enable sysboot

2014-02-05 Thread Stephen Warren
Rework rpi_b's bootcmd (and sub-commands) to match Tegra's bootcmd as
much as possible. This will aid in a future patch which will create a
common header e.g. config_distro_bootcmd.h.

While at it, enable booting from extlinux.conf using the sysboot command.

The iteration and componentization currently makes a little more sense
for Tegra than RPi, but I'd still like to keep the two as similar as
possible. USB and networking support is coming to the RPi in due course,
and it'll all make more sense then anyway.

Signed-off-by: Stephen Warren 
---
v2:
* Replace ; in the middle of echo'd text in boot scripts.
* Add missing space between commands in boot scripts.
---
 include/configs/rpi_b.h | 87 -
 1 file changed, 72 insertions(+), 15 deletions(-)

diff --git a/include/configs/rpi_b.h b/include/configs/rpi_b.h
index 4b5a0c2..68bb2b0 100644
--- a/include/configs/rpi_b.h
+++ b/include/configs/rpi_b.h
@@ -100,12 +100,20 @@
"env import -t ${loadaddr} ${filesize}; " \
"fi"
 
+#define ENV_DEVICE_SETTINGS \
+   "stdin=serial,lcd\0" \
+   "stdout=serial,lcd\0" \
+   "stderr=serial,lcd\0"
+
 /*
  * Memory layout for where various images get loaded by boot scripts:
  *
  * scriptaddr can be pretty much anywhere that doesn't conflict with something
  *   else. Put it low in memory to avoid conflicts.
  *
+ * pxefile_addr_r can be pretty much anywhere that doesn't conflict with
+ *   something else. Put it low in memory to avoid conflicts.
+ *
  * kernel_addr_r must be within the first 128M of RAM in order for the
  *   kernel's CONFIG_AUTO_ZRELADDR option to work. Since the kernel will
  *   decompress itself to 0x8000 after the start of RAM, kernel_addr_r
@@ -121,35 +129,84 @@
  * ramdisk_addr_r simply shouldn't overlap anything else. Choosing 33M allows
  *   for the FDT/DTB to be up to 1M, which is hopefully plenty.
  */
-#define CONFIG_EXTRA_ENV_SETTINGS \
-   "stdin=serial\0" \
-   "stderr=serial,lcd\0" \
-   "stdout=serial,lcd\0" \
+#define ENV_MEM_LAYOUT_SETTINGS \
"scriptaddr=0x\0" \
+   "pxefile_addr_r=0x0010\0" \
"kernel_addr_r=0x0100\0" \
"fdt_addr_r=0x0200\0" \
"fdtfile=bcm2835-rpi-b.dtb\0" \
"ramdisk_addr_r=0x0210\0" \
-   "boot_targets=mmc0\0" \
-   \
-   "script_boot=" \
-   "if fatload ${devtype} ${devnum}:1 " \
-   "${scriptaddr} boot.scr.uimg; then " \
-   "source ${scriptaddr}; " \
-   "fi;\0" \
-   \
+
+#define BOOTCMDS_MMC \
"mmc_boot=" \
"setenv devtype mmc; " \
"if mmc dev ${devnum}; then " \
-   "run script_boot; " \
+   "run scan_boot; " \
"fi\0" \
+   "bootcmd_mmc0=setenv devnum 0; run mmc_boot;\0"
+#define BOOT_TARGETS_MMC "mmc0"
+
+#define BOOTCMDS_COMMON \
+   "rootpart=1\0" \
+   \
+   "do_script_boot=" \
+   "load ${devtype} ${devnum}:${rootpart} "  \
+   "${scriptaddr} ${prefix}${script}; "  \
+   "source ${scriptaddr}\0"  \
+   \
+   "script_boot="\
+   "for script in ${boot_scripts}; do "  \
+   "if test -e ${devtype} ${devnum}:${rootpart} "\
+   "${prefix}${script}; then "   \
+   "echo Found U-Boot script "   \
+   "${prefix}${script}; "\
+   "run do_script_boot; "\
+   "echo SCRIPT FAILED: continuing...; " \
+   "fi; "\
+   "done\0"  \
\
-   "bootcmd_mmc0=setenv devnum 0; run mmc_boot\0" \
+   "do_sysboot_boot="\
+   "sysboot ${devtype} ${devnum}:${rootpart} any "   \
+   "${scriptaddr} ${prefix}extlinux.conf\0"  \
+   \
+   "sysboot_boot="   \
+   "if test -e ${devtype} ${devnum}:${rootpart} "\
+   "${prefix}extlinux.conf; then "   \
+   "echo Found extlinux config " \
+   "${prefix}extlinux.conf; "\
+   "run do_sysboot_boot; "   \
+   "echo SCRIPT FAILED: continuing...; " \
+   "fi\0"\

[U-Boot] [PATCH V2 1/4] pxe: allow compilation when !defined(CONFIG_CMD_NET)

2014-02-05 Thread Stephen Warren
pxe.c provides both the "pxe" command which relies on a network, and the
"sysboot" command which doesn't. Fix the file to compile when network
support isn't enabled. This is useful e.g. on the Raspberry Pi which has
no network support yet, but will soon support the sysboot command.

Signed-off-by: Stephen Warren 
---
v2: No change.

This patch doesn't appear to depend on anything much, but is needed by
the rest of this series. Given the dependencies in the rest of this
series, either (a) this one patch can be applied to u-boot/master, and
then u-boot/arm can merge that in before the rest of the series, or (b)
u-boot/master can be merged into u-boot-arm/master, then this whole
series applied there.
---
 common/cmd_pxe.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/common/cmd_pxe.c b/common/cmd_pxe.c
index 29e48db..3d13268 100644
--- a/common/cmd_pxe.c
+++ b/common/cmd_pxe.c
@@ -45,6 +45,7 @@ static char *from_env(const char *envvar)
return ret;
 }
 
+#ifdef CONFIG_CMD_NET
 /*
  * Convert an ethaddr from the environment to the format used by pxelinux
  * filenames based on mac addresses. Convert's ':' to '-', and adds "01-" to
@@ -75,6 +76,7 @@ static int format_mac_pxe(char *outbuf, size_t outbuf_len)
 
return 1;
 }
+#endif
 
 /*
  * Returns the directory the file specified in the bootfile env variable is
@@ -120,6 +122,7 @@ static int get_bootfile_path(const char *file_path, char 
*bootfile_path,
 
 static int (*do_getfile)(cmd_tbl_t *cmdtp, const char *file_path, char 
*file_addr);
 
+#ifdef CONFIG_CMD_NET
 static int do_get_tftp(cmd_tbl_t *cmdtp, const char *file_path, char 
*file_addr)
 {
char *tftp_argv[] = {"tftp", NULL, NULL, NULL};
@@ -132,6 +135,7 @@ static int do_get_tftp(cmd_tbl_t *cmdtp, const char 
*file_path, char *file_addr)
 
return 1;
 }
+#endif
 
 static char *fs_argv[5];
 
@@ -249,6 +253,8 @@ static int get_pxe_file(cmd_tbl_t *cmdtp, const char 
*file_path, void *file_addr
return 1;
 }
 
+#ifdef CONFIG_CMD_NET
+
 #define PXELINUX_DIR "pxelinux.cfg/"
 
 /*
@@ -397,6 +403,7 @@ do_pxe_get(cmd_tbl_t *cmdtp, int flag, int argc, char * 
const argv[])
 
return 1;
 }
+#endif
 
 /*
  * Wrapper to make it easier to store the file at file_path in the location
@@ -647,6 +654,7 @@ static int label_boot(cmd_tbl_t *cmdtp, struct pxe_label 
*label)
len += strlen(ip_str);
}
 
+#ifdef CONFIG_CMD_NET
if (label->ipappend & 0x2) {
int err;
strcpy(mac_str, " BOOTIF=");
@@ -655,6 +663,7 @@ static int label_boot(cmd_tbl_t *cmdtp, struct pxe_label 
*label)
mac_str[0] = '\0';
len += strlen(mac_str);
}
+#endif
 
if (label->append)
len += strlen(label->append);
@@ -1500,6 +1509,7 @@ static void handle_pxe_menu(cmd_tbl_t *cmdtp, struct 
pxe_menu *cfg)
boot_unattempted_labels(cmdtp, cfg);
 }
 
+#ifdef CONFIG_CMD_NET
 /*
  * Boots a system using a pxe file
  *
@@ -1576,6 +1586,7 @@ U_BOOT_CMD(
"get - try to retrieve a pxe file using tftp\npxe "
"boot [pxefile_addr_r] - boot from the pxe file at pxefile_addr_r\n"
 );
+#endif
 
 /*
  * Boots a system using a local disk syslinux/extlinux file
-- 
1.8.3.2

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


Re: [U-Boot] [PATCH v2 6/8] cmd_mmc.c: Add 'partconf' command to mmc

2014-02-05 Thread Jaehoon Chung
Dear, Tom.

On 02/05/2014 10:03 PM, Tom Rini wrote:
> On Tue, Feb 04, 2014 at 09:58:06AM +0900, Jaehoon Chung wrote:
>> On 01/31/2014 06:31 AM, Tom Rini wrote:
>>> Add a partconf sub-command to the mmc command to allow for setting
>>> the boot_ack, boot_partition and partition_access fields of
>>> PARTITION_CONFIG (formerly BOOT_CONFIG, EXT_CSD[179]).  Part of this
>>> requires changing the check for 'part' from an strncmp to a strcmp, like
>>> the rest of the sub-commands.
> [snip]
>>> @@ -451,6 +477,8 @@ U_BOOT_CMD(
>>> " - Enable boot_part for booting and disable access to boot_part\n"
>>> "mmc bootpart-resize   \n"
>>> " - Change sizes of boot and RPMB partitions of specified device\n"
>>> +   "mmc partconf dev boot_ack boot_partition partition_access\n"
>>
>> How about using bracket("< >") for more readable?
>> mmc partconf
> 
> Except for bootpart-resize the rest of the mmc commands (and most in
> general) don't use "< >" around required parameters unless it's part of
> some sub-choices (such as spl export  ...).
Thanks for explanation.

Best Regards,
Jaehoon Chung.
> 
>> Anyway, looks good to me.
> 
> Thanks!
> 

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


Re: [U-Boot] [PATCH 1/3] fit: Add support for SHA256 hash

2014-02-05 Thread Heiko Schocher

Hello Marek,

Am 06.02.2014 04:47, schrieb Marek Vasut:

This patch adds support for SHA-256 hash into the FIT image. The usage is
as with the other hashing algorithms:

"
hash@1 {
algo = "sha256";
};
"

Signed-off-by: Marek Vasut
---
  common/image-fit.c |  5 +
  include/image.h| 15 ++-
  tools/Makefile |  2 ++
  3 files changed, 21 insertions(+), 1 deletion(-)


seems I posted similiar patches ... you find them here:

[U-Boot,1/7] tools/image-host: fix sign-images bug
http://patchwork.ozlabs.org/patch/314125/

[U-Boot,2/7] fdt: add "fdt sign" command
http://patchwork.ozlabs.org/patch/314120/

[U-Boot,3/7] fit: add sha256 support
http://patchwork.ozlabs.org/patch/314126/

[U-Boot,4/7] rsa: add sha256-rsa2048 algorithm
http://patchwork.ozlabs.org/patch/314124/

[U-Boot,5/7] rsa: add sha256,rsa4096 algorithm
http://patchwork.ozlabs.org/patch/314121/

I reworked the comments, except one is missing, and I can post "v2"
Maybe you can try this patches?

bye,
Heiko
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
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 1/2] exynos: clock: fixed that cfg is set to wrong value.

2014-02-05 Thread Jaehoon Chung
From: Inha Song 

This patch fixed that cfg value is set to wrong value.
Because it didn't read the related register.
(Based on Inha's patch : "arm:exynos:add missing readl")

Signed-off-by: Inha Song 
Signed-off-by: Jaehoon Chung 
---
 arch/arm/cpu/armv7/exynos/clock.c |3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm/cpu/armv7/exynos/clock.c 
b/arch/arm/cpu/armv7/exynos/clock.c
index 6807ff3..61cd8cf 100644
--- a/arch/arm/cpu/armv7/exynos/clock.c
+++ b/arch/arm/cpu/armv7/exynos/clock.c
@@ -1114,6 +1114,7 @@ void exynos4_set_lcd_clk(void)
 * MIPI0_PRE_RATIO  [23:20]
 * set fimd ratio
 */
+   cfg = readl(&clk->div_lcd0);
cfg &= ~(0xf);
cfg |= 0x1;
writel(cfg, &clk->div_lcd0);
@@ -1176,6 +1177,7 @@ void exynos5_set_lcd_clk(void)
 * MIPI0_PRE_RATIO  [23:20]
 * set fimd ratio
 */
+   cfg = readl(&clk->div_disp1_0);
cfg &= ~(0xf);
cfg |= 0x0;
writel(cfg, &clk->div_disp1_0);
@@ -1236,6 +1238,7 @@ void exynos4_set_mipi_clk(void)
 * MIPI0_PRE_RATIO  [23:20]
 * set mipi ratio
 */
+   cfg = readl(&clk->div_lcd0);
cfg &= ~(0xf << 16);
cfg |= (0x1 << 16);
writel(cfg, &clk->div_lcd0);
-- 
1.7.9.5
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 2/2] exynos: clock: use the clear and set bits macros.

2014-02-05 Thread Jaehoon Chung
From: Inha Song 

Use setbits/clrbits macro instead of readl/writel function.
(Suggested by Wolfgang)
(Based on Inha's patch :
"arm: exynos: change to use clrbits macro instead of readl/writel function")

Singed-off-by: Inha Song 
Signed-off-by: Jaehoon Chung 
---
 arch/arm/cpu/armv7/exynos/clock.c |   85 +
 1 file changed, 20 insertions(+), 65 deletions(-)

diff --git a/arch/arm/cpu/armv7/exynos/clock.c 
b/arch/arm/cpu/armv7/exynos/clock.c
index 61cd8cf..1fea4d6 100644
--- a/arch/arm/cpu/armv7/exynos/clock.c
+++ b/arch/arm/cpu/armv7/exynos/clock.c
@@ -870,7 +870,6 @@ static void exynos4_set_mmc_clk(int dev_index, unsigned int 
div)
struct exynos4_clock *clk =
(struct exynos4_clock *)samsung_get_base_clock();
unsigned int addr;
-   unsigned int val;
 
/*
 * CLK_DIV_FSYS1
@@ -890,10 +889,8 @@ static void exynos4_set_mmc_clk(int dev_index, unsigned 
int div)
dev_index -= 2;
}
 
-   val = readl(addr);
-   val &= ~(0xff << ((dev_index << 4) + 8));
-   val |= (div & 0xff) << ((dev_index << 4) + 8);
-   writel(val, addr);
+   clrsetbits_le32(addr, 0xff << ((dev_index << 4) + 8),
+   (div & 0xff) << ((dev_index << 4) + 8));
 }
 
 /* exynos4x12: set the mmc clock */
@@ -902,7 +899,6 @@ static void exynos4x12_set_mmc_clk(int dev_index, unsigned 
int div)
struct exynos4x12_clock *clk =
(struct exynos4x12_clock *)samsung_get_base_clock();
unsigned int addr;
-   unsigned int val;
 
/*
 * CLK_DIV_FSYS1
@@ -917,10 +913,8 @@ static void exynos4x12_set_mmc_clk(int dev_index, unsigned 
int div)
dev_index -= 2;
}
 
-   val = readl(addr);
-   val &= ~(0xff << ((dev_index << 4) + 8));
-   val |= (div & 0xff) << ((dev_index << 4) + 8);
-   writel(val, addr);
+   clrsetbits_le32(addr, 0xff << ((dev_index << 4) + 8),
+   (div & 0xff) << ((dev_index << 4) + 8));
 }
 
 /* exynos5: set the mmc clock */
@@ -929,7 +923,6 @@ static void exynos5_set_mmc_clk(int dev_index, unsigned int 
div)
struct exynos5_clock *clk =
(struct exynos5_clock *)samsung_get_base_clock();
unsigned int addr;
-   unsigned int val;
 
/*
 * CLK_DIV_FSYS1
@@ -944,10 +937,8 @@ static void exynos5_set_mmc_clk(int dev_index, unsigned 
int div)
dev_index -= 2;
}
 
-   val = readl(addr);
-   val &= ~(0xff << ((dev_index << 4) + 8));
-   val |= (div & 0xff) << ((dev_index << 4) + 8);
-   writel(val, addr);
+   clrsetbits_le32(addr, 0xff << ((dev_index << 4) + 8),
+   (div & 0xff) << ((dev_index << 4) + 8));
 }
 
 /* exynos5: set the mmc clock */
@@ -956,7 +947,7 @@ static void exynos5420_set_mmc_clk(int dev_index, unsigned 
int div)
struct exynos5420_clock *clk =
(struct exynos5420_clock *)samsung_get_base_clock();
unsigned int addr;
-   unsigned int val, shift;
+   unsigned int shift;
 
/*
 * CLK_DIV_FSYS1
@@ -967,10 +958,7 @@ static void exynos5420_set_mmc_clk(int dev_index, unsigned 
int div)
addr = (unsigned int)&clk->div_fsys1;
shift = dev_index * 10;
 
-   val = readl(addr);
-   val &= ~(0x3ff << shift);
-   val |= (div & 0x3ff) << shift;
-   writel(val, addr);
+   clrsetbits_le32(addr, 0x3ff << shift, (div & 0x3ff) << shift);
 }
 
 /* get_lcd_clk: return lcd clock frequency */
@@ -1061,7 +1049,6 @@ void exynos4_set_lcd_clk(void)
 {
struct exynos4_clock *clk =
(struct exynos4_clock *)samsung_get_base_clock();
-   unsigned int cfg = 0;
 
/*
 * CLK_GATE_BLOCK
@@ -1073,9 +1060,7 @@ void exynos4_set_lcd_clk(void)
 * CLK_LCD1 [5]
 * CLK_GPS  [7]
 */
-   cfg = readl(&clk->gate_block);
-   cfg |= 1 << 4;
-   writel(cfg, &clk->gate_block);
+   setbits_le32(&clk->gate_block, 1 << 4);
 
/*
 * CLK_SRC_LCD0
@@ -1085,10 +1070,7 @@ void exynos4_set_lcd_clk(void)
 * MIPI0_SEL[12:15]
 * set lcd0 src clock 0x6: SCLK_MPLL
 */
-   cfg = readl(&clk->src_lcd0);
-   cfg &= ~(0xf);
-   cfg |= 0x6;
-   writel(cfg, &clk->src_lcd0);
+   clrsetbits_le32(&clk->src_lcd0, 0xf, 0x6);
 
/*
 * CLK_GATE_IP_LCD0
@@ -1100,9 +1082,7 @@ void exynos4_set_lcd_clk(void)
 * CLK_PPMULCD0 [5]
 * Gating all clocks for FIMD0
 */
-   cfg = readl(&clk->gate_ip_lcd0);
-   cfg |= 1 << 0;
-   writel(cfg, &clk->gate_ip_lcd0);
+   setbits_le32(&clk->gate_ip_lcd0, 1 << 0);
 
/*
 * CLK_DIV_LCD0
@@ -1114,17 +1094,13 @@ void exynos4_set_lcd_clk(void)
 * MIPI0_PRE_RATIO  [23:20]
 * set fimd ratio
 */
-   cfg = readl(&clk->div_lcd0);
-   cfg &= ~(0xf);
-   cfg |= 0x1;
-   wr

[U-Boot] [RFC PATCH 1/2] ARM: rpi_b: enable USB features in config

2014-02-05 Thread Stephen Warren
* Enable USB HW driver
* Don't disable USB-related commands any more
* Add USB-related support to bootcmd

Signed-off-by: Stephen Warren 
---
These two patches are RFC, since they rely on the DWC2 USB driver, from:
[RFC PATCH] usb: add driver for Synopsis DWC2 USB IP block

 include/configs/rpi_b.h | 60 -
 1 file changed, 50 insertions(+), 10 deletions(-)

diff --git a/include/configs/rpi_b.h b/include/configs/rpi_b.h
index 68bb2b0..0061de5 100644
--- a/include/configs/rpi_b.h
+++ b/include/configs/rpi_b.h
@@ -146,6 +146,41 @@
"bootcmd_mmc0=setenv devnum 0; run mmc_boot;\0"
 #define BOOT_TARGETS_MMC "mmc0"
 
+#define BOOTCMD_INIT_USB "run usb_init; "
+#define BOOTCMDS_USB \
+   "usb_init=" \
+   "if ${usb_need_init}; then " \
+   "set usb_need_init false; " \
+   "usb start 0; " \
+   "fi\0" \
+   \
+   "usb_boot=" \
+   "setenv devtype usb; " \
+   BOOTCMD_INIT_USB \
+   "if usb dev ${devnum}; then " \
+   "run scan_boot; " \
+   "fi\0" \
+   \
+   "bootcmd_usb0=setenv devnum 0; run usb_boot;\0"
+#define BOOT_TARGETS_USB "usb0"
+
+#define BOOTCMDS_DHCP \
+   "bootcmd_dhcp=" \
+   BOOTCMD_INIT_USB \
+   "if dhcp ${scriptaddr} boot.scr.uimg; then "\
+   "source ${scriptaddr}; " \
+   "fi\0"
+#define BOOT_TARGETS_DHCP "dhcp"
+
+#define BOOTCMDS_PXE \
+   "bootcmd_pxe=" \
+   BOOTCMD_INIT_USB \
+   "dhcp; " \
+   "if pxe get; then " \
+   "pxe boot; " \
+   "fi\0"
+#define BOOT_TARGETS_PXE "pxe"
+
 #define BOOTCMDS_COMMON \
"rootpart=1\0" \
\
@@ -187,18 +222,22 @@
\
"boot_targets=" \
BOOT_TARGETS_MMC " " \
+   BOOT_TARGETS_USB " " \
+   BOOT_TARGETS_PXE " " \
+   BOOT_TARGETS_DHCP " " \
"\0" \
\
"boot_prefixes=/\0" \
\
"boot_scripts=boot.scr.uimg\0" \
\
-   BOOTCMDS_MMC
-
-#define CONFIG_BOOTCOMMAND \
-   "for target in ${boot_targets}; do run bootcmd_${target}; done"
+   BOOTCMDS_MMC \
+   BOOTCMDS_USB \
+   BOOTCMDS_DHCP \
+   BOOTCMDS_PXE
 
 #define CONFIG_BOOTCOMMAND \
+   "set usb_need_init; " \
"for target in ${boot_targets}; do run bootcmd_${target}; done"
 
 #define CONFIG_EXTRA_ENV_SETTINGS \
@@ -227,16 +266,17 @@
 #define CONFIG_CMDLINE_TAG
 #define CONFIG_INITRD_TAG
 
+/* USB support */
+#define CONFIG_USB_DWC2_OTG
+#define CONFIG_USB_HOST_ETHER
+#define CONFIG_USB_STORAGE
+#define CONFIG_USB_ETHER_SMSC95XX
+#define CONFIG_CMD_USB
+
 #include 
 
 /* Some things don't make sense on this HW or yet */
 #undef CONFIG_CMD_FPGA
-#undef CONFIG_CMD_NET
-#undef CONFIG_CMD_NFS
 #undef CONFIG_CMD_SAVEENV
-#undef CONFIG_CMD_DHCP
-#undef CONFIG_CMD_MII
-#undef CONFIG_CMD_NET
-#undef CONFIG_CMD_PING
 
 #endif
-- 
1.8.3.2

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


[U-Boot] [RFC PATCH 2/2] ARM: rpi_b: query internal MAC address from firmware

2014-02-05 Thread Stephen Warren
The built-in SMSC 95xx chip doesn't know its own MAC address. Instead,
we must query it from the VC firmware; it's probably encoded in fuses
on the BCM2835.

Signed-off-by: Stephen Warren 
---
 arch/arm/include/asm/arch-bcm2835/mbox.h | 14 ++
 board/raspberrypi/rpi_b/rpi_b.c  | 26 ++
 include/configs/rpi_b.h  |  1 +
 3 files changed, 41 insertions(+)

diff --git a/arch/arm/include/asm/arch-bcm2835/mbox.h 
b/arch/arm/include/asm/arch-bcm2835/mbox.h
index dded857..61f427d 100644
--- a/arch/arm/include/asm/arch-bcm2835/mbox.h
+++ b/arch/arm/include/asm/arch-bcm2835/mbox.h
@@ -119,6 +119,20 @@ struct bcm2835_mbox_tag_hdr {
  * };
  */
 
+#define BCM2835_MBOX_TAG_GET_MAC_ADDRESS   0x00010003
+
+struct bcm2835_mbox_tag_get_mac_address {
+   struct bcm2835_mbox_tag_hdr tag_hdr;
+   union {
+   struct {
+   } req;
+   struct {
+   u8 mac[6];
+   u8 pad[2];
+   } resp;
+   } body;
+};
+
 #define BCM2835_MBOX_TAG_GET_ARM_MEMORY0x00010005
 
 struct bcm2835_mbox_tag_get_arm_mem {
diff --git a/board/raspberrypi/rpi_b/rpi_b.c b/board/raspberrypi/rpi_b/rpi_b.c
index f33fae9..eaeb182 100644
--- a/board/raspberrypi/rpi_b/rpi_b.c
+++ b/board/raspberrypi/rpi_b/rpi_b.c
@@ -29,6 +29,12 @@ struct msg_get_arm_mem {
u32 end_tag;
 };
 
+struct msg_get_mac_address {
+   struct bcm2835_mbox_hdr hdr;
+   struct bcm2835_mbox_tag_get_mac_address get_mac_address;
+   u32 end_tag;
+};
+
 struct msg_set_power_state {
struct bcm2835_mbox_hdr hdr;
struct bcm2835_mbox_tag_set_power_state set_power_state;
@@ -60,6 +66,26 @@ int dram_init(void)
return 0;
 }
 
+int misc_init_r(void)
+{
+   ALLOC_ALIGN_BUFFER(struct msg_get_mac_address, msg, 1, 16);
+   int ret;
+
+   BCM2835_MBOX_INIT_HDR(msg);
+   BCM2835_MBOX_INIT_TAG(&msg->get_mac_address, GET_MAC_ADDRESS);
+
+   ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg->hdr);
+   if (ret) {
+   printf("bcm2835: Could not query MAC address\n");
+   /* Ignore error; not critical */
+   return 0;
+   }
+
+   eth_setenv_enetaddr("usbethaddr", msg->get_mac_address.body.resp.mac);
+
+   return 0;
+}
+
 static int power_on_module(u32 module)
 {
ALLOC_ALIGN_BUFFER(struct msg_set_power_state, msg_pwr, 1, 16);
diff --git a/include/configs/rpi_b.h b/include/configs/rpi_b.h
index 0061de5..480d747 100644
--- a/include/configs/rpi_b.h
+++ b/include/configs/rpi_b.h
@@ -272,6 +272,7 @@
 #define CONFIG_USB_STORAGE
 #define CONFIG_USB_ETHER_SMSC95XX
 #define CONFIG_CMD_USB
+#define CONFIG_MISC_INIT_R
 
 #include 
 
-- 
1.8.3.2

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


Re: [U-Boot] [PATCH v2 2/3] dts: move device tree sources to arch/$(ARCH)/dts/

2014-02-05 Thread Masahiro Yamada
Hello Simon,


> Hi Masahiro,
> 
> On 4 February 2014 02:38, Masahiro Yamada  wrote:
> > Unlike Linux Kernel, U-Boot historically had *.dts files under
> > board/$(VENDOR)/dts/ and *.dtsi files under arch/$(ARCH)/dts/.
> >
> > I think arch/$(ARCH)/dts dicretory is a better location
> > to store both *.dts and *.dtsi files.
> >
> > For example, before this commit, board/xilinx/dts directory
> > had both MicroBlaze dts (microblaze-generic.dts) and
> > ARM dts (zynq-*.dts), which are totally unrelated.
> >
> > This commit moves *.dts to arch/$(ARCH)/dts/ directories,
> > allowing us to describe nicely mutiple DTBs generation in the next commit.
> 
> What is the motivation for this? I worry that we might end up with a
> lot of files in one directory.

We have only 35 .dtsi and .dts for ARM.
I think it will be OK at least until we have 500.

Linux v3.13 has 500 .dtsi and .dts files in arch/arm/boot/dts/
and they are still adding device trees to that directory.

I have no idea if they will keep going, or someone will scream and turn
around.

Anyway, when Linux guys someday invents a nice idea to work arond
increasing device trees, we can import it to U-Boot.
It should be easy for us because we already have a similar build system.

> One benefit of the current approach is
> that .dts files are split up by vendor. Even if we put the SoC .dtsi
> files in arch/arm, perhaps there is a benefit in leaving the board
> .dts files in board/?

I don't like the idea to split up by vendor.

Now Xilinx has device trees both for ARM and Microblaze,
resulting in totally unrelated device trees in one directory.

What if Freescale decided to adopt device tree?
They support various boards on ARM, PowerPC, M68K.

Renesus is the same. They have ARM and SuperH boards.


On the other hand, different vendors can produce similar boards.
For example avionic design, which develops Tegra boards,
are using nVidia's sources.

When I saw  board/nvidia/common/common.mk
and board/avionic-design/*/Makefile, etc., I think we're screwed up
with  directory.

Best Regards
Masahiro Yamada

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


Re: [U-Boot] [PATCH v2 1/6] usb:gadget:ums: Replace malloc calls with memalign to fix cache buffer alignment

2014-02-05 Thread Lukasz Majewski
Hi Marek,

> On Wednesday, February 05, 2014 at 10:10:41 AM, Lukasz Majewski wrote:
> > Calls to malloc() have been replaced by memalign. It now provides
> > proper buffer alignment.
> > 
> > Signed-off-by: Lukasz Majewski 
> > Cc: Marek Vasut 
> > 
> > ---
> > Changes for v2:
> > - Remove Change-Id.
> > ---
> >  drivers/usb/gadget/f_mass_storage.c |4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/usb/gadget/f_mass_storage.c
> > b/drivers/usb/gadget/f_mass_storage.c index b1fe8bd..f896169 100644
> > --- a/drivers/usb/gadget/f_mass_storage.c
> > +++ b/drivers/usb/gadget/f_mass_storage.c
> > @@ -2515,7 +2515,7 @@ static struct fsg_common
> > *fsg_common_init(struct fsg_common *common, buffhds_first_it:
> > bh->inreq_busy = 0;
> > bh->outreq_busy = 0;
> > -   bh->buf = kmalloc(FSG_BUFLEN, GFP_KERNEL);
> > +   bh->buf = memalign(CONFIG_SYS_CACHELINE_SIZE,
> > FSG_BUFLEN); if (unlikely(!bh->buf)) {
> > rc = -ENOMEM;
> > goto error_release;
> > @@ -2622,7 +2622,7 @@ usb_copy_descriptors(struct
> > usb_descriptor_header **src) bytes += (*tmp)->bLength;
> > bytes += (n_desc + 1) * sizeof(*tmp);
> > 
> > -   mem = kmalloc(bytes, GFP_KERNEL);
> > +   mem = memalign(CONFIG_SYS_CACHELINE_SIZE, bytes);
> 
> I wonder, does this align the begining of the buffer as well or only
> the size? Can we rely on the fact the begining is also
> cacheline-aligned ?

In this case, the memalign assures, that beginning of the buffer is
aligned to a cache line.

It is the programmer's responsibility to either have "bytes" aligned to
cache line size or use a wrapper like DEFINE_CACHE_ALIGN_BUFFER().

> 
> > if (!mem)
> > return NULL;
> 
> Best regards,
> Marek Vasut



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [RFC PATCH] usb: add driver for Synopsis DWC2 USB IP block

2014-02-05 Thread Marek Vasut
On Thursday, February 06, 2014 at 06:27:01 AM, Stephen Warren wrote:

Tom, Wolfgang, can you please check the license of the 
drivers/usb/host/dwc2_otg_core_if.h below ? Thanks!

[...]

> +void handle_error(int line, uint32_t d)
> +{
> + hcint_data_t hcint;
> + hcint.d32 = d;
> +
> + printf("Error condition at line %d: ", line);
> + if (hcint.b.ahberr)
> + printf(" AHBERR");

puts(), please fix globally. Is such verbosity needed anyway?

> + if (hcint.b.stall)
> + printf(" STALL");
> + if (hcint.b.bblerr)
> + printf(" NAK");
> + if (hcint.b.ack)
> + printf(" ACK");
> + if (hcint.b.nyet)
> + printf(" NYET");
> + if (hcint.b.xacterr)
> + printf(" XACTERR");
> + if (hcint.b.datatglerr)
> + printf(" DATATGLERR");
> + printf("\n");
> +}
> +
> +/*
> + * U-Boot USB interface
> + */
> +int usb_lowlevel_init(int index, enum usb_init_type init, void
> **controller) +{
> + /*
> +  * We need doubleword-aligned buffers for DMA transfers
> +  */
> + allocated_buffer = (uint8_t *)malloc(DWC_OTG_HCD_STATUS_BUF_SIZE +
> DWC_OTG_HCD_DATA_BUF_SIZE + 8); + uint32_t addr =
> (uint32_t)allocated_buffer;
> + aligned_buffer = (uint8_t *) ((addr + 7) & ~7);
> + status_buffer = (uint8_t *)((uint32_t)aligned_buffer +
> DWC_OTG_HCD_DATA_BUF_SIZE); + int i, j;
> + hprt0_data_t hprt0 = {.d32 = 0 };

Use DEFINE_CACHE_ALIGN_BUFFER or similar from include/common.h instead .

> +
> + root_hub_devnum = 0;
> + memset(&g_core_if, 0, sizeof(g_core_if));

This would then be moot.

> + dwc_otg_cil_init(&g_core_if, (uint32_t *)0x2098);
> +
> + if ((g_core_if.snpsid & 0xF000) !=
> + 0x4F542000) {
> + printf("SNPSID is invalid (not DWC OTG device): %08x\n",
> g_core_if.snpsid); +  return -1;
> + }

Get rid of the magic constants please. Use regular errno.h definitions for 
return values please.

> + dwc_otg_core_init(&g_core_if);
> + dwc_otg_core_host_init(&g_core_if);
> +
> + hprt0.d32 = dwc_otg_read_hprt0(&g_core_if);
> + hprt0.b.prtrst = 1;
> + dwc_write_reg32(g_core_if.host_if->hprt0, hprt0.d32);
> + udelay(5);

That's quite a delay you have here ... is it needed? Also, use mdelay(50) 
instead ?

> + hprt0.b.prtrst = 0;
> + dwc_write_reg32(g_core_if.host_if->hprt0, hprt0.d32);
> +
> + udelay(5);
> + hprt0.d32 = dwc_read_reg32(g_core_if.host_if->hprt0);
> +
> + for (i = 0; i < MAX_DEVICE; i++) {
> + for (j = 0; j < MAX_ENDPOINT; j++) {
> + control_data_toggle[i][j] = DWC_OTG_HC_PID_DATA1;
> + bulk_data_toggle[i][j] = DWC_OTG_HC_PID_DATA0;
> + }
> + }
> +
> + return 0;
> +}
> +
> +int usb_lowlevel_stop(int index)
> +{
> + free(allocated_buffer);
> +
> + return 0;
> +}
> +
> +/* based on usb_ohci.c */
> +#define min_t(type, x, y) \
> + ({ type __x = (x); type __y = (y); __x < __y ? __x : __y; })
> +/*
> -* + * Virtual Root Hub
> +
> *-
> */ +
> +/* Device descriptor */
> +static __u8 root_hub_dev_des[] = {

How many copies of these descriptors do we need until we will have enough of 
them? Can you not pull them out of the other drivers so we would have only one 
set of them ?
[...]

> +
> +static int dwc_otg_submit_rh_msg(struct usb_device *dev, unsigned long
> pipe, +void *buffer, int transfer_len,
> +  struct devrequest *cmd)
> +{
> + int leni = transfer_len;
> + int len = 0;
> + int stat = 0;
> + __u16 bmRType_bReq;
> + __u16 wValue;
> + __u16 wLength;
> + unsigned char data[32];
> + hprt0_data_t hprt0 = {.d32 = 0 };
> +
> + if (usb_pipeint(pipe)) {
> + printf("Root-Hub submit IRQ: NOT implemented");
> + return 0;
> + }
> +
> + bmRType_bReq  = cmd->requesttype | (cmd->request << 8);
> + wValue= cpu_to_le16 (cmd->value);
> + wLength   = cpu_to_le16 (cmd->length);
> +
> + switch (bmRType_bReq) {
> + case RH_GET_STATUS:
> + *(__u16 *)buffer = cpu_to_le16(1);

What makes you believe that the pointer will have an aligned value and you 
won't 
trigger alignment fault by storing data like so ? :) Use put_unaligned.*()

> + len = 2;
> + break;
> + case RH_GET_STATUS | RH_INTERFACE:
> + *(__u16 *)buffer = cpu_to_le16(0);
> + len = 2;
> + break;
> + case RH_GET_STATUS | RH_ENDPOINT:
> + *(__u16 *)buffer = cpu_to_le16(0);
> + len = 2;
> + break;
> + case RH_GET_STATUS | RH_CLASS:
> + *(__u32 *)buffer = cpu_to_le32(0);
> + len = 4;
> + break;
> + c

Re: [U-Boot] [PATCH v2 1/6] usb:gadget:ums: Replace malloc calls with memalign to fix cache buffer alignment

2014-02-05 Thread Marek Vasut
On Thursday, February 06, 2014 at 07:33:07 AM, Lukasz Majewski wrote:
> Hi Marek,
> 
> > On Wednesday, February 05, 2014 at 10:10:41 AM, Lukasz Majewski wrote:
> > > Calls to malloc() have been replaced by memalign. It now provides
> > > proper buffer alignment.
> > > 
> > > Signed-off-by: Lukasz Majewski 
> > > Cc: Marek Vasut 
> > > 
> > > ---
> > > Changes for v2:
> > > - Remove Change-Id.
> > > ---
> > > 
> > >  drivers/usb/gadget/f_mass_storage.c |4 ++--
> > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/drivers/usb/gadget/f_mass_storage.c
> > > b/drivers/usb/gadget/f_mass_storage.c index b1fe8bd..f896169 100644
> > > --- a/drivers/usb/gadget/f_mass_storage.c
> > > +++ b/drivers/usb/gadget/f_mass_storage.c
> > > @@ -2515,7 +2515,7 @@ static struct fsg_common
> > > 
> > > *fsg_common_init(struct fsg_common *common, buffhds_first_it:
> > >   bh->inreq_busy = 0;
> > >   bh->outreq_busy = 0;
> > > 
> > > - bh->buf = kmalloc(FSG_BUFLEN, GFP_KERNEL);
> > > + bh->buf = memalign(CONFIG_SYS_CACHELINE_SIZE,
> > > FSG_BUFLEN); if (unlikely(!bh->buf)) {
> > > 
> > >   rc = -ENOMEM;
> > >   goto error_release;
> > > 
> > > @@ -2622,7 +2622,7 @@ usb_copy_descriptors(struct
> > > usb_descriptor_header **src) bytes += (*tmp)->bLength;
> > > 
> > >   bytes += (n_desc + 1) * sizeof(*tmp);
> > > 
> > > - mem = kmalloc(bytes, GFP_KERNEL);
> > > + mem = memalign(CONFIG_SYS_CACHELINE_SIZE, bytes);
> > 
> > I wonder, does this align the begining of the buffer as well or only
> > the size? Can we rely on the fact the begining is also
> > cacheline-aligned ?
> 
> In this case, the memalign assures, that beginning of the buffer is
> aligned to a cache line.

How so ? :)
[...]

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


[U-Boot] i.mx6 board booting

2014-02-05 Thread JYOTI DUBEY
I followed the following commands to achieve a successful booting of i.mx6
board using SD card
dd if=u-boot.imx of=/dev/sdb bs=1k seek=1
The above command burnt the u-boot.imx image on the SD card though nothing
was seen on SD card.
Next the gtkterm configurations were set and after the board was started
serial console output was interrupted(by pressing a key).
U-Boot>> sf probe (to probe the flash memory)
U-Boot>> sf erase 0 0x8 (to erase the flash)
U-Boot>>fatload mmc 1 1200 u-boot.imx
The above command throws an error -"Unable to read file u-boot.imx"

SO what can be the problem behind it and how can we overcome it?
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot