[U-Boot] unsupported manufacturer 20 for micron device

2013-05-08 Thread sathaps
Hello All,
while trying to detect the QSPI on our custom board, sf probe returns
unsupported manufacturer: 20.

I am using the U-Boot from the latest version Zynq 14.5 / 2013.1 Release
(latest). when i looked at the code, it looks like the code is already there
in.

My device is actually Micron N25Q512a 
anybody ever faced this..any  suggestion?

Best Regards,



--
View this message in context: 
http://u-boot.10912.n7.nabble.com/unsupported-manufacturer-20-for-micron-device-tp154304.html
Sent from the U-Boot mailing list archive at Nabble.com.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH V2 0/5] ARM: OMAP: Cleanup save_boot_params function

2013-05-08 Thread Sricharan R
Hi Tom,

On Wednesday 08 May 2013 11:26 PM, Tom Rini wrote:
> On Wed, May 08, 2013 at 02:50:14PM +0530, Sricharan R wrote:
>> Tom,
>>
>> On Wednesday 24 April 2013 04:11 PM, Sricharan R wrote:
>>> The save_boot_params function does not store the data in a
>>> always writable area. So the code is broken for a 'XIP' boot.
>>> This series corrects this by storing it in 'gd' and also
>>> adds a 'C' equivalent function for the same. The essential cleanups
>>> for the same are added in this.
>>>
>>> Tested this on omap5 uevm board with SD/EMMC boot.
>>> omap4/5 boards does not have a XIP flash.
>>> So yet to test XIP with this series.
>>>
>>> Also verfied a MAKEALL for armv7.
>>>
>>> Sricharan R (5):
>>>   ARM: OMAP: Make omap_boot_parameters common across socs
>>>   ARM: OMAP4/5: Make OMAPx_SRAM_SCRATCH_ defines common
>>>   ARM: OMAP: Correct save_boot_params and replace with 'C' function
>>>   ARM: OMAP: Cleanup boot parameters usage
>>>   ARM: OMAP: Add arch_cpu_init function
>>>
>>>  arch/arm/cpu/armv7/lowlevel_init.S |8 +++-
>>>  arch/arm/cpu/armv7/omap-common/boot-common.c   |   20 ++--
>>>  arch/arm/cpu/armv7/omap-common/hwinit-common.c |   61 
>>> +---
>>>  arch/arm/cpu/armv7/omap-common/lowlevel_init.S |   50 +--
>>>  arch/arm/cpu/armv7/omap4/emif.c|4 +-
>>>  arch/arm/cpu/armv7/omap4/hw_data.c |2 +-
>>>  arch/arm/cpu/armv7/omap4/hwinit.c  |3 +-
>>>  arch/arm/cpu/armv7/omap5/emif.c|4 +-
>>>  arch/arm/cpu/armv7/omap5/hw_data.c |2 +-
>>>  arch/arm/cpu/armv7/omap5/hwinit.c  |3 +-
>>>  arch/arm/include/asm/arch-am33xx/omap.h|   25 --
>>>  arch/arm/include/asm/arch-omap4/omap.h |   36 --
>>>  arch/arm/include/asm/arch-omap4/sys_proto.h|   11 ++---
>>>  arch/arm/include/asm/arch-omap5/omap.h |   36 --
>>>  arch/arm/include/asm/arch-omap5/sys_proto.h|   12 ++---
>>>  arch/arm/include/asm/global_data.h |8 
>>>  arch/arm/include/asm/omap_boot.h   |   50 +++
>>>  arch/arm/include/asm/omap_common.h |   19 
>>>  common/spl/spl.c   |   12 +++--
>>>  include/configs/am335x_evm.h   |4 ++
>>>  include/configs/omap4_common.h |4 ++
>>>  include/configs/omap5_common.h |3 ++
>>>  include/configs/pcm051.h   |4 ++
>>>  include/configs/ti814x_evm.h   |4 ++
>>>  include/spl.h  |1 -
>>>  25 files changed, 187 insertions(+), 199 deletions(-)
>>>  create mode 100644 arch/arm/include/asm/omap_boot.h
>>>
>>  Does this look ok, go to get in ?
> With the posted changes to 4 and 5 (for platforms that are new to
> u-boot-ti/master), applied, thanks for the reminder!
>
  Thanks for it !!

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


[U-Boot] [PATCH 2/2] spi: mxc_spi: Update pre and post divider algorithm

2013-05-08 Thread Dirk Behme
The spi clock divisor is of the form x * (2**y),  or  x  << y, where x is
1 to 16, and y is 0 to 15. Note the similarity with floating point numbers.
Convert the desired divisor to the smallest number which is >= desired divisor,
and can be represented in this form. The previous algorithm chose a divisor
which could be almost twice as large as needed.

Signed-off-by: Troy Kisky 
Signed-off-by: Dirk Behme 
---
 drivers/spi/mxc_spi.c |   27 ---
 1 file changed, 12 insertions(+), 15 deletions(-)

diff --git a/drivers/spi/mxc_spi.c b/drivers/spi/mxc_spi.c
index 3e903b3..66c2ad8 100644
--- a/drivers/spi/mxc_spi.c
+++ b/drivers/spi/mxc_spi.c
@@ -128,7 +128,7 @@ static s32 spi_cfg_mxc(struct mxc_spi_slave *mxcs, unsigned 
int cs,
unsigned int max_hz, unsigned int mode)
 {
u32 clk_src = mxc_get_clock(MXC_CSPI_CLK);
-   s32 pre_div = 1, post_div = 0, i, reg_ctrl, reg_config;
+   s32 pre_div = 1, post_div = 0, reg_ctrl, reg_config;
u32 ss_pol = 0, sclkpol = 0, sclkpha = 0;
struct cspi_regs *regs = (struct cspi_regs *)mxcs->base;
 
@@ -147,27 +147,24 @@ static s32 spi_cfg_mxc(struct mxc_spi_slave *mxcs, 
unsigned int cs,
reg_ctrl |=  MXC_CSPICTRL_EN;
reg_write(®s->ctrl, reg_ctrl);
 
-   /*
-* The following computation is taken directly from Freescale's code.
-*/
if (clk_src > max_hz) {
pre_div = DIV_ROUND_UP(clk_src, max_hz);
-   if (pre_div > 16) {
-   post_div = pre_div / 16;
-   pre_div = 16;
-   }
-   if (post_div != 0) {
-   for (i = 0; i < 16; i++) {
-   if ((1 << i) >= post_div)
-   break;
-   }
-   if (i == 16) {
+   /* fls(1) = 1, fls(0x8000) = 32, fls(16) = 5 */
+   post_div = fls(pre_div - 1);
+   if (post_div > 4) {
+   post_div -= 4;
+
+   if (post_div >= 16) {
printf("Error: no divider for the freq: %d\n",
max_hz);
return -1;
}
-   post_div = i;
+   pre_div = (pre_div + (1 << post_div) - 1) >> post_div;
+
+   } else {
+   post_div = 0;
}
+
}
 
debug("pre_div = %d, post_div=%d\n", pre_div, post_div);
-- 
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/2] spi: mxc_spi: Fix pre and post divider calculation

2013-05-08 Thread Dirk Behme
Fix two issues with the calculation of pre_div and post_div:

1. pre_div: While the calculation of pre_div looks correct, to set the
CONREG[15-12] bits pre_div needs to be decremented by 1:

The i.MX 6Dual/6Quad Applications Processor Reference Manual (IMX6DQRM
Rev. 0, 11/2012) states:

CONREG[15-12]: PRE_DIVIDER
 Divide by 1
0001 Divide by 2
0010 Divide by 3
...
1101 Divide by 14
1110 Divide by 15
 Divide by 16

I.e. if we want to divide by 2, we have to write 1 to CONREG[15-12].

2. In case the post divider becomes necessary, pre_div will be divided by
16. So set pre_div to 16, too. And not 15.

Both issues above are tested using the following examples:

clk_src = 6000 (60MHz, default i.MX6 ECSPI clock)

a) max_hz == 2300 (23MHz, max i.MX6 ECSPI read clock)

-> pre_div =  3 (divide by 3 => CONREG[15-12] == 2)
-> post_div = 0 (divide by 1 => CONREG[11- 8] == 0)
   => 60MHz / 3 = 20MHz SPI clock

b) max_hz == 200 (2MHz)

-> pre_div =  16 (divide by 16 => CONREG[15-12] == 15)
-> post_div = 1  (divide by  2 => CONREG[11- 8] == 1)
   => 60MHz / 32 = 1.875MHz SPI clock

c) max_hz == 100 (1MHz)

-> pre_div =  16 (divide by 16 => CONREG[15-12] == 15)
-> post_div = 2  (divide by  4 => CONREG[11- 8] == 2)
   => 60MHz / 64 = 937.5kHz SPI clock

d) max_hz == 50 (500kHz)

-> pre_div =  16 (divide by 16 => CONREG[15-12] == 15)
-> post_div = 3  (divide by  8 => CONREG[11- 8] == 3)
   => 60MHz / 128 = 468.75kHz SPI clock

Signed-off-by: Dirk Behme 
---

Note: Changes in v2: Use pre_div divider /16 instead of /15 in the
  first version of this patch.

 drivers/spi/mxc_spi.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/spi/mxc_spi.c b/drivers/spi/mxc_spi.c
index 843a1f2..3e903b3 100644
--- a/drivers/spi/mxc_spi.c
+++ b/drivers/spi/mxc_spi.c
@@ -128,7 +128,7 @@ static s32 spi_cfg_mxc(struct mxc_spi_slave *mxcs, unsigned 
int cs,
unsigned int max_hz, unsigned int mode)
 {
u32 clk_src = mxc_get_clock(MXC_CSPI_CLK);
-   s32 pre_div = 0, post_div = 0, i, reg_ctrl, reg_config;
+   s32 pre_div = 1, post_div = 0, i, reg_ctrl, reg_config;
u32 ss_pol = 0, sclkpol = 0, sclkpha = 0;
struct cspi_regs *regs = (struct cspi_regs *)mxcs->base;
 
@@ -154,7 +154,7 @@ static s32 spi_cfg_mxc(struct mxc_spi_slave *mxcs, unsigned 
int cs,
pre_div = DIV_ROUND_UP(clk_src, max_hz);
if (pre_div > 16) {
post_div = pre_div / 16;
-   pre_div = 15;
+   pre_div = 16;
}
if (post_div != 0) {
for (i = 0; i < 16; i++) {
@@ -174,7 +174,7 @@ static s32 spi_cfg_mxc(struct mxc_spi_slave *mxcs, unsigned 
int cs,
reg_ctrl = (reg_ctrl & ~MXC_CSPICTRL_SELCHAN(3)) |
MXC_CSPICTRL_SELCHAN(cs);
reg_ctrl = (reg_ctrl & ~MXC_CSPICTRL_PREDIV(0x0F)) |
-   MXC_CSPICTRL_PREDIV(pre_div);
+   MXC_CSPICTRL_PREDIV(pre_div - 1);
reg_ctrl = (reg_ctrl & ~MXC_CSPICTRL_POSTDIV(0x0F)) |
MXC_CSPICTRL_POSTDIV(post_div);
 
-- 
1.7.10.4

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


Re: [U-Boot] [PATCH 1/2] lcd: add functions to setup up simplefb device tree

2013-05-08 Thread Simon Glass
Hi Stephen,

On Tue, May 7, 2013 at 10:21 PM, Stephen Warren  wrote:
> simple-framebuffer is a new device tree binding that describes a pre-
> configured frame-buffer memory region and its format. The Linux kernel
> contains a driver that supports this binding. Implement functions to
> create a DT node (or fill in an existing node) with parameters that
> describe the framebuffer format that U-Boot is using.
>
> This will be immediately used by the Raspberry Pi board in U-Boot, and
> likely will be used by the Samsung ARM ChromeBook support soon too. It
> could well be used by many other boards (e.g. Tegra boards with built-in
> LCD panels, which aren't yet supported by the Linux kernel).
>
> Signed-off-by: Stephen Warren 
> ---
>  common/lcd.c  |   87 
> +
>  include/lcd.h |5 
>  2 files changed, 92 insertions(+)

This looks OK - is a better place for it than the common lcd code? I
presume it is here because it accesses panel_info?

Also is there a binding file we can bring in?

>
> diff --git a/common/lcd.c b/common/lcd.c
> index edae835..3a60484 100644
> --- a/common/lcd.c
> +++ b/common/lcd.c
> @@ -57,6 +57,10 @@
>  #include 
>  #endif
>
> +#if defined(CONFIG_LCD_DT_SIMPLEFB)
> +#include 
> +#endif
> +
>  //
>  /* ** FONT DATA  
>   */
>  //
> @@ -1182,3 +1186,86 @@ int lcd_get_screen_columns(void)
>  {
> return CONSOLE_COLS;
>  }
> +
> +#if defined(CONFIG_LCD_DT_SIMPLEFB)
> +static int lcd_dt_simplefb_configure_node(void *blob, int off)
> +{
> +   u32 stride;
> +   fdt32_t cells[2];
> +   int ret;
> +   const char format[] =
> +#if LCD_BPP == LCD_COLOR16
> +   "r5g6b5";
> +#else
> +   "";
> +#endif
> +
> +   if (!format[0])
> +   return -1;
> +
> +   stride = panel_info.vl_col * 2;
> +
> +   cells[0] = cpu_to_fdt32(gd->fb_base);
> +   cells[1] = cpu_to_fdt32(stride * panel_info.vl_row);
> +   ret = fdt_setprop(blob, off, "reg", cells, sizeof(cells[0]) * 2);
> +   if (ret < 0)
> +   return -1;
> +
> +   cells[0] = cpu_to_fdt32(panel_info.vl_col);
> +   ret = fdt_setprop(blob, off, "width", cells, sizeof(cells[0]));
> +   if (ret < 0)
> +   return -1;
> +
> +   cells[0] = cpu_to_fdt32(panel_info.vl_row);
> +   ret = fdt_setprop(blob, off, "height", cells, sizeof(cells[0]));
> +   if (ret < 0)
> +   return -1;
> +
> +   cells[0] = cpu_to_fdt32(stride);
> +   ret = fdt_setprop(blob, off, "stride", cells, sizeof(cells[0]));
> +   if (ret < 0)
> +   return -1;
> +
> +   ret = fdt_setprop(blob, off, "format", format, strlen(format) + 1);
> +   if (ret < 0)
> +   return -1;
> +
> +   ret = fdt_delprop(blob, off, "status");
> +   if (ret < 0)
> +   return -1;
> +
> +   return 0;
> +}
> +
> +int lcd_dt_simplefb_add_node(void *blob)

Can we not automatically find the node and update it?

> +{
> +   const char compat[] = "simple-framebuffer";
> +   const char disabled[] = "disabled";
> +   int off, ret;
> +
> +   off = fdt_add_subnode(blob, 0, "framebuffer");
> +   if (off < 0)
> +   return -1;
> +
> +   ret = fdt_setprop(blob, off, "status", disabled, sizeof(disabled));
> +   if (ret < 0)
> +   return -1;
> +
> +   ret = fdt_setprop(blob, off, "compatible", compat, sizeof(compat));
> +   if (ret < 0)
> +   return -1;
> +
> +   return lcd_dt_simplefb_configure_node(blob, off);
> +}
> +
> +int lcd_dt_simplefb_enable_existing_node(void *blob)
> +{
> +   int off;
> +
> +   off = fdt_node_offset_by_compatible(blob, -1, "simple-framebuffer");

Do we ever need to support more than one node, iwc perhaps we want to
pass in the offset? If not, then see above question re searching.

> +   if (off < 0)
> +   return -1;
> +
> +   return lcd_dt_simplefb_configure_node(blob, off);
> +}
> +#endif
> diff --git a/include/lcd.h b/include/lcd.h
> index c6e7fc5..7c5410d 100644
> --- a/include/lcd.h
> +++ b/include/lcd.h
> @@ -324,6 +324,11 @@ void lcd_show_board_info(void);
>  /* Return the size of the LCD frame buffer, and the line length */
>  int lcd_get_size(int *line_length);
>
> +#if defined(CONFIG_LCD_DT_SIMPLEFB)

Probably don't need this #ifdef? It will complicate things if we use
the autoconf series.

> +int lcd_dt_simplefb_add_node(void *blob);
> +int lcd_dt_simplefb_enable_existing_node(void *blob);
> +#endif
> +
>  //
>  /* ** BITMAP DISPLAY SUPPORT   */
>  //
> --
> 

Re: [U-Boot] [PATCH 2/2] ARM: bcm2835: add simplefb DT node during bootz/m

2013-05-08 Thread Simon Glass
On Tue, May 7, 2013 at 10:21 PM, Stephen Warren  wrote:
> Add a DT simple-framebuffer node to DT when booting the Linux kernel.
> This will allow the kernel to inherit the framebuffer configuration from
> U-Boot, and display a graphical boot console, and even run a full SW-
> rendered X server.
>
> Signed-off-by: Stephen Warren 

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


Re: [U-Boot] [PATCH] EXYNOS: SPI: Support word transfers

2013-05-08 Thread Simon Glass
On Mon, Mar 25, 2013 at 1:56 AM, Rajeshwari Shinde
 wrote:
> Since SPI register access is so expensive, it is worth transferring data
> a word at a time if we can. This complicates the driver unfortunately.
>
> Use the byte-swapping feature to avoid having to convert to/from big
> endian in software.
>
> This change increases speed from about 2MB/s to about 4.5MB/s.
>
> Based on "EXYNOS: SPI: Minimise access to SPI FIFO level"
> link: http://patchwork.ozlabs.org/patch/230034/
>
> Signed-off-by: Simon Glass 
> Signed-off-by: Rajeshwari Shinde 

We tested this today.

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


[U-Boot] Pull request: u-boot-blackfin

2013-05-08 Thread Sonic Zhang
Hi Tom,

Please pull the following patches from u-boot-blackfin into your tree.

Thanks

Sonic

The following changes since commit fe8e4dbad1d31c452af3fbabba21e72b210381b3:

  nds32: Use sections header to obtain link symbols (2013-05-08 12:38:10 +0800)

are available in the git repository at:

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

for you to fetch changes up to 2ac75146988bdcf8c30aee9c286af7f2f93b474e:

  bfin: Move gpio support for bf54x and bf60x into the generic driver
folder. (2013-05-09 10:53:47 +0800)


Bob Liu (3):
  blackfin: reduce size of u-boot.ldr in bf548-ezkit default config.
  blackfin: add baudrate to bdinfo
  blackfin: bf609: add softswitch config command

Marek Vasut (1):
  blackfin: The buf variable in bfin_mac.c is not used and produces warning,

Mike Frysinger (1):
  Blackfin: adjust asm constraints with NMI workaround

Scott Jiang (3):
  bfin: Remove spi dma function in bf5xx.
  bfin: discard invalid data and clear RXS in bf5xx spi driver
  bf609: add SPI register base address

Sonic Zhang (14):
  blackfin: Change the member's type in dma structures.
  blackfin: limit the max memory dma peripheral transfer size to 4 bytes.
  blackfin: run core1 from L1 code sram start address in uboot
init code on core 0
  blackfin: Set correct early debug serial baudrate.
  blackfin: Correct early serial mess output in BYPASS boot mode.
  blackfin: bf609: implement soft switch
  blackfin: Fit u-boot image size into limited nor flash on blackfin.
  blackfin: Enable early print via the generic serial API.
  blackfin: Add memory virtual console to blackfin serial driver.
  blackfin: Uart divisor should be set after their values are generated.
  blackfin: Move blackfin watchdog driver out of the blackfin arch folder.
  blackfin: Move blackfin serial driver out of blackfin arch folder.
  blackfin: Add comments for watchdog event initialization.
  bfin: Move gpio support for bf54x and bf60x into the generic
driver folder.

 arch/blackfin/cpu/Makefile |4 +-
 arch/blackfin/cpu/cpu.c|   32 +-
 arch/blackfin/cpu/gpio.c   |  145 +--
 arch/blackfin/cpu/initcode.c   |   71 ++--
 arch/blackfin/cpu/start.S  |   29 +-
 arch/blackfin/include/asm/clock.h  |   78 
 arch/blackfin/include/asm/dma.h|   24 +-
 arch/blackfin/include/asm/gpio.h   |   62 +--
 arch/blackfin/include/asm/mach-bf561/BF561_def.h   |2 +
 arch/blackfin/include/asm/mach-bf609/BF609_def.h   |5 +
 arch/blackfin/include/asm/portmux.h|5 -
 arch/blackfin/{cpu => include/asm}/serial.h|   23 +-
 arch/blackfin/{cpu => include/asm}/serial1.h   |   48 +--
 arch/blackfin/{cpu => include/asm}/serial4.h   |   27 +-
 arch/blackfin/include/asm/soft_switch.h|   18 +
 arch/blackfin/lib/board.c  |6 +-
 arch/blackfin/lib/clocks.c |   12 +-
 arch/blackfin/lib/string.c |9 +-
 board/bf609-ezkit/soft_switch.c|  171 
 board/bf609-ezkit/soft_switch.h|   80 
 common/Makefile|1 +
 common/cmd_softswitch.c|   41 ++
 doc/README.watchdog|3 +
 drivers/gpio/Makefile  |1 +
 drivers/gpio/adi_gpio2.c   |  440 
 drivers/net/bfin_mac.c |2 -
 drivers/serial/Makefile|1 +
 .../cpu/serial.c => drivers/serial/serial_bfin.c   |  110 +++--
 drivers/spi/bfin_spi.c |  105 +
 drivers/watchdog/Makefile  |1 +
 .../cpu/watchdog.c => drivers/watchdog/bfin_wdt.c  |7 +-
 include/configs/bf527-ezkit.h  |   12 +-
 include/configs/bf537-stamp.h  |   10 +-
 include/configs/bf548-ezkit.h  |   25 +-
 include/configs/bf561-ezkit.h  |5 +
 include/configs/bf609-ezkit.h  |   10 +
 include/configs/bfin_adi_common.h  |   14 +-
 include/watchdog.h |3 +-
 38 files changed, 1163 insertions(+), 479 deletions(-)
 create mode 100644 arch/blackfin/include/asm/clock.h
 rename arch/blackfin/{cpu => include/asm}/serial.h (82%)
 rename arch/blackfin/{cpu => include/asm}/serial1.h (94%)
 rename arch/blackfin/{cpu => include/asm}/serial4.h (86%)
 create mode 100644 arch/blackfin/include/asm/soft_switch.h
 create mode 100644 board/bf609-ezkit/soft_switch.c
 create mode 100644 board/bf609-ezkit/soft_switch.h
 create mode 100644 common/cmd_softswitch.

[U-Boot] [PATCH v5 4/4] usb: gadget: add Faraday FOTG210 USB gadget support

2013-05-08 Thread Kuo-Jung Su
From: Kuo-Jung Su 

The Faraday FOTG210 is an OTG chip which could operate
as either an EHCI Host or a USB Device as a time.

Signed-off-by: Kuo-Jung Su 
CC: Marek Vasut 
---
Changes for v5:
   - Coding Style cleanup.
   - Drop postfix '__iomem' from struct fotg210_regs
   - Use permanent delay for hardware reset
   - Drop '#ifndef CONFIG_SYS_DCACHE_OFF'
   - Drop magic numbers

Changes for v4:
   - Use only macro constants and named bit/mask
   - Remove dcache_enable() from usb_gadget_register_driver()

Changes for v3:
   - Coding Style cleanup.
   - Drop bit fields from c struct.
   - Drop macros for wirtel()/readl(), call them directly.
   - Always insert a blank line between declarations and code.
   - Replace all the infinite wait loop with a timeout.
   - Add '__iomem' to all the declaration of HW register pointers.

Changes for v2:
   - Coding Style cleanup.
   - Use readl(), writel(), clrsetbits_le32() to replace REG() macros.
   - Use structure based hardware registers to replace the macro constants.
   - Replace BIT() with BIT_MASK().
   - echi-faraday: Remove debug codes.

 drivers/usb/gadget/Makefile   |1 +
 drivers/usb/gadget/fotg210.c  |  948 +
 drivers/usb/gadget/gadget_chips.h |8 +
 3 files changed, 957 insertions(+)
 create mode 100644 drivers/usb/gadget/fotg210.c

diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
index e545b6b..432cf17 100644
--- a/drivers/usb/gadget/Makefile
+++ b/drivers/usb/gadget/Makefile
@@ -35,6 +35,7 @@ endif
 # new USB gadget layer dependencies
 ifdef CONFIG_USB_GADGET
 COBJS-$(CONFIG_USB_GADGET_S3C_UDC_OTG) += s3c_udc_otg.o
+COBJS-$(CONFIG_USB_GADGET_FOTG210) += fotg210.o
 COBJS-$(CONFIG_USBDOWNLOAD_GADGET) += g_dnl.o
 COBJS-$(CONFIG_DFU_FUNCTION) += f_dfu.o
 endif
diff --git a/drivers/usb/gadget/fotg210.c b/drivers/usb/gadget/fotg210.c
new file mode 100644
index 000..d003331
--- /dev/null
+++ b/drivers/usb/gadget/fotg210.c
@@ -0,0 +1,948 @@
+/*
+ * Faraday USB 2.0 OTG Controller
+ *
+ * (C) Copyright 2010 Faraday Technology
+ * Dante Su 
+ *
+ * This file is released under the terms of GPL v2 and any later version.
+ * See the file COPYING in the root directory of the source tree for details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#define CFG_NUM_ENDPOINTS  4
+#define CFG_EP0_MAX_PACKET_SIZE64
+#define CFG_EPX_MAX_PACKET_SIZE512
+
+#define CFG_CMD_TIMEOUT (CONFIG_SYS_HZ >> 2) /* 250 ms */
+
+struct fotg210_chip;
+
+struct fotg210_ep {
+   struct usb_ep ep;
+
+   uint maxpacket;
+   uint id;
+   uint stopped;
+
+   struct list_head  queue;
+   struct fotg210_chip  *chip;
+   const struct usb_endpoint_descriptor *desc;
+};
+
+struct fotg210_request {
+   struct usb_request req;
+   struct list_head   queue;
+   struct fotg210_ep *ep;
+};
+
+struct fotg210_chip {
+   struct usb_gadget gadget;
+   struct usb_gadget_driver *driver;
+   struct fotg210_regs  *regs;
+   uint8_t   irq;
+   uint16_t  addr;
+   int   pullup;
+   enum usb_device_state state;
+   struct fotg210_ep ep[1 + CFG_NUM_ENDPOINTS];
+};
+
+static struct usb_endpoint_descriptor ep0_desc = {
+   .bLength = sizeof(struct usb_endpoint_descriptor),
+   .bDescriptorType = USB_DT_ENDPOINT,
+   .bEndpointAddress = USB_DIR_IN,
+   .bmAttributes = USB_ENDPOINT_XFER_CONTROL,
+};
+
+static inline int fifo_to_ep(struct fotg210_chip *chip, int id, int in)
+{
+   return (id < 0) ? 0 : ((id & 0x03) + 1);
+}
+
+static inline int ep_to_fifo(struct fotg210_chip *chip, int id)
+{
+   return (id <= 0) ? -1 : ((id - 1) & 0x03);
+}
+
+static inline int ep_reset(struct fotg210_chip *chip, uint8_t ep_addr)
+{
+   int ep = ep_addr & USB_ENDPOINT_NUMBER_MASK;
+   struct fotg210_regs *regs = chip->regs;
+
+   if (ep_addr & USB_DIR_IN) {
+   /* reset endpoint */
+   setbits_le32(®s->iep[ep - 1], IEP_RESET);
+   mdelay(1);
+   clrbits_le32(®s->iep[ep - 1], IEP_RESET);
+   /* clear endpoint stall */
+   clrbits_le32(®s->iep[ep - 1], IEP_STALL);
+   } else {
+   /* reset endpoint */
+   setbits_le32(®s->oep[ep - 1], OEP_RESET);
+   mdelay(1);
+   clrbits_le32(®s->oep[ep - 1], OEP_RESET);
+   /* clear endpoint stall */
+   clrbits_le32(®s->oep[ep - 1], OEP_STALL);
+   }
+
+   return 0;
+}
+
+static int fotg210_reset(struct fotg210_chip *chip)
+{
+   struct fotg210_regs *regs = chip->regs;
+   uint32_t i;
+
+   chip->state = USB_STATE_POWERED;
+
+   /* chip enable */
+   writel(DEVCTRL_EN, ®s->dev_ctrl);
+
+   /* device address reset */
+   c

Re: [U-Boot] [PATCH v2] at91sam9x5ek: Pass serial and revision tags to Linux

2013-05-08 Thread Bo Shen

Hi Julius,

On 5/3/2013 18:54, Julius Hemanth P wrote:

This code is small snippet from patch
ftp://ftp.linux4sam.org/pub/uboot/u-boot-v2010.06/u-boot-5series_1.0.patch

Bug:-


I think this should not report bug, it should for compatible with old 
kernel (only for Linux 2.6.39 released on www.at91.com/linux4sam).



  For board at91sam9x5ek, U-boot doesn't pass serial and revision tags
to Linux kernel, hence kernel fails to identify correct revision and assumes
as rev-A, resulting in failing to detect NAND device.

This patch enables u-boot to pass serial and revision tags to Linux
kernel, which helps Linux to detect NAND device.

Signed-off-by: Julius Hemanth 
---
Changes for v2:
 - access GPBR using c structure
 - removed tailing 1 for #define
 - s/Miscelaneous/Miscellaneous
 - s/initialisations/initializations

  board/atmel/at91sam9x5ek/at91sam9x5ek.c |   33 ++-
  include/configs/at91sam9x5ek.h  |5 
  2 files changed, 37 insertions(+), 1 deletions(-)


This patch can not be applied based on u-boot master branch or else on 
u-boot-atmel master branch.


Please re-generate this patch based on u-boot master branch or 
u-boot-atmel master branch.



diff --git a/board/atmel/at91sam9x5ek/at91sam9x5ek.c
b/board/atmel/at91sam9x5ek/at91sam9x5ek.c
index 8773e6f..c05bdb7 100644
--- a/board/atmel/at91sam9x5ek/at91sam9x5ek.c
+++ b/board/atmel/at91sam9x5ek/at91sam9x5ek.c
@@ -27,6 +27,7 @@
  #include 
  #include 
  #include 
+#include 
  #include 
  #include 
  #include 
@@ -48,8 +49,34 @@ DECLARE_GLOBAL_DATA_PTR;

  /* - 
*/
  /*
- * Miscelaneous platform dependent initialisations
+ * Miscellaneous platform dependent initializations
   */
+
+#ifdef CONFIG_LOAD_ONE_WIRE_INFO
+static u32 system_rev;
+static u32 system_serial_low;
+
+u32 get_board_rev(void)
+{
+   return system_rev;
+}
+
+void get_board_serial(struct tag_serialnr *serialnr)
+{
+   serialnr->high = 0; /* Not used */
+   serialnr->low = system_serial_low;
+}
+
+void load_1wire_info(void)
+{
+   at91_gpbr_t *gpbr = (at91_gpbr_t *) ATMEL_BASE_GPBR;
+
+   /* serial is in GPBR #2 and revision is in GPBR #3 */
+   system_serial_low = readl(gpbr->reg[2]);
+   system_rev = readl(gpbr->reg[3]);
+}


This is wrong which will cause u-boot hang up. It should be:

system_serial_low = readl(&gpbr->reg[2]);
system_rev = readl(&gpbr->reg[3]);

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


[U-Boot] [PATCH v5 3/4] usb: ehci: add Faraday USB 2.0 EHCI support

2013-05-08 Thread Kuo-Jung Su
From: Kuo-Jung Su 

This patch adds support to both Faraday FUSBH200 and FOTG210,
the differences between Faraday EHCI and standard EHCI are
listed bellow:

1. The PORTSC starts at 0x30 instead of 0x44.
2. The CONFIGFLAG(0x40) is not only un-implemented, and
   also has its address space removed.
3. Faraday EHCI is a TDI design, but it doesn't
   compatible with the general TDI implementation
   found at both U-Boot and Linux.
4. The ISOC descriptors differs from standard EHCI in
   several ways. And since U-boot doesn't support ISOC,
   we don't have to worry about that.

Signed-off-by: Kuo-Jung Su 
CC: Marek Vasut 
---
Changes for v5:
   - Break down EHCI changes as seperate changesets.
   - Fix the invalid multi-line comment style.

Changes for v4:
   - Use only macro constants and named bit/mask
   - Use weak-aliased functions for tdi implementation and
 also portsc registers to avoid poluting ehci.h with ifdefs

Changes for v3:
   - Coding Style cleanup.
   - Drop bit fields from c struct.
   - Drop macros for wirtel()/readl(), call them directly.
   - Always insert a blank line between declarations and code.
   - Replace all the infinite wait loop with a timeout.
   - Add '__iomem' to all the declaration of HW register pointers.

Changes for v2:
   - Coding Style cleanup.
   - Use readl(), writel(), clrsetbits_le32() to replace REG() macros.
   - Use structure based hardware registers to replace the macro constants.
   - Replace BIT() with BIT_MASK().
   - echi-faraday: Remove debug codes.

 common/usb_hub.c|7 +-
 drivers/usb/host/Makefile   |1 +
 drivers/usb/host/ehci-faraday.c |  146 
 drivers/usb/host/ehci-hcd.c |4 +
 include/usb/fotg210.h   |  364 +++
 include/usb/fusbh200.h  |   61 +++
 6 files changed, 582 insertions(+), 1 deletion(-)
 create mode 100644 drivers/usb/host/ehci-faraday.c
 create mode 100644 include/usb/fotg210.h
 create mode 100644 include/usb/fusbh200.h

diff --git a/common/usb_hub.c b/common/usb_hub.c
index 0db3530..6513abe 100644
--- a/common/usb_hub.c
+++ b/common/usb_hub.c
@@ -447,7 +447,11 @@ static int usb_hub_configure(struct usb_device *dev)
i + 1, portstatus);
usb_clear_port_feature(dev, i + 1,
USB_PORT_FEAT_C_ENABLE);
-
+   /*
+* The following hack causes a ghost device problem
+* to Faraday EHCI
+*/
+#ifndef CONFIG_USB_EHCI_FARADAY
/* EM interference sometimes causes bad shielded USB
 * devices to be shutdown by the hub, this hack enables
 * them again. Works at least with mouse driver */
@@ -459,6 +463,7 @@ static int usb_hub_configure(struct usb_device *dev)
"re-enabling...\n", i + 1);
usb_hub_port_connect_change(dev, i);
}
+#endif
}
if (portstatus & USB_PORT_STAT_SUSPEND) {
USB_HUB_PRINTF("port %d suspend change\n", i + 1);
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
index 87a5970..98f2a10 100644
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -43,6 +43,7 @@ COBJS-$(CONFIG_USB_EHCI_FSL) += ehci-mpc512x.o
 else
 COBJS-$(CONFIG_USB_EHCI_FSL) += ehci-fsl.o
 endif
+COBJS-$(CONFIG_USB_EHCI_FARADAY) += ehci-faraday.o
 COBJS-$(CONFIG_USB_EHCI_EXYNOS) += ehci-exynos.o
 COBJS-$(CONFIG_USB_EHCI_MXC) += ehci-mxc.o
 COBJS-$(CONFIG_USB_EHCI_MXS) += ehci-mxs.o
diff --git a/drivers/usb/host/ehci-faraday.c b/drivers/usb/host/ehci-faraday.c
new file mode 100644
index 000..1be9369
--- /dev/null
+++ b/drivers/usb/host/ehci-faraday.c
@@ -0,0 +1,146 @@
+/*
+ * Faraday USB 2.0 EHCI Controller
+ *
+ * (C) Copyright 2010 Faraday Technology
+ * Dante Su 
+ *
+ * This file is released under the terms of GPL v2 and any later version.
+ * See the file COPYING in the root directory of the source tree for details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "ehci.h"
+
+#ifndef CONFIG_USB_EHCI_BASE_LIST
+#define CONFIG_USB_EHCI_BASE_LIST  { CONFIG_USB_EHCI_BASE }
+#endif
+
+union ehci_faraday_regs {
+   struct fusbh200_regs usb;
+   struct fotg210_regs  otg;
+};
+
+static inline int ehci_is_fotg2xx(union ehci_faraday_regs *regs)
+{
+   return !readl(®s->usb.easstr);
+}
+
+/*
+ * Create the appropriate control structures to manage
+ * a new EHCI host controller.
+ */
+int ehci_hcd_init(int index, struct ehci_hccr **ret_hccr,
+   struct ehci_hcor **ret_hcor)
+{
+   struct ehci_hccr *hccr;
+   struct ehci_hcor *hcor;
+   union ehci_faraday_regs *regs;
+   uint32_t base_list[] = CONFIG_USB_EHCI_BASE_LIST;
+
+   if (index < 0 || inde

[U-Boot] [PATCH v5 2/4] usb: ehci: add weak-aliased functions to portsc & tdi

2013-05-08 Thread Kuo-Jung Su
From: Kuo-Jung Su 

There is at least one non-EHCI compliant controller (i.e. Faraday EHCI)
known to implement a non-standard TDI stuff.
Futhermore, it not only leave reserved and CONFIGFLAG registers
un-implemented but also has their address spaces removed.

And thus, we need weak-aliased functions to both TDI stuff
and PORTSC registers for interface abstraction.

Signed-off-by: Kuo-Jung Su 
CC: Marek Vasut 
---
Changes for v5:
   - Split up from Faraday EHCI patch

Changes for v2 - v4:
   - See 'usb: ehci: add Faraday USB 2.0 EHCI support'

 drivers/usb/host/ehci-hcd.c |  100 +++
 1 file changed, 64 insertions(+), 36 deletions(-)

diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index c816878..b334173 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -117,10 +117,50 @@ static struct descriptor {
 };

 #if defined(CONFIG_EHCI_IS_TDI)
-#define ehci_is_TDI()  (1)
-#else
-#define ehci_is_TDI()  (0)
+# define ehci_is_TDI() (1)
+
+/* put TDI/ARC silicon into EHCI mode */
+void __ehci_tdi_reset(struct ehci_hcor *hcor)
+{
+   uint32_t tmp, *reg_ptr;
+
+   reg_ptr = (uint32_t *)((uint8_t *) + USBMODE);
+   tmp = ehci_readl(reg_ptr);
+   tmp |= USBMODE_CM_HC;
+#if defined(CONFIG_EHCI_MMIO_BIG_ENDIAN)
+   tmp |= USBMODE_BE;
 #endif
+   ehci_writel(reg_ptr, tmp);
+}
+
+void ehci_tdi_reset(struct ehci_hcor *hcor)
+   __attribute__((weak, alias("__ehci_tdi_reset")));
+
+int __ehci_port_speed(struct ehci_hcor *hcor, unsigned int portsc)
+{
+   int ret = 0;
+
+   switch (PORTSC_PSPD(portsc)) {
+   case PORTSC_PSPD_FS:
+   break;
+   case PORTSC_PSPD_LS:
+   ret = USB_PORT_STAT_LOW_SPEED;
+   break;
+   case PORTSC_PSPD_HS:
+   default:
+   ret = USB_PORT_STAT_HIGH_SPEED;
+   break;
+   }
+
+   return ret;
+}
+
+int ehci_port_speed(struct ehci_hcor *hcor, unsigned int portsc)
+   __attribute__((weak, alias("__ehci_port_speed")));
+
+#else  /* CONFIG_EHCI_IS_TDI */
+# define ehci_is_TDI() (0)
+#endif /* CONFIG_EHCI_IS_TDI */

 void __ehci_powerup_fixup(uint32_t *status_reg, uint32_t *reg)
 {
@@ -149,8 +189,6 @@ static int handshake(uint32_t *ptr, uint32_t mask, uint32_t 
done, int usec)
 static int ehci_reset(int index)
 {
uint32_t cmd;
-   uint32_t tmp;
-   uint32_t *reg_ptr;
int ret = 0;

cmd = ehci_readl(&ehcic[index].hcor->or_usbcmd);
@@ -163,15 +201,8 @@ static int ehci_reset(int index)
goto out;
}

-   if (ehci_is_TDI()) {
-   reg_ptr = (uint32_t *)((u8 *)ehcic[index].hcor + USBMODE);
-   tmp = ehci_readl(reg_ptr);
-   tmp |= USBMODE_CM_HC;
-#if defined(CONFIG_EHCI_MMIO_BIG_ENDIAN)
-   tmp |= USBMODE_BE;
-#endif
-   ehci_writel(reg_ptr, tmp);
-   }
+   if (ehci_is_TDI())
+   ehci_tdi_reset(ehcic[index].hcor);

 #ifdef CONFIG_USB_EHCI_TXFIFO_THRESH
cmd = ehci_readl(&ehcic[index].hcor->or_txfilltuning);
@@ -597,6 +628,18 @@ static inline int min3(int a, int b, int c)
return a;
 }

+uint32_t *__ehci_get_portsc_register(struct ehci_hcor *hcor, int port)
+{
+   if (port >= CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS) {
+   printf("The request port(%d) is not configured\n", port);
+   return NULL;
+   }
+
+   return (uint32_t *)&hcor->or_portsc[port];
+}
+uint32_t *ehci_get_portsc_register(struct ehci_hcor *hcor, int port)
+   __attribute__((weak, alias("__ehci_get_portsc_register")));
+
 int
 ehci_submit_root(struct usb_device *dev, unsigned long pipe, void *buffer,
 int length, struct devrequest *req)
@@ -609,13 +652,10 @@ ehci_submit_root(struct usb_device *dev, unsigned long 
pipe, void *buffer,
uint32_t *status_reg;
struct ehci_ctrl *ctrl = dev->controller;

-   if (le16_to_cpu(req->index) > CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS) {
-   printf("The request port(%d) is not configured\n",
-   le16_to_cpu(req->index) - 1);
+   status_reg = ehci_get_portsc_register(ctrl->hcor,
+   le16_to_cpu(req->index) - 1);
+   if (!status_reg)
return -1;
-   }
-   status_reg = (uint32_t *)&ctrl->hcor->or_portsc[
-   le16_to_cpu(req->index) - 1];
srclen = 0;

debug("req=%u (%#x), type=%u (%#x), value=%u, index=%u\n",
@@ -709,23 +749,10 @@ ehci_submit_root(struct usb_device *dev, unsigned long 
pipe, void *buffer,
tmpbuf[0] |= USB_PORT_STAT_RESET;
if (reg & EHCI_PS_PP)
tmpbuf[1] |= USB_PORT_STAT_POWER >> 8;
-
-   if (ehci_is_TDI()) {
-   switch (PORTSC_PSPD(reg)) {
-   case PORTSC_PSPD_FS:
-   break;
-   case PORTSC_

[U-Boot] [PATCH v5 1/4] usb: hub: make minimum power-on delay configurable

2013-05-08 Thread Kuo-Jung Su
From: Kuo-Jung Su 

This patch makes the minimum power-on delay for USB HUB
become configurable. The original design waits at least
100 msec here, but some EHCI controlers(e.g. Faraday EHCI)
are known to require much longer delay interval.

NOTE:
The minimal delay is still 100 msec, a small value defined
in CONFIG_USB_HUB_MIN_POWER_ON_DELAY would be automatically
justified in common/usb_hub.c.

Signed-off-by: Kuo-Jung Su 
CC: Marek Vasut 
---
Changes for v5:
   - Split up from Faraday EHCI patch
   - Replace the Faraday EHCI ifdef for the long delay
 in usb_hub_configure() with the new configuration option:
 USB_HUB_MIN_POWER_ON_DELAY, which is used in usb_hub_power_on()
 to control the minimum usb hub power-on delay.

Changes for v2 - v4:
   - See 'usb: ehci: add Faraday USB 2.0 EHCI support'

 README   |3 +++
 common/usb_hub.c |8 +++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/README b/README
index 0d37d56..c70a59b 100644
--- a/README
+++ b/README
@@ -1244,6 +1244,9 @@ The following options need to be configured:
CONFIG_USB_EHCI_TXFIFO_THRESH enables setting of the
txfilltuning field in the EHCI controller on reset.

+   CONFIG_USB_HUB_MIN_POWER_ON_DELAY defines the minimum
+   interval for usb hub power-on delay.(minimum 100msec)
+
 - USB Device:
Define the below if you wish to use the USB console.
Once firmware is rebuilt from a serial console issue the
diff --git a/common/usb_hub.c b/common/usb_hub.c
index b5eeb62..0db3530 100644
--- a/common/usb_hub.c
+++ b/common/usb_hub.c
@@ -61,6 +61,12 @@
 #define USB_HUB_DEBUG  0
 #endif

+#if CONFIG_USB_HUB_MIN_POWER_ON_DELAY > 100
+# define USB_HUB_MIN_POWER_ON_DELAYCONFIG_USB_HUB_MIN_POWER_ON_DELAY
+#else
+# define USB_HUB_MIN_POWER_ON_DELAY100
+#endif
+
 #define USB_PRINTF(fmt, args...)   debug_cond(USB_DEBUG, fmt, ##args)
 #define USB_HUB_PRINTF(fmt, args...)   debug_cond(USB_HUB_DEBUG, fmt, ##args)

@@ -121,7 +127,7 @@ static void usb_hub_power_on(struct usb_hub_device *hub)
}

/* Wait at least 100 msec for power to become stable */
-   mdelay(max(pgood_delay, (unsigned)100));
+   mdelay(max(pgood_delay, USB_HUB_MIN_POWER_ON_DELAY));
 }

 void usb_hub_reset(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 v5 0/4] usb: add Faraday EHCI & Gadget support

2013-05-08 Thread Kuo-Jung Su
From: Kuo-Jung Su 

This patch adds support to both Faraday FUSBH200 and FOTG210,
the differences between Faraday EHCI and standard EHCI are
listed bellow:

1. The PORTSC starts at 0x30 instead of 0x44.
2. The CONFIGFLAG(0x40) is not only un-implemented, and
   also has its address removed.
3. Faraday EHCI is a TDI design, but it doesn't
   compatible with the general TDI implementation
   found at both U-Boot and Linux.
4. The ISOC descriptors differs from standard EHCI in
   several ways. And since U-boot doesn't support ISOC,
   we don't have to worry about that.

The Faraday FOTG210 is an OTG chip which could operate
as either an EHCI Host or a USB Device as a time.

Changes for v5:
   - Split up EHCI changeset
   - usb_hub: replace the Faraday EHCI ifdef for the long delay
 in usb_hub_configure() with the new configuration option:
 USB_HUB_MIN_POWER_ON_DELAY, which is used in usb_hub_power_on()
 to control the minimum usb hub power-on delay.
   - ehci-faraday: fix the invalid multi-line comment style.
   - gadget-fotg210: coding style cleanup.
   - gadget-fotg210: drop postfix '__iomem' from struct fotg210_regs
   - gadget-fotg210: use permanent delay for hardware reset
   - gadget-fotg210: drop '#ifndef CONFIG_SYS_DCACHE_OFF'
   - gadget-fotg210: drop magic numbers

Changes for v4:
   - Use only macro constants and named bit/mask
   - Use weak-aliased functions for tdi implementation and
 also portsc registers to avoid poluting ehci.h with ifdefs

Changes for v3:
   - Coding Style cleanup.
   - Drop bit fields from c struct.
   - Drop macros for wirtel()/readl(), call them directly.
   - Always insert a blank line between declarations and code.
   - Replace all the infinite wait loop with a timeout.
   - Add '__iomem' to all the declaration of HW register pointers.

Changes for v2:
   - Coding Style cleanup.
   - Use readl(), writel(), clrsetbits_le32() to replace REG() macros.
   - Use structure based hardware registers to replace the macro constants.
   - Replace BIT() with BIT_MASK().
   - echi-faraday: Remove debug codes.

Kuo-Jung Su (4):
  usb: make usb hub minimum power-on delay configurable
  usb: add weak-aliased functions EHCI portsc & tdi routines
  usb: ehci: add Faraday USB 2.0 EHCI support
  usb: gadget: add Faraday FOTG210 USB gadget support

 README|3 +
 common/usb_hub.c  |   15 +-
 drivers/usb/gadget/Makefile   |1 +
 drivers/usb/gadget/fotg210.c  |  948 +
 drivers/usb/gadget/gadget_chips.h |8 +
 drivers/usb/host/Makefile |1 +
 drivers/usb/host/ehci-faraday.c   |  146 ++
 drivers/usb/host/ehci-hcd.c   |  104 ++--
 include/usb/fotg210.h |  364 ++
 include/usb/fusbh200.h|   61 +++
 10 files changed, 1613 insertions(+), 38 deletions(-)
 create mode 100644 drivers/usb/gadget/fotg210.c
 create mode 100644 drivers/usb/host/ehci-faraday.c
 create mode 100644 include/usb/fotg210.h
 create mode 100644 include/usb/fusbh200.h

--
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 UBI support

2013-05-08 Thread Paul B. Henson
On Tue, May 07, 2013 at 11:01:35PM -0400, Tom Rini wrote:

> All changes do, but you can just reply to this thread.

Ok, here it is again, with the tag.
>From 532cc340712c0542526be601c3f9f886e7054e5c Mon Sep 17 00:00:00 2001
From: "Paul B. Henson" 
Date: Sat, 4 May 2013 17:44:43 -0700
Subject: [PATCH] Update doc/README.ubi to add description of accessing ubi
 filesystems.

Signed-off-by: "Paul B. Henson" 
---
 doc/README.ubi |   80 +++-
 1 files changed, 79 insertions(+), 1 deletions(-)

diff --git a/doc/README.ubi b/doc/README.ubi
index da2dfac..3cf4ef2 100644
--- a/doc/README.ubi
+++ b/doc/README.ubi
@@ -2,7 +2,8 @@
 UBI usage in U-Boot
 ---
 
-Here the list of the currently implemented UBI commands:
+UBI support in U-Boot is broken down into five separate commands.
+The first is the ubi command, which has six subcommands:
 
 => help ubi
 ubi - ubi commands
@@ -142,3 +143,80 @@ read 524288 bytes from volume 0 to 90(buf address)
 
 => cmp.b 80 90 8
 Total of 524288 bytes were the same
+
+
+Next, the ubifsmount command allows you to access filesystems on the
+UBI partition which has been attached with the ubi part command:
+
+=> help ubifsmount
+ubifsmount - mount UBIFS volume
+
+Usage:
+ubifsmount 
+- mount 'volume-name' volume
+
+For example:
+
+=> ubifsmount ubi0:recovery
+UBIFS: mounted UBI device 0, volume 0, name "recovery"
+UBIFS: mounted read-only
+UBIFS: file system size:   46473216 bytes (45384 KiB, 44 MiB, 366 LEBs)
+UBIFS: journal size:   6348800 bytes (6200 KiB, 6 MiB, 50 LEBs)
+UBIFS: media format:   w4/r0 (latest is w4/r0)
+UBIFS: default compressor: LZO
+UBIFS: reserved for root:  0 bytes (0 KiB)
+
+Note that unlike Linux, U-Boot can only have one active UBI partition
+at a time, which can be referred to as ubi0, and must be supplied along
+with the name of the filesystem you are mounting.
+
+
+Once a UBI filesystem has been mounted, the ubifsls command allows you
+to list the contents of a directory in the filesystem:
+
+
+=> help ubifsls
+ubifsls - list files in a directory
+
+Usage:
+ubifsls [directory]
+- list files in a 'directory' (default '/')
+
+For example:
+
+=> ubifsls
+17442  Thu Jan 01 02:57:38 1970  imx28-evk.dtb
+  2998146  Thu Jan 01 02:57:43 1970  zImage
+
+
+And the ubifsload command allows you to load a file from a UBI
+filesystem:
+
+
+=> help ubifsload
+ubifsload - load file from an UBIFS filesystem
+
+Usage:
+ubifsload   [bytes]
+- load file 'filename' to address 'addr'
+
+For example:
+
+=> ubifsload ${loadaddr} zImage
+Loading file 'zImage' to addr 0x4200 with size 2998146 (0x002dbf82)...
+Done
+
+
+Finally, you can unmount the UBI filesystem with the ubifsumount
+command:
+
+=> help ubifsumount
+ubifsumount - unmount UBIFS volume
+
+Usage:
+ubifsumount - unmount current volume
+
+For example:
+
+=> ubifsumount
+Unmounting UBIFS volume recovery!
-- 
1.7.8.6

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


Re: [U-Boot] [PATCH v4 1/2] usb: ehci: add Faraday USB 2.0 EHCI support

2013-05-08 Thread Kuo-Jung Su
2013/5/8 Marek Vasut :
> Dear Kuo-Jung Su,
>
>> 2013/5/8 Marek Vasut :
>> > Dear Kuo-Jung Su,
>> >
>> > [...]
>> >
>> >> >> --- a/common/usb_hub.c
>> >> >> +++ b/common/usb_hub.c
>> >> >> @@ -419,6 +419,14 @@ static int usb_hub_configure(struct usb_device
>> >> >> *dev)
>> >> >>
>> >> >>   portstatus = le16_to_cpu(portsts->wPortStatus);
>> >> >>   portchange = le16_to_cpu(portsts->wPortChange);
>> >> >>
>> >> >> +#ifdef CONFIG_USB_EHCI_FARADAY
>> >> >> + /* Faraday EHCI needs a long long delay here */
>> >> >> + if (!portchange && !portstatus) {
>> >> >> + if (get_timer(start) < 250)
>> >> >> + continue;
>> >> >> + }
>> >> >> +#endif
>> >> >
>> >> > I'd say just call a weak function here, in case some other non-EHCI
>> >> > compliant controller happened to need this too. btw. does it need to
>> >> > be 250 ms or can you poll for readiness somehow ?
>> >>
>> >> Got it, thanks. I'll add a weak function later,
>> >> and about the 250 ms is actually an estimated value.
>> >> The delay time is actually board specific, it looks to me
>> >> that it's somehow related to the number of usb host controllers
>> >> and the attached usb flash drivers.
>> >>
>> >> For example:
>> >>
>> >> 1.  A369 - FUSBH200: a usb flash driver attached
>> >>
>> >>  A369 - FOTG210: nothing attached
>> >>
>> >> => no extra delay required.
>> >>
>> >> 2.  A369 - FUSBH200: nothing attached
>> >>
>> >>  A369 - FOTG210: a usb flash driver attached
>> >>
>> >> => no extra delay required.
>> >>
>> >> 3. A369 - FUSBH200: a usb flash driver attached
>> >>
>> >> A369 - FOTG210: a usb flash driver attached
>> >>
>> >> => The 2nd ehci host requires 200 ms extra delay to detect the attached
>> >> device. So I put a 250ms here for safe.
>> >
>> > Urgh, isn't it a PHY problem then? Or can this not be solved like
>> > board/genesi/mx51_efikamx/efikamx-usb.c board_ehci_hcd_postinit() or such
>> > function?
>>
>> It looks to me that it's something related to root hub reset.
>> And now I've found that adding a extra delay to usb_hub_power_on()
>> would help to resolve this issue.
>> So I plan to add a new macro constant for it.
>> For example:
>>
>> 1. Add this to README:
>> CONFIG_USB_HUB_MIN_POWER_ON_DELAY defines the minimum
>> interval for usb hub power-on delay.(minimum 100msec)
>>
>> 2. Update usb_hub.c as bellow:
>> static void usb_hub_power_on(struct usb_hub_device *hub)
>> {
>> ..
>> /* Wait at least 100 msec for power to become stable */
>> mdelay(max(pgood_delay, USB_HUB_MIN_POWER_ON_DELAY));
>> }
>
> Let's try it.
>

Got it, thanks

> Best regards,
> Marek Vasut



--
Best wishes,
Kuo-Jung Su
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v5] nand: add Faraday FTNANDC021 NAND controller support

2013-05-08 Thread Kuo-Jung Su
From: Kuo-Jung Su 

Faraday FTNANDC021 is a integrated NAND flash controller.
It use a build-in command table to abstract the underlying
NAND flash control logic.

For example:

Issuing a command 0x10 to FTNANDC021 would result in
a page write + a read status operation.

Signed-off-by: Kuo-Jung Su 
CC: Scott Wood 
---
Changes for v5:
   - Update README for the description of CONFIG_SYS_FTNANDC021_TIMING.
   - Drop redundant white space. (i.e. if (mtd->writesize >= ' '4096))

Changes for v4:
   - Make it a separate patch, rather then a part of
 Faraday A36x patch series
   - Drop the faraday/nand.h to remove dependency to
 Faraday A36x patch series.
   - CONFIG_SYS_NAND_TIMING -> CONFIG_SYS_FTNANDC021_TIMING
   - Remove non-ECC code.
   - Implement private hwecc read/write_page functions
 to get rid of .eccpos & .eccbytes.
   - Use macro constants for timeout control

Changes for v3:
   - Coding Style cleanup.
   - Drop macros for wirtel()/readl(), call them directly.
   - Always insert a blank line between declarations and code.
   - Replace all the infinite wait loop with a timeout.
   - Add '__iomem' to all the declaration of HW register pointers.
   - Re-write this driver with ECC enabled and correct column address
 handling for OOB read/write,
   - Fix issuses addressed by Scott.

Changes for v2:
   - Coding Style cleanup.
   - Use readl(), writel(), clrsetbits_le32() to replace REG() macros.
   - Use structure based hardware registers to replace the macro constants.
   - Replace BIT() with BIT_MASK().

 README|6 +
 drivers/mtd/nand/Makefile |1 +
 drivers/mtd/nand/ftnandc021.c |  607 +
 include/faraday/ftnandc021.h  |  146 ++
 4 files changed, 760 insertions(+)
 create mode 100644 drivers/mtd/nand/ftnandc021.c
 create mode 100644 include/faraday/ftnandc021.h

diff --git a/README b/README
index 0d37d56..94c15e0 100644
--- a/README
+++ b/README
@@ -3879,6 +3879,12 @@ Low Level (hardware related) configuration options:
- drivers/mtd/nand/ndfc.c
- drivers/mtd/nand/mxc_nand.c

+- CONFIG_SYS_FTNANDC021_TIMING
+   This option specifies an array of customized timing parameters
+   for Faraday FTNANDC021 NAND flash controller.
+   e.g.
+   #define CONFIG_SYS_FTNANDC021_TIMING { 0x02240264, 0x42054209 }
+
 - CONFIG_SYS_NDFC_EBC0_CFG
Sets the EBC0_CFG register for the NDFC. If not defined
a default value will be used.
diff --git a/drivers/mtd/nand/Makefile b/drivers/mtd/nand/Makefile
index 35769c5..f6f89f0 100644
--- a/drivers/mtd/nand/Makefile
+++ b/drivers/mtd/nand/Makefile
@@ -63,6 +63,7 @@ COBJS-$(CONFIG_NAND_FSL_ELBC) += fsl_elbc_nand.o
 COBJS-$(CONFIG_NAND_FSL_IFC) += fsl_ifc_nand.o
 COBJS-$(CONFIG_NAND_FSL_UPM) += fsl_upm.o
 COBJS-$(CONFIG_NAND_FSMC) += fsmc_nand.o
+COBJS-$(CONFIG_NAND_FTNANDC021) += ftnandc021.o
 COBJS-$(CONFIG_NAND_JZ4740) += jz4740_nand.o
 COBJS-$(CONFIG_NAND_KB9202) += kb9202_nand.o
 COBJS-$(CONFIG_NAND_KIRKWOOD) += kirkwood_nand.o
diff --git a/drivers/mtd/nand/ftnandc021.c b/drivers/mtd/nand/ftnandc021.c
new file mode 100644
index 000..213b67a
--- /dev/null
+++ b/drivers/mtd/nand/ftnandc021.c
@@ -0,0 +1,607 @@
+/*
+ * Faraday NAND Flash Controller
+ *
+ * (C) Copyright 2010 Faraday Technology
+ * Dante Su 
+ *
+ * This file is released under the terms of GPL v2 and any later version.
+ * See the file COPYING in the root directory of the source tree for details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#define CFG_CMD_TIMEOUT (CONFIG_SYS_HZ >> 2) /* 250 ms */
+#define CFG_RST_TIMEOUT CONFIG_SYS_HZ /* 1 sec reset timeout */
+#define CFG_PIO_TIMEOUT (CONFIG_SYS_HZ >> 3) /* 125 ms */
+
+struct ftnandc021_chip {
+   void __iomem *regs;
+   int alen;
+   int pgsz;
+   int bksz;
+
+   int col;/* current column address */
+   int page;   /* current row address/page index */
+   int cmd;/* current NAND command code */
+   int cmd_hc; /* current FTNANDC021 command code */
+};
+
+static struct nand_ecclayout ftnandc021_ecclayout[] = {
+   { /* page size = 512 (oob size = 16) */
+   .oobfree = {
+   { 9, 3 },
+   }
+   },
+   { /* page size = 2048 (oob size = 64) */
+   .oobfree = {
+   { 9, 3 },
+   },
+   },
+   { /* page size = 4096 (oob size = 128) */
+   .oobfree = {
+   { 9, 7 },
+   },
+   },
+};
+
+static inline int ftnandc021_ckst(struct ftnandc021_chip *priv)
+{
+   struct ftnandc021_regs __iomem *regs = priv->regs;
+   uint32_t st = readl(®s->idr[1]);
+
+   if (st & NAND_STATUS_FAIL)
+   return -EIO;
+
+   if (!(st & NAND_STATUS_READY))
+   return -EBUSY;
+
+   if (!(st & NAND_STATUS_WP))
+ 

Re: [U-Boot] [PATCH v4] nand: add Faraday FTNANDC021 NAND controller support

2013-05-08 Thread Kuo-Jung Su
2013/5/9 Scott Wood :
> On 05/07/2013 01:33:11 AM, Kuo-Jung Su wrote:
>>
>> From: Kuo-Jung Su 
>>
>> Faraday FTNANDC021 is a integrated NAND flash controller.
>> It use a build-in command table to abstract the underlying
>> NAND flash control logic.
>>
>> For example:
>>
>> Issuing a command 0x10 to FTNANDC021 would result in
>> a page write + a read status operation.
>>
>> Signed-off-by: Kuo-Jung Su 
>> CC: Scott Wood 
>
>
> Looks mostly OK, just a couple nits:
>
>
>> diff --git a/README b/README
>> index 0d37d56..883182d 100644
>> --- a/README
>> +++ b/README
>> @@ -3879,6 +3879,10 @@ Low Level (hardware related) configuration options:
>> - drivers/mtd/nand/ndfc.c
>> - drivers/mtd/nand/mxc_nand.c
>>
>> +- CONFIG_SYS_FTNANDC021_TIMING
>> +   Defined to tell the FTNANDC021 controller that the NAND
>> chip is
>> +   using customized timing parameters.
>
>
> This makes it sound like a boolean option, but it's actually an array --
> would be nice to mention what's actually expected.
>
>

Got it, thanks

>> +   if (mtd->writesize >=  4096) {
>

Got it, thanks

>
> Whitespace
>
> -Scott



--
Best wishes,
Kuo-Jung Su
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v4] nand: add Faraday FTNANDC021 NAND controller support

2013-05-08 Thread Scott Wood

On 05/07/2013 01:33:11 AM, Kuo-Jung Su wrote:

From: Kuo-Jung Su 

Faraday FTNANDC021 is a integrated NAND flash controller.
It use a build-in command table to abstract the underlying
NAND flash control logic.

For example:

Issuing a command 0x10 to FTNANDC021 would result in
a page write + a read status operation.

Signed-off-by: Kuo-Jung Su 
CC: Scott Wood 


Looks mostly OK, just a couple nits:


diff --git a/README b/README
index 0d37d56..883182d 100644
--- a/README
+++ b/README
@@ -3879,6 +3879,10 @@ Low Level (hardware related) configuration  
options:

- drivers/mtd/nand/ndfc.c
- drivers/mtd/nand/mxc_nand.c

+- CONFIG_SYS_FTNANDC021_TIMING
+		Defined to tell the FTNANDC021 controller that the NAND  
chip is

+   using customized timing parameters.


This makes it sound like a boolean option, but it's actually an array --
would be nice to mention what's actually expected.


+   if (mtd->writesize >=  4096) {


Whitespace

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


Re: [U-Boot] [Patch v2, batch 2 17/23] powerpc/85xx: add missing QMAN frequency calculation

2013-05-08 Thread Fleming Andy-AFLEMING
Ah, ok, makes sense.

On May 7, 2013, at 18:18, "sun york-R58495"  wrote:

> On 05/07/2013 04:04 PM, Andy Fleming wrote:
>> 
>> 
>> 
>> On Mon, Mar 25, 2013 at 12:33 PM, York Sun > > wrote:
>> 
>>From: Shaohui Xie >>
>> 
>>When CONFIG_SYS_FSL_QORIQ_CHASSIS2 is not defined, QMAN frequency
>>will not
>>be initialized, and QMAN will have a wrong frequency display.
>> 
>>Signed-off-by: Shaohui Xie >>
>>---
>> arch/powerpc/cpu/mpc85xx/speed.c |4 
>> 1 file changed, 4 insertions(+)
>> 
>>diff --git a/arch/powerpc/cpu/mpc85xx/speed.c
>>b/arch/powerpc/cpu/mpc85xx/speed.c
>>index 9fc7b54..f00b1ab 100644
>>--- a/arch/powerpc/cpu/mpc85xx/speed.c
>>+++ b/arch/powerpc/cpu/mpc85xx/speed.c
>>@@ -293,6 +293,10 @@ void get_sys_info (sys_info_t * sysInfo)
>> #endif
>> #endif
>> 
>>+#ifdef CONFIG_SYS_DPAA_QBMAN
>>+   sysInfo->freqQMAN = sysInfo->freqSystemBus / 2;
>>+#endif
>>+
>> 
>> 
>> 
>> Can we just move the original copy of the above lines out of the #ifdef?
>> I don't see any reason to do it the same way in two places.
> You mean delete #ifdef? It will have a compiling error, won't it? See
> include/e500.h, the freqQMAN is withing #ifdef.
> 
> York
> 

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


Re: [U-Boot] [PATCH] powerpc/p1022ds: boot from SD card/SPI flash with SPL

2013-05-08 Thread Scott Wood

On 05/08/2013 05:04:23 AM, ying.zh...@freescale.com wrote:

From: Ying Zhang 

This patch introduces SPL to enable a loader stub that runs in the L2  
SRAM,
after being loaded by the code from the internal on-chip ROM. It  
loads the

final uboot image into DDR, then jump to it to begin execution.

The SPL's size is sizeable, the maximum size must not exceed the size  
of L2
SRAM.It initializes the DDR through SPD code, and copys final uboot  
image to

DDR. So there are two stage uboot images:
* spl_boot, 96KB size. The env variables are copied to offset  
96KB.
in L2 SRAM, so that ddr spd code can get the interleaving  
mode setting

in env. It loads final uboot image from offset 96KB.
* final uboot image, size is variable depends on the functions  
enabled.


Signed-off-by: Ying Zhang 
---


Andy Fleming  is the MMC and mpc85xx maintainer;  
please CC him on these

patches.

This patch needs to be broken into several patches that each take care  
of
one logical problem; it's too hard to properly review (and have the  
right

people pay attention to certain parts) in its current state.

Is this on top of the already-posted P1022DS NAND patch?  If so, please
say so.


diff --git a/README b/README
index 862bb3e..f974bca 100644
--- a/README
+++ b/README
@@ -2887,6 +2887,10 @@ FIT uImage format:
CONFIG_SPL_INIT_MINIMAL
Arch init code should be built for a very small image

+   CONFIG_SPL_INIT_NORMAL
+		This is relative to MINIMAL, this init code contains  
some

+   features that the minimal SPL doesn't contains.


Why do we need a symbol for this?  The only place you use it is already
limited to CONFIG_SPL_BUILD and !CONFIG_SPL_INIT_MINIMAL.

diff --git a/arch/powerpc/cpu/mpc85xx/tlb.c  
b/arch/powerpc/cpu/mpc85xx/tlb.c

index 0dff37f..d21b324 100644
--- a/arch/powerpc/cpu/mpc85xx/tlb.c
+++ b/arch/powerpc/cpu/mpc85xx/tlb.c
@@ -55,7 +55,7 @@ void init_tlbs(void)
return ;
 }

-#if !defined(CONFIG_NAND_SPL) && !defined(CONFIG_SPL_BUILD)
+#if !defined(CONFIG_NAND_SPL) && !defined(CONFIG_SPL_BUILD_MINIMAL)
 void read_tlbcam_entry(int idx, u32 *valid, u32 *tsize, unsigned  
long *epn,

   phys_addr_t *rpn)
 {


Aren't you breaking the existing minimal targets?
CONFIG_SPL_BUILD_MINIMAL does not currently exist, and you add it only
for P1022DS.

diff --git a/arch/powerpc/cpu/mpc85xx/u-boot-spl.lds  
b/arch/powerpc/cpu/mpc85xx/u-boot-spl.lds

index f2b7bff..f1a9ac9 100644
--- a/arch/powerpc/cpu/mpc85xx/u-boot-spl.lds
+++ b/arch/powerpc/cpu/mpc85xx/u-boot-spl.lds
@@ -26,6 +26,13 @@
 #include "config.h"  /* CONFIG_BOARDDIR */

 OUTPUT_ARCH(powerpc)
+#ifdef CONFIG_SYS_MPC85XX_NO_RESETVEC
+PHDRS
+{
+  text PT_LOAD;
+  bss PT_LOAD;
+}
+#endif


Whitespace.


@@ -68,9 +80,21 @@ SECTIONS
 #else
 #error unknown NAND controller
 #endif
+
+#ifndef CONFIG_FSL_IFC
+#ifdef CONFIG_SYS_MPC85XX_NO_RESETVEC
+   .bootpg ADDR(.text) - 0x1000 :
+   {
+   KEEP(*(.bootpg))
+   } :text = 0x
+#endif
+#endif
+
+#ifndef CONFIG_SYS_MPC85XX_NO_RESETVEC
.resetvec ADDR(.text) + RESET_VECTOR_OFFSET : {
KEEP(*(.resetvec))
} = 0x
+#endif


Get rid of the IFC ifdef -- this should apply equally well to IFC.

Can you make the "no resetvec" stuff a separate patch?


@@ -83,5 +107,6 @@ SECTIONS
*(.sbss*)
*(.bss*)
}
+   . = ALIGN(4);
__bss_end = .;
 }


This seems unrelated.

diff --git a/board/freescale/common/sdhc_boot.c  
b/board/freescale/common/sdhc_boot.c

index e432318..96b0680 100644
--- a/board/freescale/common/sdhc_boot.c
+++ b/board/freescale/common/sdhc_boot.c
@@ -24,6 +24,7 @@
 #include 
 #include 

+DECLARE_GLOBAL_DATA_PTR;
 /*
  * The environment variables are written to just after the u-boot  
image
  * on SDCard, so we must read the MBR to get the start address and  
code

@@ -31,6 +32,9 @@
  */
 #define ESDHC_BOOT_IMAGE_SIZE  0x48
 #define ESDHC_BOOT_IMAGE_ADDR  0x50
+#define ESDHC_BOOT_IMAGE_SIGN   0x55AA
+#define ESDHC_BOOT_IMAGE_SIGN_ADDR  0x1FE
+#define CONFIG_CFG_DATA_SECTOR  0

 int mmc_get_env_addr(struct mmc *mmc, u32 *env_addr)
 {
@@ -61,3 +65,122 @@ int mmc_get_env_addr(struct mmc *mmc, u32  
*env_addr)


return 0;
 }
+
+#ifdef CONFIG_SPL_BUILD
+void mmc_get_env(void)
+{
+   /* load environment */
+   struct mmc *mmc;
+   int err;
+   u32 offset;
+   uint blk_start, blk_cnt, ret;
+
+   mmc_initialize(gd->bd);
+   /* We register only one device. So, the dev id is always 0 */
+   mmc = find_mmc_device(0);
+   if (!mmc) {
+   puts("spl: mmc device not found!!\n");
+   hang();
+   }
+   err = mmc_init(mmc);
+   if (err) {
+   puts("spl: mmc init failed!");
+   hang();
+   }
+   if (1 == mmc_get_env_addr(mmc, &offset))
+   puts("spl: mmc get env error!!\n");


Constants go on the right

Re: [U-Boot] [Patch v2, batch 2 15/23] T4/USB: Add USB 2.0 UTMI dual phy support

2013-05-08 Thread Andy Fleming
On Mon, Mar 25, 2013 at 12:33 PM, York Sun  wrote:

> From: Roy Zang 
>
> T4240 internal UTMI phy is different comparing to previous UTMI PHY
> in P3041.
> This patch adds USB 2.0 UTMI Dual PHY new memory map and enable it for
> T4240.
> The phy timing is very sensitive and moving the phy enable code to
> cpu_init.c will not work.
>
> Signed-off-by: Roy Zang 
> ---
>  arch/powerpc/include/asm/config_mpc85xx.h |3 +--
>  arch/powerpc/include/asm/immap_85xx.h |   41
> +
>  drivers/usb/host/ehci-fsl.c   |   21 +++
>  3 files changed, 63 insertions(+), 2 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/config_mpc85xx.h
> b/arch/powerpc/include/asm/config_mpc85xx.h
> index 3740785..ca235dc 100644
> --- a/arch/powerpc/include/asm/config_mpc85xx.h
> +++ b/arch/powerpc/include/asm/config_mpc85xx.h
> @@ -536,8 +536,7 @@
>  #define CONFIG_SYS_FSL_SRIO_MAX_PORTS  2
>  #define CONFIG_SYS_FSL_SRIO_OB_WIN_NUM 9
>  #define CONFIG_SYS_FSL_SRIO_IB_WIN_NUM 5
> -#define CONFIG_SYS_FSL_USB1_PHY_ENABLE
> -#define CONFIG_SYS_FSL_USB2_PHY_ENABLE
> +#define CONFIG_SYS_FSL_USB_DUAL_PHY_ENABLE
>  #define CONFIG_SYS_FSL_USB_INTERNAL_UTMI_PHY
>  #define CONFIG_SYS_FSL_ERRATUM_A004468
>  #define CONFIG_SYS_FSL_ERRATUM_A_004934
> diff --git a/arch/powerpc/include/asm/immap_85xx.h
> b/arch/powerpc/include/asm/immap_85xx.h
> index 8bc047b..29ee38f 100644
> --- a/arch/powerpc/include/asm/immap_85xx.h
> +++ b/arch/powerpc/include/asm/immap_85xx.h
> @@ -2828,12 +2828,53 @@ typedef struct ccsr_pme {
> u8  res4[0x400];
>  } ccsr_pme_t;
>
> +#ifdef CONFIG_SYS_FSL_USB_DUAL_PHY_ENABLE
> +struct ccsr_usb_port_ctrl {
> +   u32 ctrl;
> +   u32 drvvbuscfg;
> +   u32 pwrfltcfg;
> +   u32 sts;
> +   u8  res_14[0xc];
> +   u32 bistcfg;
> +   u32 biststs;
> +   u32 abistcfg;
> +   u32 abiststs;
> +   u8  res_30[0x10];
> +   u32 xcvrprg;
> +   u32 anaprg;
> +   u32 anadrv;
> +   u32 anasts;
> +};
> +
> +struct ccsr_usb_phy {
> +   u32 id;
> +   struct  ccsr_usb_port_ctrl port1;
> +   u8  res_50[0xc];
> +   u32 tvr;
> +   u32 pllprg[4];
> +   u8  res_70[0x4];
> +   u32 anaccfg;
> +   u32 dbg;
> +   u8  res_7c[0x4];
> +   struct  ccsr_usb_port_ctrl port2;
> +   u8  res_dc[0x334];
> +} ccsr_usb_phy_t;
>


I get a build error whenever the code attempts to use ccsr_usb_phy_t. Was
this even build-tested? Am I going to find a later patch that fixes this?
Am I running into a compiler version thing, where it's ok to do struct foo
{ } foo_t, without "typedef" before? My impression is that's just for C++...

I'm going to add "typedef" before this struct, and apply the patch, but
please be more careful.

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


[U-Boot] [PATCH 6/6] am335x_evm: Add support to boot from NOR.

2013-05-08 Thread Tom Rini
From: Steve Kipisz 

NOR requires that s_init be within the first 4KiB of the image so that
we can perform the rest of the required pinmuxing to talk with the rest
of NOR that we are found on.  When NOR_BOOT is set we save our
environment in NOR at 512KiB and a redundant copy at 768KiB.

Signed-off-by: Steve Kipisz 
Signed-off-by: Tom Rini 
---
 arch/arm/cpu/armv7/am33xx/emif4.c |6 +-
 board/ti/am335x/Makefile  |2 +-
 board/ti/am335x/board.c   |   31 ++-
 board/ti/am335x/mux.c |6 +-
 board/ti/am335x/u-boot.lds|  110 +
 boards.cfg|1 +
 include/configs/am335x_evm.h  |   27 -
 7 files changed, 174 insertions(+), 9 deletions(-)
 create mode 100644 board/ti/am335x/u-boot.lds

diff --git a/arch/arm/cpu/armv7/am33xx/emif4.c 
b/arch/arm/cpu/armv7/am33xx/emif4.c
index aa84e96..370230b 100644
--- a/arch/arm/cpu/armv7/am33xx/emif4.c
+++ b/arch/arm/cpu/armv7/am33xx/emif4.c
@@ -43,9 +43,11 @@ void dram_init_banksize(void)
 }
 
 
-#ifdef CONFIG_SPL_BUILD
+#if defined(CONFIG_SPL_BUILD) || defined(CONFIG_NOR_BOOT)
+#ifdef CONFIG_TI81XX
 static struct dmm_lisa_map_regs *hw_lisa_map_regs =
(struct dmm_lisa_map_regs *)DMM_BASE;
+#endif
 static struct vtp_reg *vtpreg[2] = {
(struct vtp_reg *)VTP0_CTRL_ADDR,
(struct vtp_reg *)VTP1_CTRL_ADDR};
@@ -53,6 +55,7 @@ static struct vtp_reg *vtpreg[2] = {
 static struct ddr_ctrl *ddrctrl = (struct ddr_ctrl *)DDR_CTRL_ADDR;
 #endif
 
+#ifdef CONFIG_TI81XX
 void config_dmm(const struct dmm_lisa_map_regs *regs)
 {
enable_dmm_clocks();
@@ -67,6 +70,7 @@ void config_dmm(const struct dmm_lisa_map_regs *regs)
writel(regs->dmm_lisa_map_1, &hw_lisa_map_regs->dmm_lisa_map_1);
writel(regs->dmm_lisa_map_0, &hw_lisa_map_regs->dmm_lisa_map_0);
 }
+#endif
 
 static void config_vtp(int nr)
 {
diff --git a/board/ti/am335x/Makefile b/board/ti/am335x/Makefile
index 67a87a1..1795e3e 100644
--- a/board/ti/am335x/Makefile
+++ b/board/ti/am335x/Makefile
@@ -18,7 +18,7 @@ include $(TOPDIR)/config.mk
 
 LIB= $(obj)lib$(BOARD).o
 
-ifdef CONFIG_SPL_BUILD
+ifeq ($(CONFIG_SPL_BUILD)$(CONFIG_NOR_BOOT),y)
 COBJS  := mux.o
 endif
 
diff --git a/board/ti/am335x/board.c b/board/ti/am335x/board.c
index 6f6b5d0..a0ad4bc 100644
--- a/board/ti/am335x/board.c
+++ b/board/ti/am335x/board.c
@@ -38,7 +38,7 @@
 DECLARE_GLOBAL_DATA_PTR;
 
 static struct wd_timer *wdtimer = (struct wd_timer *)WDT_BASE;
-#ifdef CONFIG_SPL_BUILD
+#if defined(CONFIG_SPL_BUILD) || (CONFIG_NOR_BOOT)
 static struct uart_sys *uart_base = (struct uart_sys *)DEFAULT_UART_BASE;
 #endif
 
@@ -94,7 +94,7 @@ static int read_eeprom(struct am335x_baseboard_id *header)
 }
 
 /* UART Defines */
-#ifdef CONFIG_SPL_BUILD
+#if defined(CONFIG_SPL_BUILD) || defined(CONFIG_NOR_BOOT)
 #define UART_RESET (0x1 << 1)
 #define UART_CLK_RUNNING_MASK  0x1
 #define UART_SMART_IDLE_EN (0x1 << 0x3)
@@ -273,6 +273,24 @@ void s_init(void)
 {
__maybe_unused struct am335x_baseboard_id header;
 
+   /*
+* The ROM will only have set up sufficient pinmux to allow for the
+* first 4KiB NOR to be read, we must finish doing what we know of
+* the NOR mux in this space in order to continue.
+*/
+#ifdef CONFIG_NOR_BOOT
+   asm("stmfd  sp!, {r2 - r4}");
+   asm("movw   r4, #0x8A4");
+   asm("movw   r3, #0x44E1");
+   asm("orrr4, r4, r3, lsl #16");
+   asm("movr2, #9");
+   asm("movr3, #8");
+   asm("gpmc_mux:  str r2, [r4], #4");
+   asm("subs   r3, r3, #1");
+   asm("bnegpmc_mux");
+   asm("ldmfd  sp!, {r2 - r4}");
+#endif
+
/* WDT1 is already running when the bootloader gets control
 * Disable it to avoid "random" resets
 */
@@ -283,7 +301,7 @@ void s_init(void)
while (readl(&wdtimer->wdtwwps) != 0x0)
;
 
-#ifdef CONFIG_SPL_BUILD
+#if defined(CONFIG_SPL_BUILD) || defined(CONFIG_NOR_BOOT)
/* Setup the PLLs and the clocks for the peripherals */
pll_init();
 
@@ -324,9 +342,16 @@ void s_init(void)
regVal |= UART_SMART_IDLE_EN;
writel(regVal, &uart_base->uartsyscfg);
 
+#if defined(CONFIG_NOR_BOOT)
+   /* We want our console now. */
+   gd->baudrate = CONFIG_BAUDRATE;
+   serial_init();
+   gd->have_console = 1;
+#else
gd = &gdata;
 
preloader_console_init();
+#endif
 
/* Initalize the board header */
enable_i2c0_pin_mux();
diff --git a/board/ti/am335x/mux.c b/board/ti/am335x/mux.c
index 187468e..5b7ed63 100644
--- a/board/ti/am335x/mux.c
+++ b/board/ti/am335x/mux.c
@@ -190,7 +190,7 @@ static struct module_pin_mux nand_pin_mux[] = {
{-1},
 };
 
-#if defined(CONFIG_NOR)
+#if defined(CONFIG_NOR) && !defined(CONFIG_NOR_BOOT)
 static struct module_pin_mux bon

[U-Boot] [PATCH 5/6] am335x_evm:Add support for the NOR module on the memory cape

2013-05-08 Thread Tom Rini
From: Steve Kipisz 

This patch adds support for the NOR module that attaches
to the memory cape for a Beaglebone board. This does not
add booting support; only support so that you can boot from
SD/MMC and see the NOR module so that it can be programmed.

Signed-off-by: Steve Kipisz 
[trini: Clean up config changes slightly]
Signed-off-by: Tom Rini 
---
 arch/arm/cpu/armv7/am33xx/mem.c|   30 +-
 arch/arm/include/asm/arch-am33xx/mem.h |9 ++
 board/ti/am335x/mux.c  |   53 
 boards.cfg |1 +
 include/configs/am335x_evm.h   |   28 +
 5 files changed, 120 insertions(+), 1 deletion(-)

diff --git a/arch/arm/cpu/armv7/am33xx/mem.c b/arch/arm/cpu/armv7/am33xx/mem.c
index b86b0de..e46201a 100644
--- a/arch/arm/cpu/armv7/am33xx/mem.c
+++ b/arch/arm/cpu/armv7/am33xx/mem.c
@@ -46,6 +46,19 @@ static const u32 gpmc_m_nand[GPMC_MAX_REG] = {
 };
 #endif
 
+#if defined(CONFIG_CMD_FLASH)
+static const u32 gpmc_nor[GPMC_MAX_REG] = {
+   STNOR_GPMC_CONFIG1,
+   STNOR_GPMC_CONFIG2,
+   STNOR_GPMC_CONFIG3,
+   STNOR_GPMC_CONFIG4,
+   STNOR_GPMC_CONFIG5,
+   STNOR_GPMC_CONFIG6,
+   STNOR_GPMC_CONFIG7
+};
+
+#define GPMC_CS 0
+#endif
 
 void enable_gpmc_cs_config(const u32 *gpmc_config, struct gpmc_cs *cs, u32 
base,
u32 size)
@@ -75,16 +88,22 @@ void gpmc_init(void)
/* putting a blanket check on GPMC based on ZeBu for now */
gpmc_cfg = (struct gpmc *)GPMC_BASE;
 
-#ifdef CONFIG_CMD_NAND
+#if defined(CONFIG_CMD_NAND) || defined(CONFIG_NOR)
const u32 *gpmc_config = NULL;
u32 base = 0;
u32 size = 0;
 #endif
/* global settings */
writel(0x0008, &gpmc_cfg->sysconfig);
+#ifdef CONFIG_NOR
+   writel(0x, &gpmc_cfg->irqstatus);
+   writel(0x, &gpmc_cfg->irqenable);
+   writel(0x0A00, &gpmc_cfg->config);
+#else
writel(0x0100, &gpmc_cfg->irqstatus);
writel(0x0100, &gpmc_cfg->irqenable);
writel(0x0012, &gpmc_cfg->config);
+#endif
/*
 * Disable the GPMC0 config set by ROM code
 */
@@ -98,4 +117,13 @@ void gpmc_init(void)
size = PISMO1_NAND_SIZE;
enable_gpmc_cs_config(gpmc_config, &gpmc_cfg->cs[0], base, size);
 #endif
+
+#ifdef CONFIG_NOR
+   /* NOR - CS0 */
+   gpmc_config = gpmc_nor;
+   base = CONFIG_SYS_FLASH_BASE;
+   size = GPMC_SIZE_16M;
+   enable_gpmc_cs_config(gpmc_config, &gpmc_cfg->cs[0], base, size);
+   writel(0x0a00, 0x5050);
+#endif
 }
diff --git a/arch/arm/include/asm/arch-am33xx/mem.h 
b/arch/arm/include/asm/arch-am33xx/mem.h
index c3bf74e..ddcad62 100644
--- a/arch/arm/include/asm/arch-am33xx/mem.h
+++ b/arch/arm/include/asm/arch-am33xx/mem.h
@@ -61,6 +61,15 @@
 #define M_NAND_GPMC_CONFIG60x16000f80
 #define M_NAND_GPMC_CONFIG70x0008
 
+/* NOR chip on NOR module for Beaglebone */
+#define STNOR_GPMC_CONFIG1 0x1200
+#define STNOR_GPMC_CONFIG2 0x00101000
+#define STNOR_GPMC_CONFIG3 0x00030301
+#define STNOR_GPMC_CONFIG4 0x10041004
+#define STNOR_GPMC_CONFIG5 0x000C1010
+#define STNOR_GPMC_CONFIG6 0x08070280
+#define STNOR_GPMC_CONFIG7 0x0F48
+
 /* max number of GPMC Chip Selects */
 #define GPMC_MAX_CS8
 /* max number of GPMC regs */
diff --git a/board/ti/am335x/mux.c b/board/ti/am335x/mux.c
index 2e09d98..187468e 100644
--- a/board/ti/am335x/mux.c
+++ b/board/ti/am335x/mux.c
@@ -190,6 +190,56 @@ static struct module_pin_mux nand_pin_mux[] = {
{-1},
 };
 
+#if defined(CONFIG_NOR)
+static struct module_pin_mux bone_norcape_pin_mux[] = {
+   {OFFSET(lcd_data0), MODE(1) | PULLUDEN | RXACTIVE}, /* NOR_A0 */
+   {OFFSET(lcd_data1), MODE(1) | PULLUDEN | RXACTIVE}, /* NOR_A1 */
+   {OFFSET(lcd_data2), MODE(1) | PULLUDEN | RXACTIVE}, /* NOR_A2 */
+   {OFFSET(lcd_data3), MODE(1) | PULLUDEN | RXACTIVE}, /* NOR_A3 */
+   {OFFSET(lcd_data4), MODE(1) | PULLUDEN | RXACTIVE}, /* NOR_A4 */
+   {OFFSET(lcd_data5), MODE(1) | PULLUDEN | RXACTIVE}, /* NOR_A5 */
+   {OFFSET(lcd_data6), MODE(1) | PULLUDEN | RXACTIVE}, /* NOR_A6 */
+   {OFFSET(lcd_data7), MODE(1) | PULLUDEN | RXACTIVE}, /* NOR_A7 */
+   {OFFSET(lcd_vsync), MODE(1) | PULLUDEN | RXACTIVE}, /* NOR_A8 */
+   {OFFSET(lcd_hsync), MODE(1) | PULLUDEN | RXACTIVE}, /* NOR_A9 */
+   {OFFSET(lcd_pclk), MODE(1)| PULLUDEN | RXACTIVE},   /* NOR_A10 */
+   {OFFSET(lcd_ac_bias_en), MODE(1)| PULLUDEN | RXACTIVE}, /* NOR_A11 */
+   {OFFSET(lcd_data8), MODE(1) | PULLUDEN | RXACTIVE}, /* NOR_A12 */
+   {OFFSET(lcd_data9), MODE(1) | PULLUDEN | RXACTIVE}, /* NOR_A13 */
+   {OFFSET(lcd_data10), MODE(1) | PULLUDEN | RXACTIVE},/* NOR_A14 */
+   {OFFSET(lcd_data11), MODE(1) | PULLUDEN | RXACTIVE},/* NOR_A15 */
+   {OFFSET(lcd_data12), 

[U-Boot] [PATCH 4/6] am335x_evm: Rework board_is_foo() checks

2013-05-08 Thread Tom Rini
We rework the various board_is_foo() checks to take a pointer to
struct am335x_baseboard_id rather than using a local copy in board.c.
This allows us to make use of the same checks in mux.c as well as fixing
problems when this code could be running from read-only memory.

Signed-off-by: Tom Rini 
---
 board/ti/am335x/board.c |   78 ---
 board/ti/am335x/board.h |   31 +++
 board/ti/am335x/mux.c   |   10 +++---
 3 files changed, 62 insertions(+), 57 deletions(-)

diff --git a/board/ti/am335x/board.c b/board/ti/am335x/board.c
index b371376..6f6b5d0 100644
--- a/board/ti/am335x/board.c
+++ b/board/ti/am335x/board.c
@@ -51,43 +51,10 @@ static struct uart_sys *uart_base = (struct uart_sys 
*)DEFAULT_UART_BASE;
 
 static struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE;
 
-static struct am335x_baseboard_id __attribute__((section (".data"))) header;
-
-static inline int board_is_bone(void)
-{
-   return !strncmp(header.name, "A335BONE", HDR_NAME_LEN);
-}
-
-static inline int board_is_bone_lt(void)
-{
-   return !strncmp(header.name, "A335BNLT", HDR_NAME_LEN);
-}
-
-static inline int board_is_evm_sk(void)
-{
-   return !strncmp("A335X_SK", header.name, HDR_NAME_LEN);
-}
-
-static inline int board_is_idk(void)
-{
-   return !strncmp(header.config, "SKU#02", 6);
-}
-
-static int __maybe_unused board_is_gp_evm(void)
-{
-   return !strncmp("A33515BB", header.name, 8);
-}
-
-int board_is_evm_15_or_later(void)
-{
-   return (!strncmp("A33515BB", header.name, 8) &&
-   strncmp("1.5", header.version, 3) <= 0);
-}
-
 /*
  * Read header information from EEPROM into global structure.
  */
-static int read_eeprom(void)
+static int read_eeprom(struct am335x_baseboard_id *header)
 {
/* Check if baseboard eeprom is available */
if (i2c_probe(CONFIG_SYS_I2C_EEPROM_ADDR)) {
@@ -97,28 +64,28 @@ static int read_eeprom(void)
}
 
/* read the eeprom using i2c */
-   if (i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, 0, 2, (uchar *)&header,
-   sizeof(header))) {
+   if (i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, 0, 2, (uchar *)header,
+   sizeof(struct am335x_baseboard_id))) {
puts("Could not read the EEPROM; something fundamentally"
" wrong on the I2C bus.\n");
return -EIO;
}
 
-   if (header.magic != 0xEE3355AA) {
+   if (header->magic != 0xEE3355AA) {
/*
 * read the eeprom using i2c again,
 * but use only a 1 byte address
 */
-   if (i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, 0, 1,
-   (uchar *)&header, sizeof(header))) {
+   if (i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, 0, 1, (uchar *)header,
+   sizeof(struct am335x_baseboard_id))) {
puts("Could not read the EEPROM; something "
"fundamentally wrong on the I2C bus.\n");
return -EIO;
}
 
-   if (header.magic != 0xEE3355AA) {
+   if (header->magic != 0xEE3355AA) {
printf("Incorrect magic number (0x%x) in EEPROM\n",
-   header.magic);
+   header->magic);
return -EINVAL;
}
}
@@ -304,6 +271,8 @@ static struct emif_regs ddr3_evm_emif_reg_data = {
  */
 void s_init(void)
 {
+   __maybe_unused struct am335x_baseboard_id header;
+
/* WDT1 is already running when the bootloader gets control
 * Disable it to avoid "random" resets
 */
@@ -362,11 +331,11 @@ void s_init(void)
/* Initalize the board header */
enable_i2c0_pin_mux();
i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
-   if (read_eeprom() < 0)
+   if (read_eeprom(&header) < 0)
puts("Could not get board ID.\n");
 
enable_board_pin_mux(&header);
-   if (board_is_evm_sk()) {
+   if (board_is_evm_sk(&header)) {
/*
 * EVM SK 1.2A and later use gpio0_7 to enable DDR3.
 * This is safe enough to do on older revs.
@@ -375,15 +344,15 @@ void s_init(void)
gpio_direction_output(GPIO_DDR_VTT_EN, 1);
}
 
-   if (board_is_evm_sk())
+   if (board_is_evm_sk(&header))
config_ddr(303, MT41J128MJT125_IOCTRL_VALUE, &ddr3_data,
   &ddr3_cmd_ctrl_data, &ddr3_emif_reg_data, 0);
-   else if (board_is_bone_lt())
+   else if (board_is_bone_lt(&header))
config_ddr(400, MT41K256M16HA125E_IOCTRL_VALUE,
   &ddr3_beagleblack_data,
   &ddr3_beagleblack_cmd_ctrl_data,
   &ddr3_b

[U-Boot] [PATCH 2/6] am335x_evm: Add MTDPARTS info for SPI flash

2013-05-08 Thread Tom Rini
Signed-off-by: Tom Rini 
---
 include/configs/am335x_evm.h |7 +++
 1 file changed, 7 insertions(+)

diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h
index 945ec09..004a06a 100644
--- a/include/configs/am335x_evm.h
+++ b/include/configs/am335x_evm.h
@@ -436,6 +436,13 @@
 # define CONFIG_ENV_SPI_MAX_HZ CONFIG_SF_DEFAULT_SPEED
 # define CONFIG_ENV_OFFSET (892 << 10) /* 892 KiB in */
 # define CONFIG_ENV_SECT_SIZE  (4 << 10) /* 4 KB sectors */
+#define CONFIG_CMD_MTDPARTS
+#define MTDIDS_DEFAULT "nor0=physmap-flash.0"
+#define MTDPARTS_DEFAULT   "mtdparts=physmap-flash.0:128k(SPL)," \
+   "128k(SPL.backup1)," \
+   "128k(SPL.backup2)," \
+   "128k(SPL.backup3),384k(u-boot)," \
+   "4k(u-boot-env),3464k(kernel),-(rootfs)"
 #endif /* SPI support */
 
 /* Unsupported features */
-- 
1.7.9.5

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


[U-Boot] [PATCH 3/6] am335x_evm: Only set CONFIG_NAND when !CONFIG_SPI_BOOT

2013-05-08 Thread Tom Rini
Due to hardware design, we can't have NAND present (as we know of NAND
today) when booting from SPI, so disable NAND then as that simplifies
logic.

Signed-off-by: Tom Rini 
---
 include/configs/am335x_evm.h |9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h
index 004a06a..90cc1f5 100644
--- a/include/configs/am335x_evm.h
+++ b/include/configs/am335x_evm.h
@@ -230,7 +230,9 @@
 /* USB Device Firmware Update support */
 #define CONFIG_DFU_FUNCTION
 #define CONFIG_DFU_MMC
+#ifdef CONFIG_NAND
 #define CONFIG_DFU_NAND
+#endif
 #define CONFIG_CMD_DFU
 #define DFU_ALT_INFO_MMC \
"boot part 0 1;" \
@@ -335,6 +337,7 @@
 #define CONFIG_SPL_LDSCRIPT"$(CPUDIR)/am33xx/u-boot-spl.lds"
 
 #define CONFIG_SPL_BOARD_INIT
+#ifdef CONFIG_NAND
 #define CONFIG_SPL_NAND_AM33XX_BCH
 #define CONFIG_SPL_NAND_SUPPORT
 #define CONFIG_SPL_NAND_BASE
@@ -365,6 +368,7 @@
 #defineCONFIG_SYS_NAND_U_BOOT_STARTCONFIG_SYS_TEXT_BASE
 
 #define CONFIG_SYS_NAND_U_BOOT_OFFS0x8
+#endif
 
 /*
  * 1MB into the SDRAM to allow for SPL's bss at the beginning of SDRAM
@@ -466,7 +470,10 @@
 #define CONFIG_PHY_ADDR0
 #define CONFIG_PHY_SMSC
 
+#if !defined(CONFIG_SPI_BOOT)
 #define CONFIG_NAND
+#endif
+
 /* NAND support */
 #ifdef CONFIG_NAND
 #define CONFIG_CMD_NAND
@@ -484,11 +491,9 @@
/* CS0 */
 #define CONFIG_SYS_MAX_NAND_DEVICE 1   /* Max number of NAND
   devices */
-#if !defined(CONFIG_SPI_BOOT)
 #define CONFIG_ENV_IS_IN_NAND
 #define CONFIG_ENV_OFFSET  0x26 /* environment starts here */
 #define CONFIG_SYS_ENV_SECT_SIZE   (128 << 10) /* 128 KiB */
 #endif
-#endif
 
 #endif /* ! __CONFIG_AM335X_EVM_H */
-- 
1.7.9.5

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


[U-Boot] [PATCH 1/6] am335x_evm: Drop useless CONFIG_ENV_IS_NOWHERE

2013-05-08 Thread Tom Rini
We always set a CONFIG_ENV_IS_...somewhere... so drop the initial define
of NOWHERE.

Signed-off-by: Tom Rini 
---
 include/configs/am335x_evm.h |4 
 1 file changed, 4 deletions(-)

diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h
index ef00306..945ec09 100644
--- a/include/configs/am335x_evm.h
+++ b/include/configs/am335x_evm.h
@@ -298,8 +298,6 @@
 #define CONFIG_ENV_OVERWRITE   1
 #define CONFIG_SYS_CONSOLE_INFO_QUIET
 
-#define CONFIG_ENV_IS_NOWHERE
-
 /* Defines for SPL */
 #define CONFIG_SPL
 #define CONFIG_SPL_FRAMEWORK
@@ -434,7 +432,6 @@
  * 0x442000 - 0x80 : Userland
  */
 #if defined(CONFIG_SPI_BOOT)
-# undef CONFIG_ENV_IS_NOWHERE
 # define CONFIG_ENV_IS_IN_SPI_FLASH
 # define CONFIG_ENV_SPI_MAX_HZ CONFIG_SF_DEFAULT_SPEED
 # define CONFIG_ENV_OFFSET (892 << 10) /* 892 KiB in */
@@ -481,7 +478,6 @@
 #define CONFIG_SYS_MAX_NAND_DEVICE 1   /* Max number of NAND
   devices */
 #if !defined(CONFIG_SPI_BOOT)
-#undef CONFIG_ENV_IS_NOWHERE
 #define CONFIG_ENV_IS_IN_NAND
 #define CONFIG_ENV_OFFSET  0x26 /* environment starts here */
 #define CONFIG_SYS_ENV_SECT_SIZE   (128 << 10) /* 128 KiB */
-- 
1.7.9.5

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


[U-Boot] representing multi-socket CPU platform in .dts

2013-05-08 Thread Curt Brune

Hi,

What does u-boot expect to find in the device tree for a system with 
multiple CPU sockets (not multi-core, but multiple physical CPUs) ?


For example if you have a two socket system, with a dual-core CPU per 
socket would there just be 4 nodes in cpus {} with reg = 0, 1, 2, 3 or 
is there a "cpu-socket" node?


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


Re: [U-Boot] [PATCHv2 6/6] RFC: am335x: enable falcon boot mode for mmc (raw and fat) and nand

2013-05-08 Thread Peter Korsgaard
> "Tom" == Tom Rini  writes:

Hi,

 >> This also enables the spl command in the full u-boot so the kernel
 >> parameter area snapshot can be created.
 >> 
 >> Signed-off-by: Peter Korsgaard 

 Tom> You forgot to drop the RFC part :)

Argh, indeed.

 >> +/* nand */
 >> +#define CONFIG_CMD_SPL_NAND_OFS0x24 /* end of 
 >> u-boot */

 Tom> This is fine but please update MTDPARTS_DEFAULT with this change
 Tom> as well (call it u-boot-spl-os).  Thanks!

Ok, I will give it a day or two to see if there's more feedback and then
send a v3 with this fixed.

Thanks for the review.

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


Re: [U-Boot] [PATCHv2 6/6] RFC: am335x: enable falcon boot mode for mmc (raw and fat) and nand

2013-05-08 Thread Tom Rini
On Wed, May 08, 2013 at 09:09:56PM +0200, Peter Korsgaard wrote:

> Jump into full u-boot mode if a 'c' character is received on the uart.
> 
> We need to adjust the spl bss/malloc area to not overlap with the
> loadaddr of the kernel (sdram + 32k), so move it past u-boot instead.
> 
> For raw mmc, we store the kernel parameter area in the free space after
> the MBR (if used). For nand, we use the last sector of the partition
> reserved for u-boot.
> 
> This also enables the spl command in the full u-boot so the kernel
> parameter area snapshot can be created.
> 
> Signed-off-by: Peter Korsgaard 

You forgot to drop the RFC part :)

> +/* nand */
> +#define CONFIG_CMD_SPL_NAND_OFS  0x24 /* end of 
> u-boot */

This is fine but please update MTDPARTS_DEFAULT with this change as
well (call it u-boot-spl-os).  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] [PATCHv2 4/6] spl_mmc: mmc_load_image_raw(): Add sector argument

2013-05-08 Thread Peter Korsgaard
So we can use it for falcon mode as well.

Signed-off-by: Peter Korsgaard 
---
 drivers/mmc/spl_mmc.c |   15 ++-
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/mmc/spl_mmc.c b/drivers/mmc/spl_mmc.c
index d250b40..d710c0d 100644
--- a/drivers/mmc/spl_mmc.c
+++ b/drivers/mmc/spl_mmc.c
@@ -32,7 +32,7 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-static int mmc_load_image_raw(struct mmc *mmc)
+static int mmc_load_image_raw(struct mmc *mmc, unsigned long sector)
 {
unsigned long err;
u32 image_size_sectors;
@@ -42,10 +42,7 @@ static int mmc_load_image_raw(struct mmc *mmc)
sizeof(struct image_header));
 
/* read image header to find the image size & load address */
-   err = mmc->block_dev.block_read(0,
-   CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR, 1,
-   header);
-
+   err = mmc->block_dev.block_read(0, sector, 1, header);
if (err == 0)
goto end;
 
@@ -56,9 +53,8 @@ static int mmc_load_image_raw(struct mmc *mmc)
mmc->read_bl_len;
 
/* Read the header too to avoid extra memcpy */
-   err = mmc->block_dev.block_read(0,
-   CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR,
-   image_size_sectors, (void *)spl_image.load_addr);
+   err = mmc->block_dev.block_read(0, sector, image_size_sectors,
+   (void *)spl_image.load_addr);
 
 end:
if (err == 0)
@@ -134,7 +130,8 @@ void spl_mmc_load_image(void)
boot_mode = spl_boot_mode();
if (boot_mode == MMCSD_MODE_RAW) {
debug("boot mode - RAW\n");
-   err = mmc_load_image_raw(mmc);
+   err = mmc_load_image_raw(mmc,
+
CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR);
 #ifdef CONFIG_SPL_FAT_SUPPORT
} else if (boot_mode == MMCSD_MODE_FAT) {
debug("boot mode - FAT\n");
-- 
1.7.10.4

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


[U-Boot] [PATCHv2 0/6] Falcon boot mode for spl_mmc

2013-05-08 Thread Peter Korsgaard
This patch series adds falcon boot mode for MMC (raw and FAT), similar to
the existing nand support.

As an example, it adds falcon boot support for the am335x evm board, which
is the platform that has been used to test the series.

Changes since V1:
- Adjusted am335x parameters according to Tom Rini's feedback. Added spl
  command for easy kernel parameter area snapshot creation.

Peter Korsgaard (6):
  spl_mmc: return error from mmc_load_image_{raw,fat} rather than
hanging
  spl_mmc: mmc_load_image_fat(): Add filename argument and move fat
init out
  spl_mmc: add Falcon mode support for FAT variant
  spl_mmc: mmc_load_image_raw(): Add sector argument
  spl_mmc: add Falcon mode support for raw variant
  RFC: am335x: enable falcon boot mode for mmc (raw and fat) and nand

 README   |   18 +
 board/ti/am335x/board.c  |9 +
 drivers/mmc/spl_mmc.c|   91 ++
 include/configs/am335x_evm.h |   27 -
 4 files changed, 117 insertions(+), 28 deletions(-)

-- 
1.7.10.4

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


[U-Boot] [PATCHv2 6/6] RFC: am335x: enable falcon boot mode for mmc (raw and fat) and nand

2013-05-08 Thread Peter Korsgaard
Jump into full u-boot mode if a 'c' character is received on the uart.

We need to adjust the spl bss/malloc area to not overlap with the
loadaddr of the kernel (sdram + 32k), so move it past u-boot instead.

For raw mmc, we store the kernel parameter area in the free space after
the MBR (if used). For nand, we use the last sector of the partition
reserved for u-boot.

This also enables the spl command in the full u-boot so the kernel
parameter area snapshot can be created.

Signed-off-by: Peter Korsgaard 
---
 board/ti/am335x/board.c  |9 +
 include/configs/am335x_evm.h |   27 +--
 2 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/board/ti/am335x/board.c b/board/ti/am335x/board.c
index b371376..23fe188 100644
--- a/board/ti/am335x/board.c
+++ b/board/ti/am335x/board.c
@@ -297,6 +297,15 @@ static struct emif_regs ddr3_evm_emif_reg_data = {
.emif_ddr_phy_ctlr_1 = MT41J512M8RH125_EMIF_READ_LATENCY |
PHY_EN_DYN_PWRDN,
 };
+
+#ifdef CONFIG_SPL_OS_BOOT
+int spl_start_uboot(void)
+{
+   /* break into full u-boot on 'c' */
+   return (serial_tstc() && serial_getc() == 'c');
+}
+#endif
+
 #endif
 
 /*
diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h
index ef00306..3b90211 100644
--- a/include/configs/am335x_evm.h
+++ b/include/configs/am335x_evm.h
@@ -307,13 +307,36 @@
 #define CONFIG_SPL_MAX_SIZE(101 * 1024)
 #define CONFIG_SPL_STACK   CONFIG_SYS_INIT_SP_ADDR
 
-#define CONFIG_SPL_BSS_START_ADDR  0x8000
+#define CONFIG_SPL_OS_BOOT
+
+#define CONFIG_SPL_BSS_START_ADDR  0x80a0
 #define CONFIG_SPL_BSS_MAX_SIZE0x8 /* 512 KB */
 
 #define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR0x300 /* address 
0x6 */
 #define CONFIG_SYS_U_BOOT_MAX_SIZE_SECTORS 0x200 /* 256 KB */
 #define CONFIG_SYS_MMC_SD_FAT_BOOT_PARTITION   1
 #define CONFIG_SPL_FAT_LOAD_PAYLOAD_NAME   "u-boot.img"
+
+#ifdef CONFIG_SPL_OS_BOOT
+/* fat */
+#define CONFIG_SPL_FAT_LOAD_KERNEL_NAME"uImage"
+#define CONFIG_SPL_FAT_LOAD_ARGS_NAME  "args"
+#define CONFIG_SYS_SPL_ARGS_ADDR   (PHYS_DRAM_1 + 0x100)
+
+/* raw mmc */
+#define CONFIG_SYS_MMCSD_RAW_MODE_KERNEL_SECTOR0x500 /* address 
0xa */
+#define CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTOR  0x8   /* address 0x1000 */
+#define CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTORS 8 /* 4KB */
+
+/* nand */
+#define CONFIG_CMD_SPL_NAND_OFS0x24 /* end of 
u-boot */
+#define CONFIG_SYS_NAND_SPL_KERNEL_OFFS0x28
+#define CONFIG_CMD_SPL_WRITE_SIZE  0x1000
+
+/* spl export command */
+#define CONFIG_CMD_SPL
+#endif
+
 #define CONFIG_SPL_MMC_SUPPORT
 #define CONFIG_SPL_FAT_SUPPORT
 #define CONFIG_SPL_I2C_SUPPORT
@@ -375,7 +398,7 @@
  * other needs.
  */
 #define CONFIG_SYS_TEXT_BASE   0x8080
-#define CONFIG_SYS_SPL_MALLOC_START0x80208000
+#define CONFIG_SYS_SPL_MALLOC_START0x80a08000
 #define CONFIG_SYS_SPL_MALLOC_SIZE 0x10
 
 /* Since SPL did pll and ddr initialization for us,
-- 
1.7.10.4

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


[U-Boot] [PATCHv2 3/6] spl_mmc: add Falcon mode support for FAT variant

2013-05-08 Thread Peter Korsgaard
If Falcon mode support is enabled (and the system isn't directed into
booting u-boot), it will instead try to load kernel from
CONFIG_SPL_FAT_LOAD_KERNEL_NAME file and kernel argument parameters from
CONFIG_SPL_FAT_LOAD_ARGS_NAME, both from the same partition as u-boot.

Signed-off-by: Peter Korsgaard 
---
 README|8 
 drivers/mmc/spl_mmc.c |   21 +
 2 files changed, 29 insertions(+)

diff --git a/README b/README
index 0d37d56..595c05d 100644
--- a/README
+++ b/README
@@ -2921,6 +2921,14 @@ FIT uImage format:
CONFIG_SPL_FAT_LOAD_PAYLOAD_NAME
Filename to read to load U-Boot when reading from FAT
 
+   CONFIG_SPL_FAT_LOAD_KERNEL_NAME
+   Filename to read to load kernel uImage when reading
+   from FAT (for Falcon mode)
+
+   CONFIG_SPL_FAT_LOAD_ARGS_NAME
+   Filename to read to load kernel argument parameters
+   when reading from FAT (for Falcon mode)
+
CONFIG_SPL_MPC83XX_WAIT_FOR_NAND
Set this for NAND SPL on PPC mpc83xx targets, so that
start.S waits for the rest of the SPL to load before
diff --git a/drivers/mmc/spl_mmc.c b/drivers/mmc/spl_mmc.c
index fac6f2d..d250b40 100644
--- a/drivers/mmc/spl_mmc.c
+++ b/drivers/mmc/spl_mmc.c
@@ -91,6 +91,24 @@ end:
 
return (err <= 0);
 }
+
+#ifdef CONFIG_SPL_OS_BOOT
+static int mmc_load_image_fat_os(struct mmc *mmc)
+{
+   int err;
+
+   err = file_fat_read(CONFIG_SPL_FAT_LOAD_ARGS_NAME,
+   (void *)CONFIG_SYS_SPL_ARGS_ADDR, 0);
+   if (err <= 0) {
+   printf("spl: error reading image %s, err - %d\n",
+  CONFIG_SPL_FAT_LOAD_ARGS_NAME, err);
+   return -1;
+   }
+
+   return mmc_load_image_fat(mmc, CONFIG_SPL_FAT_LOAD_KERNEL_NAME);
+}
+#endif
+
 #endif
 
 void spl_mmc_load_image(void)
@@ -128,6 +146,9 @@ void spl_mmc_load_image(void)
hang();
}
 
+#ifdef CONFIG_SPL_OS_BOOT
+   if (spl_start_uboot() || mmc_load_image_fat_os(mmc))
+#endif
err = mmc_load_image_fat(mmc, CONFIG_SPL_FAT_LOAD_PAYLOAD_NAME);
 #endif
} else {
-- 
1.7.10.4

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


[U-Boot] [PATCHv2 5/6] spl_mmc: add Falcon mode support for raw variant

2013-05-08 Thread Peter Korsgaard
If Falcon mode support is enabled (and the system isn't directed into
booting u-boot), it will instead try to load kernel from sector
CONFIG_SYS_MMCSD_RAW_MODE_KERNEL_SECTOR and
CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTORS of kernel argument parameters
starting from sector CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTOR.

Signed-off-by: Peter Korsgaard 
---
 README|   10 ++
 drivers/mmc/spl_mmc.c |   18 ++
 2 files changed, 28 insertions(+)

diff --git a/README b/README
index 595c05d..3bac95b 100644
--- a/README
+++ b/README
@@ -2915,6 +2915,16 @@ FIT uImage format:
Address, size and partition on the MMC to load U-Boot from
when the MMC is being used in raw mode.
 
+   CONFIG_SYS_MMCSD_RAW_MODE_KERNEL_SECTOR
+   Sector to load kernel uImage from when MMC is being
+   used in raw mode (for Falcon mode)
+
+   CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTOR,
+   CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTORS
+   Sector and number of sectors to load kernel argument
+   parameters from when MMC is being used in raw mode
+   (for falcon mode)
+
CONFIG_SPL_FAT_SUPPORT
Support for fs/fat/libfat.o in SPL binary
 
diff --git a/drivers/mmc/spl_mmc.c b/drivers/mmc/spl_mmc.c
index d710c0d..170fa38 100644
--- a/drivers/mmc/spl_mmc.c
+++ b/drivers/mmc/spl_mmc.c
@@ -63,6 +63,21 @@ end:
return (err == 0);
 }
 
+#ifdef CONFIG_SPL_OS_BOOT
+static int mmc_load_image_raw_os(struct mmc *mmc)
+{
+   if (!mmc->block_dev.block_read(0,
+  CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTOR,
+  CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTORS,
+  (void *)CONFIG_SYS_SPL_ARGS_ADDR)) {
+   printf("mmc args blk read error\n");
+   return -1;
+   }
+
+   return mmc_load_image_raw(mmc, CONFIG_SYS_MMCSD_RAW_MODE_KERNEL_SECTOR);
+}
+#endif
+
 #ifdef CONFIG_SPL_FAT_SUPPORT
 static int mmc_load_image_fat(struct mmc *mmc, const char *filename)
 {
@@ -130,6 +145,9 @@ void spl_mmc_load_image(void)
boot_mode = spl_boot_mode();
if (boot_mode == MMCSD_MODE_RAW) {
debug("boot mode - RAW\n");
+#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);
 #ifdef CONFIG_SPL_FAT_SUPPORT
-- 
1.7.10.4

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


[U-Boot] [PATCHv2 2/6] spl_mmc: mmc_load_image_fat(): Add filename argument and move fat init out

2013-05-08 Thread Peter Korsgaard
So we can use it for falcon mode as well.

Signed-off-by: Peter Korsgaard 
---
 drivers/mmc/spl_mmc.c |   27 +--
 1 file changed, 13 insertions(+), 14 deletions(-)

diff --git a/drivers/mmc/spl_mmc.c b/drivers/mmc/spl_mmc.c
index 0c50657..fac6f2d 100644
--- a/drivers/mmc/spl_mmc.c
+++ b/drivers/mmc/spl_mmc.c
@@ -68,7 +68,7 @@ end:
 }
 
 #ifdef CONFIG_SPL_FAT_SUPPORT
-static int mmc_load_image_fat(struct mmc *mmc)
+static int mmc_load_image_fat(struct mmc *mmc, const char *filename)
 {
int err;
struct image_header *header;
@@ -76,27 +76,18 @@ static int mmc_load_image_fat(struct mmc *mmc)
header = (struct image_header *)(CONFIG_SYS_TEXT_BASE -
sizeof(struct image_header));
 
-   err = fat_register_device(&mmc->block_dev,
-   CONFIG_SYS_MMC_SD_FAT_BOOT_PARTITION);
-   if (err) {
-   printf("spl: fat register err - %d\n", err);
-   hang();
-   }
-
-   err = file_fat_read(CONFIG_SPL_FAT_LOAD_PAYLOAD_NAME,
-   header, sizeof(struct image_header));
+   err = file_fat_read(filename, header, sizeof(struct image_header));
if (err <= 0)
goto end;
 
spl_parse_image_header(header);
 
-   err = file_fat_read(CONFIG_SPL_FAT_LOAD_PAYLOAD_NAME,
-   (u8 *)spl_image.load_addr, 0);
+   err = file_fat_read(filename, (u8 *)spl_image.load_addr, 0);
 
 end:
if (err <= 0)
printf("spl: error reading image %s, err - %d\n",
-   CONFIG_SPL_FAT_LOAD_PAYLOAD_NAME, err);
+  filename, err);
 
return (err <= 0);
 }
@@ -129,7 +120,15 @@ void spl_mmc_load_image(void)
 #ifdef CONFIG_SPL_FAT_SUPPORT
} else if (boot_mode == MMCSD_MODE_FAT) {
debug("boot mode - FAT\n");
-   err = mmc_load_image_fat(mmc);
+
+   err = fat_register_device(&mmc->block_dev,
+ CONFIG_SYS_MMC_SD_FAT_BOOT_PARTITION);
+   if (err) {
+   printf("spl: fat register err - %d\n", err);
+   hang();
+   }
+
+   err = mmc_load_image_fat(mmc, CONFIG_SPL_FAT_LOAD_PAYLOAD_NAME);
 #endif
} else {
puts("spl: wrong MMC boot mode\n");
-- 
1.7.10.4

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


[U-Boot] [PATCHv2 1/6] spl_mmc: return error from mmc_load_image_{raw, fat} rather than hanging

2013-05-08 Thread Peter Korsgaard
So we can instead fallback to doing something else on errors.

Signed-off-by: Peter Korsgaard 
---
 drivers/mmc/spl_mmc.c |   24 ++--
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/drivers/mmc/spl_mmc.c b/drivers/mmc/spl_mmc.c
index 7efdcb8..0c50657 100644
--- a/drivers/mmc/spl_mmc.c
+++ b/drivers/mmc/spl_mmc.c
@@ -32,7 +32,7 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-static void mmc_load_image_raw(struct mmc *mmc)
+static int mmc_load_image_raw(struct mmc *mmc)
 {
unsigned long err;
u32 image_size_sectors;
@@ -61,14 +61,14 @@ static void mmc_load_image_raw(struct mmc *mmc)
image_size_sectors, (void *)spl_image.load_addr);
 
 end:
-   if (err == 0) {
+   if (err == 0)
printf("spl: mmc blk read err - %lu\n", err);
-   hang();
-   }
+
+   return (err == 0);
 }
 
 #ifdef CONFIG_SPL_FAT_SUPPORT
-static void mmc_load_image_fat(struct mmc *mmc)
+static int mmc_load_image_fat(struct mmc *mmc)
 {
int err;
struct image_header *header;
@@ -94,11 +94,11 @@ static void mmc_load_image_fat(struct mmc *mmc)
(u8 *)spl_image.load_addr, 0);
 
 end:
-   if (err <= 0) {
+   if (err <= 0)
printf("spl: error reading image %s, err - %d\n",
CONFIG_SPL_FAT_LOAD_PAYLOAD_NAME, err);
-   hang();
-   }
+
+   return (err <= 0);
 }
 #endif
 
@@ -121,17 +121,21 @@ void spl_mmc_load_image(void)
printf("spl: mmc init failed: err - %d\n", err);
hang();
}
+
boot_mode = spl_boot_mode();
if (boot_mode == MMCSD_MODE_RAW) {
debug("boot mode - RAW\n");
-   mmc_load_image_raw(mmc);
+   err = mmc_load_image_raw(mmc);
 #ifdef CONFIG_SPL_FAT_SUPPORT
} else if (boot_mode == MMCSD_MODE_FAT) {
debug("boot mode - FAT\n");
-   mmc_load_image_fat(mmc);
+   err = mmc_load_image_fat(mmc);
 #endif
} else {
puts("spl: wrong MMC boot mode\n");
hang();
}
+
+   if (err)
+   hang();
 }
-- 
1.7.10.4

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


[U-Boot] [PATCH v3 08/12] powerpc: Use image_setup_linux() instead of local code

2013-05-08 Thread Simon Glass
Rather than having similar code in powerpc, use image_setup_linux() which
should be common across all architectures that use the FDT.

Signed-off-by: Simon Glass 
---
Changes in v3: None
Changes in v2: None

 arch/powerpc/lib/bootm.c | 84 +---
 1 file changed, 1 insertion(+), 83 deletions(-)

diff --git a/arch/powerpc/lib/bootm.c b/arch/powerpc/lib/bootm.c
index 0119a7b..340b545 100644
--- a/arch/powerpc/lib/bootm.c
+++ b/arch/powerpc/lib/bootm.c
@@ -220,101 +220,19 @@ static int boot_bd_t_linux(bootm_headers_t *images)
return ret;
 }
 
-/*
- * Verify the device tree.
- *
- * This function is called after all device tree fix-ups have been enacted,
- * so that the final device tree can be verified.  The definition of "verified"
- * is up to the specific implementation.  However, it generally means that the
- * addresses of some of the devices in the device tree are compared with the
- * actual addresses at which U-Boot has placed them.
- *
- * Returns 1 on success, 0 on failure.  If 0 is returned, U-boot will halt the
- * boot process.
- */
-static int __ft_verify_fdt(void *fdt)
-{
-   return 1;
-}
-__attribute__((weak, alias("__ft_verify_fdt"))) int ft_verify_fdt(void *fdt);
-
 static int boot_body_linux(bootm_headers_t *images)
 {
-   ulong rd_len;
-   struct lmb *lmb = &images->lmb;
-   ulong *initrd_start = &images->initrd_start;
-   ulong *initrd_end = &images->initrd_end;
-#if defined(CONFIG_OF_LIBFDT)
-   ulong of_size = images->ft_len;
-   char **of_flat_tree = &images->ft_addr;
-#endif
-
int ret;
 
-#if defined(CONFIG_OF_LIBFDT)
-   boot_fdt_add_mem_rsv_regions(lmb, *of_flat_tree);
-#endif
-
-   /* allocate space and init command line */
-   ret = boot_cmdline_linux(images);
-   if (ret)
-   return ret;
-
/* allocate space for kernel copy of board info */
ret = boot_bd_t_linux(images);
if (ret)
return ret;
 
-   rd_len = images->rd_end - images->rd_start;
-   ret = boot_ramdisk_high (lmb, images->rd_start, rd_len, initrd_start, 
initrd_end);
-   if (ret)
-   return ret;
-
-#if defined(CONFIG_OF_LIBFDT)
-   ret = boot_relocate_fdt(lmb, of_flat_tree, &of_size);
+   ret = image_setup_linux(images);
if (ret)
return ret;
 
-   /*
-* Add the chosen node if it doesn't exist, add the env and bd_t
-* if the user wants it (the logic is in the subroutines).
-*/
-   if (of_size) {
-   if (fdt_chosen(*of_flat_tree, 1) < 0) {
-   puts ("ERROR: ");
-   puts ("/chosen node create failed");
-   puts (" - must RESET the board to recover.\n");
-   return -1;
-   }
-#ifdef CONFIG_OF_BOARD_SETUP
-   /* Call the board-specific fixup routine */
-   ft_board_setup(*of_flat_tree, gd->bd);
-#endif
-
-   /* Delete the old LMB reservation */
-   lmb_free(lmb, (phys_addr_t)(u32)*of_flat_tree,
-   (phys_size_t)fdt_totalsize(*of_flat_tree));
-
-   ret = fdt_resize(*of_flat_tree);
-   if (ret < 0)
-   return ret;
-   of_size = ret;
-
-   if (*initrd_start && *initrd_end) {
-   of_size += FDT_RAMDISK_OVERHEAD;
-   fdt_set_totalsize(*of_flat_tree, of_size);
-   }
-   /* Create a new LMB reservation */
-   lmb_reserve(lmb, (ulong)*of_flat_tree, of_size);
-
-   /* fixup the initrd now that we know where it should be */
-   if (*initrd_start && *initrd_end)
-   fdt_initrd(*of_flat_tree, *initrd_start, *initrd_end, 
1);
-
-   if (!ft_verify_fdt(*of_flat_tree))
-   return -1;
-   }
-#endif /* CONFIG_OF_LIBFDT */
return 0;
 }
 
-- 
1.8.2.1

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


[U-Boot] [PATCH v3 11/12] buildman: Allow conflicting tags to avoid spurious errors

2013-05-08 Thread Simon Glass
Conflicting tags can prevent buildman from building two series which exist
one after the other in a branch. There is no reason not to allow this sort
of workflow with buildman, so ignore conflicting tags in buildman.

Signed-off-by: Simon Glass 
---
Changes in v3: None
Changes in v2: None

 tools/buildman/control.py | 5 +
 tools/patman/series.py| 4 +++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/tools/buildman/control.py b/tools/buildman/control.py
index 8d7b9b5..1ce8b6f 100644
--- a/tools/buildman/control.py
+++ b/tools/buildman/control.py
@@ -137,6 +137,11 @@ def DoBuildman(options, args):
 upstream_commit = gitutil.GetUpstream(options.git_dir, options.branch)
 series = patchstream.GetMetaDataForList(upstream_commit, options.git_dir,
 1)
+# Conflicting tags are not a problem for buildman, since it does not use
+# then. For example, Series-version is not useful for buildman. On the
+# other hand conflicting tags will cause an error. So allow later tags
+# to overwrite earlier ones.
+series.allow_overwrite = True
 series = patchstream.GetMetaDataForList(range_expr, options.git_dir, None,
 series)
 
diff --git a/tools/patman/series.py b/tools/patman/series.py
index 783b3dd..85ed316 100644
--- a/tools/patman/series.py
+++ b/tools/patman/series.py
@@ -40,6 +40,7 @@ class Series(dict):
 notes: List of lines in the notes
 changes: (dict) List of changes for each version, The key is
 the integer version number
+allow_overwrite: Allow tags to overwrite an existing tag
 """
 def __init__(self):
 self.cc = []
@@ -49,6 +50,7 @@ class Series(dict):
 self.cover = None
 self.notes = []
 self.changes = {}
+self.allow_overwrite = False
 
 # Written in MakeCcFile()
 #  key: name of patch file
@@ -72,7 +74,7 @@ class Series(dict):
 """
 # If we already have it, then add to our list
 name = name.replace('-', '_')
-if name in self:
+if name in self and not self.allow_overwrite:
 values = value.split(',')
 values = [str.strip() for str in values]
 if type(self[name]) != type([]):
-- 
1.8.2.1

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


[U-Boot] [PATCH v3 09/12] m68k: Use image_setup_linux() instead of local code

2013-05-08 Thread Simon Glass
Rather than having similar code in m68k, use image_setup_linux() which
should be common across all architectures that use the FDT.

Signed-off-by: Simon Glass 
---
Changes in v3: None
Changes in v2: None

 arch/m68k/lib/bootm.c | 15 +++
 1 file changed, 3 insertions(+), 12 deletions(-)

diff --git a/arch/m68k/lib/bootm.c b/arch/m68k/lib/bootm.c
index d506d0c..56b6512 100644
--- a/arch/m68k/lib/bootm.c
+++ b/arch/m68k/lib/bootm.c
@@ -78,13 +78,6 @@ int do_bootm_linux(int flag, int argc, char * const argv[], 
bootm_headers_t *ima
if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
return 1;
 
-   /* allocate space and init command line */
-   ret = boot_get_cmdline (lmb, &cmd_start, &cmd_end);
-   if (ret) {
-   puts("ERROR with allocation of cmdline\n");
-   goto error;
-   }
-
/* allocate space for kernel copy of board info */
ret = boot_get_kbd (lmb, &kbd);
if (ret) {
@@ -93,14 +86,12 @@ int do_bootm_linux(int flag, int argc, char * const argv[], 
bootm_headers_t *ima
}
set_clocks_in_mhz(kbd);
 
-   kernel = (void (*)(bd_t *, ulong, ulong, ulong, ulong))images->ep;
-
-   rd_len = images->rd_end - images->rd_start;
-   ret = boot_ramdisk_high (lmb, images->rd_start, rd_len,
-   &initrd_start, &initrd_end);
+   ret = image_setup_linux(images);
if (ret)
goto error;
 
+   kernel = (void (*)(bd_t *, ulong, ulong, ulong, ulong))images->ep;
+
debug("## Transferring control to Linux (at address %08lx) ...\n",
  (ulong) kernel);
 
-- 
1.8.2.1

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


[U-Boot] [PATCH v3 06/12] arm: Refactor bootm to reduce #ifdefs

2013-05-08 Thread Simon Glass
With fewer #ifdefs the code is more readable and more of the code is
compiled for all boards. Add defines in the header file to control
what features are enabled, and then use if() instead of #ifdef.

Signed-off-by: Simon Glass 
---
Changes in v3: None
Changes in v2:
- Fix checkpatch checks about parenthesis alignment

 arch/arm/include/asm/bootm.h  | 54 -
 arch/arm/include/asm/u-boot-arm.h |  2 -
 arch/arm/lib/bootm.c  | 84 ++-
 common/cmd_bootm.c|  2 +-
 4 files changed, 73 insertions(+), 69 deletions(-)

diff --git a/arch/arm/include/asm/bootm.h b/arch/arm/include/asm/bootm.h
index db2ff94..2c4fa19 100644
--- a/arch/arm/include/asm/bootm.h
+++ b/arch/arm/include/asm/bootm.h
@@ -1,4 +1,7 @@
-/* Copyright (C) 2011
+/*
+ * Copyright (c) 2013, Google Inc.
+ *
+ * Copyright (C) 2011
  * Corscience GmbH & Co. KG - Simon Schwarz 
  *
  * This program is free software; you can redistribute it and/or modify
@@ -19,8 +22,55 @@
 #ifndef ARM_BOOTM_H
 #define ARM_BOOTM_H
 
-#ifdef CONFIG_USB_DEVICE
 extern void udc_disconnect(void);
+
+#if defined(CONFIG_SETUP_MEMORY_TAGS) || \
+   defined(CONFIG_CMDLINE_TAG) || \
+   defined(CONFIG_INITRD_TAG) || \
+   defined(CONFIG_SERIAL_TAG) || \
+   defined(CONFIG_REVISION_TAG)
+# define BOOTM_ENABLE_TAGS 1
+#else
+# define BOOTM_ENABLE_TAGS 0
+#endif
+
+#ifdef CONFIG_SETUP_MEMORY_TAGS
+# define BOOTM_ENABLE_MEMORY_TAGS  1
+#else
+# define BOOTM_ENABLE_MEMORY_TAGS  0
+#endif
+
+#ifdef CONFIG_CMDLINE_TAG
+ #define BOOTM_ENABLE_CMDLINE_TAG  1
+#else
+ #define BOOTM_ENABLE_CMDLINE_TAG  0
+#endif
+
+#ifdef CONFIG_INITRD_TAG
+ #define BOOTM_ENABLE_INITRD_TAG   1
+#else
+ #define BOOTM_ENABLE_INITRD_TAG   0
+#endif
+
+#ifdef CONFIG_SERIAL_TAG
+ #define BOOTM_ENABLE_SERIAL_TAG   1
+void get_board_serial(struct tag_serialnr *serialnr);
+#else
+ #define BOOTM_ENABLE_SERIAL_TAG   0
+static inline void get_board_serial(struct tag_serialnr *serialnr)
+{
+}
+#endif
+
+#ifdef CONFIG_REVISION_TAG
+ #define BOOTM_ENABLE_REVISION_TAG 1
+u32 get_board_rev(void);
+#else
+ #define BOOTM_ENABLE_REVISION_TAG 0
+static inline u32 get_board_rev(void)
+{
+   return 0;
+}
 #endif
 
 #endif
diff --git a/arch/arm/include/asm/u-boot-arm.h 
b/arch/arm/include/asm/u-boot-arm.h
index f16861a..c01eef3 100644
--- a/arch/arm/include/asm/u-boot-arm.h
+++ b/arch/arm/include/asm/u-boot-arm.h
@@ -54,8 +54,6 @@ int   arch_early_init_r(void);
 intboard_init(void);
 intdram_init (void);
 void   dram_init_banksize (void);
-void   setup_serial_tag (struct tag **params);
-void   setup_revision_tag (struct tag **params);
 
 /* cpu/.../interrupt.c */
 intarch_interrupt_init (void);
diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c
index f3b30c5..08c11b7 100644
--- a/arch/arm/lib/bootm.c
+++ b/arch/arm/lib/bootm.c
@@ -37,13 +37,7 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#if defined(CONFIG_SETUP_MEMORY_TAGS) || \
-   defined(CONFIG_CMDLINE_TAG) || \
-   defined(CONFIG_INITRD_TAG) || \
-   defined(CONFIG_SERIAL_TAG) || \
-   defined(CONFIG_REVISION_TAG)
 static struct tag *params;
-#endif
 
 static ulong get_sp(void)
 {
@@ -109,11 +103,6 @@ static void announce_and_cleanup(void)
cleanup_before_linux();
 }
 
-#if defined(CONFIG_SETUP_MEMORY_TAGS) || \
-   defined(CONFIG_CMDLINE_TAG) || \
-   defined(CONFIG_INITRD_TAG) || \
-   defined(CONFIG_SERIAL_TAG) || \
-   defined(CONFIG_REVISION_TAG)
 static void setup_start_tag (bd_t *bd)
 {
params = (struct tag *)bd->bi_boot_params;
@@ -127,9 +116,7 @@ static void setup_start_tag (bd_t *bd)
 
params = tag_next (params);
 }
-#endif
 
-#ifdef CONFIG_SETUP_MEMORY_TAGS
 static void setup_memory_tags(bd_t *bd)
 {
int i;
@@ -144,9 +131,7 @@ static void setup_memory_tags(bd_t *bd)
params = tag_next (params);
}
 }
-#endif
 
-#ifdef CONFIG_CMDLINE_TAG
 static void setup_commandline_tag(bd_t *bd, char *commandline)
 {
char *p;
@@ -171,9 +156,7 @@ static void setup_commandline_tag(bd_t *bd, char 
*commandline)
 
params = tag_next (params);
 }
-#endif
 
-#ifdef CONFIG_INITRD_TAG
 static void setup_initrd_tag(bd_t *bd, ulong initrd_start, ulong initrd_end)
 {
/* an ATAG_INITRD node tells the kernel where the compressed
@@ -187,14 +170,11 @@ static void setup_initrd_tag(bd_t *bd, ulong 
initrd_start, ulong initrd_end)
 
params = tag_next (params);
 }
-#endif
 
-#ifdef CONFIG_SERIAL_TAG
-void setup_serial_tag(struct tag **tmp)
+static void setup_serial_tag(struct tag **tmp)
 {
struct tag *params = *tmp;
struct tag_serialnr serialnr;
-   void get_board_serial(struct tag_serialnr *serialnr);
 
get_board_serial(&serialnr);
params->hdr.tag = ATAG_SERIAL;
@@ -204,13 +184,10 @@ void setup_serial_tag(struct tag **tmp)
params 

[U-Boot] [PATCH v3 12/12] buildman: Produce a sensible error message when branch is missing

2013-05-08 Thread Simon Glass
Rather than a backtrace, produce a nice error message when an invalid
branch is provided to buildman.

Signed-off-by: Simon Glass 
---
Changes in v3: None
Changes in v2: None

 tools/buildman/control.py |  4 
 tools/patman/gitutil.py   | 21 +++--
 2 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/tools/buildman/control.py b/tools/buildman/control.py
index 1ce8b6f..85a4a34 100644
--- a/tools/buildman/control.py
+++ b/tools/buildman/control.py
@@ -111,6 +111,10 @@ def DoBuildman(options, args):
 print col.Color(col.RED, str)
 sys.exit(1)
 count = gitutil.CountCommitsInBranch(options.git_dir, options.branch)
+if count is None:
+str = "Branch '%s' not found or has no upstream" % options.branch
+print col.Color(col.RED, str)
+sys.exit(1)
 count += 1   # Build upstream commit also
 
 if not count:
diff --git a/tools/patman/gitutil.py b/tools/patman/gitutil.py
index e31da15..b7f6739 100644
--- a/tools/patman/gitutil.py
+++ b/tools/patman/gitutil.py
@@ -56,10 +56,14 @@ def GetUpstream(git_dir, branch):
 Returns:
 Name of upstream branch (e.g. 'upstream/master') or None if none
 """
-remote = command.OutputOneLine('git', '--git-dir', git_dir, 'config',
-'branch.%s.remote' % branch)
-merge = command.OutputOneLine('git', '--git-dir', git_dir, 'config',
-'branch.%s.merge' % branch)
+try:
+remote = command.OutputOneLine('git', '--git-dir', git_dir, 'config',
+   'branch.%s.remote' % branch)
+merge = command.OutputOneLine('git', '--git-dir', git_dir, 'config',
+  'branch.%s.merge' % branch)
+except:
+return None
+
 if remote == '.':
 return merge
 elif remote and merge:
@@ -78,9 +82,11 @@ def GetRangeInBranch(git_dir, branch, 
include_upstream=False):
 branch: Name of branch
 Return:
 Expression in the form 'upstream..branch' which can be used to
-access the commits.
+access the commits. If the branch does not exist, returns None.
 """
 upstream = GetUpstream(git_dir, branch)
+if not upstream:
+return None
 return '%s%s..%s' % (upstream, '~' if include_upstream else '', branch)
 
 def CountCommitsInBranch(git_dir, branch, include_upstream=False):
@@ -90,9 +96,12 @@ def CountCommitsInBranch(git_dir, branch, 
include_upstream=False):
 git_dir: Directory containing git repo
 branch: Name of branch
 Return:
-Number of patches that exist on top of the branch
+Number of patches that exist on top of the branch, or None if the
+branch does not exist.
 """
 range_expr = GetRangeInBranch(git_dir, branch, include_upstream)
+if not range_expr:
+return None
 pipe = [['git', '--git-dir', git_dir, 'log', '--oneline', '--no-decorate',
  range_expr],
 ['wc', '-l']]
-- 
1.8.2.1

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


[U-Boot] [PATCH v3 05/12] image: Add device tree setup to image library

2013-05-08 Thread Simon Glass
This seems to be a common function for several architectures, so create
a common function rather than duplicating the code in each arch.

Also make an attempt to avoid introducing #ifdefs in the new code, partly
by removing useless #ifdefs around function declarations in the image.h
header.

Signed-off-by: Simon Glass 
---
Changes in v3:
- Adjust indenting of #ifdefs

Changes in v2:
- Fix checkpatch checks about parenthesis alignment

 common/image-fdt.c| 62 +++
 common/image.c| 50 +
 include/common.h  | 10 +
 include/fdt_support.h |  2 --
 include/image.h   | 61 ++
 include/lmb.h |  2 --
 6 files changed, 174 insertions(+), 13 deletions(-)

diff --git a/common/image-fdt.c b/common/image-fdt.c
index 8e8f35c..158c9cf 100644
--- a/common/image-fdt.c
+++ b/common/image-fdt.c
@@ -589,3 +589,65 @@ error:
*of_size = 0;
return 1;
 }
+
+/*
+ * Verify the device tree.
+ *
+ * This function is called after all device tree fix-ups have been enacted,
+ * so that the final device tree can be verified.  The definition of "verified"
+ * is up to the specific implementation.  However, it generally means that the
+ * addresses of some of the devices in the device tree are compared with the
+ * actual addresses at which U-Boot has placed them.
+ *
+ * Returns 1 on success, 0 on failure.  If 0 is returned, U-boot will halt the
+ * boot process.
+ */
+__weak int ft_verify_fdt(void *fdt)
+{
+   return 1;
+}
+
+__weak int arch_fixup_memory_node(void *blob)
+{
+   return 0;
+}
+
+int image_setup_libfdt(bootm_headers_t *images, void *blob,
+  int of_size, struct lmb *lmb)
+{
+   ulong *initrd_start = &images->initrd_start;
+   ulong *initrd_end = &images->initrd_end;
+   int ret;
+
+   if (fdt_chosen(blob, 1) < 0) {
+   puts("ERROR: /chosen node create failed");
+   puts(" - must RESET the board to recover.\n");
+   return -1;
+   }
+   arch_fixup_memory_node(blob);
+   if (IMAAGE_OF_BOARD_SETUP)
+   ft_board_setup(blob, gd->bd);
+   fdt_fixup_ethernet(blob);
+
+   /* Delete the old LMB reservation */
+   lmb_free(lmb, (phys_addr_t)(u32)(uintptr_t)blob,
+(phys_size_t)fdt_totalsize(blob));
+
+   ret = fdt_resize(blob);
+   if (ret < 0)
+   return ret;
+   of_size = ret;
+
+   if (*initrd_start && *initrd_end) {
+   of_size += FDT_RAMDISK_OVERHEAD;
+   fdt_set_totalsize(blob, of_size);
+   }
+   /* Create a new LMB reservation */
+   lmb_reserve(lmb, (ulong)blob, of_size);
+
+   fdt_initrd(blob, *initrd_start, *initrd_end, 1);
+   if (!ft_verify_fdt(blob))
+   return -1;
+
+   return 0;
+}
diff --git a/common/image.c b/common/image.c
index 0792fdc..e91c89e 100644
--- a/common/image.c
+++ b/common/image.c
@@ -70,6 +70,10 @@ static const image_header_t *image_get_ramdisk(ulong 
rd_addr, uint8_t arch,
 
 #include 
 
+#ifndef CONFIG_SYS_BARGSIZE
+#define CONFIG_SYS_BARGSIZE 512
+#endif
+
 static const table_entry_t uimage_arch[] = {
{   IH_ARCH_INVALID,NULL,   "Invalid ARCH", },
{   IH_ARCH_ALPHA,  "alpha","Alpha",},
@@ -1223,4 +1227,50 @@ int boot_get_kbd(struct lmb *lmb, bd_t **kbd)
return 0;
 }
 #endif /* CONFIG_SYS_BOOT_GET_KBD */
+
+#ifdef CONFIG_LMB
+int image_setup_linux(bootm_headers_t *images)
+{
+   ulong of_size = images->ft_len;
+   char **of_flat_tree = &images->ft_addr;
+   ulong *initrd_start = &images->initrd_start;
+   ulong *initrd_end = &images->initrd_end;
+   struct lmb *lmb = &images->lmb;
+   ulong rd_len;
+   int ret;
+
+   if (IMAGE_ENABLE_OF_LIBFDT)
+   boot_fdt_add_mem_rsv_regions(lmb, *of_flat_tree);
+
+   if (IMAGE_BOOT_GET_CMDLINE) {
+   ret = boot_get_cmdline(lmb, &images->cmdline_start,
+   &images->cmdline_end);
+   if (ret) {
+   puts("ERROR with allocation of cmdline\n");
+   return ret;
+   }
+   }
+   if (IMAGE_ENABLE_RAMDISK_HIGH) {
+   rd_len = images->rd_end - images->rd_start;
+   ret = boot_ramdisk_high(lmb, images->rd_start, rd_len,
+   initrd_start, initrd_end);
+   if (ret)
+   return ret;
+   }
+
+   if (IMAGE_ENABLE_OF_LIBFDT) {
+   ret = boot_relocate_fdt(lmb, of_flat_tree, &of_size);
+   if (ret)
+   return ret;
+   }
+
+   if (IMAGE_ENABLE_OF_LIBFDT && of_size) {
+   ret = image_setup_libfdt(images, *of_flat_tree, of_size, lmb);
+   if (ret)
+   return ret;
+   }
+
+

[U-Boot] [PATCH v3 03/12] image: Add CONFIG_FIT_SPL_PRINT to control FIT image printing in SPL

2013-05-08 Thread Simon Glass
This code is very large, and in SPL it isn't always useful to print
out image information (in fact there might not even be a console
active). So disable this feature unless this option is set.

Signed-off-by: Simon Glass 
---
Changes in v3: None
Changes in v2:
- Add new patch to control FIT image printing in SPL
- Fix checkpatch warnings about space after cast

 README |  6 ++
 common/image-fit.c |  8 +---
 include/image.h| 33 +++--
 3 files changed, 42 insertions(+), 5 deletions(-)

diff --git a/README b/README
index 0d37d56..f68a839 100644
--- a/README
+++ b/README
@@ -2996,6 +2996,12 @@ FIT uImage format:
use an arch-specific makefile fragment instead, for
example if more than one image needs to be produced.
 
+   CONFIG_FIT_SPL_PRINT
+   Printing information about a FIT image adds quite a bit of
+   code to SPL. So this is normally disabled in SPL. Use this
+   option to re-enable it. This will affect the output of the
+   bootm command when booting a FIT image.
+
 Modem Support:
 --
 
diff --git a/common/image-fit.c b/common/image-fit.c
index ec7b038..254feec 100644
--- a/common/image-fit.c
+++ b/common/image-fit.c
@@ -124,6 +124,7 @@ static void fit_get_debug(const void *fit, int noffset,
  fdt_strerror(err));
 }
 
+#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_FIT_SPL_PRINT)
 /**
  * fit_print_contents - prints out the contents of the FIT format image
  * @fit: pointer to the FIT format image header
@@ -402,6 +403,7 @@ void fit_image_print(const void *fit, int image_noffset, 
const char *p)
}
}
 }
+#endif
 
 /**
  * fit_get_desc - get node description property
@@ -852,16 +854,16 @@ int fit_set_timestamp(void *fit, int noffset, time_t 
timestamp)
 int calculate_hash(const void *data, int data_len, const char *algo,
uint8_t *value, int *value_len)
 {
-   if (strcmp(algo, "crc32") == 0) {
+   if (IMAGE_ENABLE_CRC32 && strcmp(algo, "crc32") == 0) {
*((uint32_t *)value) = crc32_wd(0, data, data_len,
CHUNKSZ_CRC32);
*((uint32_t *)value) = cpu_to_uimage(*((uint32_t *)value));
*value_len = 4;
-   } else if (strcmp(algo, "sha1") == 0) {
+   } else if (IMAGE_ENABLE_SHA1 && strcmp(algo, "sha1") == 0) {
sha1_csum_wd((unsigned char *)data, data_len,
 (unsigned char *)value, CHUNKSZ_SHA1);
*value_len = 20;
-   } else if (strcmp(algo, "md5") == 0) {
+   } else if (IMAGE_ENABLE_MD5 && strcmp(algo, "md5") == 0) {
md5_wd((unsigned char *)data, data_len, value, CHUNKSZ_MD5);
*value_len = 16;
} else {
diff --git a/include/image.h b/include/image.h
index 27c977e..bfce861 100644
--- a/include/image.h
+++ b/include/image.h
@@ -61,8 +61,37 @@
 #if defined(CONFIG_FIT)
 #include 
 #include 
-#define CONFIG_MD5 /* FIT images need MD5 support */
-#define CONFIG_SHA1/* and SHA1 */
+# ifdef CONFIG_SPL_BUILD
+#  ifdef CONFIG_SPL_CRC32_SUPPORT
+#   define IMAGE_ENABLE_CRC32  1
+#  endif
+#  ifdef CONFIG_SPL_MD5_SUPPORT
+#   define IMAGE_ENABLE_MD51
+#  endif
+#  ifdef CONFIG_SPL_SHA1_SUPPORT
+#   define IMAGE_ENABLE_SHA1   1
+#  endif
+# else
+#  define CONFIG_CRC32 /* FIT images need CRC32 support */
+#  define CONFIG_MD5   /* and MD5 */
+#  define CONFIG_SHA1  /* and SHA1 */
+#  define IMAGE_ENABLE_CRC32   1
+#  define IMAGE_ENABLE_MD5 1
+#  define IMAGE_ENABLE_SHA11
+# endif
+
+#ifndef IMAGE_ENABLE_CRC32
+#define IMAGE_ENABLE_CRC32 0
+#endif
+
+#ifndef IMAGE_ENABLE_MD5
+#define IMAGE_ENABLE_MD5   0
+#endif
+
+#ifndef IMAGE_ENABLE_SHA1
+#define IMAGE_ENABLE_SHA1  0
+#endif
+
 #endif
 
 /*
-- 
1.8.2.1

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


[U-Boot] [PATCH v3 07/12] arm: Use image_setup_linux() instead of local code

2013-05-08 Thread Simon Glass
Use the common FDT setup function that is now available in image. Move
the FDT-specific code to a new bootm-fdt.c and remove unused headers
from bootm.c.

Signed-off-by: Simon Glass 
---
Changes in v3: None
Changes in v2: None

 arch/arm/lib/Makefile|  1 +
 arch/arm/lib/bootm-fdt.c | 52 +++
 arch/arm/lib/bootm.c | 57 +---
 3 files changed, 54 insertions(+), 56 deletions(-)
 create mode 100644 arch/arm/lib/bootm-fdt.c

diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile
index 6ae161a..5b2cb61 100644
--- a/arch/arm/lib/Makefile
+++ b/arch/arm/lib/Makefile
@@ -45,6 +45,7 @@ endif
 COBJS-y += bss.o
 
 COBJS-y+= bootm.o
+COBJS-$(CONFIG_OF_LIBFDT) += bootm-fdt.o
 COBJS-$(CONFIG_SYS_L2_PL310) += cache-pl310.o
 SOBJS-$(CONFIG_USE_ARCH_MEMSET) += memset.o
 SOBJS-$(CONFIG_USE_ARCH_MEMCPY) += memcpy.o
diff --git a/arch/arm/lib/bootm-fdt.c b/arch/arm/lib/bootm-fdt.c
new file mode 100644
index 000..93888f8
--- /dev/null
+++ b/arch/arm/lib/bootm-fdt.c
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2013, Google Inc.
+ *
+ * Copyright (C) 2011
+ * Corscience GmbH & Co. KG - Simon Schwarz 
+ *  - Added prep subcommand support
+ *  - Reorganized source - modeled after powerpc version
+ *
+ * (C) Copyright 2002
+ * Sysgo Real-Time Solutions, GmbH 
+ * Marius Groeger 
+ *
+ * Copyright (C) 2001  Erik Mouw (j.a.k.m...@its.tudelft.nl)
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include 
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
+
+int arch_fixup_memory_node(void *blob)
+{
+   bd_t *bd = gd->bd;
+   int bank;
+   u64 start[CONFIG_NR_DRAM_BANKS];
+   u64 size[CONFIG_NR_DRAM_BANKS];
+
+   for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) {
+   start[bank] = bd->bi_dram[bank].start;
+   size[bank] = bd->bi_dram[bank].size;
+   }
+
+   return fdt_fixup_memory_banks(blob, start, size, CONFIG_NR_DRAM_BANKS);
+}
diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c
index 08c11b7..1b6e0ac 100644
--- a/arch/arm/lib/bootm.c
+++ b/arch/arm/lib/bootm.c
@@ -22,7 +22,6 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
 USA
- *
  */
 
 #include 
@@ -69,23 +68,6 @@ void arch_lmb_reserve(struct lmb *lmb)
gd->bd->bi_dram[0].start + gd->bd->bi_dram[0].size - sp);
 }
 
-#ifdef CONFIG_OF_LIBFDT
-static int fixup_memory_node(void *blob)
-{
-   bd_t*bd = gd->bd;
-   int bank;
-   u64 start[CONFIG_NR_DRAM_BANKS];
-   u64 size[CONFIG_NR_DRAM_BANKS];
-
-   for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) {
-   start[bank] = bd->bi_dram[bank].start;
-   size[bank] = bd->bi_dram[bank].size;
-   }
-
-   return fdt_fixup_memory_banks(blob, start, size, CONFIG_NR_DRAM_BANKS);
-}
-#endif
-
 static void announce_and_cleanup(void)
 {
printf("\nStarting kernel ...\n\n");
@@ -202,43 +184,6 @@ static void setup_end_tag(bd_t *bd)
params->hdr.size = 0;
 }
 
-#ifdef CONFIG_OF_LIBFDT
-static int create_fdt(bootm_headers_t *images)
-{
-   ulong of_size = images->ft_len;
-   char **of_flat_tree = &images->ft_addr;
-   ulong *initrd_start = &images->initrd_start;
-   ulong *initrd_end = &images->initrd_end;
-   struct lmb *lmb = &images->lmb;
-   ulong rd_len;
-   int ret;
-
-   debug("using: FDT\n");
-
-   boot_fdt_add_mem_rsv_regions(lmb, *of_flat_tree);
-
-   rd_len = images->rd_end - images->rd_start;
-   ret = boot_ramdisk_high(lmb, images->rd_start, rd_len,
-   initrd_start, initrd_end);
-   if (ret)
-   return ret;
-
-   ret = boot_relocate_fdt(lmb, of_flat_tree, &of_size);
-   if (ret)
-   return ret;
-
-   fdt_chosen(*of_flat_tree, 1);
-   fixup_memory_node(*of_flat_tree);
-   fdt_fixup_ethernet(*of_flat_tree);
-   fdt_initrd(*of_flat_tree, *initrd_start, *initrd_end, 1);
-#ifdef CONFIG_OF_BOARD_SETUP
-   ft_board_setup(*of_flat_tree, gd->bd);
-#endif
-
-   return 0;

[U-Boot] [PATCH v3 02/12] image: Remove remaining #ifdefs in image-fit.c

2013-05-08 Thread Simon Glass
There are only two left. One is unnecessary and the other can be moved
to the header file.

Signed-off-by: Simon Glass 
---
Changes in v3: None
Changes in v2:
- Add new patch to remove #ifdefs in image-fit.c

 common/image-fit.c | 9 ++---
 common/image.c | 7 +--
 include/image.h| 2 ++
 3 files changed, 5 insertions(+), 13 deletions(-)

diff --git a/common/image-fit.c b/common/image-fit.c
index 9516abf..ec7b038 100644
--- a/common/image-fit.c
+++ b/common/image-fit.c
@@ -149,11 +149,8 @@ void fit_print_contents(const void *fit)
const char *p;
time_t timestamp;
 
-#ifdef USE_HOSTCC
-   p = "";
-#else
-   p = "   ";
-#endif
+   /* Indent string is defined in header image.h */
+   p = IMAGE_INDENT_STRING;
 
/* Root node properties */
ret = fit_get_desc(fit, 0, &desc);
@@ -1463,7 +1460,6 @@ void fit_conf_print(const void *fit, int noffset, const 
char *p)
  * 1, on success
  * 0, on failure
  */
-#ifndef USE_HOSTCC
 int fit_check_ramdisk(const void *fit, int rd_noffset, uint8_t arch,
int verify)
 {
@@ -1492,4 +1488,3 @@ int fit_check_ramdisk(const void *fit, int rd_noffset, 
uint8_t arch,
bootstage_mark(BOOTSTAGE_ID_FIT_RD_CHECK_ALL_OK);
return 1;
 }
-#endif /* USE_HOSTCC */
diff --git a/common/image.c b/common/image.c
index 564ed90..d249758 100644
--- a/common/image.c
+++ b/common/image.c
@@ -296,12 +296,7 @@ void image_print_contents(const void *ptr)
const image_header_t *hdr = (const image_header_t *)ptr;
const char *p;
 
-#ifdef USE_HOSTCC
-   p = "";
-#else
-   p = "   ";
-#endif
-
+   p = IMAGE_INDENT_STRING;
printf("%sImage Name:   %.*s\n", p, IH_NMLEN, image_get_name(hdr));
if (IMAGE_ENABLE_TIMESTAMP) {
printf("%sCreated:  ", p);
diff --git a/include/image.h b/include/image.h
index df020ff..27c977e 100644
--- a/include/image.h
+++ b/include/image.h
@@ -44,6 +44,7 @@
 #define CONFIG_FIT_VERBOSE 1 /* enable fit_format_{error,warning}() */
 
 #define IMAGE_ENABLE_IGNORE0
+#define IMAGE_INDENT_STRING""
 
 #else
 
@@ -53,6 +54,7 @@
 
 /* Take notice of the 'ignore' property for hashes */
 #define IMAGE_ENABLE_IGNORE1
+#define IMAGE_INDENT_STRING"   "
 
 #endif /* USE_HOSTCC */
 
-- 
1.8.2.1

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


[U-Boot] [PATCH v3 10/12] sparc: Use image_setup_linux() instead of local code

2013-05-08 Thread Simon Glass
Sparc only really sets up the ramdisk, but we should still use
image_setup_linux() so that setup is common across all architectures
that use the FDT.

Cover-letter
Introduce a common image_setup_linux() function
This series continues the work to tidy up the image code. Each
architecture has its own code for setting up ready for booting linux.
An attempt is made here to unify these in a single image_setup_linux()
function.

The part of the image code that deals with FDT is split into image-fdt.c
and a few tweaks are added to make FIT images more viable in SPL.
END
Signed-off-by: Simon Glass 
---
Changes in v3:
- Split the image_setup_linux() commits into their own series

Changes in v2: None

 arch/sparc/lib/bootm.c | 17 +++--
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/arch/sparc/lib/bootm.c b/arch/sparc/lib/bootm.c
index bcc6358..1a9343c 100644
--- a/arch/sparc/lib/bootm.c
+++ b/arch/sparc/lib/bootm.c
@@ -95,10 +95,8 @@ void arch_lmb_reserve(struct lmb *lmb)
 int do_bootm_linux(int flag, int argc, char * const argv[], bootm_headers_t * 
images)
 {
char *bootargs;
-   ulong initrd_start, initrd_end;
ulong rd_len;
void (*kernel) (struct linux_romvec *, void *);
-   struct lmb *lmb = &images->lmb;
int ret;
 
if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
@@ -131,24 +129,23 @@ int do_bootm_linux(int flag, int argc, char * const 
argv[], bootm_headers_t * im
 * extracted and is writeable.
 */
 
+   ret = image_setup_linux(images);
+   if (ret) {
+   puts("### Failed to relocate RAM disk\n");
+   goto error;
+   }
+
/* Calc length of RAM disk, if zero no ramdisk available */
rd_len = images->rd_end - images->rd_start;
 
if (rd_len) {
-   ret = boot_ramdisk_high(lmb, images->rd_start, rd_len,
-   &initrd_start, &initrd_end);
-   if (ret) {
-   puts("### Failed to relocate RAM disk\n");
-   goto error;
-   }
-
/* Update SPARC kernel header so that Linux knows
 * what is going on and where to find RAM disk.
 *
 * Set INITRD Image address relative to RAM Start
 */
linux_hdr->hdr_input.ver_0203.sparc_ramdisk_image =
-   initrd_start - CONFIG_SYS_RAM_BASE;
+   images->initrd_start - CONFIG_SYS_RAM_BASE;
linux_hdr->hdr_input.ver_0203.sparc_ramdisk_size = rd_len;
/* Clear READ ONLY flag if set to non-zero */
linux_hdr->hdr_input.ver_0203.root_flags = 1;
-- 
1.8.2.1

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


[U-Boot] [PATCH v3 04/12] image: Split libfdt code into image-fdt.c

2013-05-08 Thread Simon Glass
The image file is still very large, and some of the code is only used when
libfdt is in use. Move this code into a new file.

Signed-off-by: Simon Glass 
---
Changes in v3: None
Changes in v2:
- Fix checkpatch checks about parenthesis alignment
- Fix checkpatch warnings about split strings

 common/Makefile|   1 +
 common/image-fdt.c | 591 +
 common/image.c | 566 --
 3 files changed, 592 insertions(+), 566 deletions(-)
 create mode 100644 common/image-fdt.c

diff --git a/common/Makefile b/common/Makefile
index ea53bed..444d546 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -230,6 +230,7 @@ COBJS-$(CONFIG_BOUNCE_BUFFER) += bouncebuf.o
 COBJS-y += console.o
 COBJS-y += dlmalloc.o
 COBJS-y += image.o
+COBJS-$(CONFIG_OF_LIBFDT) += image-fdt.o
 COBJS-$(CONFIG_FIT) += image-fit.o
 COBJS-y += memsize.o
 COBJS-y += stdio.o
diff --git a/common/image-fdt.c b/common/image-fdt.c
new file mode 100644
index 000..8e8f35c
--- /dev/null
+++ b/common/image-fdt.c
@@ -0,0 +1,591 @@
+/*
+ * Copyright (c) 2013, Google Inc.
+ *
+ * (C) Copyright 2008 Semihalf
+ *
+ * (C) Copyright 2000-2006
+ * Wolfgang Denk, DENX Software Engineering, w...@denx.de.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#ifndef CONFIG_SYS_FDT_PAD
+#define CONFIG_SYS_FDT_PAD 0x3000
+#endif
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static void fdt_error(const char *msg)
+{
+   puts("ERROR: ");
+   puts(msg);
+   puts(" - must RESET the board to recover.\n");
+}
+
+static const image_header_t *image_get_fdt(ulong fdt_addr)
+{
+   const image_header_t *fdt_hdr = map_sysmem(fdt_addr, 0);
+
+   image_print_contents(fdt_hdr);
+
+   puts("   Verifying Checksum ... ");
+   if (!image_check_hcrc(fdt_hdr)) {
+   fdt_error("fdt header checksum invalid");
+   return NULL;
+   }
+
+   if (!image_check_dcrc(fdt_hdr)) {
+   fdt_error("fdt checksum invalid");
+   return NULL;
+   }
+   puts("OK\n");
+
+   if (!image_check_type(fdt_hdr, IH_TYPE_FLATDT)) {
+   fdt_error("uImage is not a fdt");
+   return NULL;
+   }
+   if (image_get_comp(fdt_hdr) != IH_COMP_NONE) {
+   fdt_error("uImage is compressed");
+   return NULL;
+   }
+   if (fdt_check_header((char *)image_get_data(fdt_hdr)) != 0) {
+   fdt_error("uImage data is not a fdt");
+   return NULL;
+   }
+   return fdt_hdr;
+}
+
+/**
+ * boot_fdt_add_mem_rsv_regions - Mark the memreserve sections as unusable
+ * @lmb: pointer to lmb handle, will be used for memory mgmt
+ * @fdt_blob: pointer to fdt blob base address
+ *
+ * Adds the memreserve regions in the dtb to the lmb block.  Adding the
+ * memreserve regions prevents u-boot from using them to store the initrd
+ * or the fdt blob.
+ */
+void boot_fdt_add_mem_rsv_regions(struct lmb *lmb, void *fdt_blob)
+{
+   uint64_t addr, size;
+   int i, total;
+
+   if (fdt_check_header(fdt_blob) != 0)
+   return;
+
+   total = fdt_num_mem_rsv(fdt_blob);
+   for (i = 0; i < total; i++) {
+   if (fdt_get_mem_rsv(fdt_blob, i, &addr, &size) != 0)
+   continue;
+   printf("   reserving fdt memory region: addr=%llx size=%llx\n",
+  (unsigned long long)addr, (unsigned long long)size);
+   lmb_reserve(lmb, addr, size);
+   }
+}
+
+/**
+ * boot_relocate_fdt - relocate flat device tree
+ * @lmb: pointer to lmb handle, will be used for memory mgmt
+ * @of_flat_tree: pointer to a char* variable, will hold fdt start address
+ * @of_size: pointer to a ulong variable, will hold fdt length
+ *
+ * boot_relocate_fdt() allocates a region of memory within the bootmap and
+ * relocates the of_flat_tree into that region, even if the fdt is already in
+ * the bootmap.  It also expands the size of the fdt by CONFIG_SYS_FDT_PAD
+ * bytes.
+ *
+ * of_flat_tree and of_size are set to final (after relocation) values
+ *
+ * returns:
+ *  0 - success
+ *  1 - failure

[U-Boot] [PATCH v3 01/12] mkimage: Put FIT loading in function and tidy error handling

2013-05-08 Thread Simon Glass
The fit_handle_file() function is quite long - split out the part that
loads and checks a FIT into its own function. We will use this
function for storing public keys into a destination FDT file.

The error handling is currently a bit repetitive - tidy it.

Signed-off-by: Simon Glass 
---
Changes in v3: None
Changes in v2:
- Fix spelling of quite
- Add comment about why mkimage needs to open FIT with O_RDWR
- Fix checkpatch checks about parenthesis alignment

 tools/fit_image.c | 96 +--
 1 file changed, 57 insertions(+), 39 deletions(-)

diff --git a/tools/fit_image.c b/tools/fit_image.c
index 8f51159..cc123dd 100644
--- a/tools/fit_image.c
+++ b/tools/fit_image.c
@@ -47,6 +47,48 @@ static int fit_check_image_types (uint8_t type)
return EXIT_FAILURE;
 }
 
+int mmap_fdt(struct mkimage_params *params, const char *fname, void **blobp,
+   struct stat *sbuf)
+{
+   void *ptr;
+   int fd;
+
+   /* Load FIT blob into memory (we need to write hashes/signatures) */
+   fd = open(fname, O_RDWR | O_BINARY);
+
+   if (fd < 0) {
+   fprintf(stderr, "%s: Can't open %s: %s\n",
+   params->cmdname, fname, strerror(errno));
+   unlink(fname);
+   return -1;
+   }
+
+   if (fstat(fd, sbuf) < 0) {
+   fprintf(stderr, "%s: Can't stat %s: %s\n",
+   params->cmdname, fname, strerror(errno));
+   unlink(fname);
+   return -1;
+   }
+
+   ptr = mmap(0, sbuf->st_size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
+   if (ptr == MAP_FAILED) {
+   fprintf(stderr, "%s: Can't read %s: %s\n",
+   params->cmdname, fname, strerror(errno));
+   unlink(fname);
+   return -1;
+   }
+
+   /* check if ptr has a valid blob */
+   if (fdt_check_header(ptr)) {
+   fprintf(stderr, "%s: Invalid FIT blob\n", params->cmdname);
+   unlink(fname);
+   return -1;
+   }
+
+   *blobp = ptr;
+   return fd;
+}
+
 /**
  * fit_handle_file - main FIT file processing function
  *
@@ -65,7 +107,7 @@ static int fit_handle_file (struct mkimage_params *params)
char cmd[MKIMAGE_MAX_DTC_CMDLINE_LEN];
int tfd;
struct stat sbuf;
-   unsigned char *ptr;
+   void *ptr;
 
/* Flattened Image Tree (FIT) format  handling */
debug ("FIT format handling\n");
@@ -87,57 +129,25 @@ static int fit_handle_file (struct mkimage_params *params)
if (system (cmd) == -1) {
fprintf (stderr, "%s: system(%s) failed: %s\n",
params->cmdname, cmd, strerror(errno));
-   unlink (tmpfile);
-   return (EXIT_FAILURE);
-   }
-
-   /* load FIT blob into memory */
-   tfd = open (tmpfile, O_RDWR|O_BINARY);
-
-   if (tfd < 0) {
-   fprintf (stderr, "%s: Can't open %s: %s\n",
-   params->cmdname, tmpfile, strerror(errno));
-   unlink (tmpfile);
-   return (EXIT_FAILURE);
-   }
-
-   if (fstat (tfd, &sbuf) < 0) {
-   fprintf (stderr, "%s: Can't stat %s: %s\n",
-   params->cmdname, tmpfile, strerror(errno));
-   unlink (tmpfile);
-   return (EXIT_FAILURE);
-   }
-
-   ptr = mmap (0, sbuf.st_size, PROT_READ|PROT_WRITE, MAP_SHARED,
-   tfd, 0);
-   if (ptr == MAP_FAILED) {
-   fprintf (stderr, "%s: Can't read %s: %s\n",
-   params->cmdname, tmpfile, strerror(errno));
-   unlink (tmpfile);
-   return (EXIT_FAILURE);
+   goto err_system;
}
 
-   /* check if ptr has a valid blob */
-   if (fdt_check_header (ptr)) {
-   fprintf (stderr, "%s: Invalid FIT blob\n", params->cmdname);
-   unlink (tmpfile);
-   return (EXIT_FAILURE);
-   }
+   tfd = mmap_fdt(params, tmpfile, &ptr, &sbuf);
+   if (tfd < 0)
+   goto err_mmap;
 
/* set hashes for images in the blob */
if (fit_add_verification_data(ptr)) {
fprintf (stderr, "%s Can't add hashes to FIT blob",
params->cmdname);
-   unlink (tmpfile);
-   return (EXIT_FAILURE);
+   goto err_add_hashes;
}
 
/* add a timestamp at offset 0 i.e., root  */
if (fit_set_timestamp (ptr, 0, sbuf.st_mtime)) {
fprintf (stderr, "%s: Can't add image timestamp\n",
params->cmdname);
-   unlink (tmpfile);
-   return (EXIT_FAILURE);
+   goto err_add_timestamp;
}
debug ("Added timestamp successfully\n");
 
@@ -153,6 +163,14 @@ static int fit_handle_file (struct mkimage_pa

Re: [U-Boot] [PATCH V2 0/5] ARM: OMAP: Cleanup save_boot_params function

2013-05-08 Thread Tom Rini
On Wed, May 08, 2013 at 02:50:14PM +0530, Sricharan R wrote:
> Tom,
> 
> On Wednesday 24 April 2013 04:11 PM, Sricharan R wrote:
> > The save_boot_params function does not store the data in a
> > always writable area. So the code is broken for a 'XIP' boot.
> > This series corrects this by storing it in 'gd' and also
> > adds a 'C' equivalent function for the same. The essential cleanups
> > for the same are added in this.
> >
> > Tested this on omap5 uevm board with SD/EMMC boot.
> > omap4/5 boards does not have a XIP flash.
> > So yet to test XIP with this series.
> >
> > Also verfied a MAKEALL for armv7.
> >
> > Sricharan R (5):
> >   ARM: OMAP: Make omap_boot_parameters common across socs
> >   ARM: OMAP4/5: Make OMAPx_SRAM_SCRATCH_ defines common
> >   ARM: OMAP: Correct save_boot_params and replace with 'C' function
> >   ARM: OMAP: Cleanup boot parameters usage
> >   ARM: OMAP: Add arch_cpu_init function
> >
> >  arch/arm/cpu/armv7/lowlevel_init.S |8 +++-
> >  arch/arm/cpu/armv7/omap-common/boot-common.c   |   20 ++--
> >  arch/arm/cpu/armv7/omap-common/hwinit-common.c |   61 
> > +---
> >  arch/arm/cpu/armv7/omap-common/lowlevel_init.S |   50 +--
> >  arch/arm/cpu/armv7/omap4/emif.c|4 +-
> >  arch/arm/cpu/armv7/omap4/hw_data.c |2 +-
> >  arch/arm/cpu/armv7/omap4/hwinit.c  |3 +-
> >  arch/arm/cpu/armv7/omap5/emif.c|4 +-
> >  arch/arm/cpu/armv7/omap5/hw_data.c |2 +-
> >  arch/arm/cpu/armv7/omap5/hwinit.c  |3 +-
> >  arch/arm/include/asm/arch-am33xx/omap.h|   25 --
> >  arch/arm/include/asm/arch-omap4/omap.h |   36 --
> >  arch/arm/include/asm/arch-omap4/sys_proto.h|   11 ++---
> >  arch/arm/include/asm/arch-omap5/omap.h |   36 --
> >  arch/arm/include/asm/arch-omap5/sys_proto.h|   12 ++---
> >  arch/arm/include/asm/global_data.h |8 
> >  arch/arm/include/asm/omap_boot.h   |   50 +++
> >  arch/arm/include/asm/omap_common.h |   19 
> >  common/spl/spl.c   |   12 +++--
> >  include/configs/am335x_evm.h   |4 ++
> >  include/configs/omap4_common.h |4 ++
> >  include/configs/omap5_common.h |3 ++
> >  include/configs/pcm051.h   |4 ++
> >  include/configs/ti814x_evm.h   |4 ++
> >  include/spl.h  |1 -
> >  25 files changed, 187 insertions(+), 199 deletions(-)
> >  create mode 100644 arch/arm/include/asm/omap_boot.h
> >
>  Does this look ok, go to get in ?

With the posted changes to 4 and 5 (for platforms that are new to
u-boot-ti/master), applied, thanks for the reminder!

-- 
Tom


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


Re: [U-Boot] [PATCH V2 5/5] ARM: OMAP: Add arch_cpu_init function

2013-05-08 Thread Tom Rini
On Wed, Apr 24, 2013 at 04:11:25PM +0530, Sricharan R wrote:

> The boot parameters passed from SPL to UBOOT
> must be saved as a part of uboot's gd data
> as early as possible, before we will inadvertently
> overwrite it. So adding a arch_cpu_init for the required
> Socs to save it.
> 
> Signed-off-by: Sricharan R 

With the following change, applied to u-boot-ti/master, thanks!

diff --git a/include/configs/igep0033.h b/include/configs/igep0033.h
index 50eafdf..38a2755 100644
--- a/include/configs/igep0033.h
+++ b/include/configs/igep0033.h
@@ -156,6 +156,9 @@
 #define CONFIG_CONS_INDEX  1
 #define CONFIG_BAUDRATE115200
 
+/* CPU */
+#define CONFIG_ARCH_CPU_INIT
+
 #define CONFIG_ENV_OVERWRITE   1
 #define CONFIG_SYS_CONSOLE_INFO_QUIET
 
-- 
Tom


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


Re: [U-Boot] [PATCH V2 4/5] ARM: OMAP: Cleanup boot parameters usage

2013-05-08 Thread Tom Rini
On Wed, Apr 24, 2013 at 04:11:24PM +0530, Sricharan R wrote:

> The boot parameters are read from individual variables
> assigned for each of them. This been corrected and now
> they are stored as a part of the global data 'gd'
> structure. So read them from 'gd' instead.
> 
> Signed-off-by: Sricharan R 

With the following change, applied to u-boot-ti/master, thanks!

diff --git a/include/configs/igep0033.h b/include/configs/igep0033.h
index 50eafdf..14063a8 100644
--- a/include/configs/igep0033.h
+++ b/include/configs/igep0033.h
@@ -15,6 +15,7 @@
 #define __CONFIG_IGEP0033_H
 
 #define CONFIG_AM33XX
+#define CONFIG_OMAP
 
 #include 
 
-- 
Tom


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


Re: [U-Boot] [PATCH] ARM: cfi_flash: Fix unaligned accesses to cfi_qry structure

2013-05-08 Thread Gabbasov, Andrew
Hi Marek,

> From: Marek Vasut [ma...@denx.de]
> Sent: Wednesday, May 08, 2013 21:26
> To: u-boot@lists.denx.de
> Cc: Gabbasov, Andrew; Tom Rini; Albert Aribaud
> Subject: Re: [U-Boot] [PATCH] ARM: cfi_flash: Fix unaligned accesses to 
> cfi_qry structure
> 
> Dear Andrew Gabbasov,
> 
> > Packed structure cfi_qry contains unaligned 16- and 32-bits members,
> > accessing which causes problems when cfi_flash driver is compiled with
> > -munaligned-access option: flash initialization hangs, probably
> > due to data error.
> >
> > This fix converts 16- and 32-bit members to byte arrays and uses special
> > macros to access such fields. It removes possible unaligned accesses
> > in cfi_flash driver.
> >
> > Signed-off-by: Andrew Gabbasov 
> 
> It seems OK. I just wonder if the le16_to_cpu you removed can have no impact 
> now
> on obscure-endian architectures, that's my only concern.
> 
> Best regards,
> Marek Vasut

Thank you for your feedback.

Using le16_to_cpu macros assumed that the data, read from flash, are always in 
little-endian
order, that is the LSB byte comes first in those 2-bytes unaligned fields. This 
is exactly how
the data is read by new macros. So, it looks like new macros should work on any 
host
endianness.

Thanks.

Best regards,
Andrew

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


Re: [U-Boot] [PATCH] ARM: cfi_flash: Fix unaligned accesses to cfi_qry structure

2013-05-08 Thread Marek Vasut
Dear Andrew Gabbasov,

> Packed structure cfi_qry contains unaligned 16- and 32-bits members,
> accessing which causes problems when cfi_flash driver is compiled with
> -munaligned-access option: flash initialization hangs, probably
> due to data error.
> 
> This fix converts 16- and 32-bit members to byte arrays and uses special
> macros to access such fields. It removes possible unaligned accesses
> in cfi_flash driver.
> 
> Signed-off-by: Andrew Gabbasov 

It seems OK. I just wonder if the le16_to_cpu you removed can have no impact 
now 
on obscure-endian architectures, that's my only concern.

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 0/3] Tegra: USB: EHCI: add Tegra30 compatible support

2013-05-08 Thread Stephen Warren
On 05/03/2013 09:02 AM, Stephen Warren wrote:
> On 04/29/2013 03:21 AM, Jim Lin wrote:
>> Tegra114 USB EHCI is compatible with Tegra30 USB EHCI
>> except:
>> 1. Port Reset - Tegra30 takes 55ms, Tegra114 takes 50 ms to finish.
>> 2. PLL parameters.
>>
>> Jim Lin (3):
>>   ARM: Tegra: FDT: Add USB support for T20/T30/T114
>>   ARM: Tegra: USB: Add driver support for Tegra30/Tegra114
>>   Tegra: Config: Enable Tegra30/Tegra114 USB function
> 
> The series,
> 
> Tested-by: Stephen Warren 
> 
> On both Cardhu (Tegra30) and Dalmore (Tegra114). :-) :-) Now, I can
> netboot with upstream U-Boot on all my boards.

I just noticed one problem with this patch series. If I run the
following commands with Cardhu in its dock, and a USB Ethernet dongle
attached to the dock:

usb start 0
dhcp ${scriptaddr} boot.scr.uimg

... then everything works as expected; the file is downloaded.

However, if I run those same commands with Cardhu either undocked, or
docked but with no USB Ethernet dongle plugged into the dock, then the
dhcp command hangs the system hard; CTRL-C won't interrupt it for example.

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


Re: [U-Boot] [PATCH v2 06/10] powerpc/ppc4xx: Use generic FPGA accessors on all gdsys 405ep/ex boards

2013-05-08 Thread Wolfgang Denk
Dear Dirk,

In message <913a7e8badaaed06605fdf68faace...@gdsys.cc> you wrote:
> 
> thanks for investing so much time into this. It is really appreciated.

Well, just rejecting a patch without being able to give
recommendations _how_ to improve it is not exactly nice.
Sometimes it happens (like due to lack of time and/or better
knowledge), but I try to avoid that.

> > NULL == (struct ihs_fpga *)0
> 
> You are right. This is *exactly* what I meant when I wrote: "We have 
> FPGAs that are memory mapped and others that are not. They must be 
> accessed by the same drivers. So the alternative would be to create FPGA 
> instances at address NULL and getting the register offesets by casting 
> pointers to u16. Not very nice either." on monday.

You don't get what I mean.  There is no guarantee by the C standard
that the "value" of NULL actually resolves to 0; it could be something
else.  So assuming it does is not only ugly, but non-conforming to the
C standard, and thus error prone.

> > What do you think?
> 
> Very nice.
> I think this looks supringsingly similar to my original implementation 
> in the patch series. There we have:

Yes, except that now we still have 1) the full type checking when we
access struct elements in the standard I/O accessors and 2) no need
for casts when using offsets, and 3) no need to assume that NULL == 0.

> Sorry, I'm a little confused here. Is your approach an improvement 
> anyway?

Yes, definitely.  At least I'm convinced of that.

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 main thing is the play itself. I swear that greed for  money  has
nothing  to  do with it, although heaven knows I am sorely in need of
money.   - Feodor Dostoyevsky
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] ARM: cfi_flash: Avoid generation of unaligned accesses

2013-05-08 Thread Gabbasov, Andrew
> From: Gabbasov, Andrew
> Sent: Monday, April 29, 2013 13:40
> To: Marek Vasut; u-boot@lists.denx.de
> Cc: Albert ARIBAUD; Tom Rini
> Subject: RE: [U-Boot] [PATCH] ARM: cfi_flash: Avoid generation of unaligned 
> accesses

[ skipped ]

> Hi Marek,
> 
> Thank you for your response.
> 
> I was thinking about this way of fixing, but it seemed too require too much 
> effort.
> However, after some closer look it turned out to be not quite difficult, since
> there are quite a few accesses to such unaligned fields. So, I made another 
> fix and
> sent to separately to the list with Subject: "[U-Boot][PATCH] ARM: cfi_flash: 
> Fix unaligned
> accesses to cfi_qry structure". Please, look at it, if it is OK from your 
> point of view.
> 
> Thanks.
> 
> Best regards,
> Andrew

Any comments on that new fix?

Thanks.

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


[U-Boot] Mircron MT46* SDRAM support

2013-05-08 Thread Karolis B.
Hello,

Is Micron MT46H128M16LFB7-5IT (
http://www.micron.com/parts/dram/mobile-ddr-sdram/mt46h128m16lfb7-5-it?source=ps)
supported by U-Boot? I am porting U-Boot to the the custom board based on
am335x_evm using U-Boot 2013.01.01 (found in the latest am335x psp) and it
seems that sdram is not working as u-boot.img can not be loaded.
If it is not, could somebody point to the example implementation or at
least mention what should be done to add support for the mentioned part?

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


[U-Boot] Reading uninitialized SDRAM values on OMAP4460 (PandaBoard)

2013-05-08 Thread An Schall
Hi there,

my task is to output the uninitialized SDRAM values over UART during device
startup.

Therefore, I first searched for the code that handles the SDRAM
initialization since I have to put my code in front of it. After digging
through the code and reading some mailing list entries, I guess it takes
place either in:

arch/arm/cpu/armv7/start.S: after line 159 (after CPU was set to SVC3232
mode)

or

arch/arm/cpu/armv7/omap-common/lowlevel_init.S (which is quiet confusing to
me).

I guess it takes place in start.S. If you could confirm this, it would be
very helpful.

Next, I need to configure UART so I can iterate over the SDRAM and put each
single byte on UART.

Do you have any information where I can find info on how to write ASM to
configure UART? ARM helpcenter is way too huge to find info in reasonable
time.

Thanks in advance,
André
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] Patch for RAMBOOT

2013-05-08 Thread Stefan Roese
On 05/08/2013 01:51 PM, sadashiva reddy wrote:
> Hi,
> 
> I am using AMCC PPC440Gx processor and using reference u-boot code of
> taishan board.
> 
> Is there any patch to convert the u-boot code instead of building the boot
> loader for FLASH boot to RAM BOOT.

RAM booting is currently only support for 440EPx. It should not be hard
to port it to 440GX though.

> Because I want to load u-boot directly to SDRAM location instead of loading
> FLASH.
> 
> Why because I want debug my u-boot code.

I already gave you some hints. Adding ramboot support is most likely
even more complex and error prone than debugging and solving the
problems in your "normal" PPC4xx custom board support.

Best regards,
Stefan

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


[U-Boot] bug regarding ext4 filesystem

2013-05-08 Thread ScottyYi
Hi ,

Ext4load command fail to load large file.

 

S3 # ext4load mmc 0:1 0x600 system.img

invalid extent block

** Unable to read file system.img **

S3 # ext4ls mmc 0:1

   4096 .

   4096 ..

1015 boot_script.uimg

4314 data.img

   177477960 system.img

  238604 u-boot-bret.bin

 3260352 uImage

   4096 32.00.12-NAND

 706 .ash_history

   4096 32.00.12-NoneNAND.bak

 

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


Re: [U-Boot] [PATCH v4 1/2] usb: ehci: add Faraday USB 2.0 EHCI support

2013-05-08 Thread Marek Vasut
Dear Kuo-Jung Su,

> 2013/5/8 Marek Vasut :
> > Dear Kuo-Jung Su,
> > 
> > [...]
> > 
> >> >> --- a/common/usb_hub.c
> >> >> +++ b/common/usb_hub.c
> >> >> @@ -419,6 +419,14 @@ static int usb_hub_configure(struct usb_device
> >> >> *dev)
> >> >> 
> >> >>   portstatus = le16_to_cpu(portsts->wPortStatus);
> >> >>   portchange = le16_to_cpu(portsts->wPortChange);
> >> >> 
> >> >> +#ifdef CONFIG_USB_EHCI_FARADAY
> >> >> + /* Faraday EHCI needs a long long delay here */
> >> >> + if (!portchange && !portstatus) {
> >> >> + if (get_timer(start) < 250)
> >> >> + continue;
> >> >> + }
> >> >> +#endif
> >> > 
> >> > I'd say just call a weak function here, in case some other non-EHCI
> >> > compliant controller happened to need this too. btw. does it need to
> >> > be 250 ms or can you poll for readiness somehow ?
> >> 
> >> Got it, thanks. I'll add a weak function later,
> >> and about the 250 ms is actually an estimated value.
> >> The delay time is actually board specific, it looks to me
> >> that it's somehow related to the number of usb host controllers
> >> and the attached usb flash drivers.
> >> 
> >> For example:
> >> 
> >> 1.  A369 - FUSBH200: a usb flash driver attached
> >> 
> >>  A369 - FOTG210: nothing attached
> >> 
> >> => no extra delay required.
> >> 
> >> 2.  A369 - FUSBH200: nothing attached
> >> 
> >>  A369 - FOTG210: a usb flash driver attached
> >> 
> >> => no extra delay required.
> >> 
> >> 3. A369 - FUSBH200: a usb flash driver attached
> >> 
> >> A369 - FOTG210: a usb flash driver attached
> >> 
> >> => The 2nd ehci host requires 200 ms extra delay to detect the attached
> >> device. So I put a 250ms here for safe.
> > 
> > Urgh, isn't it a PHY problem then? Or can this not be solved like
> > board/genesi/mx51_efikamx/efikamx-usb.c board_ehci_hcd_postinit() or such
> > function?
> 
> It looks to me that it's something related to root hub reset.
> And now I've found that adding a extra delay to usb_hub_power_on()
> would help to resolve this issue.
> So I plan to add a new macro constant for it.
> For example:
> 
> 1. Add this to README:
> CONFIG_USB_HUB_MIN_POWER_ON_DELAY defines the minimum
> interval for usb hub power-on delay.(minimum 100msec)
> 
> 2. Update usb_hub.c as bellow:
> static void usb_hub_power_on(struct usb_hub_device *hub)
> {
> ..
> /* Wait at least 100 msec for power to become stable */
> mdelay(max(pgood_delay, USB_HUB_MIN_POWER_ON_DELAY));
> }

Let's try it.

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


[U-Boot] Patch for RAMBOOT

2013-05-08 Thread sadashiva reddy
Hi,

I am using AMCC PPC440Gx processor and using reference u-boot code of
taishan board.

Is there any patch to convert the u-boot code instead of building the boot
loader for FLASH boot to RAM BOOT.

Because I want to load u-boot directly to SDRAM location instead of loading
FLASH.

Why because I want debug my u-boot code.


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


Re: [U-Boot] Pull request: u-boot-nds32

2013-05-08 Thread Tom Rini
On Wed, May 08, 2013 at 12:49:57PM +0800, Macpaul Lin wrote:

> Hi Tom,
> 
> Please pull the following patch from u-boot-nds32 into your tree.
> Thanks!
> 
> The following changes since commit 7e7501f4bb0d550fbc6960e7e2fb2bc84d9795cf:
> 
>   Merge branch 'master' of git://www.denx.de/git/u-boot-mmc
> (2013-05-07 10:09:00 -0400)
> 
> are available in the git repository at:
> 
> 
>   git://git.denx.de/u-boot-nds32.git master
> 
> for you to fetch changes up to fe8e4dbad1d31c452af3fbabba21e72b210381b3:
> 
>   nds32: Use sections header to obtain link symbols (2013-05-08 12:38:10 
> +0800)
> 
> 
> Kuan-Yu Kuo (1):
>   nds32: Use sections header to obtain link symbols
> 
>  arch/nds32/include/asm/u-boot-nds32.h | 5 -
>  arch/nds32/lib/board.c| 3 ++-
>  2 files changed, 2 insertions(+), 6 deletions(-)

Applied to u-boot/master, thanks!

-- 
Tom


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


[U-Boot] [PATCH] powerpc/p1022ds: boot from SD card/SPI flash with SPL

2013-05-08 Thread ying.zhang
From: Ying Zhang 

This patch introduces SPL to enable a loader stub that runs in the L2 SRAM,
after being loaded by the code from the internal on-chip ROM. It loads the
final uboot image into DDR, then jump to it to begin execution.

The SPL's size is sizeable, the maximum size must not exceed the size of L2
SRAM.It initializes the DDR through SPD code, and copys final uboot image to
DDR. So there are two stage uboot images:
* spl_boot, 96KB size. The env variables are copied to offset 96KB.
in L2 SRAM, so that ddr spd code can get the interleaving mode setting
in env. It loads final uboot image from offset 96KB.
* final uboot image, size is variable depends on the functions enabled.

Signed-off-by: Ying Zhang 
---
 README  |   24 +
 arch/powerpc/cpu/mpc85xx/tlb.c  |2 +-
 arch/powerpc/cpu/mpc85xx/u-boot-spl.lds |   25 +
 arch/powerpc/cpu/mpc85xx/u-boot.lds |8 ++
 arch/powerpc/cpu/mpc8xxx/law.c  |4 +-
 board/freescale/common/Makefile |5 +-
 board/freescale/common/sdhc_boot.c  |  123 +
 board/freescale/common/sdhc_boot.h  |   29 ++
 board/freescale/common/spi_boot.c   |   96 
 board/freescale/common/spi_boot.h   |   26 ++
 board/freescale/p1022ds/Makefile|3 +
 board/freescale/p1022ds/spl.c   |  148 +++
 board/freescale/p1022ds/tlb.c   |9 ++-
 common/Makefile |5 +
 doc/README.mpc85xx-sd-spi-boot  |   82 +
 include/configs/P1022DS.h   |  116 
 lib/Makefile|5 +
 spl/Makefile|3 +
 18 files changed, 688 insertions(+), 25 deletions(-)
 create mode 100644 board/freescale/common/sdhc_boot.h
 create mode 100644 board/freescale/common/spi_boot.c
 create mode 100644 board/freescale/common/spi_boot.h
 create mode 100644 board/freescale/p1022ds/spl.c
 create mode 100644 doc/README.mpc85xx-sd-spi-boot

diff --git a/README b/README
index 862bb3e..f974bca 100644
--- a/README
+++ b/README
@@ -2887,6 +2887,10 @@ FIT uImage format:
CONFIG_SPL_INIT_MINIMAL
Arch init code should be built for a very small image
 
+   CONFIG_SPL_INIT_NORMAL
+   This is relative to MINIMAL, this init code contains some
+   features that the minimal SPL doesn't contains.
+
CONFIG_SPL_LIBCOMMON_SUPPORT
Support for common/libcommon.o in SPL binary
 
@@ -2977,6 +2981,21 @@ FIT uImage format:
CONFIG_SPL_LIBGENERIC_SUPPORT
Support for lib/libgeneric.o in SPL binary
 
+   CONFIG_SPL_INIT_DDR_SUPPORT
+   Support for common DDR init in SPL binary
+
+   CONFIG_SPL_HWCONFIG_SUPPORT
+   Support for configuring hardware via environment in SPL binary
+
+   CONFIG_SPL_ENV_SUPPORT
+   Support for the environment operating in SPL binary
+
+   CONFIG_SPL_ADDR_MAP_SUPPORT
+   Support for mutual transformation between virtual addr to CPU 
bus addr
+
+   CONFIG_SPL_UTILITYLIB_SUPPORT
+   Support for some common tools in SPL binary, such as: hashtable
+
CONFIG_SPL_PAD_TO
Image offset to which the SPL should be padded before appending
the SPL payload. By default, this is defined as
@@ -3965,6 +3984,11 @@ Low Level (hardware related) configuration options:
that is executed before the actual U-Boot. E.g. when
compiling a NAND SPL.
 
+- CONFIG_SYS_MPC85XX_NO_RESETVEC
+   Only for 85xx systems. If this variable is specified, the 
section
+   .resetvec is not kept and the section .bootpg is placed in the
+   previous 4k of the .text section.
+
 - CONFIG_ARCH_MAP_SYSMEM
Generally U-Boot (and in particular the md command) uses
effective address. It is therefore not necessary to regard
diff --git a/arch/powerpc/cpu/mpc85xx/tlb.c b/arch/powerpc/cpu/mpc85xx/tlb.c
index 0dff37f..d21b324 100644
--- a/arch/powerpc/cpu/mpc85xx/tlb.c
+++ b/arch/powerpc/cpu/mpc85xx/tlb.c
@@ -55,7 +55,7 @@ void init_tlbs(void)
return ;
 }
 
-#if !defined(CONFIG_NAND_SPL) && !defined(CONFIG_SPL_BUILD)
+#if !defined(CONFIG_NAND_SPL) && !defined(CONFIG_SPL_BUILD_MINIMAL)
 void read_tlbcam_entry(int idx, u32 *valid, u32 *tsize, unsigned long *epn,
   phys_addr_t *rpn)
 {
diff --git a/arch/powerpc/cpu/mpc85xx/u-boot-spl.lds 
b/arch/powerpc/cpu/mpc85xx/u-boot-spl.lds
index f2b7bff..f1a9ac9 100644
--- a/arch/powerpc/cpu/mpc85xx/u-boot-spl.lds
+++ b/arch/powerpc/cpu/mpc85xx/u-boot-spl.lds
@@ -26,6 +26,13 @@
 #include "config.h"/* CONFIG_BOARDDIR */
 
 OUTPUT_ARCH(powerpc)
+#ifdef CONFIG_SYS_MPC85XX_NO_RESET

Re: [U-Boot] [PATCH 1/3] net: macb: using AT91FAMILY replace #ifdeferry

2013-05-08 Thread Andreas Bießmann
On 04/24/2013 09:59 AM, Bo Shen wrote:
> Using CONFIG_AT91FAMILY replace #ifdeferry for atmel SoC
> 
> Signed-off-by: Bo Shen 

Acked-by: Andreas Bießmann 

> ---
>  drivers/net/macb.c |   10 ++
>  1 file changed, 2 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/net/macb.c b/drivers/net/macb.c
> index 8bacbda..753fb96 100644
> --- a/drivers/net/macb.c
> +++ b/drivers/net/macb.c
> @@ -466,19 +466,13 @@ static int macb_init(struct eth_device *netdev, bd_t 
> *bd)
>  
>   /* choose RMII or MII mode. This depends on the board */
>  #ifdef CONFIG_RMII
> -#if  defined(CONFIG_AT91CAP9) || defined(CONFIG_AT91SAM9260) || \
> - defined(CONFIG_AT91SAM9263) || defined(CONFIG_AT91SAM9G20) || \
> - defined(CONFIG_AT91SAM9G45) || defined(CONFIG_AT91SAM9M10G45) || \
> - defined(CONFIG_AT91SAM9XE) || defined(CONFIG_AT91SAM9X5)
> +#ifdef CONFIG_AT91FAMILY
>   macb_writel(macb, USRIO, MACB_BIT(RMII) | MACB_BIT(CLKEN));
>  #else
>   macb_writel(macb, USRIO, 0);
>  #endif
>  #else
> -#if  defined(CONFIG_AT91CAP9) || defined(CONFIG_AT91SAM9260) || \
> - defined(CONFIG_AT91SAM9263) || defined(CONFIG_AT91SAM9G20) || \
> - defined(CONFIG_AT91SAM9G45) || defined(CONFIG_AT91SAM9M10G45) || \
> - defined(CONFIG_AT91SAM9XE) || defined(CONFIG_AT91SAM9X5)
> +#ifdef CONFIG_AT91FAMILY
>   macb_writel(macb, USRIO, MACB_BIT(CLKEN));
>  #else
>   macb_writel(macb, USRIO, MACB_BIT(MII));
> 

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


Re: [U-Boot] [PATCH v2 06/10] powerpc/ppc4xx: Use generic FPGA accessors on all gdsys 405ep/ex boards

2013-05-08 Thread Dirk Eibach

Hi Wolfgang,

thanks for investing so much time into this. It is really appreciated.

Am 08.05.2013 12:13, schrieb Wolfgang Denk:

Dear Dirk,

In message <58ff5023adcbf08481bc2707b0a70...@gdsys.cc> you wrote:


in my example we have four FPGAs. One is memory mapped while the 
other

three are not.
They all have the same register interface which is mapped by
   struct ihs_fpga {
u16 reflection_low;
u16 versions;
...
u16 mc_tx_address;
u16 mc_tx_data;
u16 mc_tx_cmd;
...
   };

To have instances of those FPGA structs, we might create an array 
like

this:
   struct ihs_fpga system_fpgas[] = {
(struct ihs_fpga *)CONFIG_SYS_FPGA_BASE,
(struct ihs_fpga *)NULL,
(struct ihs_fpga *)NULL,
(struct ihs_fpga *)NULL,
   };
The first element ist our memory mapped FPGA with base address
CONFIG_SYS_FPGA_BASE. For the other three I use NULL as base address
because I don't have any better idea what else to choose.

To probe those FPGAs we might have to do something like:
   for (k=0; k < 4; ++k)
fpga_set_reg(k, &system_fpgas[k].reflection_low,


I think using index notation everywhere makes the code hard to read.
Use a pointer, for example like that:

struct ihs_fpga *fpgap = system_fpgas[k];

fpga_set_reg(k, &fpgap->reflection_low, ...


The implementation of fpga_set_reg() might look like:

void fpga_set_reg(unsigned int fpga, u16 *reg, u16 data)
{
switch (fpga) {
case 0:
out_le16(reg, data);
break;
default:
mclink_send(fpga - 1, (u16)reg, data);
break;
}
}


The problem here comes from your decision to use the same interface
for two different, incompatible things.  There are two ugly parts in
this code:  first is the need for a cast, second (and even worse) is
the use of a pointer value of 0 to get to the offset of a field.
Actually this is not even standard conformng, as you initialize the
pointer as NULL, and there is no real guarantee that

NULL == (struct ihs_fpga *)0


You are right. This is *exactly* what I meant when I wrote: "We have 
FPGAs that are memory mapped and others that are not. They must be 
accessed by the same drivers. So the alternative would be to create FPGA 
instances at address NULL and getting the register offesets by casting 
pointers to u16. Not very nice either." on monday.




It appears you need both the element address and the offset in your
fpga_set_reg() code, so you should pass this information, like that
[note that we no longer need an array of addresses]:

struct ihs_fpga fpga_ptr = (struct ihs_fpga *)CONFIG_SYS_FPGA_BASE;
...

void fpga_set_reg(u32 fpga, u16 *reg, off_t regoff, u16 data)
{
if (fpga)
return mclink_send(fpga - 1, regoff, data);

return out_le16(reg, data);
}


where mclink_send() is the routine to access the non memory mapped
FPGAs through the memory mapped FPGA:
   int mclink_send(u8 slave, u16 addr, u16 data)
   {
...
fpga_set_reg(0, &system_fpgas[0].mc_tx_address, addr);
fpga_set_reg(0, &system_fpgas[0].mc_tx_data, data);
fpga_set_reg(0, &system_fpgas[0].mc_tx_cmd, (slave & 0x03) << 14);
   }


And this becomes:

fpga_set_reg(0,
 &fpga_ptr->mc_tx_address,
 offsetof(struct ihs_fpga, mc_tx_address),
 addr);

etc. Yes, this is long and ugly to write, so you may want to define a
helper macro like:

#define FPGA_SET_REG(ix,fld,val)\
fpga_set_reg((ix),  \
&fpga_ptr->fld,  \
offsetof(struct ihs_fpga, fld), \
val)

so this turns into a plain and simple

FPGA_SET_REG(0, mc_tx_address, addr);
FPGA_SET_REG(0, mc_tx_data, data);
FPGA_SET_REG(0, mc_tx_cmd, (slave & 0x03) << 14);


What do you think?


Very nice.
I think this looks supringsingly similar to my original implementation 
in the patch series. There we have:

  #define REG(reg) offsetof(struct ihs_fpga, reg)
and
  fpga_set_reg(k, REG(reflection_low), REFLECTION_TESTPATTERN);
and
  void fpga_set_reg(unsigned int fpga, u16 reg, u16 data)
  {
int res;
struct ihs_fpga *fpga_0 = (struct ihs_fpga *)CONFIG_SYS_FPGA_BASE(0);

switch (fpga) {
case 0:
out_le16((u16 *)fpga_0 + reg / sizeof(u16), data);
break;
default:
res = mclink_send(fpga - 1, reg, data);
if (res < 0)
printf("mclink_send reg %02x data %04x returned %d\n",
   reg, data, res);
break;
}
  }

Sorry, I'm a little confused here. Is your approach an improvement 
anyway?


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


Re: [U-Boot] [PATCH v2 06/10] powerpc/ppc4xx: Use generic FPGA accessors on all gdsys 405ep/ex boards

2013-05-08 Thread Wolfgang Denk
Dear Dirk,

In message <58ff5023adcbf08481bc2707b0a70...@gdsys.cc> you wrote:
> 
> in my example we have four FPGAs. One is memory mapped while the other 
> three are not.
> They all have the same register interface which is mapped by
>struct ihs_fpga {
>   u16 reflection_low;
>   u16 versions;
>   ...
>   u16 mc_tx_address;
>   u16 mc_tx_data;
>   u16 mc_tx_cmd;
>   ...
>};
> 
> To have instances of those FPGA structs, we might create an array like 
> this:
>struct ihs_fpga system_fpgas[] = {
>   (struct ihs_fpga *)CONFIG_SYS_FPGA_BASE,
>   (struct ihs_fpga *)NULL,
>   (struct ihs_fpga *)NULL,
>   (struct ihs_fpga *)NULL,
>};
> The first element ist our memory mapped FPGA with base address 
> CONFIG_SYS_FPGA_BASE. For the other three I use NULL as base address 
> because I don't have any better idea what else to choose.
> 
> To probe those FPGAs we might have to do something like:
>for (k=0; k < 4; ++k)
>   fpga_set_reg(k, &system_fpgas[k].reflection_low, 

I think using index notation everywhere makes the code hard to read.
Use a pointer, for example like that:

struct ihs_fpga *fpgap = system_fpgas[k];

fpga_set_reg(k, &fpgap->reflection_low, ...

> The implementation of fpga_set_reg() might look like:
> 
> void fpga_set_reg(unsigned int fpga, u16 *reg, u16 data)
> {
>   switch (fpga) {
>   case 0:
>   out_le16(reg, data);
>   break;
>   default:
>   mclink_send(fpga - 1, (u16)reg, data);
>   break;
>   }
> }

The problem here comes from your decision to use the same interface
for two different, incompatible things.  There are two ugly parts in
this code:  first is the need for a cast, second (and even worse) is
the use of a pointer value of 0 to get to the offset of a field.
Actually this is not even standard conformng, as you initialize the
pointer as NULL, and there is no real guarantee that

NULL == (struct ihs_fpga *)0

It appears you need both the element address and the offset in your
fpga_set_reg() code, so you should pass this information, like that
[note that we no longer need an array of addresses]:

struct ihs_fpga fpga_ptr = (struct ihs_fpga *)CONFIG_SYS_FPGA_BASE;
...

void fpga_set_reg(u32 fpga, u16 *reg, off_t regoff, u16 data)
{
if (fpga)
return mclink_send(fpga - 1, regoff, data);

return out_le16(reg, data);
}

> where mclink_send() is the routine to access the non memory mapped 
> FPGAs through the memory mapped FPGA:
>int mclink_send(u8 slave, u16 addr, u16 data)
>{
>   ...
>   fpga_set_reg(0, &system_fpgas[0].mc_tx_address, addr);
>   fpga_set_reg(0, &system_fpgas[0].mc_tx_data, data);
>   fpga_set_reg(0, &system_fpgas[0].mc_tx_cmd, (slave & 0x03) << 14);
>}

And this becomes:

fpga_set_reg(0,
 &fpga_ptr->mc_tx_address,
 offsetof(struct ihs_fpga, mc_tx_address),
 addr);

etc. Yes, this is long and ugly to write, so you may want to define a
helper macro like:

#define FPGA_SET_REG(ix,fld,val)\
fpga_set_reg((ix),  \
&fpga_ptr->fld, \
offsetof(struct ihs_fpga, fld), \
val)

so this turns into a plain and simple

FPGA_SET_REG(0, mc_tx_address, addr);
FPGA_SET_REG(0, mc_tx_data, data);
FPGA_SET_REG(0, mc_tx_cmd, (slave & 0x03) << 14);


What do you think?

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
It is much easier to suggest solutions when you know nothing
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] avr32: fix relocation address calculation

2013-05-08 Thread Andreas Bießmann
Commit 1865286466a5d0c7f2e3c37632da56556c838e9e (Introduce generic link
section.h symbol files) changed the __bss_end symbol type from char[] to
ulong. This led to wrong relocation parameters which ended up in a not working
u-boot. Unfortunately this is not clear to see cause due to RAM aliasing we
may get a 'half-working' u-boot then.

Fix this by dereferencing the __bss_end symbol where needed.

Signed-off-by: Andreas Bießmann 
---
 arch/avr32/lib/board.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/avr32/lib/board.c b/arch/avr32/lib/board.c
index ccf862a..2e79e98 100644
--- a/arch/avr32/lib/board.c
+++ b/arch/avr32/lib/board.c
@@ -116,7 +116,7 @@ static int display_banner (void)
printf ("\n\n%s\n\n", version_string);
printf ("U-Boot code: %08lx -> %08lx  data: %08lx -> %08lx\n",
(unsigned long)_text, (unsigned long)_etext,
-   (unsigned long)_data, (unsigned long)__bss_end);
+   (unsigned long)_data, (unsigned long)(&__bss_end));
return 0;
 }
 
@@ -183,7 +183,7 @@ void board_init_f(ulong board_type)
 *  - stack
 */
addr = CONFIG_SYS_SDRAM_BASE + sdram_size;
-   monitor_len = (char *)__bss_end - _text;
+   monitor_len = (char *)(&__bss_end) - _text;
 
/*
 * Reserve memory for u-boot code, data and bss.
-- 
1.7.10.4

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


Re: [U-Boot] [PATCH V2 0/5] ARM: OMAP: Cleanup save_boot_params function

2013-05-08 Thread Sricharan R
Tom,

On Wednesday 24 April 2013 04:11 PM, Sricharan R wrote:
> The save_boot_params function does not store the data in a
> always writable area. So the code is broken for a 'XIP' boot.
> This series corrects this by storing it in 'gd' and also
> adds a 'C' equivalent function for the same. The essential cleanups
> for the same are added in this.
>
> Tested this on omap5 uevm board with SD/EMMC boot.
> omap4/5 boards does not have a XIP flash.
> So yet to test XIP with this series.
>
> Also verfied a MAKEALL for armv7.
>
> Sricharan R (5):
>   ARM: OMAP: Make omap_boot_parameters common across socs
>   ARM: OMAP4/5: Make OMAPx_SRAM_SCRATCH_ defines common
>   ARM: OMAP: Correct save_boot_params and replace with 'C' function
>   ARM: OMAP: Cleanup boot parameters usage
>   ARM: OMAP: Add arch_cpu_init function
>
>  arch/arm/cpu/armv7/lowlevel_init.S |8 +++-
>  arch/arm/cpu/armv7/omap-common/boot-common.c   |   20 ++--
>  arch/arm/cpu/armv7/omap-common/hwinit-common.c |   61 
> +---
>  arch/arm/cpu/armv7/omap-common/lowlevel_init.S |   50 +--
>  arch/arm/cpu/armv7/omap4/emif.c|4 +-
>  arch/arm/cpu/armv7/omap4/hw_data.c |2 +-
>  arch/arm/cpu/armv7/omap4/hwinit.c  |3 +-
>  arch/arm/cpu/armv7/omap5/emif.c|4 +-
>  arch/arm/cpu/armv7/omap5/hw_data.c |2 +-
>  arch/arm/cpu/armv7/omap5/hwinit.c  |3 +-
>  arch/arm/include/asm/arch-am33xx/omap.h|   25 --
>  arch/arm/include/asm/arch-omap4/omap.h |   36 --
>  arch/arm/include/asm/arch-omap4/sys_proto.h|   11 ++---
>  arch/arm/include/asm/arch-omap5/omap.h |   36 --
>  arch/arm/include/asm/arch-omap5/sys_proto.h|   12 ++---
>  arch/arm/include/asm/global_data.h |8 
>  arch/arm/include/asm/omap_boot.h   |   50 +++
>  arch/arm/include/asm/omap_common.h |   19 
>  common/spl/spl.c   |   12 +++--
>  include/configs/am335x_evm.h   |4 ++
>  include/configs/omap4_common.h |4 ++
>  include/configs/omap5_common.h |3 ++
>  include/configs/pcm051.h   |4 ++
>  include/configs/ti814x_evm.h   |4 ++
>  include/spl.h  |1 -
>  25 files changed, 187 insertions(+), 199 deletions(-)
>  create mode 100644 arch/arm/include/asm/omap_boot.h
>
 Does this look ok, go to get in ?

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


[U-Boot] [PATCH v5] i2c: add Faraday FTI2C010 I2C controller support

2013-05-08 Thread Kuo-Jung Su
From: Kuo-Jung Su 

Faraday FTI2C010 is a multi-function I2C controller
which supports both master and slave mode.
This patch simplily implements the master mode only.

Signed-off-by: Kuo-Jung Su 
CC: Heiko Schocher 
---
Changes for v5:
   - Coding Style cleanup.
   - Use CONFIG_SYS_I2C_SPEED for default speed.
   - Put a permanent 100 ms delay to chip reset.
   - Makefile: CONFIG_FTI2C010 -> CONFIG_SYS_I2C_FTI2C010

Changes for v4:
   - Coding Style cleanup.
   - Make it a separate patch, rather then a part of
 Faraday A36x patch series
   - Use macro constants for timeout control

Changes for v3:
   - Coding Style cleanup.
   - Drop macros for wirtel()/readl(), call them directly.
   - Always insert a blank line between declarations and code.
   - Replace all the infinite wait loop with a timeout.
   - Add '__iomem' to all the declaration of HW register pointers.

Changes for v2:
   - Coding Style cleanup.
   - Use readl(), writel(), clrsetbits_le32() to replace REG() macros.
   - Use structure based hardware registers to replace the macro constants.
   - Replace BIT() with BIT_MASK().

 drivers/i2c/Makefile   |1 +
 drivers/i2c/fti2c010.c |  369 
 drivers/i2c/fti2c010.h |   81 +++
 3 files changed, 451 insertions(+)
 create mode 100644 drivers/i2c/fti2c010.c
 create mode 100644 drivers/i2c/fti2c010.h

diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile
index 5dbdbe3..9654607 100644
--- a/drivers/i2c/Makefile
+++ b/drivers/i2c/Makefile
@@ -29,6 +29,7 @@ COBJS-$(CONFIG_BFIN_TWI_I2C) += bfin-twi_i2c.o
 COBJS-$(CONFIG_DRIVER_DAVINCI_I2C) += davinci_i2c.o
 COBJS-$(CONFIG_DW_I2C) += designware_i2c.o
 COBJS-$(CONFIG_FSL_I2C) += fsl_i2c.o
+COBJS-$(CONFIG_SYS_I2C_FTI2C010) += fti2c010.o
 COBJS-$(CONFIG_I2C_MVTWSI) += mvtwsi.o
 COBJS-$(CONFIG_I2C_MV) += mv_i2c.o
 COBJS-$(CONFIG_I2C_MXC) += mxc_i2c.o
diff --git a/drivers/i2c/fti2c010.c b/drivers/i2c/fti2c010.c
new file mode 100644
index 000..f639854
--- /dev/null
+++ b/drivers/i2c/fti2c010.c
@@ -0,0 +1,369 @@
+/*
+ * Faraday I2C Controller
+ *
+ * (C) Copyright 2010 Faraday Technology
+ * Dante Su 
+ *
+ * This file is released under the terms of GPL v2 and any later version.
+ * See the file COPYING in the root directory of the source tree for details.
+ */
+
+#include 
+#include 
+#include 
+
+#include "fti2c010.h"
+
+#ifndef CONFIG_HARD_I2C
+#error "fti2c010: CONFIG_HARD_I2C is not defined"
+#endif
+
+#ifndef CONFIG_SYS_I2C_SPEED
+#define CONFIG_SYS_I2C_SPEED5
+#endif
+
+#ifndef CONFIG_FTI2C010_FREQ
+#define CONFIG_FTI2C010_FREQclk_get_rate("I2C")
+#endif
+
+/* command timeout */
+#define CFG_CMD_TIMEOUT 10 /* ms */
+
+/* 7-bit chip address + 1-bit read/write */
+#define I2C_RD(chip)chip) << 1) & 0xff) | 1)
+#define I2C_WR(chip)(((chip) << 1) & 0xff)
+
+struct fti2c010_chip {
+   void __iomem *regs;
+   uint bus;
+   uint speed;
+};
+
+static struct fti2c010_chip chip_list[] = {
+   {
+   .bus  = 0,
+   .regs = (void __iomem *)CONFIG_FTI2C010_BASE,
+   },
+#ifdef CONFIG_I2C_MULTI_BUS
+# ifdef CONFIG_FTI2C010_BASE1
+   {
+   .bus  = 1,
+   .regs = (void __iomem *)CONFIG_FTI2C010_BASE1,
+   },
+# endif
+# ifdef CONFIG_FTI2C010_BASE2
+   {
+   .bus  = 2,
+   .regs = (void __iomem *)CONFIG_FTI2C010_BASE2,
+   },
+# endif
+# ifdef CONFIG_FTI2C010_BASE3
+   {
+   .bus  = 3,
+   .regs = (void __iomem *)CONFIG_FTI2C010_BASE3,
+   },
+# endif
+#endif  /* #ifdef CONFIG_I2C_MULTI_BUS */
+};
+
+static struct fti2c010_chip *curr = chip_list;
+
+static int fti2c010_wait(uint32_t mask)
+{
+   int ret = -1;
+   uint32_t stat, ts;
+   struct fti2c010_regs *regs = curr->regs;
+
+   for (ts = get_timer(0); get_timer(ts) < CFG_CMD_TIMEOUT; ) {
+   stat = readl(®s->sr);
+   if ((stat & mask) == mask) {
+   ret = 0;
+   break;
+   }
+   }
+
+   return ret;
+}
+
+/*
+ * u-boot I2C API
+ */
+
+/*
+ * Initialization, must be called once on start up, may be called
+ * repeatedly to change the speed and slave addresses.
+ */
+void i2c_init(int speed, int slaveaddr)
+{
+   if (speed || !curr->speed)
+   i2c_set_bus_speed(speed);
+
+   /* if slave mode disabled */
+   if (!slaveaddr)
+   return;
+
+   /*
+* TODO:
+* Implement slave mode, but is it really necessary?
+*/
+}
+
+/*
+ * Probe the given I2C chip address.  Returns 0 if a chip responded,
+ * not 0 on failure.
+ */
+int i2c_probe(uchar chip)
+{
+   int ret;
+   struct fti2c010_regs *regs = curr->regs;
+
+   i2c_init(0, 0);
+
+   /* 1. Select slave device (7bits Address + 1bit R/W) */
+   writel(I2C_WR(chip), ®s->dr);
+   writel(CR_ENABLE | CR_TBEN | CR_START, ®s->cr);
+   ret = fti2c010_w