Re: [U-Boot] [PATCH] ARM: uniphier: drop UniPhier specific SMP code

2015-11-08 Thread Tom Rini
On Sat, Nov 07, 2015 at 01:12:14AM +0900, Masahiro Yamada wrote:
> 2015-11-06 22:46 GMT+09:00 Tom Rini :
> > On Fri, Nov 06, 2015 at 10:16:30PM +0900, Masahiro Yamada wrote:
> >
> >> The latest Linux can directly handle SMP operations for UniPhier SoCs
> >> without any help of U-boot.  Drop the relevant code from U-boot.
> >>
> >> See commit b1e4006aeda8c8784029de17d47987c21ea75f6d ("ARM: uniphier:
> >> rework SMP operations to use trampoline code") in Linux Kernel.
> >>
> >> Signed-off-by: Masahiro Yamada 
> >
> > So my question for you is how much of a concern is running older kernels
> > and newer U-Boots on these platforms?  I know that for example we
> > couldn't do something like that in "beagle" land, and for Allwinner
> > platforms we still have ways of making the older but most featureful
> > kernels work.
> 
> 
> Good question.
> 
> Socionext (and my former company, Panasonic) tended to
> modify source code locally (ugly hacks here and there) and never tried
> to push patches to the upstream.
> 
> I started the kernel upstreaming this year,
> and the company changed the mind and stared to realize its importance,
> but it is under way.
> 
> The mainline kernel requires some more extra patches that have not
> been upstreamed yet.
> 
> So, our customers cannot do anything with the mainline kernel alone.
> They are supposed to use software stacks released from us.
> 
> So, the combination of the older kernels + newer U-boot does not matter.
> The older kernels were not working in the first place.

Thanks!

Reviewed-by: Tom Rini 

-- 
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] Makefile: Include vendor common library in include search path

2015-11-08 Thread Tom Rini
On Sun, Nov 08, 2015 at 09:56:18AM -0600, menon.nisha...@gmail.com wrote:
> On Sat, Nov 7, 2015 at 8:18 PM, Tom Rini  wrote:
> 
> > Conceptually fine with me.  Do we really need a config option for it
> > tho?
> 
> I was following the lines of CONFIG_CREATE_ARCH_SYMLINK here. Is there
> some reason why you'd not want it so?

Masahiro?

-- 
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 V4 08/13] spl: change return values of spl_*_load_image()

2015-11-08 Thread Nikita Kiryanov
Make spl_*_load_image() functions return a value instead of
hanging if a problem is encountered. This enables main spl code
to make the decision whether to hang or not, thus preparing
it to support alternative boot devices.

Some boot devices (namely nand and spi) do not hang on error.
Instead, they return normally and SPL proceeds to boot the
contents of the load address. This is considered a bug and
is rectified by hanging on error for these devices as well.

Signed-off-by: Nikita Kiryanov 
Cc: Igor Grinberg 
Cc: Tom Rini 
Cc: Simon Glass 
Cc: Ian Campbell 
Cc: Hans De Goede 
Cc: Albert Aribaud 
Cc: Jagan Teki 
Reviewed-by: Tom Rini 
Reviewed-by: Simon Glass 
---
Changes in V4:
- No changes.

Changes in V3:
- Added documentation for spl_board_load_image().

Changes in V2:
- Minor collateral adjustments from changes in patch 2 (only one return
  statement at the end of spl_mmc_load_image).

 arch/arm/cpu/armv7/sunxi/board.c |  4 +++-
 arch/arm/include/asm/spl.h   | 10 --
 common/spl/spl.c | 43 +++-
 common/spl/spl_mmc.c | 26 ++--
 common/spl/spl_nand.c| 18 +++--
 common/spl/spl_net.c |  9 ++---
 common/spl/spl_nor.c |  6 --
 common/spl/spl_onenand.c |  4 +++-
 common/spl/spl_sata.c| 11 +++---
 common/spl/spl_usb.c | 17 ++--
 common/spl/spl_ymodem.c  |  5 +++--
 drivers/mtd/spi/spi_spl_load.c   | 17 +++-
 include/spl.h| 18 -
 13 files changed, 123 insertions(+), 65 deletions(-)

diff --git a/arch/arm/cpu/armv7/sunxi/board.c b/arch/arm/cpu/armv7/sunxi/board.c
index 4785ac6..9b5c46b 100644
--- a/arch/arm/cpu/armv7/sunxi/board.c
+++ b/arch/arm/cpu/armv7/sunxi/board.c
@@ -95,10 +95,12 @@ static int gpio_init(void)
return 0;
 }
 
-void spl_board_load_image(void)
+int spl_board_load_image(void)
 {
debug("Returning to FEL sp=%x, lr=%x\n", fel_stash.sp, fel_stash.lr);
return_to_fel(fel_stash.sp, fel_stash.lr);
+
+   return 0;
 }
 
 void s_init(void)
diff --git a/arch/arm/include/asm/spl.h b/arch/arm/include/asm/spl.h
index 6db405d..5c5d33f 100644
--- a/arch/arm/include/asm/spl.h
+++ b/arch/arm/include/asm/spl.h
@@ -31,8 +31,14 @@ enum {
 };
 #endif
 
-/* Board-specific load method */
-void spl_board_load_image(void);
+/**
+ * Board specific load method for boards that have a special way of loading
+ * U-Boot, which does not fit with the existing SPL code.
+ *
+ * @return 0 on success, negative errno value on failure.
+ */
+
+int spl_board_load_image(void);
 
 /* Linker symbols. */
 extern char __bss_start[], __bss_end[];
diff --git a/common/spl/spl.c b/common/spl/spl.c
index 4b319d6..ff1bad2 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -132,7 +132,7 @@ __weak void __noreturn jump_to_image_no_args(struct 
spl_image_info *spl_image)
 }
 
 #ifdef CONFIG_SPL_RAM_DEVICE
-static void spl_ram_load_image(void)
+static int spl_ram_load_image(void)
 {
const struct image_header *header;
 
@@ -145,6 +145,8 @@ static void spl_ram_load_image(void)
(CONFIG_SYS_TEXT_BASE - sizeof(struct image_header));
 
spl_parse_image_header(header);
+
+   return 0;
 }
 #endif
 
@@ -208,68 +210,81 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
switch (boot_device) {
 #ifdef CONFIG_SPL_RAM_DEVICE
case BOOT_DEVICE_RAM:
-   spl_ram_load_image();
+   if (spl_ram_load_image())
+   hang();
break;
 #endif
 #ifdef CONFIG_SPL_MMC_SUPPORT
case BOOT_DEVICE_MMC1:
case BOOT_DEVICE_MMC2:
case BOOT_DEVICE_MMC2_2:
-   spl_mmc_load_image();
+   if (spl_mmc_load_image())
+   hang();
break;
 #endif
 #ifdef CONFIG_SPL_NAND_SUPPORT
case BOOT_DEVICE_NAND:
-   spl_nand_load_image();
+   if (spl_nand_load_image())
+   hang();
break;
 #endif
 #ifdef CONFIG_SPL_ONENAND_SUPPORT
case BOOT_DEVICE_ONENAND:
-   spl_onenand_load_image();
+   if (spl_onenand_load_image())
+   hang();
break;
 #endif
 #ifdef CONFIG_SPL_NOR_SUPPORT
case BOOT_DEVICE_NOR:
-   spl_nor_load_image();
+   if (spl_nor_load_image())
+   hang();
break;
 #endif
 #ifdef CONFIG_SPL_YMODEM_SUPPORT
case BOOT_DEVICE_UART:
-   spl_ymodem_load_image();
+   if (spl_ymodem_load_image())
+   hang();
break;
 #endif
 #ifdef 

[U-Boot] [PATCH V4 02/13] spl: mmc: add break statements in spl_mmc_load_image()

2015-11-08 Thread Nikita Kiryanov
The original intention of the mmc load_image() function was to try multiple
boot modes before failing. This is evident by the lack of break statements
in the switch, and the following line in the default case:
puts("spl: mmc: no boot mode left to try\n");

This implementation is problematic because:
- The availability of alternative boot modes is very arbitrary since it
depends on the specific order of the switch cases. If your boot mode happens to
be the first case, then you'll have a bunch of other boot modes as alternatives.
If it happens to be the last case, then you have none.
- Opting in/out is tied to config options, so the only way for you to prevent an
alternative boot mode from being attempted is to give up on the feature 
completely.
- This implementation makes the code more complicated and difficult to
understand.

Address these issues by inserting a break statements between the cases to make 
the
function try only one boot mode.

Signed-off-by: Nikita Kiryanov 
Cc: Igor Grinberg 
Cc: Paul Kocialkowski 
Cc: Pantelis Antoniou 
Cc: Tom Rini 
Cc: Simon Glass 
Reviewed-by: Simon Glass 
Reviewed-by: Tom Rini 
---
Changes in V4:
- No changes.

Changes in V3:
- No changes.

Changes in V2:
- Removed hang() in default cases, moved default case into ifdef
  LIBCOMMON.

 common/spl/spl_mmc.c | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c
index ce58c58..6011f77 100644
--- a/common/spl/spl_mmc.c
+++ b/common/spl/spl_mmc.c
@@ -164,6 +164,7 @@ void spl_mmc_load_image(void)
if (!err)
return;
 #endif
+   break;
case MMCSD_MODE_FS:
debug("spl: mmc boot mode: fs\n");
 
@@ -203,6 +204,7 @@ void spl_mmc_load_image(void)
 #endif
 #endif
 #endif
+   break;
 #ifdef CONFIG_SUPPORT_EMMC_BOOT
case MMCSD_MODE_EMMCBOOT:
/*
@@ -240,15 +242,14 @@ void spl_mmc_load_image(void)
if (!err)
return;
 #endif
+   break;
 #endif
case MMCSD_MODE_UNDEFINED:
-   default:
 #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
-   if (err)
-   puts("spl: mmc: no boot mode left to try\n");
-   else
-   puts("spl: mmc: wrong boot mode\n");
+   default:
+   puts("spl: mmc: wrong boot mode\n");
 #endif
-   hang();
}
+
+   hang();
 }
-- 
1.9.1

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


[U-Boot] [PATCH V4 12/13] arm: mx6: cm-fx6: define fallback boot devices for spl

2015-11-08 Thread Nikita Kiryanov
Use spl alternate boot device feature to define fallback to
the main boot device as it is defined by hardware.

Signed-off-by: Nikita Kiryanov 
Cc: Igor Grinberg 
Cc: Stefano Babic 
Cc: Tom Rini 
Reviewed-by: Tom Rini 
Reviewed-by: Stefano Babic 
---
Changes in V4:
- No changes.

Changes in V3:
- No changes.

Changes in V2:
- No changes.

 board/compulab/cm_fx6/spl.c | 19 ++-
 include/configs/cm_fx6.h|  1 -
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/board/compulab/cm_fx6/spl.c b/board/compulab/cm_fx6/spl.c
index d94ced9..d8328fd 100644
--- a/board/compulab/cm_fx6/spl.c
+++ b/board/compulab/cm_fx6/spl.c
@@ -337,16 +337,17 @@ void board_init_f(ulong dummy)
board_init_r(NULL, 0);
 }
 
-void spl_board_init(void)
+void board_boot_order(u32 *spl_boot_list)
 {
-   u32 boot_device = spl_boot_device();
-
-   if (boot_device == BOOT_DEVICE_SPI)
-   puts("Booting from SPI flash\n");
-   else if (boot_device == BOOT_DEVICE_MMC1)
-   puts("Booting from MMC\n");
-   else
-   puts("Unknown boot device\n");
+   spl_boot_list[0] = spl_boot_device();
+   switch (spl_boot_list[0]) {
+   case BOOT_DEVICE_SPI:
+   spl_boot_list[1] = BOOT_DEVICE_MMC1;
+   break;
+   case BOOT_DEVICE_MMC1:
+   spl_boot_list[1] = BOOT_DEVICE_SPI;
+   break;
+   }
 }
 
 #ifdef CONFIG_SPL_MMC_SUPPORT
diff --git a/include/configs/cm_fx6.h b/include/configs/cm_fx6.h
index 0513204..180ea28 100644
--- a/include/configs/cm_fx6.h
+++ b/include/configs/cm_fx6.h
@@ -230,7 +230,6 @@
 
 /* SPL */
 #include "imx6_spl.h"
-#define CONFIG_SPL_BOARD_INIT
 #define CONFIG_SPL_MMC_SUPPORT
 #define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR0x80 /* offset 64 kb */
 #define CONFIG_SYS_MONITOR_LEN (CONFIG_SYS_U_BOOT_MAX_SIZE_SECTORS / 2 * 1024)
-- 
1.9.1

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


[U-Boot] [PATCH V4 07/13] spl: mmc: get rid of emmc boot code duplication

2015-11-08 Thread Nikita Kiryanov
Get rid of emmc boot code duplication in spl_mmc_load_image() using a switch
case fallthrough into MMCSD_MODE_RAW. Since the #ifdef CONFIG_SUPPORT_EMMC_BOOT
check is not really necessary, remove it in the process.

No functional changes.

Signed-off-by: Nikita Kiryanov 
Cc: Igor Grinberg 
Cc: Paul Kocialkowski 
Cc: Pantelis Antoniou 
Cc: Tom Rini 
Cc: Simon Glass 
Reviewed-by: Simon Glass 
Reviewed-by: Tom Rini 
---
Changes in V4:
- No changes.

Changes in V3:
- No changes.

Changes in V2:
- No changes.

 common/spl/spl_mmc.c | 54 ++--
 1 file changed, 18 insertions(+), 36 deletions(-)

diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c
index 5dc576b..7d100fa 100644
--- a/common/spl/spl_mmc.c
+++ b/common/spl/spl_mmc.c
@@ -240,6 +240,24 @@ void spl_mmc_load_image(void)
 
boot_mode = spl_boot_mode();
switch (boot_mode) {
+   case MMCSD_MODE_EMMCBOOT:
+   /*
+* We need to check what the partition is configured to.
+* 1 and 2 match up to boot0 / boot1 and 7 is user data
+* which is the first physical partition (0).
+*/
+   part = (mmc->part_config >> 3) & PART_ACCESS_MASK;
+
+   if (part == 7)
+   part = 0;
+
+   if (mmc_switch_part(0, part)) {
+#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
+   puts("spl: mmc partition switch failed\n");
+#endif
+   hang();
+   }
+   /* Fall through */
case MMCSD_MODE_RAW:
debug("spl: mmc boot mode: raw\n");
 
@@ -268,42 +286,6 @@ void spl_mmc_load_image(void)
return;
 
break;
-#ifdef CONFIG_SUPPORT_EMMC_BOOT
-   case MMCSD_MODE_EMMCBOOT:
-   /*
-* We need to check what the partition is configured to.
-* 1 and 2 match up to boot0 / boot1 and 7 is user data
-* which is the first physical partition (0).
-*/
-   part = (mmc->part_config >> 3) & PART_ACCESS_MASK;
-
-   if (part == 7)
-   part = 0;
-
-   if (mmc_switch_part(0, part)) {
-#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
-   puts("spl: mmc partition switch failed\n");
-#endif
-   hang();
-   }
-
-   if (!spl_start_uboot()) {
-   err = mmc_load_image_raw_os(mmc);
-   if (!err)
-   return;
-   }
-   err = mmc_load_image_raw_partition(mmc,
-   CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION);
-   if (!err)
-   return;
-#if defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR)
-   err = mmc_load_image_raw_sector(mmc,
-   CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR);
-   if (!err)
-   return;
-#endif
-   break;
-#endif
case MMCSD_MODE_UNDEFINED:
 #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
default:
-- 
1.9.1

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


[U-Boot] [PATCH V4 04/13] spl: mmc: remove #ifdef CONFIG_SPL_OS_BOOT check

2015-11-08 Thread Nikita Kiryanov
Implement default versions of falcon mode functions to make the
CONFIG_SPL_OS_BOOT check in spl_mmc_load_image() unnecessary, thus reducing
its #ifdef complexity.

No functional changes.

Signed-off-by: Nikita Kiryanov 
Cc: Igor Grinberg 
Cc: Paul Kocialkowski 
Cc: Pantelis Antoniou 
Cc: Tom Rini 
Cc: Simon Glass 
Cc: Guillaume GARDET 
Cc: Suriyan Ramasami 
Reviewed-by: Simon Glass 
Reviewed-by: Tom Rini 
---
Changes in V4:
- No changes.

Changes in V3:
- No changes.

Changes in V2:
- No changes.

 common/spl/spl_ext.c |  6 ++
 common/spl/spl_fat.c |  6 ++
 common/spl/spl_mmc.c | 17 +
 3 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/common/spl/spl_ext.c b/common/spl/spl_ext.c
index 9d37fd3..a42fbd0 100644
--- a/common/spl/spl_ext.c
+++ b/common/spl/spl_ext.c
@@ -6,6 +6,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #ifdef CONFIG_SPL_EXT_SUPPORT
@@ -135,5 +136,10 @@ defaults:
return spl_load_image_ext(block_dev, partition,
CONFIG_SPL_FS_LOAD_KERNEL_NAME);
 }
+#else
+int spl_load_image_ext_os(block_dev_desc_t *block_dev, int partition)
+{
+   return -ENOSYS;
+}
 #endif
 #endif
diff --git a/common/spl/spl_fat.c b/common/spl/spl_fat.c
index 350f7d9..0daadbe 100644
--- a/common/spl/spl_fat.c
+++ b/common/spl/spl_fat.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 static int fat_registered;
@@ -119,5 +120,10 @@ defaults:
return spl_load_image_fat(block_dev, partition,
CONFIG_SPL_FS_LOAD_KERNEL_NAME);
 }
+#else
+int spl_load_image_fat_os(block_dev_desc_t *block_dev, int partition)
+{
+   return -ENOSYS;
+}
 #endif
 #endif
diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c
index 9d3c09e..837fa0d 100644
--- a/common/spl/spl_mmc.c
+++ b/common/spl/spl_mmc.c
@@ -154,6 +154,15 @@ static int mmc_load_image_raw_os(struct mmc *mmc)
return mmc_load_image_raw_sector(mmc,
CONFIG_SYS_MMCSD_RAW_MODE_KERNEL_SECTOR);
 }
+#else
+int spl_start_uboot(void)
+{
+   return 1;
+}
+static int mmc_load_image_raw_os(struct mmc *mmc)
+{
+   return -ENOSYS;
+}
 #endif
 
 void spl_mmc_load_image(void)
@@ -179,13 +188,11 @@ void spl_mmc_load_image(void)
case MMCSD_MODE_RAW:
debug("spl: mmc boot mode: raw\n");
 
-#ifdef CONFIG_SPL_OS_BOOT
if (!spl_start_uboot()) {
err = mmc_load_image_raw_os(mmc);
if (!err)
return;
}
-#endif
 #if defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION)
err = mmc_load_image_raw_partition(mmc,
CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION);
@@ -203,14 +210,12 @@ void spl_mmc_load_image(void)
 
 #ifdef CONFIG_SYS_MMCSD_FS_BOOT_PARTITION
 #ifdef CONFIG_SPL_FAT_SUPPORT
-#ifdef CONFIG_SPL_OS_BOOT
if (!spl_start_uboot()) {
err = spl_load_image_fat_os(>block_dev,
CONFIG_SYS_MMCSD_FS_BOOT_PARTITION);
if (!err)
return;
}
-#endif
 #ifdef CONFIG_SPL_FS_LOAD_PAYLOAD_NAME
err = spl_load_image_fat(>block_dev,
 CONFIG_SYS_MMCSD_FS_BOOT_PARTITION,
@@ -220,14 +225,12 @@ void spl_mmc_load_image(void)
 #endif
 #endif
 #ifdef CONFIG_SPL_EXT_SUPPORT
-#ifdef CONFIG_SPL_OS_BOOT
if (!spl_start_uboot()) {
err = spl_load_image_ext_os(>block_dev,
CONFIG_SYS_MMCSD_FS_BOOT_PARTITION);
if (!err)
return;
}
-#endif
 #ifdef CONFIG_SPL_FS_LOAD_PAYLOAD_NAME
err = spl_load_image_ext(>block_dev,
 CONFIG_SYS_MMCSD_FS_BOOT_PARTITION,
@@ -257,13 +260,11 @@ void spl_mmc_load_image(void)
hang();
}
 
-#ifdef CONFIG_SPL_OS_BOOT
if (!spl_start_uboot()) {
err = mmc_load_image_raw_os(mmc);
if (!err)
return;
}
-#endif
 #if defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION)
err = mmc_load_image_raw_partition(mmc,
CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION);
-- 
1.9.1

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


[U-Boot] [PATCH V4 11/13] spl: announce boot devices

2015-11-08 Thread Nikita Kiryanov
Now that we support alternative boot devices, it can sometimes be
unclear which boot devices was actually used. Provide a function to
announce which boot devices are attempted during boot.

Signed-off-by: Nikita Kiryanov 
Cc: Igor Grinberg 
Cc: Tom Rini 
Cc: Simon Glass 
Reviewed-by: Tom Rini 
---
Changes in V2:
- Moved new code to be located after #ifndef BOOT_DEVICE_NONE

Changes in V3:
- Reworked announce_boot_device() to make the code less repititive by
  utilizing a table of boot_device --> name.

Changes in V2:
- No changes.

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

diff --git a/common/spl/spl.c b/common/spl/spl.c
index 7913c52..b522c8b 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -195,6 +195,84 @@ __weak void board_boot_order(u32 *spl_boot_list)
spl_boot_list[0] = spl_boot_device();
 }
 
+#ifdef CONFIG_SPL_BOARD_LOAD_IMAGE
+__weak void spl_board_announce_boot_device(void) { }
+#endif
+
+#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
+struct boot_device_name {
+   u32 boot_dev;
+   const char *name;
+};
+
+struct boot_device_name boot_name_table[] = {
+#ifdef CONFIG_SPL_RAM_DEVICE
+   { BOOT_DEVICE_RAM, "RAM" },
+#endif
+#ifdef CONFIG_SPL_MMC_SUPPORT
+   { BOOT_DEVICE_MMC1, "MMC" },
+   { BOOT_DEVICE_MMC2, "MMC" },
+   { BOOT_DEVICE_MMC2_2, "MMC" },
+#endif
+#ifdef CONFIG_SPL_NAND_SUPPORT
+   { BOOT_DEVICE_NAND, "NAND" },
+#endif
+#ifdef CONFIG_SPL_ONENAND_SUPPORT
+   { BOOT_DEVICE_ONENAND, "OneNAND" },
+#endif
+#ifdef CONFIG_SPL_NOR_SUPPORT
+   { BOOT_DEVICE_NOR, "NOR" },
+#endif
+#ifdef CONFIG_SPL_YMODEM_SUPPORT
+   { BOOT_DEVICE_UART, "UART" },
+#endif
+#ifdef CONFIG_SPL_SPI_SUPPORT
+   { BOOT_DEVICE_SPI, "SPI" },
+#endif
+#ifdef CONFIG_SPL_ETH_SUPPORT
+#ifdef CONFIG_SPL_ETH_DEVICE
+   { BOOT_DEVICE_CPGMAC, "eth device" },
+#else
+   { BOOT_DEVICE_CPGMAC, "net" },
+#endif
+#endif
+#ifdef CONFIG_SPL_USBETH_SUPPORT
+   { BOOT_DEVICE_USBETH, "USB eth" },
+#endif
+#ifdef CONFIG_SPL_USB_SUPPORT
+   { BOOT_DEVICE_USB, "USB" },
+#endif
+#ifdef CONFIG_SPL_SATA_SUPPORT
+   { BOOT_DEVICE_SATA, "SATA" },
+#endif
+   /* Keep this entry last */
+   { BOOT_DEVICE_NONE, "unknown boot device" },
+};
+
+static void announce_boot_device(u32 boot_device)
+{
+   int i;
+
+   puts("Trying to boot from ");
+
+#ifdef CONFIG_SPL_BOARD_LOAD_IMAGE
+   if (boot_device == BOOT_DEVICE_BOARD) {
+   spl_board_announce_boot_device();
+   puts("\n");
+   return;
+   }
+#endif
+   for (i = 0; i < ARRAY_SIZE(boot_name_table) - 1; i++) {
+   if (boot_name_table[i].boot_dev == boot_device)
+   break;
+   }
+
+   printf("%s\n", boot_name_table[i].name);
+}
+#else
+static inline void announce_boot_device(u32 boot_device) { }
+#endif
+
 static int spl_load_image(u32 boot_device)
 {
switch (boot_device) {
@@ -292,6 +370,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
board_boot_order(spl_boot_list);
for (i = 0; i < ARRAY_SIZE(spl_boot_list) &&
spl_boot_list[i] != BOOT_DEVICE_NONE; i++) {
+   announce_boot_device(spl_boot_list[i]);
if (!spl_load_image(spl_boot_list[i]))
break;
}
-- 
1.9.1

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


[U-Boot] [PATCH V4 10/13] spl: add support for alternative boot device

2015-11-08 Thread Nikita Kiryanov
Introduce spl_boot_list array, which defines a list of boot devices
that SPL will try before hanging. By default this list will consist
of only spl_boot_device(), but board_boot_order() can be overridden
by board code to populate the array with custom values.

Signed-off-by: Nikita Kiryanov 
Cc: Igor Grinberg 
Cc: Tom Rini 
Cc: Simon Glass 
Reviewed-by: Tom Rini 
---
Changes in V4:
- No changes.

Changes in V3:
- No changes.

Changes in V2:
- No changes.

 common/spl/spl.c | 33 +
 1 file changed, 29 insertions(+), 4 deletions(-)

diff --git a/common/spl/spl.c b/common/spl/spl.c
index 56fccca..7913c52 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -178,6 +178,23 @@ int spl_init(void)
return 0;
 }
 
+#ifndef BOOT_DEVICE_NONE
+#define BOOT_DEVICE_NONE 0xdeadbeef
+#endif
+
+static u32 spl_boot_list[] = {
+   BOOT_DEVICE_NONE,
+   BOOT_DEVICE_NONE,
+   BOOT_DEVICE_NONE,
+   BOOT_DEVICE_NONE,
+   BOOT_DEVICE_NONE,
+};
+
+__weak void board_boot_order(u32 *spl_boot_list)
+{
+   spl_boot_list[0] = spl_boot_device();
+}
+
 static int spl_load_image(u32 boot_device)
 {
switch (boot_device) {
@@ -247,7 +264,7 @@ static int spl_load_image(u32 boot_device)
 
 void board_init_r(gd_t *dummy1, ulong dummy2)
 {
-   u32 boot_device;
+   int i;
 
debug(">>spl:board_init_r()\n");
 
@@ -272,10 +289,18 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
spl_board_init();
 #endif
 
-   boot_device = spl_boot_device();
-   debug("boot device - %d\n", boot_device);
-   if (spl_load_image(boot_device))
+   board_boot_order(spl_boot_list);
+   for (i = 0; i < ARRAY_SIZE(spl_boot_list) &&
+   spl_boot_list[i] != BOOT_DEVICE_NONE; i++) {
+   if (!spl_load_image(spl_boot_list[i]))
+   break;
+   }
+
+   if (i == ARRAY_SIZE(spl_boot_list) ||
+   spl_boot_list[i] == BOOT_DEVICE_NONE) {
+   puts("SPL: failed to boot from all boot devices\n");
hang();
+   }
 
switch (spl_image.os) {
case IH_OS_U_BOOT:
-- 
1.9.1

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


[U-Boot] [PATCH V4 13/13] spl: mmc: add support for BOOT_DEVICE_MMC2

2015-11-08 Thread Nikita Kiryanov
Currently the mmc device that SPL looks at is always mmc0, regardless
of the BOOT_DEVICE_MMCx value. This forces some boards to
implement hacks in order to boot from other mmc devices.

Make SPL take into account the correct mmc device.

Signed-off-by: Nikita Kiryanov 
Reviewed-by: Tom Rini 
---
Changes in V4:
- No changes.

Changes in V3:
- No changes.

Changes in V2:
- New patch.

 arch/arm/cpu/armv7/sunxi/board.c | 10 +-
 common/spl/spl.c |  2 +-
 common/spl/spl_mmc.c | 41 
 include/spl.h|  2 +-
 4 files changed, 36 insertions(+), 19 deletions(-)

diff --git a/arch/arm/cpu/armv7/sunxi/board.c b/arch/arm/cpu/armv7/sunxi/board.c
index 9b5c46b..794b829 100644
--- a/arch/arm/cpu/armv7/sunxi/board.c
+++ b/arch/arm/cpu/armv7/sunxi/board.c
@@ -173,16 +173,8 @@ u32 spl_boot_device(void)
 #ifdef CONFIG_MMC
if (CONFIG_MMC_SUNXI_SLOT_EXTRA == 2) {
mmc1 = find_mmc_device(1);
-   if (sunxi_mmc_has_egon_boot_signature(mmc1)) {
-   /*
-* spl_mmc.c: spl_mmc_load_image() is hard-coded to
-* use find_mmc_device(0), no matter what we
-* return. Swap mmc0 and mmc2 to make this work.
-*/
-   mmc0->block_dev.dev = 1;
-   mmc1->block_dev.dev = 0;
+   if (sunxi_mmc_has_egon_boot_signature(mmc1))
return BOOT_DEVICE_MMC2;
-   }
}
 #endif
 
diff --git a/common/spl/spl.c b/common/spl/spl.c
index b522c8b..7a393dc 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -284,7 +284,7 @@ static int spl_load_image(u32 boot_device)
case BOOT_DEVICE_MMC1:
case BOOT_DEVICE_MMC2:
case BOOT_DEVICE_MMC2_2:
-   return spl_mmc_load_image();
+   return spl_mmc_load_image(boot_device);
 #endif
 #ifdef CONFIG_SPL_NAND_SUPPORT
case BOOT_DEVICE_NAND:
diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c
index b68190a..b3c2c64 100644
--- a/common/spl/spl_mmc.c
+++ b/common/spl/spl_mmc.c
@@ -61,11 +61,32 @@ end:
return 0;
 }
 
+int spl_mmc_get_device_index(u32 boot_device)
+{
+   switch (boot_device) {
+   case BOOT_DEVICE_MMC1:
+   return 0;
+   case BOOT_DEVICE_MMC2:
+   case BOOT_DEVICE_MMC2_2:
+   return 1;
+   }
+
+#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
+   printf("spl: unsupported mmc boot device.\n");
+#endif
+
+   return -ENODEV;
+}
+
 #ifdef CONFIG_DM_MMC
-static int spl_mmc_find_device(struct mmc **mmc)
+static int spl_mmc_find_device(struct mmc **mmc, u32 boot_device)
 {
struct udevice *dev;
-   int err;
+   int err, mmc_dev;
+
+   mmc_dev = spl_mmc_get_device_index(boot_device);
+   if (mmc_dev < 0)
+   return mmc_dev;
 
err = mmc_initialize(NULL);
if (err) {
@@ -75,7 +96,7 @@ static int spl_mmc_find_device(struct mmc **mmc)
return err;
}
 
-   err = uclass_get_device(UCLASS_MMC, 0, );
+   err = uclass_get_device(UCLASS_MMC, mmc_dev, );
if (err) {
 #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
printf("spl: could not find mmc device. error: %d\n", err);
@@ -88,9 +109,13 @@ static int spl_mmc_find_device(struct mmc **mmc)
return *mmc != NULL ? 0 : -ENODEV;
 }
 #else
-static int spl_mmc_find_device(struct mmc **mmc)
+static int spl_mmc_find_device(struct mmc **mmc, u32 boot_device)
 {
-   int err;
+   int err, mmc_dev;
+
+   mmc_dev = spl_mmc_get_device_index(boot_device);
+   if (mmc_dev < 0)
+   return mmc_dev;
 
err = mmc_initialize(gd->bd);
if (err) {
@@ -101,7 +126,7 @@ static int spl_mmc_find_device(struct mmc **mmc)
}
 
/* We register only one device. So, the dev id is always 0 */
-   *mmc = find_mmc_device(0);
+   *mmc = find_mmc_device(mmc_dev);
if (!*mmc) {
 #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
puts("spl: mmc device not found\n");
@@ -221,14 +246,14 @@ int spl_mmc_do_fs_boot(struct mmc *mmc)
 }
 #endif
 
-int spl_mmc_load_image(void)
+int spl_mmc_load_image(u32 boot_device)
 {
struct mmc *mmc;
u32 boot_mode;
int err = 0;
__maybe_unused int part;
 
-   err = spl_mmc_find_device();
+   err = spl_mmc_find_device(, boot_device);
if (err)
return err;
 
diff --git a/include/spl.h b/include/spl.h
index 46fc454..92cdc04 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -54,7 +54,7 @@ int spl_onenand_load_image(void);
 int spl_nor_load_image(void);
 
 /* MMC SPL functions */
-int spl_mmc_load_image(void);
+int spl_mmc_load_image(u32 boot_device);
 
 /* YMODEM SPL functions */
 int spl_ymodem_load_image(void);
-- 
1.9.1

___

Re: [U-Boot] [PATCH v2 02/16] drivers: spi:ti_qspi: change ti_qspi_slave to ti_qspi_priv for driver model conversion

2015-11-08 Thread Tom Rini
On Wed, Nov 04, 2015 at 01:46:10PM +0530, Mugunthan V N wrote:

> Changing the ti_qspi_priv structure and its instance names from
> to priv for driver mode conversion.
> 
> Signed-off-by: Mugunthan V N 

Reviewed-by: Tom Rini 

-- 
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 01/16] drivers: spi: ti_qspi: do not hard code chip select for memory map configuration

2015-11-08 Thread Tom Rini
On Wed, Nov 04, 2015 at 01:46:09PM +0530, Mugunthan V N wrote:

> To enable memory map in dra7xx, specific chip select must be
> written to control module register. But this hard coded to chip
> select 1, fixing it by writing the specific chip select value to
> control module register.
> 
> Signed-off-by: Mugunthan V N 

Reviewed-by: Tom Rini 

-- 
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 16/16] defconfig: am437x_sk_evm: enable spi driver model

2015-11-08 Thread Tom Rini
On Wed, Nov 04, 2015 at 01:46:24PM +0530, Mugunthan V N wrote:

> enable mmc driver model for am437x_sk_evm as ti_qspi supports
> driver model
> 
> Signed-off-by: Mugunthan V N 
> Reviewed-by: Simon Glass 

Reviewed-by: Tom Rini 

-- 
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 v4 3/7] ARM: omap-common: Add standard access for board description EEPROM

2015-11-08 Thread Tom Rini
On Thu, Nov 05, 2015 at 06:39:32PM -0600, Steve Kipisz wrote:

> From: Lokesh Vutla 
> 
> Several TI EVMs have EEPROM that can contain board description information
> such as revision, DDR definition, serial number, etc. In just about all
> cases, these EEPROM are on the I2C bus and provides us the opportunity
> to centralize the generic operations involved.
> 
> The on-board EEPROM on the BeagleBone Black, BeagleBone, AM335x EVM,
> AM43x GP EVM, AM57xx-evm, BeagleBoard-X15 share the same format.
> However, DRA-7* EVMs, OMAP4SDP use a modified format.
> 
> We hence introduce logic which is generic between these platforms
> without enforcing any specific format. This allows the boards to use the
> relevant format for operations that they might choose.
> 
> This module will compile for all TI SoC based boards when I2C is enabled,
> even non-TI boards that do not have the EEPROM. If the functions are not
> used, they will not be linked in.
> 
> It is important to note that this logic is fundamental to the board
> configuration process such as DDR configuration which is needed in
> SPL, hence cannot be part of the standard u-boot driver model (which
> is available later in the process). Hence, to aid efficiency, the
> eeprom contents are copied over to SRAM scratchpad memory area at the
> first invocation to retrieve data.
> 
> The follow on patches introduce the use of this library for AM335x,
> AM437x, and AM57xx.
> 
> Signed-off-by: Lokesh Vutla 
> Signed-off-by: Steve Kipisz 

Reviewed-by: Tom Rini 

-- 
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 07/16] dts: dra7: add spi alias for qspi

2015-11-08 Thread Tom Rini
On Wed, Nov 04, 2015 at 01:46:15PM +0530, Mugunthan V N wrote:

> add spi alias for qspi so that spi probes the device and driver
> successfully.
> 
> Signed-off-by: Mugunthan V N 
> Reviewed-by: Simon Glass 
> ---
>  arch/arm/dts/dra7.dtsi | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/arch/arm/dts/dra7.dtsi b/arch/arm/dts/dra7.dtsi
> index 8f1e25b..3060e9a 100644
> --- a/arch/arm/dts/dra7.dtsi
> +++ b/arch/arm/dts/dra7.dtsi
> @@ -41,6 +41,7 @@
>   ethernet1 = _emac1;
>   d_can0 = 
>   d_can1 = 
> + spi0 = 
>   };
>  
>   timer {

Is this upstream already?

-- 
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 05/16] spi: Add support for dual and quad mode

2015-11-08 Thread Tom Rini
On Wed, Nov 04, 2015 at 01:46:13PM +0530, Mugunthan V N wrote:

> spi bus can support dual and quad wire data transfers for tx and
> rx. So defining dual and quad modes for both tx and rx. Also add
> support to parse bus width used for spi tx and rx transfers.
> 
> Signed-off-by: Mugunthan V N 
> Reviewed-by: Simon Glass 

Reviewed-by: Tom Rini 

-- 
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 09/16] arm: dts: dra7: add qspi register maps for memory map and control module

2015-11-08 Thread Tom Rini
On Wed, Nov 04, 2015 at 01:46:17PM +0530, Mugunthan V N wrote:

> Add qspi memory map and control module register maps to device tree.
> 
> Signed-off-by: Mugunthan V N 
> Reviewed-by: Simon Glass 
> ---
>  arch/arm/dts/dra7.dtsi | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm/dts/dra7.dtsi b/arch/arm/dts/dra7.dtsi
> index 3060e9a..7045c0f 100644
> --- a/arch/arm/dts/dra7.dtsi
> +++ b/arch/arm/dts/dra7.dtsi
> @@ -1104,8 +1104,8 @@
>  
>   qspi: qspi@4b30 {
>   compatible = "ti,dra7xxx-qspi";
> - reg = <0x4b30 0x100>;
> - reg-names = "qspi_base";
> + reg = <0x4b30 0x100>, <0x5c00 0x400>, 
> <0x4a002558 0x4>;
> + reg-names = "qspi_base", "qspi_mmap", "qspi_ctrlmod";
>   #address-cells = <1>;
>   #size-cells = <0>;
>   ti,hwmods = "qspi";

Is this already upstream?

-- 
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 13/16] defconfig: dra74_evm: enable spi driver model

2015-11-08 Thread Tom Rini
On Wed, Nov 04, 2015 at 01:46:21PM +0530, Mugunthan V N wrote:

> enable mmc driver model for dra74_evm as ti_qspi supports
> driver model
> 
> Signed-off-by: Mugunthan V N 
> Reviewed-by: Simon Glass 

Reviewed-by: Tom Rini 

-- 
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 08/16] drivers: spi: ti_qspi: convert driver to adopt device driver model

2015-11-08 Thread Tom Rini
On Wed, Nov 04, 2015 at 01:46:16PM +0530, Mugunthan V N wrote:

> adopt ti_qspi driver to device driver model
> 
> Signed-off-by: Mugunthan V N 

Reviewed-by: Tom Rini 

-- 
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 12/16] defconfig: dra72_evm: enable spi driver model

2015-11-08 Thread Tom Rini
On Wed, Nov 04, 2015 at 01:46:20PM +0530, Mugunthan V N wrote:

> enable mmc driver model for dra72_evm as ti_qspi supports
> driver model
> 
> Signed-off-by: Mugunthan V N 
> Reviewed-by: Simon Glass 

Reviewed-by: Tom Rini 

-- 
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 15/16] arm: dts: am4372: add qspi register maps for memory map

2015-11-08 Thread Tom Rini
On Wed, Nov 04, 2015 at 01:46:23PM +0530, Mugunthan V N wrote:
> Add qspi memory map address to device tree.
> 
> Signed-off-by: Mugunthan V N 
> Reviewed-by: Simon Glass 
> ---
>  arch/arm/dts/am4372.dtsi | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/dts/am4372.dtsi b/arch/arm/dts/am4372.dtsi
> index ade28c7..1b30d53 100644
> --- a/arch/arm/dts/am4372.dtsi
> +++ b/arch/arm/dts/am4372.dtsi
> @@ -25,6 +25,7 @@
>   serial0 = 
>   ethernet0 = _emac0;
>   ethernet1 = _emac1;
> + spi0 = 
>   };
>  
>   cpus {
> @@ -902,7 +903,8 @@
>  
>   qspi: qspi@4790 {
>   compatible = "ti,am4372-qspi";
> - reg = <0x4790 0x100>;
> + reg = <0x4790 0x100>, <0x3000 0x400>;
> + reg-names = "qspi_base", "qspi_mmap";
>   #address-cells = <1>;
>   #size-cells = <0>;
>   ti,hwmods = "qspi";

Is this upstream already?

-- 
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 v4 5/7] ti: AM437x: Use generic EEPROM detection logic

2015-11-08 Thread Tom Rini
On Thu, Nov 05, 2015 at 06:39:34PM -0600, Steve Kipisz wrote:

> From: Nishanth Menon 
> 
> Now that we have a generic TI eeprom logic which can be reused accross
> platforms, reuse the same.
> 
> Signed-off-by: Nishanth Menon 
> Signed-off-by: Steven Kipisz 

Reviewed-by: Tom Rini 

-- 
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 V4 05/13] spl: mmc: get rid of #ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION check

2015-11-08 Thread Nikita Kiryanov
Implement defaults for the raw partition image loading so that the #ifdef
CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION in spl_mmc_load_image() will no
longer be necessary.

This change makes it possible for mmc_load_image_raw_partition() and
mmc_load_image_raw_sector() to coexist.

Signed-off-by: Nikita Kiryanov 
Cc: Igor Grinberg 
Cc: Paul Kocialkowski 
Cc: Pantelis Antoniou 
Cc: Tom Rini 
Cc: Simon Glass 
Reviewed-by: Simon Glass 
Reviewed-by: Tom Rini 
---
Changes in V4:
- No changes.

Changes in V3:
- No changes.

Changes in V2:
- No changes.

 common/spl/spl_mmc.c | 13 +
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c
index 837fa0d..d646dc8 100644
--- a/common/spl/spl_mmc.c
+++ b/common/spl/spl_mmc.c
@@ -133,6 +133,12 @@ static int mmc_load_image_raw_partition(struct mmc *mmc, 
int partition)
return mmc_load_image_raw_sector(mmc, info.start);
 #endif
 }
+#else
+#define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION -1
+static int mmc_load_image_raw_partition(struct mmc *mmc, int partition)
+{
+   return -ENOSYS;
+}
 #endif
 
 #ifdef CONFIG_SPL_OS_BOOT
@@ -193,12 +199,12 @@ void spl_mmc_load_image(void)
if (!err)
return;
}
-#if defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION)
+
err = mmc_load_image_raw_partition(mmc,
CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION);
if (!err)
return;
-#elif defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR)
+#if defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR)
err = mmc_load_image_raw_sector(mmc,
CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR);
if (!err)
@@ -265,12 +271,11 @@ void spl_mmc_load_image(void)
if (!err)
return;
}
-#if defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION)
err = mmc_load_image_raw_partition(mmc,
CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION);
if (!err)
return;
-#elif defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR)
+#if defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR)
err = mmc_load_image_raw_sector(mmc,
CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR);
if (!err)
-- 
1.9.1

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


[U-Boot] [PATCH V4 00/13] SPL mmc refactor and alternate boot device feature

2015-11-08 Thread Nikita Kiryanov
This series has two parts: patches 1-7 perform refactors aimed at reducing the
ifdef complexity of SPL mmc code (and some nand as well). This refactor also
addresses a few design issues I noticed while working on the refactor.

Image size comparison for arm modules can be seen here:
http://patchwork.ozlabs.org/patch/534387/
Since the changes in V2 are minimal, the V1 results should still be valid for
the V2 as well.

The rest of the series introduces a new SPL feature that allows board code to
define a list of boot devices that SPL will try before failing (instead of the
only one device it attempts now). This feature is useful for implementing
fallbacks, as well as reacting to bootROM sequences. For example:

On CM-FX6, if boot from the alternate boot device (MMC) fails, the bootROM
proceeds to try boot from SPI flash. If the SPI flash boot is succesful, SPL
will still try to load U-Boot from MMC, instead of from the actual boot device
SPI flash), and probably fail and hang. The alternate boot feature makes it
possible for SPL to follow the MMC boot attempt with boot from the SPI flash.
The CM-FX6 based miniature PC Utilite depends on this capability for its SPI
flash boot to work, since SPI flash boot is only attempted if MMC boot fails.

Finally, patch 13 makes SPL look at the specific BOOT_DEVICE_MMCx, and search
for the correct mmc device, instead of always going for mmc0.

This series was compile tested for arm and powerpc (patches 1-12).
Patch 13 compile tested for sunxi.
Tested on CM-FX6.

Cc: Igor Grinberg 
Cc: Tom Rini 
Cc: Hans de Goede 
Cc: Pantelis Antoniou 
Cc: Otavio Salvador 

Changes in V4:
- Rebased over current mainline. Rerun compile test for arm and powerpc
- Fixed typo in a commit message
- Moved announce_boot_device() code to after #ifndef BOOT_DEVICE_NONE
- Replaced one puts with printf

Changes in V3:
- Added documentation for spl_board_load_image().
- Reworked announce_boot_device() to make the code less repititive by
  utilizing a table of boot_device --> name.

Changes in V2:
- Per request I went over the changes to see if they should cause documentation
  updates or board updates, but found none to be necessary.
- Slight modification in patch 2 (and consequentially patch 8): removal of
  hang() in default switch case, and enclosing of default case in #ifdef
  LIBCONFIG to avoid compiler complaints if LIBCONFIG support not compiled in.
- Patch 13 is a new patch which makes SPL look at the value of BOOT_DEVICE_MMCx
  instead of always working with mmc0. A hack in sunxi boards that attempted to
  circumvent this issue is thus removed.
- Rebased over current mainline.


Nikita Kiryanov (13):
  spl: nand: remove code duplication
  spl: mmc: add break statements in spl_mmc_load_image()
  spl: mmc: refactor device location code to its own function
  spl: mmc: remove #ifdef CONFIG_SPL_OS_BOOT check
  spl: mmc: get rid of #ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION
check
  spl: mmc: move fs boot into its own function
  spl: mmc: get rid of emmc boot code duplication
  spl: change return values of spl_*_load_image()
  common: spl: move image load to its own function
  spl: add support for alternative boot device
  spl: announce boot devices
  arm: mx6: cm-fx6: define fallback boot devices for spl
  spl: mmc: add support for BOOT_DEVICE_MMC2

 arch/arm/cpu/armv7/sunxi/board.c |  14 +-
 arch/arm/include/asm/spl.h   |  10 +-
 board/compulab/cm_fx6/spl.c  |  19 +--
 common/spl/spl.c | 194 +++---
 common/spl/spl_ext.c |   6 +
 common/spl/spl_fat.c |   6 +
 common/spl/spl_mmc.c | 290 ---
 common/spl/spl_nand.c|  47 ---
 common/spl/spl_net.c |   9 +-
 common/spl/spl_nor.c |   6 +-
 common/spl/spl_onenand.c |   4 +-
 common/spl/spl_sata.c|  11 +-
 common/spl/spl_usb.c |  17 ++-
 common/spl/spl_ymodem.c  |   5 +-
 drivers/mtd/spi/spi_spl_load.c   |  17 ++-
 include/configs/cm_fx6.h |   1 -
 include/spl.h|  18 +--
 17 files changed, 446 insertions(+), 228 deletions(-)

-- 
1.9.1

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


[U-Boot] [PATCH V4 09/13] common: spl: move image load to its own function

2015-11-08 Thread Nikita Kiryanov
Refactor spl image load code out of board_init_r and into its own
function. This is a preparation for supporting alternative boot
devices.

Signed-off-by: Nikita Kiryanov 
Cc: Igor Grinberg 
Cc: Tom Rini 
Cc: Simon Glass 
Reviewed-by: Simon Glass 
Reviewed-by: Tom Rini 
---
Changes in V4:
- No changes.

Changes in V3:
- No changes.

Changes in V2:
- No changes.

 common/spl/spl.c | 117 ---
 1 file changed, 50 insertions(+), 67 deletions(-)

diff --git a/common/spl/spl.c b/common/spl/spl.c
index ff1bad2..56fccca 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -178,122 +178,105 @@ int spl_init(void)
return 0;
 }
 
-void board_init_r(gd_t *dummy1, ulong dummy2)
+static int spl_load_image(u32 boot_device)
 {
-   u32 boot_device;
-
-   debug(">>spl:board_init_r()\n");
-
-#if defined(CONFIG_SYS_SPL_MALLOC_START)
-   mem_malloc_init(CONFIG_SYS_SPL_MALLOC_START,
-   CONFIG_SYS_SPL_MALLOC_SIZE);
-   gd->flags |= GD_FLG_FULL_MALLOC_INIT;
-#endif
-   if (!(gd->flags & GD_FLG_SPL_INIT)) {
-   if (spl_init())
-   hang();
-   }
-#ifndef CONFIG_PPC
-   /*
-* timer_init() does not exist on PPC systems. The timer is initialized
-* and enabled (decrementer) in interrupt_init() here.
-*/
-   timer_init();
-#endif
-
-#ifdef CONFIG_SPL_BOARD_INIT
-   spl_board_init();
-#endif
-
-   boot_device = spl_boot_device();
-   debug("boot device - %d\n", boot_device);
switch (boot_device) {
 #ifdef CONFIG_SPL_RAM_DEVICE
case BOOT_DEVICE_RAM:
-   if (spl_ram_load_image())
-   hang();
-   break;
+   return spl_ram_load_image();
 #endif
 #ifdef CONFIG_SPL_MMC_SUPPORT
case BOOT_DEVICE_MMC1:
case BOOT_DEVICE_MMC2:
case BOOT_DEVICE_MMC2_2:
-   if (spl_mmc_load_image())
-   hang();
-   break;
+   return spl_mmc_load_image();
 #endif
 #ifdef CONFIG_SPL_NAND_SUPPORT
case BOOT_DEVICE_NAND:
-   if (spl_nand_load_image())
-   hang();
-   break;
+   return spl_nand_load_image();
 #endif
 #ifdef CONFIG_SPL_ONENAND_SUPPORT
case BOOT_DEVICE_ONENAND:
-   if (spl_onenand_load_image())
-   hang();
-   break;
+   return spl_onenand_load_image();
 #endif
 #ifdef CONFIG_SPL_NOR_SUPPORT
case BOOT_DEVICE_NOR:
-   if (spl_nor_load_image())
-   hang();
-   break;
+   return spl_nor_load_image();
 #endif
 #ifdef CONFIG_SPL_YMODEM_SUPPORT
case BOOT_DEVICE_UART:
-   if (spl_ymodem_load_image())
-   hang();
-   break;
+   return spl_ymodem_load_image();
 #endif
 #ifdef CONFIG_SPL_SPI_SUPPORT
case BOOT_DEVICE_SPI:
-   if (spl_spi_load_image())
-   hang();
-   break;
+   return spl_spi_load_image();
 #endif
 #ifdef CONFIG_SPL_ETH_SUPPORT
case BOOT_DEVICE_CPGMAC:
 #ifdef CONFIG_SPL_ETH_DEVICE
-   if (spl_net_load_image(CONFIG_SPL_ETH_DEVICE))
-   hang();
+   return spl_net_load_image(CONFIG_SPL_ETH_DEVICE);
 #else
-   if (spl_net_load_image(NULL))
-   hang();
+   return spl_net_load_image(NULL);
 #endif
-   break;
 #endif
 #ifdef CONFIG_SPL_USBETH_SUPPORT
case BOOT_DEVICE_USBETH:
-   if (spl_net_load_image("usb_ether"))
-   hang();
-   break;
+   return spl_net_load_image("usb_ether");
 #endif
 #ifdef CONFIG_SPL_USB_SUPPORT
case BOOT_DEVICE_USB:
-   if (spl_usb_load_image())
-   hang();
-   break;
+   return spl_usb_load_image();
 #endif
 #ifdef CONFIG_SPL_SATA_SUPPORT
case BOOT_DEVICE_SATA:
-   if (spl_sata_load_image())
-   hang();
-   break;
+   return spl_sata_load_image();
 #endif
 #ifdef CONFIG_SPL_BOARD_LOAD_IMAGE
case BOOT_DEVICE_BOARD:
-   if (spl_board_load_image())
-   hang();
-   break;
+   return spl_board_load_image();
 #endif
default:
 #if defined(CONFIG_SPL_SERIAL_SUPPORT) && defined(CONFIG_SPL_LIBCOMMON_SUPPORT)
puts("SPL: Unsupported Boot Device!\n");
 #endif
-   hang();
+   return -ENODEV;
}
 
+   return -EINVAL;
+}
+
+void board_init_r(gd_t *dummy1, ulong dummy2)
+{
+   u32 boot_device;
+
+   debug(">>spl:board_init_r()\n");
+

[U-Boot] [PATCH V4 03/13] spl: mmc: refactor device location code to its own function

2015-11-08 Thread Nikita Kiryanov
Simplify spl_mmc_load_image() code by moving the part that finds the mmc device
into its own function spl_mmc_find_device(), available in two flavors: DM and
non-DM.

This refactor fixes a bug in which an error in the device location sequence
does not necessarily aborts the rest of the code. With this refactor, we fail
the moment there is an error.

Signed-off-by: Nikita Kiryanov 
Cc: Igor Grinberg 
Cc: Paul Kocialkowski 
Cc: Pantelis Antoniou 
Cc: Tom Rini 
Cc: Simon Glass 
Reviewed-by: Simon Glass 
---
Changes in V4:
- s/puts/printf/

Changes in V3:
- No changes.

Changes in V2:
- No changes.

 common/spl/spl_mmc.c | 77 +---
 1 file changed, 55 insertions(+), 22 deletions(-)

diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c
index 6011f77..9d3c09e 100644
--- a/common/spl/spl_mmc.c
+++ b/common/spl/spl_mmc.c
@@ -11,6 +11,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -59,6 +60,58 @@ end:
return 0;
 }
 
+#ifdef CONFIG_DM_MMC
+static int spl_mmc_find_device(struct mmc **mmc)
+{
+   struct udevice *dev;
+   int err;
+
+   err = mmc_initialize(NULL);
+   if (err) {
+#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
+   printf("spl: could not initialize mmc. error: %d\n", err);
+#endif
+   return err;
+   }
+
+   err = uclass_get_device(UCLASS_MMC, 0, );
+   if (err) {
+#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
+   printf("spl: could not find mmc device. error: %d\n", err);
+#endif
+   return err;
+   }
+
+   *mmc = NULL;
+   *mmc = mmc_get_mmc_dev(dev);
+   return *mmc != NULL ? 0 : -ENODEV;
+}
+#else
+static int spl_mmc_find_device(struct mmc **mmc)
+{
+   int err;
+
+   err = mmc_initialize(gd->bd);
+   if (err) {
+#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
+   printf("spl: could not initialize mmc. error: %d\n", err);
+#endif
+   return err;
+   }
+
+   /* We register only one device. So, the dev id is always 0 */
+   *mmc = find_mmc_device(0);
+   if (!*mmc) {
+#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
+   puts("spl: mmc device not found\n");
+#endif
+   return -ENODEV;
+   }
+
+   return 0;
+}
+#endif
+
 #ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION
 static int mmc_load_image_raw_partition(struct mmc *mmc, int partition)
 {
@@ -110,30 +163,10 @@ void spl_mmc_load_image(void)
int err = 0;
__maybe_unused int part;
 
-#ifdef CONFIG_DM_MMC
-   struct udevice *dev;
-
-   mmc_initialize(NULL);
-   err = uclass_get_device(UCLASS_MMC, 0, );
-   mmc = NULL;
-   if (!err)
-   mmc = mmc_get_mmc_dev(dev);
-#else
-   mmc_initialize(gd->bd);
-
-   /* We register only one device. So, the dev id is always 0 */
-   mmc = find_mmc_device(0);
-   if (!mmc) {
-#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
-   puts("spl: mmc device not found\n");
-#endif
+   if (spl_mmc_find_device())
hang();
-   }
-#endif
-
-   if (!err)
-   err = mmc_init(mmc);
 
+   err = mmc_init(mmc);
if (err) {
 #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
printf("spl: mmc init failed with error: %d\n", err);
-- 
1.9.1

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


[U-Boot] [PATCH V4 01/13] spl: nand: remove code duplication

2015-11-08 Thread Nikita Kiryanov
Remove code duplication in spl_nand_load_image().

No functional changes.

Signed-off-by: Nikita Kiryanov 
Cc: Scott Wood 
Cc: Igor Grinberg 
Acked-by: Scott Wood 
Reviewed-by: Simon Glass 
---
Changes in V4:
- No changes.

Changes in V3:
- No changes.

Changes in V2:
- No changes.

 common/spl/spl_nand.c | 31 ---
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/common/spl/spl_nand.c b/common/spl/spl_nand.c
index b8c369d..6e4e641 100644
--- a/common/spl/spl_nand.c
+++ b/common/spl/spl_nand.c
@@ -22,6 +22,19 @@ void spl_nand_load_image(void)
nand_deselect();
 }
 #else
+static int spl_nand_load_element(int offset, struct image_header *header)
+{
+   int err;
+
+   err = nand_spl_load_image(offset, sizeof(*header), (void *)header);
+   if (err)
+   return err;
+
+   spl_parse_image_header(header);
+   return nand_spl_load_image(offset, spl_image.size,
+  (void *)spl_image.load_addr);
+}
+
 void spl_nand_load_image(void)
 {
struct image_header *header;
@@ -73,25 +86,13 @@ void spl_nand_load_image(void)
}
 #endif
 #ifdef CONFIG_NAND_ENV_DST
-   nand_spl_load_image(CONFIG_ENV_OFFSET,
-   sizeof(*header), (void *)header);
-   spl_parse_image_header(header);
-   nand_spl_load_image(CONFIG_ENV_OFFSET, spl_image.size,
-   (void *)spl_image.load_addr);
+   spl_nand_load_element(CONFIG_ENV_OFFSET, header);
 #ifdef CONFIG_ENV_OFFSET_REDUND
-   nand_spl_load_image(CONFIG_ENV_OFFSET_REDUND,
-   sizeof(*header), (void *)header);
-   spl_parse_image_header(header);
-   nand_spl_load_image(CONFIG_ENV_OFFSET_REDUND, spl_image.size,
-   (void *)spl_image.load_addr);
+   spl_nand_load_element(CONFIG_ENV_OFFSET_REDUND, header);
 #endif
 #endif
/* Load u-boot */
-   nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS,
-   sizeof(*header), (void *)header);
-   spl_parse_image_header(header);
-   nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS,
-   spl_image.size, (void *)(unsigned long)spl_image.load_addr);
+   spl_nand_load_element(CONFIG_SYS_NAND_U_BOOT_OFFS, header);
nand_deselect();
 }
 #endif
-- 
1.9.1

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


[U-Boot] [PATCH V4 06/13] spl: mmc: move fs boot into its own function

2015-11-08 Thread Nikita Kiryanov
Move the code that handles fs boot out of spl_mmc_load_image() and into its
own function to reduce the #ifdef complexity of spl_mmc_load_image().

No functional changes.

Signed-off-by: Nikita Kiryanov 
Cc: Igor Grinberg 
Cc: Paul Kocialkowski 
Cc: Pantelis Antoniou 
Cc: Tom Rini 
Cc: Simon Glass 
Reviewed-by: Simon Glass 
Reviewed-by: Tom Rini 
---
Changes in V4:
- Fixed typo in commit message.

Changes in V3:
- No changes.

Changes in V2:
- No changes.

 common/spl/spl_mmc.c | 81 +---
 1 file changed, 51 insertions(+), 30 deletions(-)

diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c
index d646dc8..5dc576b 100644
--- a/common/spl/spl_mmc.c
+++ b/common/spl/spl_mmc.c
@@ -171,6 +171,55 @@ static int mmc_load_image_raw_os(struct mmc *mmc)
 }
 #endif
 
+#ifdef CONFIG_SYS_MMCSD_FS_BOOT_PARTITION
+int spl_mmc_do_fs_boot(struct mmc *mmc)
+{
+   int err = -ENOSYS;
+
+#ifdef CONFIG_SPL_FAT_SUPPORT
+   if (!spl_start_uboot()) {
+   err = spl_load_image_fat_os(>block_dev,
+   CONFIG_SYS_MMCSD_FS_BOOT_PARTITION);
+   if (!err)
+   return err;
+   }
+#ifdef CONFIG_SPL_FS_LOAD_PAYLOAD_NAME
+   err = spl_load_image_fat(>block_dev,
+CONFIG_SYS_MMCSD_FS_BOOT_PARTITION,
+CONFIG_SPL_FS_LOAD_PAYLOAD_NAME);
+   if (!err)
+   return err;
+#endif
+#endif
+#ifdef CONFIG_SPL_EXT_SUPPORT
+   if (!spl_start_uboot()) {
+   err = spl_load_image_ext_os(>block_dev,
+   CONFIG_SYS_MMCSD_FS_BOOT_PARTITION);
+   if (!err)
+   return err;
+   }
+#ifdef CONFIG_SPL_FS_LOAD_PAYLOAD_NAME
+   err = spl_load_image_ext(>block_dev,
+CONFIG_SYS_MMCSD_FS_BOOT_PARTITION,
+CONFIG_SPL_FS_LOAD_PAYLOAD_NAME);
+   if (!err)
+   return err;
+#endif
+#endif
+
+#if defined(CONFIG_SPL_FAT_SUPPORT) || defined(CONFIG_SPL_EXT_SUPPORT)
+   err = -ENOENT;
+#endif
+
+   return err;
+}
+#else
+int spl_mmc_do_fs_boot(struct mmc *mmc)
+{
+   return -ENOSYS;
+}
+#endif
+
 void spl_mmc_load_image(void)
 {
struct mmc *mmc;
@@ -214,38 +263,10 @@ void spl_mmc_load_image(void)
case MMCSD_MODE_FS:
debug("spl: mmc boot mode: fs\n");
 
-#ifdef CONFIG_SYS_MMCSD_FS_BOOT_PARTITION
-#ifdef CONFIG_SPL_FAT_SUPPORT
-   if (!spl_start_uboot()) {
-   err = spl_load_image_fat_os(>block_dev,
-   CONFIG_SYS_MMCSD_FS_BOOT_PARTITION);
-   if (!err)
-   return;
-   }
-#ifdef CONFIG_SPL_FS_LOAD_PAYLOAD_NAME
-   err = spl_load_image_fat(>block_dev,
-CONFIG_SYS_MMCSD_FS_BOOT_PARTITION,
-CONFIG_SPL_FS_LOAD_PAYLOAD_NAME);
-   if (!err)
-   return;
-#endif
-#endif
-#ifdef CONFIG_SPL_EXT_SUPPORT
-   if (!spl_start_uboot()) {
-   err = spl_load_image_ext_os(>block_dev,
-   CONFIG_SYS_MMCSD_FS_BOOT_PARTITION);
-   if (!err)
-   return;
-   }
-#ifdef CONFIG_SPL_FS_LOAD_PAYLOAD_NAME
-   err = spl_load_image_ext(>block_dev,
-CONFIG_SYS_MMCSD_FS_BOOT_PARTITION,
-CONFIG_SPL_FS_LOAD_PAYLOAD_NAME);
+   err = spl_mmc_do_fs_boot(mmc);
if (!err)
return;
-#endif
-#endif
-#endif
+
break;
 #ifdef CONFIG_SUPPORT_EMMC_BOOT
case MMCSD_MODE_EMMCBOOT:
-- 
1.9.1

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


Re: [U-Boot] [PATCH] Makefile: Include vendor common library in include search path

2015-11-08 Thread menon.nisha...@gmail.com
On Sat, Nov 7, 2015 at 8:18 PM, Tom Rini  wrote:

> Conceptually fine with me.  Do we really need a config option for it
> tho?

I was following the lines of CONFIG_CREATE_ARCH_SYMLINK here. Is there
some reason why you'd not want it so?

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


[U-Boot] [PATCH] openrisc: updating build tools naming convention

2015-11-08 Thread Guillaume REMBERT
Dear u-boot community,

I just made a small change on the openrisc-generic platform
configuration to take in account the new naming convention (or1k instead
of or32, so the build process gets fine).

Could you take care to review and approve the following patch, please?

Kind regards,

-- 


Guillaume REMBERT
Phone/Fax: 0033 9 72 32 55 76
Mobile: 0033 6 83 27 98 19
E-Mail: guillaume.remb...@euryecetelecom.com


On Earth and Space...
  EURYECE TELECOM
... where failure is not an option
http://www.euryecetelecom.com
__








51d13f5355943e14db4b95a7f8ae4cd87eba1fe1
 arch/openrisc/config.mk  | 2 +-
 arch/openrisc/cpu/u-boot.lds | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/openrisc/config.mk b/arch/openrisc/config.mk
index cd95f24..bfdb71f 100644
--- a/arch/openrisc/config.mk
+++ b/arch/openrisc/config.mk
@@ -6,7 +6,7 @@
 #

 ifeq ($(CROSS_COMPILE),)
-CROSS_COMPILE := or32-elf-
+CROSS_COMPILE := or1k-elf-
 endif

 # r10 used for global object pointer, already set in OR32 GCC but just
to be
diff --git a/arch/openrisc/cpu/u-boot.lds b/arch/openrisc/cpu/u-boot.lds
index d9bb7b7..854088b 100644
--- a/arch/openrisc/cpu/u-boot.lds
+++ b/arch/openrisc/cpu/u-boot.lds
@@ -1,5 +1,5 @@
 #include 
-OUTPUT_ARCH(or32)
+OUTPUT_ARCH(or1k)
 __DYNAMIC  =  0;

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


Re: [U-Boot] [PATCH V4 03/13] spl: mmc: refactor device location code to its own function

2015-11-08 Thread Tom Rini
On Sun, Nov 08, 2015 at 05:11:44PM +0200, Nikita Kiryanov wrote:

> Simplify spl_mmc_load_image() code by moving the part that finds the mmc 
> device
> into its own function spl_mmc_find_device(), available in two flavors: DM and
> non-DM.
> 
> This refactor fixes a bug in which an error in the device location sequence
> does not necessarily aborts the rest of the code. With this refactor, we fail
> the moment there is an error.
> 
> Signed-off-by: Nikita Kiryanov 
> Cc: Igor Grinberg 
> Cc: Paul Kocialkowski 
> Cc: Pantelis Antoniou 
> Cc: Tom Rini 
> Cc: Simon Glass 
> Reviewed-by: Simon Glass 

Reviewed-by: Tom Rini 

-- 
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] include: net: Simplify the usage of __always_inline

2015-11-08 Thread Fabio Estevam
From: Fabio Estevam 

Since commit de4d2e9e7ce0f9 (" bitops: Add fls_long and __ffs64")
 is included in include/linux/bitops.h,
which allows us to marking a function as 'always_inline' in a simpler
format.

Signed-off-by: Fabio Estevam 
---
 include/net.h | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/include/net.h b/include/net.h
index ebed29a..ac44d61 100644
--- a/include/net.h
+++ b/include/net.h
@@ -181,8 +181,7 @@ int eth_unregister(struct eth_device *dev);/* Remove 
network device */
 
 extern struct eth_device *eth_current;
 
-static inline __attribute__((always_inline))
-struct eth_device *eth_get_dev(void)
+static __always_inline struct eth_device *eth_get_dev(void)
 {
return eth_current;
 }
@@ -200,14 +199,14 @@ static inline unsigned char *eth_get_ethaddr(void)
 /* Used only when NetConsole is enabled */
 int eth_is_active(struct eth_device *dev); /* Test device for active state */
 /* Set active state */
-static inline __attribute__((always_inline)) int eth_init_state_only(void)
+static __always_inline int eth_init_state_only(void)
 {
eth_get_dev()->state = ETH_STATE_ACTIVE;
 
return 0;
 }
 /* Set passive state */
-static inline __attribute__((always_inline)) void eth_halt_state_only(void)
+static __always_inline void eth_halt_state_only(void)
 {
eth_get_dev()->state = ETH_STATE_PASSIVE;
 }
@@ -657,7 +656,7 @@ int nc_input_packet(uchar *pkt, struct in_addr src_ip, 
unsigned dest_port,
unsigned src_port, unsigned len);
 #endif
 
-static inline __attribute__((always_inline)) int eth_is_on_demand_init(void)
+static __always_inline int eth_is_on_demand_init(void)
 {
 #ifdef CONFIG_NETCONSOLE
extern enum proto_t net_loop_last_protocol;
-- 
1.9.1

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


Re: [U-Boot] [Patch V8 12/17] armv8/ls1043ardb: Add LS1043ARDB board support

2015-11-08 Thread Hu Vincent


> -Original Message-
> From: York Sun [mailto:york...@freescale.com]
> Sent: Saturday, November 07, 2015 4:11 AM
> To: Gong Qianyu-B52263; u-boot@lists.denx.de
> Cc: Hu Mingkai-B21284; Sun York-R58495; Hou Zhiqiang-B48286; Xie
> Shaohui-B21989; Song Wenbin-B53747; Wood Scott-B07421; Kushwaha
> Prabhakar-B32579; Wang Huan-B18965; Li Yang-Leo-R58472
> Subject: Re: [Patch V8 12/17] armv8/ls1043ardb: Add LS1043ARDB board
> support
> 
> 
> 
> On 10/26/2015 04:47 AM, Gong Qianyu wrote:
> > From: Mingkai Hu 
> >
> > LS1043ARDB Specification:
> > -
> > Memory subsystem:
> >  * 2GByte DDR4 SDRAM (32bit bus)
> >  * 128 Mbyte NOR flash single-chip memory
> >  * 512 Mbyte NAND flash
> >  * 16 Mbyte high-speed SPI flash
> >  * SD connector to interface with the SD memory card
> >
> > Ethernet:
> >  * XFI 10G port
> >  * QSGMII with 4x 1G ports
> >  * Two RGMII ports
> >
> > PCIe:
> >  * PCIe2 (Lanes C) to mini-PCIe slot
> >  * PCIe3 (Lanes D) to PCIe slot
> >
> > USB 3.0: two super speed USB 3.0 type A ports
> >
> > UART: supports two UARTs up to 115200 bps for console
> >
> > Signed-off-by: Hou Zhiqiang 
> > Signed-off-by: Li Yang 
> > Signed-off-by: Mingkai Hu 
> > Signed-off-by: York Sun 
> > Signed-off-by: Gong Qianyu 
> > ---
> > V8:
> >  - No changes.
> > V7:
> >  - No change.
> > V6:
> >  - Move GIC SMMU macros out of ls1043a_common.h.
> > V5:
> >  - No change.
> > V4:
> >  - Change arch to layerscape.
> >  - Add PCIe support.
> >  - Move SMMU_BASE, GICC_BASE, GICD_BASE to ls1043a_common.h.
> > V3:
> >  - Fix message typos.
> >  - Add ddr model number in comments.
> >  - Fix boot options in README.
> >  - Remove some dead code.
> > V2:
> >  - Replaced ns_access.h with fsl_csu.h.
> >
> >  arch/arm/Kconfig   |   7 +
> >  arch/arm/cpu/armv8/fsl-layerscape/Makefile |   4 +
> >  arch/arm/cpu/armv8/fsl-layerscape/ls1043a_serdes.c |  86 ++
> >  board/freescale/ls1043ardb/Kconfig |  16 ++
> >  board/freescale/ls1043ardb/MAINTAINERS |   7 +
> >  board/freescale/ls1043ardb/Makefile|   9 +
> >  board/freescale/ls1043ardb/README  |  85 +
> >  board/freescale/ls1043ardb/cpld.c  | 115
> +
> >  board/freescale/ls1043ardb/cpld.h  |  43 +
> >  board/freescale/ls1043ardb/ddr.c   | 191
> +
> >  board/freescale/ls1043ardb/ddr.h   |  45 +
> >  board/freescale/ls1043ardb/ls1043ardb.c| 131
> ++
> >  configs/ls1043ardb_defconfig   |   4 +
> >  include/configs/ls1043a_common.h   | 172
> +++
> >  include/configs/ls1043ardb.h   | 191
> +
> >  15 files changed, 1106 insertions(+)
> 
> 
> 
> > diff --git a/board/freescale/ls1043ardb/ddr.c
> > b/board/freescale/ls1043ardb/ddr.c
> > new file mode 100644
> > index 000..b181579
> > --- /dev/null
> > +++ b/board/freescale/ls1043ardb/ddr.c
> > @@ -0,0 +1,191 @@
> > +/*
> > + * Copyright 2015 Freescale Semiconductor, Inc.
> > + *
> > + * SPDX-License-Identifier:GPL-2.0+
> > + */
> > +
> > +#include 
> > +#include 
> > +#include 
> > +#include "ddr.h"
> > +#ifdef CONFIG_FSL_DEEP_SLEEP
> > +#include 
> > +#endif
> > +
> > +DECLARE_GLOBAL_DATA_PTR;
> > +
> > +void fsl_ddr_board_options(memctl_options_t *popts,
> > +  dimm_params_t *pdimm,
> > +  unsigned int ctrl_num)
> > +{
> > +   const struct board_specific_parameters *pbsp, *pbsp_highest =
> NULL;
> > +   ulong ddr_freq;
> > +
> > +   if (ctrl_num > 1) {
> > +   printf("Not supported controller number %d\n", ctrl_num);
> > +   return;
> > +   }
> > +   if (!pdimm->n_ranks)
> > +   return;
> > +
> > +   pbsp = udimms[0];
> > +
> > +   /* Get clk_adjust, wrlvl_start, wrlvl_ctl, according to the board
> ddr
> > +* freqency and n_banks specified in board_specific_parameters
> table.
> > +*/
> > +   ddr_freq = get_ddr_freq(0) / 100;
> > +   while (pbsp->datarate_mhz_high) {
> > +   if (pbsp->n_ranks == pdimm->n_ranks) {
> > +   if (ddr_freq <= pbsp->datarate_mhz_high) {
> > +   popts->clk_adjust = pbsp->clk_adjust;
> > +   popts->wrlvl_start = pbsp->wrlvl_start;
> > +   popts->wrlvl_ctl_2 = pbsp->wrlvl_ctl_2;
> > +   popts->wrlvl_ctl_3 = pbsp->wrlvl_ctl_3;
> > +   popts->cpo_override = pbsp->cpo_override;
> > +   popts->write_data_delay =
> > +   pbsp->write_data_delay;
> > +   goto found;
> > +   }
> > +   

Re: [U-Boot] [RFC PATCH 3/8] lib: net_utils: make string_to_ip stricter

2015-11-08 Thread Chris Packham
On Mon, Oct 12, 2015 at 8:43 PM, Chris Packham  wrote:
> Previously values greater than 255 were implicitly truncated. Add some
> stricter checking to reject addresses with components >255.
>
> With the input "1234192.168.1.1" the old behaviour would truncate the
> address to 192.168.1.1. New behaviour rejects the string outright and
> returns 0.0.0.0, which for the purposes of IP addresses can be
> considered an error.
>
> Signed-off-by: Chris Packham 
> ---
>
>  lib/net_utils.c | 13 +++--
>  1 file changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/lib/net_utils.c b/lib/net_utils.c
> index cfae842..0fca54d 100644
> --- a/lib/net_utils.c
> +++ b/lib/net_utils.c
> @@ -24,10 +24,19 @@ struct in_addr string_to_ip(const char *s)
>
> for (addr.s_addr = 0, i = 0; i < 4; ++i) {
> ulong val = s ? simple_strtoul(s, , 10) : 0;
> +   if (val > 255) {
> +   addr.s_addr = 0;
> +   return addr;
> +   }
> addr.s_addr <<= 8;
> addr.s_addr |= (val & 0xFF);
> -   if (s) {
> -   s = (*e) ? e+1 : e;
> +   if (*e == '.') {
> +   s = e + 1;
> +   } else if (*e == '\0') {
> +   break;
> +   } else {
> +   addr.s_addr = 0;
> +   return addr;

One unintended side effect of this is that is breaks parsing of things
like 'tftpboot 192.168.1.1:zImage'. I'll fix that in the next round.

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


Re: [U-Boot] [RESEND PATCH v3 15/20] rockchip: add rk3036 sdram driver

2015-11-08 Thread hl


Hi Simon,


On 07/11/15 07:58, Simon Glass wrote:

Hi Lin,

On 6 November 2015 at 01:53, Lin Huang  wrote:

add rk3036 sdram driver so we can set up sdram in SPL

Signed-off-by: Lin Huang 
---
Changes in v1: None
Changes in v2: None
Changes in v3: fix some code style error

  arch/arm/include/asm/arch-rockchip/sdram_rk3036.h | 336 ++
  arch/arm/mach-rockchip/rk3036/Makefile|   2 +
  arch/arm/mach-rockchip/rk3036/sdram_rk3036.c  | 729 ++
  3 files changed, 1067 insertions(+)
  create mode 100644 arch/arm/include/asm/arch-rockchip/sdram_rk3036.h
  create mode 100644 arch/arm/mach-rockchip/rk3036/sdram_rk3036.c


Just a few nits.


diff --git a/arch/arm/include/asm/arch-rockchip/sdram_rk3036.h 
b/arch/arm/include/asm/arch-rockchip/sdram_rk3036.h
new file mode 100644
index 000..76c8b5b
--- /dev/null
+++ b/arch/arm/include/asm/arch-rockchip/sdram_rk3036.h
@@ -0,0 +1,336 @@
+/*
+ * (C) Copyright 2015 Rockchip Electronics Co., Ltd
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+#ifndef _ASM_ARCH_SDRAM_RK3036_H
+#define _ASM_ARCH_SDRAM_RK3036_H
+
+#include 
+
+struct rk3036_ddr_pctl {
+   u32 scfg;
+   u32 sctl;
+   u32 stat;
+   u32 intrstat;
+   u32 reserved0[12];
+   u32 mcmd;
+   u32 powctl;
+   u32 powstat;
+   u32 cmdtstat;
+   u32 cmdtstaten;
+   u32 reserved1[3];
+   u32 mrrcfg0;
+   u32 mrrstat0;
+   u32 mrrstat1;
+   u32 reserved2[4];
+   u32 mcfg1;
+   u32 mcfg;
+   u32 ppcfg;
+   u32 mstat;
+   u32 lpddr2zqcfg;
+   u32 reserved3;
+   u32 dtupdes;
+   u32 dtuna;
+   u32 dtune;
+   u32 dtuprd0;
+   u32 dtuprd1;
+   u32 dtuprd2;
+   u32 dtuprd3;
+   u32 dtuawdt;
+   u32 reserved4[3];
+   u32 togcnt1u;
+   u32 tinit;
+   u32 trsth;
+   u32 togcnt100n;
+   u32 trefi;
+   u32 tmrd;
+   u32 trfc;
+   u32 trp;
+   u32 trtw;
+   u32 tal;
+   u32 tcl;
+   u32 tcwl;
+   u32 tras;
+   u32 trc;
+   u32 trcd;
+   u32 trrd;
+   u32 trtp;
+   u32 twr;
+   u32 twtr;
+   u32 texsr;
+   u32 txp;
+   u32 txpdll;
+   u32 tzqcs;
+   u32 tzqcsi;
+   u32 tdqs;
+   u32 tcksre;
+   u32 tcksrx;
+   u32 tcke;
+   u32 tmod;
+   u32 trstl;
+   u32 tzqcl;
+   u32 tmrr;
+   u32 tckesr;
+   u32 reserved5[47];
+   u32 dtuwactl;
+   u32 dturactl;
+   u32 dtucfg;
+   u32 dtuectl;
+   u32 dtuwd0;
+   u32 dtuwd1;
+   u32 dtuwd2;
+   u32 dtuwd3;
+   u32 dtuwdm;
+   u32 dturd0;
+   u32 dturd1;
+   u32 dturd2;
+   u32 dturd3;
+   u32 dtulfsrwd;
+   u32 dtulfsrrd;
+   u32 dtueaf;
+   u32 dfitctrldelay;
+   u32 dfiodtcfg;
+   u32 dfiodtcfg1;
+   u32 dfiodtrankmap;
+   u32 dfitphywrdata;
+   u32 dfitphywrlat;
+   u32 reserved7[2];
+   u32 dfitrddataen;
+   u32 dfitphyrdlat;
+   u32 reserved8[2];
+   u32 dfitphyupdtype0;
+   u32 dfitphyupdtype1;
+   u32 dfitphyupdtype2;
+   u32 dfitphyupdtype3;
+   u32 dfitctrlupdmin;
+   u32 dfitctrlupdmax;
+   u32 dfitctrlupddly;
+   u32 reserved9;
+   u32 dfiupdcfg;
+   u32 dfitrefmski;
+   u32 dfitctrlupdi;
+   u32 reserved10[4];
+   u32 dfitrcfg0;
+   u32 dfitrstat0;
+   u32 dfitrwrlvlen;
+   u32 dfitrrdlvlen;
+   u32 dfitrrdlvlgateen;
+   u32 dfiststat0;
+   u32 dfistcfg0;
+   u32 dfistcfg1;
+   u32 reserved11;
+   u32 dfitdramclken;
+   u32 dfitdramclkdis;
+   u32 dfistcfg2;
+   u32 dfistparclr;
+   u32 dfistparlog;
+   u32 reserved12[3];
+   u32 dfilpcfg0;
+   u32 reserved13[3];
+   u32 dfitrwrlvlresp0;
+   u32 dfitrwrlvlresp1;
+   u32 dfitrwrlvlresp2;
+   u32 dfitrrdlvlresp0;
+   u32 dfitrrdlvlresp1;
+   u32 dfitrrdlvlresp2;
+   u32 dfitrwrlvldelay0;
+   u32 dfitrwrlvldelay1;
+   u32 dfitrwrlvldelay2;
+   u32 dfitrrdlvldelay0;
+   u32 dfitrrdlvldelay1;
+   u32 dfitrrdlvldelay2;
+   u32 dfitrrdlvlgatedelay0;
+   u32 dfitrrdlvlgatedelay1;
+   u32 dfitrrdlvlgatedelay2;
+   u32 dfitrcmd;
+   u32 reserved14[46];
+   u32 ipvr;
+   u32 iptr;
+};
+check_member(rk3036_ddr_pctl, iptr, 0x03fc);
+
+struct rk3036_ddr_phy {
+   u32 ddrphy_reg1;
+   u32 ddrphy_reg3;
+   u32 ddrphy_reg2;
+   u32 reserve[11];
+   u32 ddrphy_reg4a;
+   u32 ddrphy_reg4b;
+   u32 reserve1[5];
+   u32 ddrphy_reg16;
+   u32 reserve2;
+   u32 ddrphy_reg18;
+   u32 ddrphy_reg19;
+   u32 reserve3;
+   u32 ddrphy_reg21;
+   u32 reserve4;
+   u32 ddrphy_reg22;
+   u32 reserve5[3];
+   u32 ddrphy_reg25;
+   u32 ddrphy_reg26;
+   u32 ddrphy_reg27;
+   u32 ddrphy_reg28;
+   u32 reserve6[17];
+   u32 ddrphy_reg6;
+   u32 

Re: [U-Boot] [PATCH] arm: socfpga: Fix cache configuration

2015-11-08 Thread Marek Vasut
On Thursday, September 17, 2015 at 05:30:29 PM, Stefan Roese wrote:

Hi!

> By not defining CONFIG_SYS_ARM_CACHE_WRITEALLOC, the WRITEBACK cache
> policy is selected. This leads to much better performance on the SoCFPGA.
> A quick network test shows this:
> 
> Without this patch:
> => tftp 10 big-40mb
> Speed: 1000, full duplex
> Using dwmac.ff702000 device
> TFTP from server 192.168.1.54; our IP address is 192.168.1.252
> Filename 'big-40mb'.
> Load address: 0x10
> Loading: #
>  #
>  #
>  #
>  ##
>  2.5 MiB/s
> 
> With this patch:
> => tftp 10 big-40mb
> Speed: 1000, full duplex
> Using dwmac.ff702000 device
> TFTP from server 192.168.1.54; our IP address is 192.168.1.252
> Filename 'big-40mb'.
> Load address: 0x10
> Loading: #
>  #
>  #
>  #
>  ##
>  7.6 MiB/s
> 
> A performance improvement of factor ~3.
> 
> Signed-off-by: Stefan Roese 
> Cc: Dinh Nguyen 
> Cc: Chin Liang See 
> Cc: Pavel Machek 
> Cc: Marek Vasut 
> ---
>  include/configs/socfpga_common.h | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/include/configs/socfpga_common.h
> b/include/configs/socfpga_common.h index 38ae763..a2811ba 100644
> --- a/include/configs/socfpga_common.h
> +++ b/include/configs/socfpga_common.h
> @@ -73,7 +73,6 @@
>  /*
>   * Cache
>   */
> -#define CONFIG_SYS_ARM_CACHE_WRITEALLOC
>  #define CONFIG_SYS_CACHELINE_SIZE 32
>  #define CONFIG_SYS_L2_PL310
>  #define CONFIG_SYS_PL310_BASESOCFPGA_MPUL2_ADDRESS

I hate to say it, but I am running into issues with this patch :-(

I use a standard USB stick here and with this patch, I am getting the following
failure (with enabled and disabled cache):

=> usb reset
resetting USB...
USB0:   Core Release: 2.93a
scanning bus 0 for devices... unable to get descriptor, error 0
usb_new_device: Cannot read configuration, skipping device 058f:6387
1 USB Device(s) found
   scanning usb for storage devices... 0 Storage Device(s) found
=> dcache off
=> usb reset 
resetting USB...
USB0:   Core Release: 2.93a
scanning bus 0 for devices... 2 USB Device(s) found
   scanning usb for storage devices... 1 Storage Device(s) found

If I revert this patch, my USB stick works as well.

I am also aware that Stefan mentions that without this patch, cache is not 
enabled at all. On the other hand, I cannot find any obviously faulty behavior
in the dwc2 driver, it does flush_dcache_range()/invalidate_dcache_range() in
the right places.

Any ideas please ?

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 v3 02/17] rockchip: move SYS_MALLOC_F_LEN to rk3288 own Kconfig

2015-11-08 Thread hl

Hi Simon,

On 06/11/15 20:08, Simon Glass wrote:

Hi,

On 6 November 2015 at 01:33, Lin Huang  wrote:

since different rockchip SOC have different size of SRAM,
So the size SYS_MALLOC_F_LEN may different, so move this
config to rk3288 own Kconfig

Signed-off-by: Lin Huang 
---
Changes in v1: None
Changes in v2: None
Changes in v3: None

  arch/arm/mach-rockchip/Kconfig| 3 ---
  arch/arm/mach-rockchip/rk3288/Kconfig | 3 +++
  2 files changed, 3 insertions(+), 3 deletions(-)

I thought I Acked this patch, and several others. To avoid me having
to review everything again, can you please pick those up and send a
new version?

i checked v1 patch,  you Ack several patchs, include:
 rockchip: Bring in RK3036 device tree file includes and bindings
 rockchip: rk3036: Add clock driver
 rockchip: rk3036: Add header files for GRF
 rockchip: rk3036: Add Soc reset driver
 rockchip: rk3036: Add a simple syscon driver
 rockchip: rk3036: Add pinctrl driver
but since we add the SPL stage,  it is a big move, so these patchs 
all have been modified,

and need your help to review again,

Regards,
Simon





--
Lin Huang

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


Re: [U-Boot] [PATCH v3 02/17] rockchip: move SYS_MALLOC_F_LEN to rk3288 own Kconfig

2015-11-08 Thread Simon Glass
Hi Lin,

On 8 November 2015 at 18:59, hl  wrote:
> Hi Simon,
>
> On 06/11/15 20:08, Simon Glass wrote:
>>
>> Hi,
>>
>> On 6 November 2015 at 01:33, Lin Huang  wrote:
>>>
>>> since different rockchip SOC have different size of SRAM,
>>> So the size SYS_MALLOC_F_LEN may different, so move this
>>> config to rk3288 own Kconfig
>>>
>>> Signed-off-by: Lin Huang 
>>> ---
>>> Changes in v1: None
>>> Changes in v2: None
>>> Changes in v3: None
>>>
>>>   arch/arm/mach-rockchip/Kconfig| 3 ---
>>>   arch/arm/mach-rockchip/rk3288/Kconfig | 3 +++
>>>   2 files changed, 3 insertions(+), 3 deletions(-)
>>
>> I thought I Acked this patch, and several others. To avoid me having
>> to review everything again, can you please pick those up and send a
>> new version?
>
> i checked v1 patch,  you Ack several patchs, include:
>  rockchip: Bring in RK3036 device tree file includes and bindings
>  rockchip: rk3036: Add clock driver
>  rockchip: rk3036: Add header files for GRF
>  rockchip: rk3036: Add Soc reset driver
>  rockchip: rk3036: Add a simple syscon driver
>  rockchip: rk3036: Add pinctrl driver
> but since we add the SPL stage,  it is a big move, so these patchs all
> have been modified,
> and need your help to review again,

OK - do you want me to do another pass now, or do you want to send a
new version first?

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


Re: [U-Boot] [PATCH 2/2] nios2: trim CONFIG_SYS_MEMTEST_END

2015-11-08 Thread Chin Liang See
Hi Thomas,

On Thu, 2015-11-05 at 13:47 +0800, tho...@wytron.com.tw wrote:
> Hi Chin Liang,
> 
> On 2015年11月04日 22:27, Chin Liang See wrote:
> >> +#define CONFIG_SYS_MEMTEST_END(CONFIG_SYS_MONITOR_BASE - \
> >> +   CONFIG_ENV_SIZE - \
> >> +   CONFIG_SYS_MALLOC_LEN -\
> >
> > Since CONFIG_ENV_IS_IN_FLASH, I believe we can take out the
> > CONFIG_ENV_SIZE here.
> >
> 
> This comes from a very old macro in common.h,
> 
> #if defined(CONFIG_ENV_IS_EMBEDDED)
> #define TOTAL_MALLOC_LEN  CONFIG_SYS_MALLOC_LEN
> #elif ( ((CONFIG_ENV_ADDR+CONFIG_ENV_SIZE) < CONFIG_SYS_MONITOR_BASE) || \
>   (CONFIG_ENV_ADDR >= (CONFIG_SYS_MONITOR_BASE + CONFIG_SYS_MONITOR_LEN)) 
> ) || \
>defined(CONFIG_ENV_IS_IN_NVRAM)
> #define   TOTAL_MALLOC_LEN(CONFIG_SYS_MALLOC_LEN + 
> CONFIG_ENV_SIZE)
> #else
> #define   TOTAL_MALLOC_LENCONFIG_SYS_MALLOC_LEN
> #endif
> 
> The TOTAL_MALLOC_LEN is (CONFIG_SYS_MALLOC_LEN + CONFIG_ENV_SIZE) for 
> nios2. I think the macro might need fix though.

Yah. In that case, it should be ok CONFIG_ENV_SIZE is much small. The
memtest should sufficiently exercise the each memory lines. Thanks again
for the patch.


Reviewed-by: Chin Liang See 

Thanks
Chin Liang


> 
> Best regards,
> Thomas

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


[U-Boot] [PATCH v2 12/26] sandbox: usb: Allow up to 4 emulated devices on a hub

2015-11-08 Thread Simon Glass
To support more advanced testing, support 4 devices instead of 2.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 drivers/usb/emul/sandbox_hub.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/emul/sandbox_hub.c b/drivers/usb/emul/sandbox_hub.c
index baf8bdc..624fbde 100644
--- a/drivers/usb/emul/sandbox_hub.c
+++ b/drivers/usb/emul/sandbox_hub.c
@@ -13,7 +13,7 @@
 DECLARE_GLOBAL_DATA_PTR;
 
 /* We only support up to 8 */
-#define SANDBOX_NUM_PORTS  2
+#define SANDBOX_NUM_PORTS  4
 
 struct sandbox_hub_platdata {
struct usb_dev_platdata plat;
-- 
2.6.0.rc2.230.g3dd15c0

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


[U-Boot] [PATCH v2 03/26] Move console definitions into a new console.h file

2015-11-08 Thread Simon Glass
The console includes a global variable and several functions that are only
used by a small subset of U-Boot files. Before adding more functions, move
the definitions into their own header file.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 arch/blackfin/lib/cmd_cache_dump.c |  1 +
 arch/powerpc/cpu/mpc8260/ether_fcc.c   |  1 +
 arch/powerpc/cpu/mpc8260/i2c.c |  1 +
 arch/powerpc/cpu/mpc8xx/i2c.c  |  1 +
 arch/sh/lib/board.c|  1 +
 arch/sparc/lib/board.c |  1 +
 board/Arcturus/ucp1020/spl.c   |  1 +
 board/astro/mcf5373l/fpga.c|  1 +
 board/cobra5272/flash.c|  1 +
 board/esd/common/cmd_loadpci.c |  1 +
 board/esd/cpci405/cpci405.c|  1 +
 board/esd/pmc405de/pmc405de.c  |  1 +
 board/esd/pmc440/cmd_pmc440.c  |  1 +
 board/esd/pmc440/pmc440.c  |  1 +
 board/esd/vme8349/caddy.c  |  1 +
 board/freescale/b4860qds/spl.c |  1 +
 board/freescale/c29xpcie/spl.c |  1 +
 board/freescale/mpc8569mds/mpc8569mds.c|  1 +
 board/freescale/p1010rdb/spl.c |  1 +
 board/freescale/p1022ds/spl.c  |  1 +
 board/freescale/p1_p2_rdb_pc/spl.c |  1 +
 board/freescale/t102xqds/spl.c |  1 +
 board/freescale/t102xrdb/spl.c |  1 +
 board/freescale/t104xrdb/spl.c |  1 +
 board/freescale/t208xqds/spl.c |  1 +
 board/freescale/t208xrdb/spl.c |  1 +
 board/freescale/t4qds/spl.c|  1 +
 board/freescale/t4rdb/spl.c|  1 +
 board/gdsys/common/cmd_ioloop.c|  1 +
 board/inka4x0/inkadiag.c   |  1 +
 board/lwmon5/kbd.c |  1 +
 board/mpl/common/kbd.c |  1 +
 board/mpl/pati/pati.c  |  1 +
 board/renesas/sh7785lcr/selfcheck.c|  1 +
 board/tqc/tqm5200/cmd_stk52xx.c|  1 +
 board/tqc/tqm5200/tqm5200.c|  1 +
 board/xes/xpedite1000/xpedite1000.c|  1 +
 common/autoboot.c  |  1 +
 common/board_f.c   |  1 +
 common/board_r.c   |  1 +
 common/cli.c   |  1 +
 common/cli_hush.c  |  1 +
 common/cli_simple.c|  1 +
 common/cmd_armflash.c  |  1 +
 common/cmd_dcr.c   |  1 +
 common/cmd_dfu.c   |  1 +
 common/cmd_fastboot.c  |  1 +
 common/cmd_fpgad.c |  1 +
 common/cmd_fuse.c  |  1 +
 common/cmd_i2c.c   |  1 +
 common/cmd_load.c  |  1 +
 common/cmd_mem.c   |  2 ++
 common/cmd_misc.c  |  1 +
 common/cmd_mmc.c   |  1 +
 common/cmd_nand.c  |  1 +
 common/cmd_nvedit.c|  1 +
 common/cmd_otp.c   |  1 +
 common/cmd_pci.c   |  1 +
 common/cmd_usb.c   |  1 +
 common/cmd_usb_mass_storage.c  |  1 +
 common/command.c   |  1 +
 common/console.c   |  1 +
 common/iomux.c |  1 +
 common/main.c  |  1 +
 common/usb_kbd.c   |  1 +
 drivers/block/fsl_sata.c   |  1 +
 drivers/fpga/ACEX1K.c  |  1 +
 drivers/fpga/virtex2.c |  1 +
 drivers/fpga/zynqpl.c  |  1 +
 drivers/i2c/adi_i2c.c  |  1 +
 drivers/input/input.c  |  1 +
 drivers/input/keyboard.c   |  1 +
 drivers/misc/cbmem_console.c   |  2 +-
 drivers/mtd/cfi_flash.c|  1 +
 drivers/mtd/nand/bfin_nand.c   |  1 +
 drivers/net/e1000_spi.c|  1 +
 drivers/net/keystone_net.c |  1 +
 drivers/net/phy/phy.c  |  1 +
 drivers/net/vsc7385.c  |  1 +
 drivers/power/battery/bat_trats.c  |  1 +
 drivers/spi/bfin_spi.c |  1 +
 drivers/spi/bfin_spi6xx.c  |  1 +
 drivers/spi/sh_qspi.c  |  1 +
 drivers/spi/sh_spi.c   |  1 +
 drivers/usb/gadget/ether.c |  1 +
 drivers/usb/gadget/f_mass_storage.c|  1 +
 drivers/usb/gadget/f_thor.c|  1 +
 drivers/usb/host/r8a66597-hcd.c|  1 +
 drivers/usb/musb-new/musb_uboot.c  |  1 +
 examples/standalone/mem_to_mem_idma2intr.c |  1 +
 examples/standalone/smc911x_eeprom.c   |  1 +
 include/common.h   | 17 -
 include/console.h   

[U-Boot] [PATCH v2 07/26] sandbox: Enable console recording and silent console

2015-11-08 Thread Simon Glass
Allow console recording so that tests can use it. Also allow the console
output to be suppressed, to reduce test output 'noise'.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 configs/sandbox_defconfig | 3 +++
 include/configs/sandbox.h | 1 +
 2 files changed, 4 insertions(+)

diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index 7fc8792..ac3cce2 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -69,3 +69,6 @@ CONFIG_REMOTEPROC_SANDBOX=y
 CONFIG_CMD_REMOTEPROC=y
 CONFIG_ADC=y
 CONFIG_ADC_SANDBOX=y
+CONFIG_CONSOLE_RECORD=y
+CONFIG_CONSOLE_RECORD_OUT_SIZE=0x1000
+CONFIG_SYS_MALLOC_F_LEN=0x2000
diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h
index 9e66da2..f52488b 100644
--- a/include/configs/sandbox.h
+++ b/include/configs/sandbox.h
@@ -66,6 +66,7 @@
 #define CONFIG_SYS_HUSH_PARSER
 #define CONFIG_SYS_LONGHELP/* #undef to save memory */
 #define CONFIG_SYS_CBSIZE  1024/* Console I/O Buffer Size */
+#define CONFIG_SILENT_CONSOLE
 
 /* Print Buffer Size */
 #define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE + sizeof(CONFIG_SYS_PROMPT) + 16)
-- 
2.6.0.rc2.230.g3dd15c0

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


[U-Boot] [PATCH v2 08/26] test: Record and silence console in tests

2015-11-08 Thread Simon Glass
When running sandbox tests, silence the console to avoid unwanted output.
Also, record the console in case tests want to check it.

The -v option can be used to enable stdout during tests.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 arch/sandbox/cpu/start.c | 8 
 arch/sandbox/include/asm/state.h | 1 +
 test/dm/test-main.c  | 9 +
 test/ut.c| 4 
 4 files changed, 22 insertions(+)

diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c
index 4c38fab..0dda4fc 100644
--- a/arch/sandbox/cpu/start.c
+++ b/arch/sandbox/cpu/start.c
@@ -257,6 +257,14 @@ static int sandbox_cmdline_cb_terminal(struct 
sandbox_state *state,
 SANDBOX_CMDLINE_OPT_SHORT(terminal, 't', 1,
  "Set terminal to raw/cooked mode");
 
+static int sandbox_cmdline_cb_verbose(struct sandbox_state *state,
+ const char *arg)
+{
+   state->show_test_output = true;
+   return 0;
+}
+SANDBOX_CMDLINE_OPT_SHORT(verbose, 'v', 0, "Show test output");
+
 int main(int argc, char *argv[])
 {
struct sandbox_state *state;
diff --git a/arch/sandbox/include/asm/state.h b/arch/sandbox/include/asm/state.h
index e876ba2..11856c2 100644
--- a/arch/sandbox/include/asm/state.h
+++ b/arch/sandbox/include/asm/state.h
@@ -64,6 +64,7 @@ struct sandbox_state {
bool reset_allowed[RESET_COUNT];/* Allowed reset types */
enum state_terminal_raw term_raw;   /* Terminal raw/cooked */
bool skip_delays;   /* Ignore any time delays (for test) */
+   bool show_test_output;  /* Don't suppress stdout in tests */
 
/* Pointer to information for each SPI bus/cs */
struct sandbox_spi_info spi[CONFIG_SANDBOX_SPI_MAX_BUS]
diff --git a/test/dm/test-main.c b/test/dm/test-main.c
index 867b517..91bdda8 100644
--- a/test/dm/test-main.c
+++ b/test/dm/test-main.c
@@ -76,6 +76,7 @@ static int dm_test_main(const char *test_name)
struct unit_test *tests = ll_entry_start(struct unit_test, dm_test);
const int n_ents = ll_entry_count(struct unit_test, dm_test);
struct unit_test_state *uts = _dm_test_state;
+   struct sandbox_state *state = state_get_current();
uts->priv = &_global_priv_dm_test_state;
struct unit_test *test;
int run_count;
@@ -114,7 +115,15 @@ static int dm_test_main(const char *test_name)
if (test->flags & DM_TESTF_SCAN_FDT)
ut_assertok(dm_scan_fdt(gd->fdt_blob, false));
 
+   /*
+* Silence the console and rely on console reocrding to get
+* our output.
+*/
+   console_record_reset();
+   if (!state->show_test_output)
+   gd->flags |= GD_FLG_SILENT;
test->func(uts);
+   gd->flags &= ~GD_FLG_SILENT;
state_set_skip_delays(false);
 
ut_assertok(dm_test_destroy(uts));
diff --git a/test/ut.c b/test/ut.c
index 0282de5..fa0f02d 100644
--- a/test/ut.c
+++ b/test/ut.c
@@ -10,9 +10,12 @@
 #include 
 #include 
 
+DECLARE_GLOBAL_DATA_PTR;
+
 void ut_fail(struct unit_test_state *uts, const char *fname, int line,
 const char *func, const char *cond)
 {
+   gd->flags &= ~(GD_FLG_SILENT | GD_FLG_RECORD);
printf("%s:%d, %s(): %s\n", fname, line, func, cond);
uts->fail_count++;
 }
@@ -22,6 +25,7 @@ void ut_failf(struct unit_test_state *uts, const char *fname, 
int line,
 {
va_list args;
 
+   gd->flags &= ~(GD_FLG_SILENT | GD_FLG_RECORD);
printf("%s:%d, %s(): %s: ", fname, line, func, cond);
va_start(args, fmt);
vprintf(fmt, args);
-- 
2.6.0.rc2.230.g3dd15c0

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


[U-Boot] [PATCH v2 06/26] console: Add a console buffer

2015-11-08 Thread Simon Glass
It is useful to be able to record console output and provide console input
via a buffer. This provides sandbox with the ability to run a command and
check its output. If the console is set to silent then no visible output
is generated.

This also provides a means to fix the problem where tests produce unwanted
output, such as errors or warnings. This can be confusing. We can instead
set the console to silent and record this output. It can be checked later
in the test if required.

It is possible that this may prove useful for non-test situations. For
example the console output may be suppressed for normal operations, but
recorded and stored for access by the OS. That feature is not implemented
at present.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 common/Kconfig| 28 ++
 common/board_f.c  | 10 
 common/board_r.c  | 10 
 common/console.c  | 50 ++-
 include/asm-generic/global_data.h |  6 +
 include/console.h | 22 +
 6 files changed, 125 insertions(+), 1 deletion(-)

diff --git a/common/Kconfig b/common/Kconfig
index 0388a6c..d56d950 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -659,3 +659,31 @@ config CMD_TPM_TEST
 endmenu
 
 endmenu
+
+config CONSOLE_RECORD
+   bool "Console recording"
+   help
+ This provides a way to record console output (and provide console
+ input) through cirular buffers. This is mostly useful for testing.
+ Console output is recorded even when the console is silent.
+ To enable console recording, call console_record_reset_enable()
+ from your code.
+
+config CONSOLE_RECORD_OUT_SIZE
+   hex "Output buffer size"
+   depends on CONSOLE_RECORD
+   default 0x400 if CONSOLE_RECORD
+   help
+ Set the size of the console output buffer. When this fills up, no
+ more data will be recorded until some is removed. The buffer is
+ allocated immediately after the malloc() region is ready.
+
+config CONSOLE_RECORD_IN_SIZE
+   hex "Input buffer size"
+   depends on CONSOLE_RECORD
+   default 0x100 if CONSOLE_RECORD
+   help
+ Set the size of the console input buffer. When this contains data,
+ tstc() and getc() will use this in preference to real device input.
+ The buffer is allocated immediately after the malloc() region is
+ ready.
diff --git a/common/board_f.c b/common/board_f.c
index dbb987f..62d86dd 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -737,6 +737,15 @@ static int mark_bootstage(void)
return 0;
 }
 
+static int initf_console_record(void)
+{
+#if defined(CONFIG_CONSOLE_RECORD) && defined(CONFIG_SYS_MALLOC_F_LEN)
+   return console_record_init();
+#else
+   return 0;
+#endif
+}
+
 static int initf_dm(void)
 {
 #if defined(CONFIG_DM) && defined(CONFIG_SYS_MALLOC_F_LEN)
@@ -773,6 +782,7 @@ static init_fnc_t init_sequence_f[] = {
trace_early_init,
 #endif
initf_malloc,
+   initf_console_record,
 #if defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx)
/* TODO: can this go into arch_cpu_init()? */
probecpu,
diff --git a/common/board_r.c b/common/board_r.c
index 5a46b47..f236ffd 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -277,6 +277,15 @@ static int initr_malloc(void)
return 0;
 }
 
+static int initr_console_record(void)
+{
+#if defined(CONFIG_CONSOLE_RECORD)
+   return console_record_init();
+#else
+   return 0;
+#endif
+}
+
 #ifdef CONFIG_SYS_NONCACHED_MEMORY
 static int initr_noncached(void)
 {
@@ -716,6 +725,7 @@ init_fnc_t init_sequence_r[] = {
 #endif
initr_barrier,
initr_malloc,
+   initr_console_record,
 #ifdef CONFIG_SYS_NONCACHED_MEMORY
initr_noncached,
 #endif
diff --git a/common/console.c b/common/console.c
index 10972b0..b3f126c 100644
--- a/common/console.c
+++ b/common/console.c
@@ -378,6 +378,15 @@ int getc(void)
if (!gd->have_console)
return 0;
 
+#ifdef CONFIG_CONSOLE_RECORD
+   if (gd->console_in.start) {
+   int ch;
+
+   ch = membuff_getbyte(>console_in);
+   if (ch != -1)
+   return 1;
+   }
+#endif
if (gd->flags & GD_FLG_DEVINIT) {
/* Get from the standard input */
return fgetc(stdin);
@@ -396,7 +405,12 @@ int tstc(void)
 
if (!gd->have_console)
return 0;
-
+#ifdef CONFIG_CONSOLE_RECORD
+   if (gd->console_in.start) {
+   if (membuff_peekbyte(>console_in) != -1)
+   return 1;
+   }
+#endif
if (gd->flags & GD_FLG_DEVINIT) {
/* Test the standard input */
return ftstc(stdin);
@@ -470,6 +484,10 @@ void putc(const char c)
return;
}
 #endif
+#ifdef 

Re: [U-Boot] [PATCH v2] mtd: add altera quadspi driver

2015-11-08 Thread Thomas Chou



On 2015年11月09日 14:52, Thomas Chou wrote:

v2
   change memory alllocation macros.
   add altera_qspi support.


Sorry, wrong patch. Please ignore this one.

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


Re: [U-Boot] [PATCH v4 7/7] board: ti: AM57xx: Add detection logic for AM57xx-evm

2015-11-08 Thread Tom Rini
On Thu, Nov 05, 2015 at 06:39:36PM -0600, Steve Kipisz wrote:

> Current AM57xx evm supports both BeagleBoard-X15
> (http://beagleboard.org/x15) and AM57xx EVM
> (http://www.ti.com/tool/tmdxevm5728).
> 
> The AM572x EValuation Module(EVM) provides an affordable platform to
> quickly start evaluation of Sitara. ARM Cortex-A15 AM57x Processors
> (AM5728, AM5726, AM5718, AM5716) and accelerate development for HMI,
> machine vision, networking, medical imaging and many other industrial
> applications. This EVM is based on the same BeagleBoard-X15 Chassis
> and adds mPCIe, mSATA, LCD, touchscreen, Camera, push button and TI's
> wlink8 offering.
> 
> Since the EEPROM contents are compatible between the BeagleBoard-X15 and
> the AM57xx-evm, we add support for the detection logic to enable
> support for various user programmable scripting capability.
> 
> NOTE: U-boot configuration is currently a superset of AM57xx evm and
> BeagleBoard-X15 and no additional configuration tweaking is needed.
> 
> This change also sets up the stage for future support of TI AM57xx EVMs
> to the same base bootloader build.
> 
> Signed-off-by: Steve Kipisz 

Reviewed-by: Tom Rini 

-- 
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 v4 4/7] ti: am335x: Use generic EEPROM detection logic

2015-11-08 Thread Tom Rini
On Thu, Nov 05, 2015 at 06:39:33PM -0600, Steve Kipisz wrote:

> From: Nishanth Menon 
> 
> Use the generic EEPROM detection logic instead of duplicating the AM
> eeprom logic.
> 
> Signed-off-by: Nishanth Menon 
> Signed-off-by: Steven Kipisz 

Reviewed-by: Tom Rini 

-- 
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 v2 17/26] dm: usb: Deprecate usb_get_dev_index()

2015-11-08 Thread Simon Glass
This function should not be used with driver model. While there are users
of USB Ethernet that use driver model for USB but not Ethernet, we have
to keep it around. Add a comment to that effect.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 drivers/usb/host/usb-uclass.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/drivers/usb/host/usb-uclass.c b/drivers/usb/host/usb-uclass.c
index 89611f1..4aa92f8 100644
--- a/drivers/usb/host/usb-uclass.c
+++ b/drivers/usb/host/usb-uclass.c
@@ -279,6 +279,14 @@ int usb_init(void)
return usb_started ? 0 : -1;
 }
 
+/*
+ * TODO(s...@chromium.org): Remove this legacy function. At present it is 
needed
+ * to support boards which use driver model for USB but not Ethernet, and want
+ * to use USB Ethernet.
+ *
+ * The #if clause is here to ensure that remains the only case.
+ */
+#if !defined(CONFIG_DM_ETH) && defined(CONFIG_USB_HOST_ETHER)
 static struct usb_device *find_child_devnum(struct udevice *parent, int devnum)
 {
struct usb_device *udev;
@@ -312,6 +320,7 @@ struct usb_device *usb_get_dev_index(struct udevice *bus, 
int index)
 
return find_child_devnum(dev, devnum);
 }
+#endif
 
 int usb_post_bind(struct udevice *dev)
 {
-- 
2.6.0.rc2.230.g3dd15c0

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


[U-Boot] [PATCH v2 20/26] dm: test: usb: Add a test for device reordering

2015-11-08 Thread Simon Glass
Add tests that 'usb tree' produces the right output when a device changes
order on the bus.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 test/dm/usb.c | 50 ++
 1 file changed, 50 insertions(+)

diff --git a/test/dm/usb.c b/test/dm/usb.c
index 721d3ad..fb193e8 100644
--- a/test/dm/usb.c
+++ b/test/dm/usb.c
@@ -208,3 +208,53 @@ static int dm_test_usb_tree_remove(struct unit_test_state 
*uts)
return 0;
 }
 DM_TEST(dm_test_usb_tree_remove, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
+const char usb_tree_reorder[] =
+"  1  Hub (12 Mb/s, 100mA)\n"
+"  |  sandbox hub 2345\n"
+"  |\n"
+"  |\b+-2  Mass Storage (12 Mb/s, 100mA)\n"
+"  |sandbox flash flash-stick@0\n"
+"  |  \n"
+"  |\b+-3  Mass Storage (12 Mb/s, 100mA)\n"
+"  |sandbox flash flash-stick@2\n"
+"  |  \n"
+"  |\b+-4  Mass Storage (12 Mb/s, 100mA)\n"
+"   sandbox flash flash-stick@1\n"
+" \n";
+
+/*
+ * test that the 'usb tree' command output looks correct when we reorder two
+ * devices.
+ */
+static int dm_test_usb_tree_reorder(struct unit_test_state *uts)
+{
+   struct udevice *dev, *parent;
+   char *data;
+   int len;
+
+   /* Remove the second emulation device */
+   ut_assertok(uclass_find_device_by_name(UCLASS_USB_EMUL, "flash-stick@1",
+  ));
+   parent = dev->parent;
+
+   /* Reorder the devices in the parent list and uclass list */
+   list_del(>sibling_node);
+   list_add_tail(>sibling_node, >child_head);
+
+   list_del(>uclass_node);
+   list_add_tail(>uclass_node, >uclass->dev_head);
+
+   state_set_skip_delays(true);
+   ut_assertok(usb_init());
+   console_record_reset_enable();
+   usb_show_tree();
+   len = membuff_getraw(>console_out, -1, true, );
+   if (len)
+   data[len] = '\0';
+   ut_asserteq_str(usb_tree_reorder, data);
+   ut_assertok(usb_stop());
+
+   return 0;
+}
+DM_TEST(dm_test_usb_tree_reorder, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
-- 
2.6.0.rc2.230.g3dd15c0

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


[U-Boot] [PATCH v2] mtd: add altera quadspi driver

2015-11-08 Thread Thomas Chou
Add Altera Generic Quad SPI Controller support. The controller
converts SPI NOR flash to parallel flash interface. So it is
not like other SPI flash, but rather like CFI flash.

Signed-off-by: Thomas Chou 
---
v2
  change memory alllocation macros.
  add altera_qspi support.

 doc/device-tree-bindings/mtd/altera_qspi.txt |  35 
 drivers/mtd/Kconfig  |   9 +
 drivers/mtd/Makefile |   1 +
 drivers/mtd/altera_qspi.c| 273 +++
 4 files changed, 318 insertions(+)
 create mode 100644 doc/device-tree-bindings/mtd/altera_qspi.txt
 create mode 100644 drivers/mtd/altera_qspi.c

diff --git a/doc/device-tree-bindings/mtd/altera_qspi.txt 
b/doc/device-tree-bindings/mtd/altera_qspi.txt
new file mode 100644
index 000..3361ac9
--- /dev/null
+++ b/doc/device-tree-bindings/mtd/altera_qspi.txt
@@ -0,0 +1,35 @@
+Altera QUADSPI driver
+
+Required properties:
+- compatible: Should be "altr,quadspi-1.0"
+- reg: Address and length of the register set  for the device. It contains
+  the information of registers in the same order as described by reg-names
+- reg-names: Should contain the reg names
+  "avl_csr": Should contain the register configuration base address
+  "avl_mem": Should contain the data base address
+- #address-cells: Must be <1>.
+- #size-cells: Must be <0>.
+- flash device tree subnode, there must be a node with the following fields:
+   - compatible: Should contain the flash name:
+ 1. EPCS:   epcs16, epcs64, epcs128
+ 2. EPCQ:   epcq16, epcq32, epcq64, epcq128, epcq256, epcq512, epcq1024
+ 3. EPCQ-L: epcql256, epcql512, epcql1024
+   - #address-cells: please refer to /mtd/partition.txt
+   - #size-cells: please refer to /mtd/partition.txt
+   For partitions inside each flash, please refer to /mtd/partition.txt
+
+Example:
+
+   quadspi_controller_0: quadspi@0x180014a0 {
+   compatible = "altr,quadspi-1.0";
+   reg = <0x180014a0 0x0020>,
+ <0x1400 0x0400>;
+   reg-names = "avl_csr", "avl_mem";
+   #address-cells = <1>;
+   #size-cells = <0>;
+   flash0: epcq512@0 {
+   compatible = "altr,epcq512";
+   #address-cells = <1>;
+   #size-cells = <1>;
+   };
+   };
diff --git a/drivers/mtd/Kconfig b/drivers/mtd/Kconfig
index 57e4b86..c58841e 100644
--- a/drivers/mtd/Kconfig
+++ b/drivers/mtd/Kconfig
@@ -19,6 +19,15 @@ config CFI_FLASH
  option. Visit 
  for more information on CFI.
 
+config ALTERA_QSPI
+   bool "Altera Generic Quad SPI Controller"
+   depends on MTD
+   help
+ This enables access to Altera EPCQ/EPCS flash chips using the
+ Altera Generic Quad SPI Controller. The controller converts SPI
+ NOR flash to parallel flash interface. Please find details on the
+ "Embedded Peripherals IP User Guide" of Altera.
+
 endmenu
 
 source "drivers/mtd/nand/Kconfig"
diff --git a/drivers/mtd/Makefile b/drivers/mtd/Makefile
index c23c0c1..7f018a4 100644
--- a/drivers/mtd/Makefile
+++ b/drivers/mtd/Makefile
@@ -11,6 +11,7 @@ endif
 obj-$(CONFIG_MTD) += mtd-uclass.o
 obj-$(CONFIG_MTD_PARTITIONS) += mtdpart.o
 obj-$(CONFIG_MTD_CONCAT) += mtdconcat.o
+obj-$(CONFIG_ALTERA_QSPI) += altera_qspi.o
 obj-$(CONFIG_HAS_DATAFLASH) += at45.o
 obj-$(CONFIG_FLASH_CFI_DRIVER) += cfi_flash.o
 obj-$(CONFIG_FLASH_CFI_MTD) += cfi_mtd.o
diff --git a/drivers/mtd/altera_qspi.c b/drivers/mtd/altera_qspi.c
new file mode 100644
index 000..1826dc8
--- /dev/null
+++ b/drivers/mtd/altera_qspi.c
@@ -0,0 +1,273 @@
+/*
+ * Copyright (C) 2015 Thomas Chou 
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
+
+/*
+ * The QUADSPI_MEM_OP register is used to do memory protect and erase 
operations
+ */
+#define QUADSPI_MEM_OP_BULK_ERASE  0x0001
+#define QUADSPI_MEM_OP_SECTOR_ERASE0x0002
+#define QUADSPI_MEM_OP_SECTOR_PROTECT  0x0003
+
+/*
+ * The QUADSPI_ISR register is used to determine whether an invalid write or
+ * erase operation trigerred an interrupt
+ */
+#define QUADSPI_ISR_ILLEGAL_ERASE  BIT(0)
+#define QUADSPI_ISR_ILLEGAL_WRITE  BIT(1)
+
+struct altera_qspi_regs {
+   u32 rd_status;
+   u32 rd_sid;
+   u32 rd_rdid;
+   u32 mem_op;
+   u32 isr;
+   u32 imr;
+   u32 chip_select;
+};
+
+struct altera_qspi_platdata {
+   struct altera_qspi_regs *regs;
+   void *base;
+   unsigned long size;
+};
+
+flash_info_t flash_info[CONFIG_SYS_MAX_FLASH_BANKS];   /* FLASH chips info */
+
+void flash_print_info(flash_info_t *info)
+{
+   

[U-Boot] [PATCH v2 22/26] usb: Avoid open-coded USB constants in usb_kbd.c

2015-11-08 Thread Simon Glass
Replace the open-coded values with constants to make it clearer what they
mean.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 common/usb_kbd.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/common/usb_kbd.c b/common/usb_kbd.c
index 1d85212..069fbd2 100644
--- a/common/usb_kbd.c
+++ b/common/usb_kbd.c
@@ -411,13 +411,13 @@ static int usb_kbd_probe_dev(struct usb_device *dev, 
unsigned int ifnum)
 
iface = >config.if_desc[ifnum];
 
-   if (iface->desc.bInterfaceClass != 3)
+   if (iface->desc.bInterfaceClass != USB_CLASS_HID)
return 0;
 
-   if (iface->desc.bInterfaceSubClass != 1)
+   if (iface->desc.bInterfaceSubClass != USB_SUB_HID_BOOT)
return 0;
 
-   if (iface->desc.bInterfaceProtocol != 1)
+   if (iface->desc.bInterfaceProtocol != USB_PROT_HID_KEYBOARD)
return 0;
 
if (iface->desc.bNumEndpoints != 1)
@@ -626,8 +626,8 @@ static const struct usb_device_id kbd_id_table[] = {
USB_DEVICE_ID_MATCH_INT_SUBCLASS |
USB_DEVICE_ID_MATCH_INT_PROTOCOL,
.bInterfaceClass = USB_CLASS_HID,
-   .bInterfaceSubClass = 1,
-   .bInterfaceProtocol = 1,
+   .bInterfaceSubClass = USB_SUB_HID_BOOT,
+   .bInterfaceProtocol = USB_PROT_HID_KEYBOARD,
},
{ } /* Terminating entry */
 };
-- 
2.6.0.rc2.230.g3dd15c0

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


[U-Boot] [PATCH v2 25/26] sandbox: Enable USB keyboard

2015-11-08 Thread Simon Glass
Enable the USB keyboard on sandbox, now that we have a suitable emulation
driver.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 configs/sandbox_defconfig | 2 ++
 include/configs/sandbox.h | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index ac3cce2..d1f10d5 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -72,3 +72,5 @@ CONFIG_ADC_SANDBOX=y
 CONFIG_CONSOLE_RECORD=y
 CONFIG_CONSOLE_RECORD_OUT_SIZE=0x1000
 CONFIG_SYS_MALLOC_F_LEN=0x2000
+CONFIG_USB_KEYBOARD=y
+CONFIG_SYS_USB_EVENT_POLL=y
diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h
index f52488b..c89bc5a 100644
--- a/include/configs/sandbox.h
+++ b/include/configs/sandbox.h
@@ -178,7 +178,7 @@
 
 #define CONFIG_KEYBOARD
 
-#define SANDBOX_SERIAL_SETTINGS"stdin=serial,cros-ec-keyb\0" \
+#define SANDBOX_SERIAL_SETTINGS
"stdin=serial,cros-ec-keyb,usbkbd\0" \
"stdout=serial,lcd\0" \
"stderr=serial,lcd\0"
 #else
-- 
2.6.0.rc2.230.g3dd15c0

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


[U-Boot] [PATCH v2 23/26] usb: sandbox: Add support for interrupt operations

2015-11-08 Thread Simon Glass
Allow USB device emulation to support interrupt URBs so that we can use USB
keyboards with sandbox.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 drivers/usb/emul/usb-emul-uclass.c | 12 
 drivers/usb/host/usb-sandbox.c | 19 +++
 include/usb.h  | 11 +++
 3 files changed, 42 insertions(+)

diff --git a/drivers/usb/emul/usb-emul-uclass.c 
b/drivers/usb/emul/usb-emul-uclass.c
index 6b5f3c0..ee7ea5a 100644
--- a/drivers/usb/emul/usb-emul-uclass.c
+++ b/drivers/usb/emul/usb-emul-uclass.c
@@ -218,6 +218,18 @@ int usb_emul_bulk(struct udevice *emul, struct usb_device 
*udev,
return ops->bulk(emul, udev, pipe, buffer, length);
 }
 
+int usb_emul_int(struct udevice *emul, struct usb_device *udev,
+ unsigned long pipe, void *buffer, int length, int interval)
+{
+   struct dm_usb_ops *ops = usb_get_emul_ops(emul);
+
+   if (!ops->interrupt)
+   return -ENOSYS;
+   debug("%s: dev=%s\n", __func__, emul->name);
+
+   return ops->interrupt(emul, udev, pipe, buffer, length, interval);
+}
+
 int usb_emul_setup_device(struct udevice *dev, int maxpacketsize,
  struct usb_string *strings, void **desc_list)
 {
diff --git a/drivers/usb/host/usb-sandbox.c b/drivers/usb/host/usb-sandbox.c
index c5f9822..5e3d96c 100644
--- a/drivers/usb/host/usb-sandbox.c
+++ b/drivers/usb/host/usb-sandbox.c
@@ -87,6 +87,24 @@ static int sandbox_submit_bulk(struct udevice *bus, struct 
usb_device *udev,
return ret;
 }
 
+static int sandbox_submit_int(struct udevice *bus, struct usb_device *udev,
+ unsigned long pipe, void *buffer, int length,
+ int interval)
+{
+   struct udevice *emul;
+   int ret;
+
+   /* Just use child of dev as emulator? */
+   debug("%s: bus=%s\n", __func__, bus->name);
+   ret = usb_emul_find(bus, pipe, );
+   usbmon_trace(bus, pipe, NULL, emul);
+   if (ret)
+   return ret;
+   ret = usb_emul_int(emul, udev, pipe, buffer, length, interval);
+
+   return ret;
+}
+
 static int sandbox_alloc_device(struct udevice *dev, struct usb_device *udev)
 {
return 0;
@@ -100,6 +118,7 @@ static int sandbox_usb_probe(struct udevice *dev)
 static const struct dm_usb_ops sandbox_usb_ops = {
.control= sandbox_submit_control,
.bulk   = sandbox_submit_bulk,
+   .interrupt  = sandbox_submit_int,
.alloc_device   = sandbox_alloc_device,
 };
 
diff --git a/include/usb.h b/include/usb.h
index d684531..55b9268 100644
--- a/include/usb.h
+++ b/include/usb.h
@@ -938,6 +938,17 @@ int usb_emul_bulk(struct udevice *emul, struct usb_device 
*udev,
  unsigned long pipe, void *buffer, int length);
 
 /**
+ * usb_emul_int() - Send an interrupt packet to an emulator
+ *
+ * @emul:  Emulator device
+ * @udev:  USB device (which the emulator is causing to appear)
+ * See struct dm_usb_ops for details on other parameters
+ * @return 0 if OK, -ve on error
+ */
+int usb_emul_int(struct udevice *emul, struct usb_device *udev,
+ unsigned long pipe, void *buffer, int length, int interval);
+
+/**
  * usb_emul_find() - Find an emulator for a particular device
  *
  * Check @pipe to find a device number on bus @bus and return it.
-- 
2.6.0.rc2.230.g3dd15c0

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


[U-Boot] [RFC PATCH v2 01/11] Initial net6.h

2015-11-08 Thread Chris Packham
The initial net6.h just has the definition of an IPv6 address and IPv6
header. Subsequent changes will build on this.

Signed-off-by: Chris Packham 

---

Changes in v2: None

 include/net6.h | 48 
 1 file changed, 48 insertions(+)
 create mode 100644 include/net6.h

diff --git a/include/net6.h b/include/net6.h
new file mode 100644
index 000..b622951
--- /dev/null
+++ b/include/net6.h
@@ -0,0 +1,48 @@
+/**
+ * Simple IPv6 network layer implementation.
+ *
+ * Based and/or adapted from the IPv4 network layer in net.[hc]
+ *
+ * (C) Copyright 2013 Allied Telesis Labs NZ
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+#ifndef __NET6_H__
+#define __NET6_H__
+
+struct in6_addr {
+   union {
+   __u8u6_addr8[16];
+   __be16  u6_addr16[8];
+   __be32  u6_addr32[4];
+   } in6_u;
+
+#define s6_addrin6_u.u6_addr8
+#define s6_addr16  in6_u.u6_addr16
+#define s6_addr32  in6_u.u6_addr32
+};
+
+/**
+ * struct ipv6hdr - Internet Protocol V6 (IPv6) header.
+ *
+ * IPv6 packet header as defined in RFC 2460.
+ */
+struct ip6_hdr {
+#if defined(__LITTLE_ENDIAN_BITFIELD)
+   __u8priority:4,
+   version:4;
+#elif defined(__BIG_ENDIAN_BITFIELD)
+   __u8version:4,
+   priority:4;
+#else
+#error  "Please fix "
+#endif
+   __u8flow_lbl[3];
+   __be16  payload_len;
+   __u8nexthdr;
+   __u8hop_limit;
+   struct in6_addr saddr;
+   struct in6_addr daddr;
+};
+
+#endif /* __NET6_H__ */
-- 
2.5.3

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


[U-Boot] [RFC PATCH v2 02/11] lib: vsprintf: add IPv6 compressed format %pI6c

2015-11-08 Thread Chris Packham
Add support for "human friendly" IPv6 address representations as
specified in
http://tools.ietf.org/html/draft-ietf-6man-text-addr-representation-00

This code has been adapted from Linux kernel with minimal modification.

Signed-off-by: Chris Packham 
---

Changes in v2: None

 include/net6.h |  13 +
 lib/vsprintf.c | 154 -
 2 files changed, 144 insertions(+), 23 deletions(-)

diff --git a/include/net6.h b/include/net6.h
index b622951..1b82c25 100644
--- a/include/net6.h
+++ b/include/net6.h
@@ -45,4 +45,17 @@ struct ip6_hdr {
struct in6_addr daddr;
 };
 
+/* :::0:0/96 is reserved for v4 mapped addresses */
+static inline int ipv6_addr_v4mapped(const struct in6_addr *a)
+{
+   return (a->s6_addr32[0] | a->s6_addr32[1] |
+   (a->s6_addr32[2] ^ htonl(0x))) == 0;
+}
+
+/* Intra-Site Automatic Tunnel Addressing Protocol Address */
+static inline int ipv6_addr_is_isatap(const struct in6_addr *a)
+{
+   return (a->s6_addr32[2] | htonl(0x0200)) == htonl(0x02005EFE);
+}
+
 #endif /* __NET6_H__ */
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 4c82837..2baac47 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -23,6 +23,7 @@
 #endif
 
 #include 
+#include 
 #define noinline __attribute__((noinline))
 
 unsigned long simple_strtoul(const char *cp, char **endp,
@@ -304,6 +305,7 @@ static noinline char *put_dec(char *buf, uint64_t num)
 #define LEFT   16  /* left justified */
 #define SMALL  32  /* Must be 32 == 0x20 */
 #define SPECIAL64  /* 0x */
+#define COMPRESSED 128 /* use compressed format */
 
 #ifdef CONFIG_SYS_VSNPRINTF
 /*
@@ -469,12 +471,121 @@ static char *mac_address_string(char *buf, char *end, u8 
*addr, int field_width,
  flags & ~SPECIAL);
 }
 
-static char *ip6_addr_string(char *buf, char *end, u8 *addr, int field_width,
+static char *ip4_string(char *p, u8 *addr)
+{
+   char temp[3];   /* hold each IP quad in reverse order */
+   int i, digits;
+
+   for (i = 0; i < 4; i++) {
+   digits = put_dec_trunc(temp, addr[i]) - temp;
+   /* reverse the digits in the quad */
+   while (digits--)
+   *p++ = temp[digits];
+   if (i != 3)
+   *p++ = '.';
+   }
+   *p = '\0';
+
+   return p;
+}
+
+static char *ip4_addr_string(char *buf, char *end, u8 *addr, int field_width,
 int precision, int flags)
 {
-   /* (8 * 4 hex digits), 7 colons and trailing zero */
-   char ip6_addr[8 * 5];
-   char *p = ip6_addr;
+   char ip4_addr[sizeof("255.255.255.255")];
+
+   ip4_string(ip4_addr, addr);
+
+   return string(buf, end, ip4_addr, field_width, precision,
+ flags & ~SPECIAL);
+}
+#endif
+
+#ifdef CONFIG_NET6
+static char *ip6_compressed_string(char *p, u8 *addr)
+{
+   int i, j, range;
+   unsigned char zerolength[8];
+   int longest = 1;
+   int colonpos = -1;
+   u16 word;
+   u8 hi, lo;
+   int needcolon = 0;
+   int useIPv4;
+   struct in6_addr in6;
+
+   memcpy(, addr, sizeof(struct in6_addr));
+
+   useIPv4 = ipv6_addr_v4mapped() || ipv6_addr_is_isatap();
+
+   memset(zerolength, 0, sizeof(zerolength));
+
+   if (useIPv4)
+   range = 6;
+   else
+   range = 8;
+
+   /* find position of longest 0 run */
+   for (i = 0; i < range; i++) {
+   for (j = i; j < range; j++) {
+   if (in6.s6_addr16[j] != 0)
+   break;
+   zerolength[i]++;
+   }
+   }
+   for (i = 0; i < range; i++) {
+   if (zerolength[i] > longest) {
+   longest = zerolength[i];
+   colonpos = i;
+   }
+   }
+   if (longest == 1)   /* don't compress a single 0 */
+   colonpos = -1;
+
+   /* emit address */
+   for (i = 0; i < range; i++) {
+   if (i == colonpos) {
+   if (needcolon || i == 0)
+   *p++ = ':';
+   *p++ = ':';
+   needcolon = 0;
+   i += longest - 1;
+   continue;
+   }
+   if (needcolon) {
+   *p++ = ':';
+   needcolon = 0;
+   }
+   /* hex u16 without leading 0s */
+   word = ntohs(in6.s6_addr16[i]);
+   hi = word >> 8;
+   lo = word & 0xff;
+   if (hi) {
+   if (hi > 0x0f)
+   p = pack_hex_byte(p, hi);
+   else
+   *p++ = hex_asc_lo(hi);
+   p = pack_hex_byte(p, lo);
+   } 

[U-Boot] [RFC PATCH v2 00/11] IPv6 support

2015-11-08 Thread Chris Packham
This series adds basic IPv6 support to U-boot. It is a reboot of my
earlier work on this[1].

Most of this is ported from Allied Telesis' additions to u-boot[2].
(Note that I am employed by Allied Telesis[3]). The hard work was done
some time ago by Angga, I've cleaned it up and made some improvements
with the hope of getting it accepted upstream.

This is still very much a work in progress but it is functional. If anyone is
willing/able to test on some other hardware I'd appreciate some feedback.

If it's helpful for testing I'm keeping the 'ipv6' branch of
https://github.com/cpackham/u-boot.git up to date with these changes.

A few open issues

1) rxhand_f currently takes an struct in_addr. TFTP doesn't use this
(I haven't looked at other users). To support V6 this may need to be a
new union, a void * with some kind of flag or nothing if no rxhandler
actually cares. It has been suggested that this parameter be removed and
any users that care can re-parse the packet.

2) Unit tests. This code needs them. The testing so-far has been ad-hoc
manual testing using qemu-x86.

3) Fancy v6 feature xyz. There are a lot of things that _could_ be
implemented on top of this (DHCPV6 and SLAAC are two obvious things that
stick out). For now I want to concentrate on getting the core code
stable and accepted, if anyone else wants to work on either of those
features that'd be great.

--
[1] - http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/151390
[2] - http://www.alliedtelesis.co.nz/support/gpl/other.html
[3] - some of this has been done on work time, other parts have been
  done in my personal time. Since I'm subscribed to the list using
  my gmail account I've signed using that.


Changes in v2:
- Split environment variables from main implementation
- remove "prefixlength6" environment variable. The prefix length is now
  set when specifying the address i.e. setenv ip6addr 2001:db8::1/64.
- split ping6 support into separate patch
- split environment variables into separate patch
- change ip6_ndisc_* to ndisc_*, fix CamelCase
- split ping6 support into it's own patch

Chris Packham (11):
  Initial net6.h
  lib: vsprintf: add IPv6 compressed format %pI6c
  lib: net_utils: make string_to_ip stricter
  lib: net_utils: add string_to_ip6
  net: add definition of udp_hdr
  net: IPv6 skeleton and environment variables
  net: IPv6 support
  net: Add ping6 command and implementation
  net: TFTP over IPv6
  net: IPv6 documentation
  net: e1000 enable multicast reception

 README |   3 +
 common/Kconfig |  15 ++
 common/cmd_net.c   |  41 +
 doc/README.ipv6|  32 
 drivers/net/e1000.c|   5 +
 include/env_callback.h |   8 +
 include/env_flags.h|   9 +
 include/net.h  |  18 +-
 include/net6.h | 262 
 lib/net_utils.c| 132 +-
 lib/vsprintf.c | 154 ++---
 net/Kconfig|   5 +
 net/Makefile   |   3 +
 net/ndisc.c| 266 
 net/ndisc.h|  25 +++
 net/net.c  |  41 -
 net/net6.c | 459 +
 net/ping6.c| 111 
 net/tftp.c |  58 +++
 19 files changed, 1616 insertions(+), 31 deletions(-)
 create mode 100644 doc/README.ipv6
 create mode 100644 include/net6.h
 create mode 100644 net/ndisc.c
 create mode 100644 net/ndisc.h
 create mode 100644 net/net6.c
 create mode 100644 net/ping6.c

-- 
2.5.3

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


[U-Boot] [RFC PATCH v2 06/11] net: IPv6 skeleton and environment variables

2015-11-08 Thread Chris Packham
Create net6.c and add CONFIG_NET6 to Kconfig/Makefile. Also add
support for the following environment variables:
 - ip6addr
 - gateway6
 - serverip6

Signed-off-by: Chris Packham 
---

Changes in v2:
- Split environment variables from main implementation
- remove "prefixlength6" environment variable. The prefix length is now
  set when specifying the address i.e. setenv ip6addr 2001:db8::1/64.

 include/env_callback.h |  8 +
 include/env_flags.h|  9 +
 net/Kconfig|  5 +++
 net/Makefile   |  1 +
 net/net6.c | 89 ++
 5 files changed, 112 insertions(+)
 create mode 100644 net/net6.c

diff --git a/include/env_callback.h b/include/env_callback.h
index 90b95b5..97e245b 100644
--- a/include/env_callback.h
+++ b/include/env_callback.h
@@ -60,6 +60,13 @@
 #define NET_CALLBACKS
 #endif
 
+#ifdef CONFIG_NET6
+#define NET6_CALLBACKS \
+   "ip6addr:ip6addr," \
+   "serverip6:serverip6,"
+#else
+#define NET6_CALLBACKS
+#endif
 /*
  * This list of callback bindings is static, but may be overridden by defining
  * a new association in the ".callbacks" environment variable.
@@ -68,6 +75,7 @@
ENV_DOT_ESCAPE ENV_FLAGS_VAR ":flags," \
"baudrate:baudrate," \
NET_CALLBACKS \
+   NET6_CALLBACKS \
"loadaddr:loadaddr," \
SILENT_CALLBACK \
SPLASHIMAGE_CALLBACK \
diff --git a/include/env_flags.h b/include/env_flags.h
index 8823fb9..bf93f15 100644
--- a/include/env_flags.h
+++ b/include/env_flags.h
@@ -65,6 +65,14 @@ enum env_flags_varaccess {
 #define NET_FLAGS
 #endif
 
+#ifdef CONFIG_NET6
+#define NET6_FLAGS \
+   "ip6addr:s," \
+   "serverip6:s,"
+#else
+#define NET6_FLAGS
+#endif
+
 #ifndef CONFIG_ENV_OVERWRITE
 #define SERIAL_FLAGS "serial#:so,"
 #else
@@ -74,6 +82,7 @@ enum env_flags_varaccess {
 #define ENV_FLAGS_LIST_STATIC \
ETHADDR_FLAGS \
NET_FLAGS \
+   NET6_FLAGS \
SERIAL_FLAGS \
CONFIG_ENV_FLAGS_LIST_STATIC
 
diff --git a/net/Kconfig b/net/Kconfig
index a44a783..bacd914 100644
--- a/net/Kconfig
+++ b/net/Kconfig
@@ -32,4 +32,9 @@ config NET_TFTP_VARS
  If unset, timeout and maximum are hard-defined as 1 second
  and 10 timouts per TFTP transfer.
 
+config NET6
+   bool "IPv6 support"
+   help
+ Support for IPv6
+
 endif   # if NET
diff --git a/net/Makefile b/net/Makefile
index e9cc8ad..6da8019 100644
--- a/net/Makefile
+++ b/net/Makefile
@@ -20,3 +20,4 @@ obj-$(CONFIG_CMD_PING) += ping.o
 obj-$(CONFIG_CMD_RARP) += rarp.o
 obj-$(CONFIG_CMD_SNTP) += sntp.o
 obj-$(CONFIG_CMD_NET)  += tftp.o
+obj-$(CONFIG_NET6) += net6.o
diff --git a/net/net6.c b/net/net6.c
new file mode 100644
index 000..f778cef
--- /dev/null
+++ b/net/net6.c
@@ -0,0 +1,89 @@
+/*
+ * Simple IPv6 network layer implementation.
+ *
+ * Based and/or adapted from the IPv4 network layer in net.[hc]
+ *
+ * (C) Copyright 2013 Allied Telesis Labs NZ
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "ndisc.h"
+
+/* Our gateway's IPv6 address */
+struct in6_addr net_gateway6 = ZERO_IPV6_ADDR;
+/* Our IPv6 addr (0 = unknown) */
+struct in6_addr net_ip6 = ZERO_IPV6_ADDR;
+/* set server IPv6 addr (0 = unknown) */
+struct in6_addr net_server_ip6 = ZERO_IPV6_ADDR;
+/* The prefix length of our network */
+u_int32_t net_prefix_length;
+
+static int on_ip6addr(const char *name, const char *value, enum env_op op,
+ int flags)
+{
+   char *v, *s, *strcopy;
+   int i;
+
+   if (flags & H_PROGRAMMATIC)
+   return 0;
+
+   if (op == env_op_delete) {
+   net_prefix_length = 0;
+   net_copy_ip6(_ip6, _null_addr_ip6);
+   return 0;
+   }
+
+   strcopy = strdup(value);
+   if (strcopy == NULL)
+   return -1;
+
+   net_prefix_length = 128;
+   i = 0;
+   s = strcopy;
+   while (s) {
+   v = strsep(, "/");
+   if (!v)
+   break;
+
+   switch (i++) {
+   case 0:
+   string_to_ip6(v, _ip6);
+   break;
+   case 1:
+   net_prefix_length = simple_strtoul(v, NULL, 10);
+   break;
+   default:
+   break;
+   }
+   }
+   free(strcopy);
+
+   return 0;
+}
+U_BOOT_ENV_CALLBACK(ip6addr, on_ip6addr);
+
+static int on_gatewayip6(const char *name, const char *value, enum env_op op,
+int flags)
+{
+   if (flags & H_PROGRAMMATIC)
+   return 0;
+
+   return string_to_ip6(value, _gateway6);
+}
+U_BOOT_ENV_CALLBACK(gatewayip6, on_gatewayip6);
+
+static int on_serverip6(const char *name, const char *value, enum env_op op,
+   int flags)
+{
+   if (flags & H_PROGRAMMATIC)
+ 

[U-Boot] [RFC PATCH v2 03/11] lib: net_utils: make string_to_ip stricter

2015-11-08 Thread Chris Packham
Previously values greater than 255 were implicitly truncated. Add some
stricter checking to reject addresses with components >255.

With the input "1234192.168.1.1" the old behaviour would truncate the
address to 192.168.1.1. New behaviour rejects the string outright and
returns 0.0.0.0, which for the purposes of IP addresses can be
considered an error.

Signed-off-by: Chris Packham 
---

Changes in v2:
- restore some lazy parsing behavior that the tftpboot command relied on.

 lib/net_utils.c | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/lib/net_utils.c b/lib/net_utils.c
index cfae842..f148b8a 100644
--- a/lib/net_utils.c
+++ b/lib/net_utils.c
@@ -24,11 +24,16 @@ struct in_addr string_to_ip(const char *s)
 
for (addr.s_addr = 0, i = 0; i < 4; ++i) {
ulong val = s ? simple_strtoul(s, , 10) : 0;
+   if (val > 255) {
+   addr.s_addr = 0;
+   return addr;
+   }
addr.s_addr <<= 8;
addr.s_addr |= (val & 0xFF);
-   if (s) {
-   s = (*e) ? e+1 : e;
-   }
+   if (*e == '.')
+   s = e + 1;
+   else
+   break;
}
 
addr.s_addr = htonl(addr.s_addr);
-- 
2.5.3

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


Re: [U-Boot] [PATCH v3 02/17] rockchip: move SYS_MALLOC_F_LEN to rk3288 own Kconfig

2015-11-08 Thread hl

Hi Simon,


On 09/11/15 12:46, Simon Glass wrote:

Hi Lin,

On 8 November 2015 at 18:59, hl  wrote:

Hi Simon,

On 06/11/15 20:08, Simon Glass wrote:

Hi,

On 6 November 2015 at 01:33, Lin Huang  wrote:

since different rockchip SOC have different size of SRAM,
So the size SYS_MALLOC_F_LEN may different, so move this
config to rk3288 own Kconfig

Signed-off-by: Lin Huang 
---
Changes in v1: None
Changes in v2: None
Changes in v3: None

   arch/arm/mach-rockchip/Kconfig| 3 ---
   arch/arm/mach-rockchip/rk3288/Kconfig | 3 +++
   2 files changed, 3 insertions(+), 3 deletions(-)

I thought I Acked this patch, and several others. To avoid me having
to review everything again, can you please pick those up and send a
new version?

 i checked v1 patch,  you Ack several patchs, include:
  rockchip: Bring in RK3036 device tree file includes and bindings
  rockchip: rk3036: Add clock driver
  rockchip: rk3036: Add header files for GRF
  rockchip: rk3036: Add Soc reset driver
  rockchip: rk3036: Add a simple syscon driver
  rockchip: rk3036: Add pinctrl driver
 but since we add the SPL stage,  it is a big move, so these patchs all
have been modified,
 and need your help to review again,

OK - do you want me to do another pass now, or do you want to send a
new version first?

I think i will send a new version later today first,
and you can help to review in the new verion patch, thank you.


Regards,
Simon





--
Lin Huang


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


[U-Boot] [PATCH 5/5] net: altera_tse: add mSG-DMA support

2015-11-08 Thread Thomas Chou
The Modular Scatter-Gather DMA core is a new DMA core to work
with the Altera Triple-Speed Ethernet MegaCore. It replaces the
legacy Scatter-Gather Direct Memory Access (SG-DMA) controller
core. Please find details on the "Embedded Peripherals IP User
Guide" of Altera.

Signed-off-by: Thomas Chou 
---
 drivers/net/altera_tse.c | 131 +++
 drivers/net/altera_tse.h |  60 ++
 2 files changed, 191 insertions(+)

diff --git a/drivers/net/altera_tse.c b/drivers/net/altera_tse.c
index 3848530..5692fe9 100644
--- a/drivers/net/altera_tse.c
+++ b/drivers/net/altera_tse.c
@@ -263,6 +263,121 @@ static void altera_tse_stop_sgdma(struct udevice *dev)
   _sgdma->control);
 }
 
+static void msgdma_reset(struct msgdma_csr *csr)
+{
+   u32 status;
+   ulong ctime;
+
+   /* Reset mSGDMA */
+   writel(MSGDMA_CSR_STAT_MASK, >status);
+   writel(MSGDMA_CSR_CTL_RESET, >control);
+   ctime = get_timer(0);
+   while (1) {
+   status = readl(>status);
+   if (!(status & MSGDMA_CSR_STAT_RESETTING))
+   break;
+   if (get_timer(ctime) > ALT_TSE_SW_RESET_TIMEOUT) {
+   debug("Reset msgdma timeout\n");
+   break;
+   }
+   }
+   /* Clear status */
+   writel(MSGDMA_CSR_STAT_MASK, >status);
+}
+
+static u32 msgdma_wait(struct msgdma_csr *csr)
+{
+   u32 status;
+   ulong ctime;
+
+   /* Wait for the descriptor to complete */
+   ctime = get_timer(0);
+   while (1) {
+   status = readl(>status);
+   if (!(status & MSGDMA_CSR_STAT_BUSY))
+   break;
+   if (get_timer(ctime) > ALT_TSE_SGDMA_BUSY_TIMEOUT) {
+   debug("sgdma timeout\n");
+   break;
+   }
+   }
+   /* Clear status */
+   writel(MSGDMA_CSR_STAT_MASK, >status);
+
+   return status;
+}
+
+static int altera_tse_send_msgdma(struct udevice *dev, void *packet,
+ int length)
+{
+   struct altera_tse_priv *priv = dev_get_priv(dev);
+   struct msgdma_extended_desc *desc = priv->tx_desc;
+   u32 tx_buf = virt_to_phys(packet);
+   u32 status;
+
+   writel(tx_buf, >read_addr_lo);
+   writel(0, >read_addr_hi);
+   writel(0, >write_addr_lo);
+   writel(0, >write_addr_hi);
+   writel(length, >len);
+   writel(0, >burst_seq_num);
+   writel(MSGDMA_DESC_TX_STRIDE, >stride);
+   writel(MSGDMA_DESC_CTL_TX_SINGLE, >control);
+   status = msgdma_wait(priv->sgdma_tx);
+   debug("sent %d bytes, status %08x\n", length, status);
+
+   return 0;
+}
+
+static int altera_tse_recv_msgdma(struct udevice *dev, int flags,
+ uchar **packetp)
+{
+   struct altera_tse_priv *priv = dev_get_priv(dev);
+   struct msgdma_csr *csr = priv->sgdma_rx;
+   struct msgdma_response *resp = priv->rx_resp;
+   u32 level, length, status;
+
+   level = readl(>resp_fill_level);
+   if (level & 0x) {
+   length = readl(>bytes_transferred);
+   status = readl(>status);
+   debug("recv %d bytes, status %08x\n", length, status);
+   *packetp = priv->rx_buf;
+
+   return length;
+   }
+
+   return -EAGAIN;
+}
+
+static int altera_tse_free_pkt_msgdma(struct udevice *dev, uchar *packet,
+ int length)
+{
+   struct altera_tse_priv *priv = dev_get_priv(dev);
+   struct msgdma_extended_desc *desc = priv->rx_desc;
+   u32 rx_buf = virt_to_phys(priv->rx_buf);
+
+   writel(0, >read_addr_lo);
+   writel(0, >read_addr_hi);
+   writel(rx_buf, >write_addr_lo);
+   writel(0, >write_addr_hi);
+   writel(PKTSIZE_ALIGN, >len);
+   writel(0, >burst_seq_num);
+   writel(MSGDMA_DESC_RX_STRIDE, >stride);
+   writel(MSGDMA_DESC_CTL_RX_SINGLE, >control);
+   debug("recv setup\n");
+
+   return 0;
+}
+
+static void altera_tse_stop_msgdma(struct udevice *dev)
+{
+   struct altera_tse_priv *priv = dev_get_priv(dev);
+
+   msgdma_reset(priv->sgdma_rx);
+   msgdma_reset(priv->sgdma_tx);
+}
+
 static int tse_mdio_read(struct mii_dev *bus, int addr, int devad, int reg)
 {
struct altera_tse_priv *priv = bus->priv;
@@ -449,6 +564,13 @@ static const struct tse_ops tse_sgdma_ops = {
.stop   = altera_tse_stop_sgdma,
 };
 
+static const struct tse_ops tse_msgdma_ops = {
+   .send   = altera_tse_send_msgdma,
+   .recv   = altera_tse_recv_msgdma,
+   .free_pkt   = altera_tse_free_pkt_msgdma,
+   .stop   = altera_tse_stop_msgdma,
+};
+
 static int altera_tse_probe(struct udevice *dev)
 {
struct eth_pdata *pdata = dev_get_platdata(dev);
@@ -466,6 +588,8 @@ static int altera_tse_probe(struct 

[U-Boot] [PATCH 2/5] net: altera_tse: factor out stop mac func

2015-11-08 Thread Thomas Chou
Factor out the stop mac function to prepare msgdma support.

Signed-off-by: Thomas Chou 
---
 drivers/net/altera_tse.c | 36 +---
 1 file changed, 21 insertions(+), 15 deletions(-)

diff --git a/drivers/net/altera_tse.c b/drivers/net/altera_tse.c
index b2002f4..fe8c524 100644
--- a/drivers/net/altera_tse.c
+++ b/drivers/net/altera_tse.c
@@ -223,16 +223,33 @@ static int altera_tse_free_pkt(struct udevice *dev, uchar 
*packet,
return 0;
 }
 
+static void altera_tse_stop_mac(struct altera_tse_priv *priv)
+{
+   struct alt_tse_mac *mac_dev = priv->mac_dev;
+   u32 status;
+   ulong ctime;
+
+   /* reset the mac */
+   writel(ALTERA_TSE_CMD_SW_RESET_MSK, _dev->command_config);
+   ctime = get_timer(0);
+   while (1) {
+   status = readl(_dev->command_config);
+   if (!(status & ALTERA_TSE_CMD_SW_RESET_MSK))
+   break;
+   if (get_timer(ctime) > ALT_TSE_SW_RESET_TIMEOUT) {
+   debug("Reset mac timeout\n");
+   break;
+   }
+   }
+}
+
 static void altera_tse_stop(struct udevice *dev)
 {
struct altera_tse_priv *priv = dev_get_priv(dev);
-   struct alt_tse_mac *mac_dev = priv->mac_dev;
struct alt_sgdma_registers *rx_sgdma = priv->sgdma_rx;
struct alt_sgdma_registers *tx_sgdma = priv->sgdma_tx;
struct alt_sgdma_descriptor *rx_desc = priv->rx_desc;
-   u32 status;
int ret;
-   ulong ctime;
 
/* clear rx desc & wait for sgdma to complete */
rx_desc->descriptor_control = 0;
@@ -248,18 +265,7 @@ static void altera_tse_stop(struct udevice *dev)
writel(ALT_SGDMA_CONTROL_SOFTWARERESET_MSK,
   _sgdma->control);
 
-   /* reset the mac */
-   writel(ALTERA_TSE_CMD_SW_RESET_MSK, _dev->command_config);
-   ctime = get_timer(0);
-   while (1) {
-   status = readl(_dev->command_config);
-   if (!(status & ALTERA_TSE_CMD_SW_RESET_MSK))
-   break;
-   if (get_timer(ctime) > ALT_TSE_SW_RESET_TIMEOUT) {
-   debug("Reset mac timeout\n");
-   break;
-   }
-   }
+   altera_tse_stop_mac(priv);
 }
 
 static int tse_mdio_read(struct mii_dev *bus, int addr, int devad, int reg)
-- 
2.5.0

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


[U-Boot] [PATCH 1/5] net: zap altera_tse_initialize prototypes

2015-11-08 Thread Thomas Chou
Zap the altera_tse_initialize() prototypes, since it is converted
to driver model.

Signed-off-by: Thomas Chou 
---
 include/netdev.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/include/netdev.h b/include/netdev.h
index 3d5a54f..28eab46 100644
--- a/include/netdev.h
+++ b/include/netdev.h
@@ -25,9 +25,6 @@ int board_eth_init(bd_t *bis);
 int cpu_eth_init(bd_t *bis);
 
 /* Driver initialization prototypes */
-int altera_tse_initialize(u8 dev_num, int mac_base,
- int sgdma_rx_base, int sgdma_tx_base,
- u32 sgdma_desc_base, u32 sgdma_desc_size);
 int at91emac_register(bd_t *bis, unsigned long iobase);
 int au1x00_enet_initialize(bd_t*);
 int ax88180_initialize(bd_t *bis);
-- 
2.5.0

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


[U-Boot] [PATCH 0/5] net: altera_tse: add mSG-DMA support

2015-11-08 Thread Thomas Chou
The Modular Scatter-Gather DMA core is a new DMA core to work
with the Altera Triple-Speed Ethernet MegaCore. It replaces the
legacy Scatter-Gather Direct Memory Access (SG-DMA) controller
core. Please find details on the "Embedded Peripherals IP User
Guide" of Altera.

Thomas Chou (5):
  net: zap altera_tse_initialize prototypes
  net: altera_tse: factor out stop mac func
  net: altera_tse: wait sgdma in altera_tse_recv
  net: altera_tse: add priv ops to prepare msgdma support
  net: altera_tse: add mSG-DMA support

 drivers/net/altera_tse.c | 237 +--
 drivers/net/altera_tse.h |  80 +++-
 include/netdev.h |   3 -
 3 files changed, 285 insertions(+), 35 deletions(-)

-- 
2.5.0

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


[U-Boot] [PATCH 4/5] net: altera_tse: add priv ops to prepare msgdma support

2015-11-08 Thread Thomas Chou
Add priv ops to prepare msgdma support. These ops are dma type
specific.

Signed-off-by: Thomas Chou 
---
 drivers/net/altera_tse.c | 86 
 drivers/net/altera_tse.h | 20 ---
 2 files changed, 81 insertions(+), 25 deletions(-)

diff --git a/drivers/net/altera_tse.c b/drivers/net/altera_tse.c
index 8ec0beb..3848530 100644
--- a/drivers/net/altera_tse.c
+++ b/drivers/net/altera_tse.c
@@ -152,13 +152,11 @@ static void tse_adjust_link(struct altera_tse_priv *priv,
writel(refvar, _dev->command_config);
 }
 
-static int altera_tse_send(struct udevice *dev, void *packet, int length)
+static int altera_tse_send_sgdma(struct udevice *dev, void *packet, int length)
 {
struct altera_tse_priv *priv = dev_get_priv(dev);
struct alt_sgdma_descriptor *tx_desc = priv->tx_desc;
-   unsigned long tx_buf = (unsigned long)packet;
 
-   flush_dcache_range(tx_buf, tx_buf + length);
alt_sgdma_construct_descriptor(
tx_desc,
tx_desc + 1,
@@ -178,7 +176,8 @@ static int altera_tse_send(struct udevice *dev, void 
*packet, int length)
return tx_desc->actual_bytes_transferred;
 }
 
-static int altera_tse_recv(struct udevice *dev, int flags, uchar **packetp)
+static int altera_tse_recv_sgdma(struct udevice *dev, int flags,
+uchar **packetp)
 {
struct altera_tse_priv *priv = dev_get_priv(dev);
struct alt_sgdma_descriptor *rx_desc = priv->rx_desc;
@@ -197,14 +196,12 @@ static int altera_tse_recv(struct udevice *dev, int 
flags, uchar **packetp)
return -EAGAIN;
 }
 
-static int altera_tse_free_pkt(struct udevice *dev, uchar *packet,
-  int length)
+static int altera_tse_free_pkt_sgdma(struct udevice *dev, uchar *packet,
+int length)
 {
struct altera_tse_priv *priv = dev_get_priv(dev);
struct alt_sgdma_descriptor *rx_desc = priv->rx_desc;
-   unsigned long rx_buf = (unsigned long)priv->rx_buf;
 
-   invalidate_dcache_range(rx_buf, rx_buf + PKTSIZE_ALIGN);
alt_sgdma_construct_descriptor(
rx_desc,
rx_desc + 1,
@@ -243,7 +240,7 @@ static void altera_tse_stop_mac(struct altera_tse_priv 
*priv)
}
 }
 
-static void altera_tse_stop(struct udevice *dev)
+static void altera_tse_stop_sgdma(struct udevice *dev)
 {
struct altera_tse_priv *priv = dev_get_priv(dev);
struct alt_sgdma_registers *rx_sgdma = priv->sgdma_rx;
@@ -264,8 +261,6 @@ static void altera_tse_stop(struct udevice *dev)
if (ret == -ETIMEDOUT)
writel(ALT_SGDMA_CONTROL_SOFTWARERESET_MSK,
   _sgdma->control);
-
-   altera_tse_stop_mac(priv);
 }
 
 static int tse_mdio_read(struct mii_dev *bus, int addr, int devad, int reg)
@@ -364,6 +359,42 @@ static int altera_tse_write_hwaddr(struct udevice *dev)
return 0;
 }
 
+static int altera_tse_send(struct udevice *dev, void *packet, int length)
+{
+   struct altera_tse_priv *priv = dev_get_priv(dev);
+   unsigned long tx_buf = (unsigned long)packet;
+
+   flush_dcache_range(tx_buf, tx_buf + length);
+
+   return priv->ops->send(dev, packet, length);
+}
+
+static int altera_tse_recv(struct udevice *dev, int flags, uchar **packetp)
+{
+   struct altera_tse_priv *priv = dev_get_priv(dev);
+
+   return priv->ops->recv(dev, flags, packetp);
+}
+
+static int altera_tse_free_pkt(struct udevice *dev, uchar *packet,
+  int length)
+{
+   struct altera_tse_priv *priv = dev_get_priv(dev);
+   unsigned long rx_buf = (unsigned long)priv->rx_buf;
+
+   invalidate_dcache_range(rx_buf, rx_buf + PKTSIZE_ALIGN);
+
+   return priv->ops->free_pkt(dev, packet, length);
+}
+
+static void altera_tse_stop(struct udevice *dev)
+{
+   struct altera_tse_priv *priv = dev_get_priv(dev);
+
+   priv->ops->stop(dev);
+   altera_tse_stop_mac(priv);
+}
+
 static int altera_tse_start(struct udevice *dev)
 {
struct altera_tse_priv *priv = dev_get_priv(dev);
@@ -411,6 +442,13 @@ static int altera_tse_start(struct udevice *dev)
return 0;
 }
 
+static const struct tse_ops tse_sgdma_ops = {
+   .send   = altera_tse_send_sgdma,
+   .recv   = altera_tse_recv_sgdma,
+   .free_pkt   = altera_tse_free_pkt_sgdma,
+   .stop   = altera_tse_stop_sgdma,
+};
+
 static int altera_tse_probe(struct udevice *dev)
 {
struct eth_pdata *pdata = dev_get_platdata(dev);
@@ -425,6 +463,9 @@ static int altera_tse_probe(struct udevice *dev)
int len, idx;
int ret;
 
+   priv->dma_type = dev_get_driver_data(dev);
+   if (priv->dma_type == ALT_SGDMA)
+   priv->ops = _sgdma_ops;
/*
 * decode regs. there are multiple reg tuples, and they need to
 * match with reg-names.
@@ -468,15 +509,18 @@ static 

[U-Boot] [PATCH 3/5] net: altera_tse: wait sgdma in altera_tse_recv

2015-11-08 Thread Thomas Chou
Move the sgdma wait from free_pkt to recv. This is the proper
place to wait recv sgdma done.

Signed-off-by: Thomas Chou 
---
 drivers/net/altera_tse.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/altera_tse.c b/drivers/net/altera_tse.c
index fe8c524..8ec0beb 100644
--- a/drivers/net/altera_tse.c
+++ b/drivers/net/altera_tse.c
@@ -186,6 +186,7 @@ static int altera_tse_recv(struct udevice *dev, int flags, 
uchar **packetp)
 
if (rx_desc->descriptor_status &
ALT_SGDMA_DESCRIPTOR_STATUS_TERMINATED_BY_EOP_MSK) {
+   alt_sgdma_wait_transfer(priv->sgdma_rx);
packet_length = rx_desc->actual_bytes_transferred;
debug("recv %d bytes\n", packet_length);
*packetp = priv->rx_buf;
@@ -203,7 +204,6 @@ static int altera_tse_free_pkt(struct udevice *dev, uchar 
*packet,
struct alt_sgdma_descriptor *rx_desc = priv->rx_desc;
unsigned long rx_buf = (unsigned long)priv->rx_buf;
 
-   alt_sgdma_wait_transfer(priv->sgdma_rx);
invalidate_dcache_range(rx_buf, rx_buf + PKTSIZE_ALIGN);
alt_sgdma_construct_descriptor(
rx_desc,
-- 
2.5.0

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


[U-Boot] [PATCH v2 13/26] sandbox: usb: Allow finding a USB emulator for a device

2015-11-08 Thread Simon Glass
Each USB device has an emulator. Currently this can only be found by
supplying the 'pipe' value, which contains the device number. Add a way
to find it directly from the emulated device.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 drivers/usb/emul/usb-emul-uclass.c | 17 +++--
 include/usb.h  | 10 ++
 2 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/emul/usb-emul-uclass.c 
b/drivers/usb/emul/usb-emul-uclass.c
index 205f2c5..6b5f3c0 100644
--- a/drivers/usb/emul/usb-emul-uclass.c
+++ b/drivers/usb/emul/usb-emul-uclass.c
@@ -108,9 +108,8 @@ static int usb_emul_get_descriptor(struct usb_dev_platdata 
*plat, int value,
return upto ? upto : length ? -EIO : 0;
 }
 
-int usb_emul_find(struct udevice *bus, ulong pipe, struct udevice **emulp)
+static int usb_emul_find_devnum(int devnum, struct udevice **emulp)
 {
-   int devnum = usb_pipedevice(pipe);
struct udevice *dev;
struct uclass *uc;
int ret;
@@ -134,6 +133,20 @@ int usb_emul_find(struct udevice *bus, ulong pipe, struct 
udevice **emulp)
return -ENOENT;
 }
 
+int usb_emul_find(struct udevice *bus, ulong pipe, struct udevice **emulp)
+{
+   int devnum = usb_pipedevice(pipe);
+
+   return usb_emul_find_devnum(devnum, emulp);
+}
+
+int usb_emul_find_for_dev(struct udevice *dev, struct udevice **emulp)
+{
+   struct usb_dev_platdata *udev = dev_get_parent_platdata(dev);
+
+   return usb_emul_find_devnum(udev->devnum, emulp);
+}
+
 int usb_emul_control(struct udevice *emul, struct usb_device *udev,
 unsigned long pipe, void *buffer, int length,
 struct devrequest *setup)
diff --git a/include/usb.h b/include/usb.h
index a09c7f1..d684531 100644
--- a/include/usb.h
+++ b/include/usb.h
@@ -950,6 +950,16 @@ int usb_emul_bulk(struct udevice *emul, struct usb_device 
*udev,
 int usb_emul_find(struct udevice *bus, ulong pipe, struct udevice **emulp);
 
 /**
+ * usb_emul_find_for_dev() - Find an emulator for a particular device
+ *
+ * @bus:   USB bus (controller)
+ * @dev:   USB device to check
+ * @emulp: Returns pointer to emulator, or NULL if not found
+ * @return 0 if found, -ve on error
+ */
+int usb_emul_find_for_dev(struct udevice *dev, struct udevice **emulp);
+
+/**
  * usb_emul_reset() - Reset all emulators ready for use
  *
  * Clear out any address information in the emulators and make then ready for
-- 
2.6.0.rc2.230.g3dd15c0

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


[U-Boot] [PATCH v2 11/26] sandbox: usb: Allow dynamic emulated USB device descriptors

2015-11-08 Thread Simon Glass
We would like the serial number to come from the device tree node name of
the emulated device. This avoids them all having the same name. Adjust the
code to support this.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 drivers/usb/emul/sandbox_flash.c | 48 +++-
 1 file changed, 28 insertions(+), 20 deletions(-)

diff --git a/drivers/usb/emul/sandbox_flash.c b/drivers/usb/emul/sandbox_flash.c
index 6e0808d..0965ad0 100644
--- a/drivers/usb/emul/sandbox_flash.c
+++ b/drivers/usb/emul/sandbox_flash.c
@@ -31,6 +31,14 @@ enum cmd_phase {
PHASE_STATUS,
 };
 
+enum {
+   STRINGID_MANUFACTURER = 1,
+   STRINGID_PRODUCT,
+   STRINGID_SERIAL,
+
+   STRINGID_COUNT,
+};
+
 /**
  * struct sandbox_flash_priv - private state for this driver
  *
@@ -61,6 +69,7 @@ struct sandbox_flash_priv {
 
 struct sandbox_flash_plat {
const char *pathname;
+   struct usb_string flash_strings[STRINGID_COUNT];
 };
 
 struct scsi_inquiry_resp {
@@ -89,21 +98,6 @@ struct __packed scsi_read10_req {
u8 spare2[3];
 };
 
-enum {
-   STRINGID_MANUFACTURER = 1,
-   STRINGID_PRODUCT,
-   STRINGID_SERIAL,
-
-   STRINGID_COUNT,
-};
-
-static struct usb_string flash_strings[] = {
-   {STRINGID_MANUFACTURER, "sandbox"},
-   {STRINGID_PRODUCT,  "flash"},
-   {STRINGID_SERIAL,   "2345"},
-   {},
-};
-
 static struct usb_device_descriptor flash_device_desc = {
.bLength =  sizeof(flash_device_desc),
.bDescriptorType =  USB_DT_DEVICE,
@@ -246,7 +240,8 @@ static void handle_read(struct sandbox_flash_priv *priv, 
ulong lba,
}
 }
 
-static int handle_ufi_command(struct sandbox_flash_priv *priv, const void 
*buff,
+static int handle_ufi_command(struct sandbox_flash_plat *plat,
+ struct sandbox_flash_priv *priv, const void *buff,
  int len)
 {
const struct SCSI_cmd_block *req = buff;
@@ -260,9 +255,10 @@ static int handle_ufi_command(struct sandbox_flash_priv 
*priv, const void *buff,
resp->data_format = 1;
resp->additional_len = 0x1f;
strncpy(resp->vendor,
-   flash_strings[STRINGID_MANUFACTURER -  1].s,
+   plat->flash_strings[STRINGID_MANUFACTURER -  1].s,
sizeof(resp->vendor));
-   strncpy(resp->product, flash_strings[STRINGID_PRODUCT - 1].s,
+   strncpy(resp->product,
+   plat->flash_strings[STRINGID_PRODUCT - 1].s,
sizeof(resp->product));
strncpy(resp->revision, "1.0", sizeof(resp->revision));
setup_response(priv, resp, sizeof(*resp));
@@ -303,6 +299,7 @@ static int handle_ufi_command(struct sandbox_flash_priv 
*priv, const void *buff,
 static int sandbox_flash_bulk(struct udevice *dev, struct usb_device *udev,
  unsigned long pipe, void *buff, int len)
 {
+   struct sandbox_flash_plat *plat = dev_get_platdata(dev);
struct sandbox_flash_priv *priv = dev_get_priv(dev);
int ep = usb_pipeendpoint(pipe);
struct umass_bbb_cbw *cbw = buff;
@@ -325,7 +322,7 @@ static int sandbox_flash_bulk(struct udevice *dev, struct 
usb_device *udev,
goto err;
priv->transfer_len = cbw->dCBWDataTransferLength;
priv->tag = cbw->dCBWTag;
-   return handle_ufi_command(priv, cbw->CBWCDB,
+   return handle_ufi_command(plat, priv, cbw->CBWCDB,
  cbw->bCDBLength);
case PHASE_DATA:
debug("data out\n");
@@ -384,7 +381,18 @@ static int sandbox_flash_ofdata_to_platdata(struct udevice 
*dev)
 
 static int sandbox_flash_bind(struct udevice *dev)
 {
-   return usb_emul_setup_device(dev, PACKET_SIZE_64, flash_strings,
+   struct sandbox_flash_plat *plat = dev_get_platdata(dev);
+   struct usb_string *fs;
+
+   fs = plat->flash_strings;
+   fs[0].id = STRINGID_MANUFACTURER;
+   fs[0].s = "sandbox";
+   fs[1].id = STRINGID_PRODUCT;
+   fs[1].s = "flash";
+   fs[2].id = STRINGID_SERIAL;
+   fs[2].s = dev->name;
+
+   return usb_emul_setup_device(dev, PACKET_SIZE_64, plat->flash_strings,
 flash_desc_list);
 }
 
-- 
2.6.0.rc2.230.g3dd15c0

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


[U-Boot] [PATCH v2 15/26] Revert "dm: usb: Use device_unbind_children to clean up usb devs on stop"

2015-11-08 Thread Simon Glass
This reverts commit 6cda369509e0d3fa5f9e33c9d71589c4523799fa.

We want to avoid having the USB stack rely on unbind.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 drivers/usb/host/usb-uclass.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/usb/host/usb-uclass.c b/drivers/usb/host/usb-uclass.c
index 838d05a..89611f1 100644
--- a/drivers/usb/host/usb-uclass.c
+++ b/drivers/usb/host/usb-uclass.c
@@ -158,9 +158,6 @@ int usb_stop(void)
ret = device_remove(bus);
if (ret && !err)
err = ret;
-   ret = device_unbind_children(bus);
-   if (ret && !err)
-   err = ret;
}
 
 #ifdef CONFIG_SANDBOX
-- 
2.6.0.rc2.230.g3dd15c0

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


[U-Boot] [PATCH v2 18/26] dm: usb: Remove inactive children after a bus scan

2015-11-08 Thread Simon Glass
Each scan of the USB bus may return different results. Existing driver-model
devices are reused when found, but if a device no longer exists it will stay
around, de-activated, but bound.

Detect these devices and remove them after the scan completes.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 drivers/usb/host/usb-uclass.c | 23 +++
 1 file changed, 23 insertions(+)

diff --git a/drivers/usb/host/usb-uclass.c b/drivers/usb/host/usb-uclass.c
index 4aa92f8..50538e0 100644
--- a/drivers/usb/host/usb-uclass.c
+++ b/drivers/usb/host/usb-uclass.c
@@ -202,6 +202,20 @@ static void usb_scan_bus(struct udevice *bus, bool recurse)
printf("%d USB Device(s) found\n", priv->next_addr);
 }
 
+static void remove_inactive_children(struct uclass *uc, struct udevice *bus)
+{
+   uclass_foreach_dev(bus, uc) {
+   struct udevice *dev, *next;
+
+   if (!device_active(bus))
+   continue;
+   device_foreach_child_safe(dev, next, bus) {
+   if (!device_active(dev))
+   device_unbind(dev);
+   }
+   }
+}
+
 int usb_init(void)
 {
int controllers_initialized = 0;
@@ -270,6 +284,15 @@ int usb_init(void)
}
 
debug("scan end\n");
+
+   /* Remove any devices that were not found on this scan */
+   remove_inactive_children(uc, bus);
+
+   ret = uclass_get(UCLASS_USB_HUB, );
+   if (ret)
+   return ret;
+   remove_inactive_children(uc, bus);
+
/* if we were not able to find at least one working bus, bail out */
if (!count)
printf("No controllers found\n");
-- 
2.6.0.rc2.230.g3dd15c0

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


[U-Boot] [PATCH v2 10/26] dm: core: Add safe device iteration macros

2015-11-08 Thread Simon Glass
Add iteration macros which support unbinding a device within the loop.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 include/dm/device.h | 12 
 include/dm/uclass.h | 15 +++
 2 files changed, 27 insertions(+)

diff --git a/include/dm/device.h b/include/dm/device.h
index 28ba4ca..7fb9935 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -509,6 +509,18 @@ static inline bool device_is_on_pci_bus(struct udevice 
*dev)
return device_get_uclass_id(dev->parent) == UCLASS_PCI;
 }
 
+/**
+ * device_foreach_child_safe() - iterate through child devices safely
+ *
+ * This allows the @pos child to be removed in the loop if required.
+ *
+ * @pos: struct udevice * for the current device
+ * @next: struct udevice * for the next device
+ * @parent: parent device to scan
+ */
+#define device_foreach_child_safe(pos, next, parent)   \
+   list_for_each_entry_safe(pos, next, >child_head, sibling_node)
+
 /* device resource management */
 typedef void (*dr_release_t)(struct udevice *dev, void *res);
 typedef int (*dr_match_t)(struct udevice *dev, void *res, void *match_data);
diff --git a/include/dm/uclass.h b/include/dm/uclass.h
index d214b88..bfbd27a 100644
--- a/include/dm/uclass.h
+++ b/include/dm/uclass.h
@@ -243,4 +243,19 @@ int uclass_resolve_seq(struct udevice *dev);
 #define uclass_foreach_dev(pos, uc)\
list_for_each_entry(pos, >dev_head, uclass_node)
 
+/**
+ * uclass_foreach_dev_safe() - Helper function to safely iteration through devs
+ *
+ * This creates a for() loop which works through the available devices in
+ * a uclass in order from start to end. Inside the loop, it is safe to remove
+ * @pos if required.
+ *
+ * @pos: struct udevice * to hold the current device. Set to NULL when there
+ * are no more devices.
+ * @next: struct udevice * to hold the next next
+ * @uc: uclass to scan
+ */
+#define uclass_foreach_dev_safe(pos, next, uc) \
+   list_for_each_entry_safe(pos, next, >dev_head, uclass_node)
+
 #endif
-- 
2.6.0.rc2.230.g3dd15c0

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


[U-Boot] [PATCH v2 09/26] usb: Refactor USB tree output code for testing

2015-11-08 Thread Simon Glass
Allow the 'usb tree' command to be used from test code, so that we can
verify that it works correctly.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 common/cmd_usb.c | 58 
 include/usb.h|  8 
 2 files changed, 41 insertions(+), 25 deletions(-)

diff --git a/common/cmd_usb.c b/common/cmd_usb.c
index c2d9803..a540b42 100644
--- a/common/cmd_usb.c
+++ b/common/cmd_usb.c
@@ -429,7 +429,7 @@ static void usb_show_tree_graph(struct usb_device *dev, 
char *pre)
 }
 
 /* main routine for the tree command */
-static void usb_show_tree(struct usb_device *dev)
+static void usb_show_subtree(struct usb_device *dev)
 {
char preamble[32];
 
@@ -437,6 +437,37 @@ static void usb_show_tree(struct usb_device *dev)
usb_show_tree_graph(dev, [0]);
 }
 
+void usb_show_tree(void)
+{
+#ifdef CONFIG_DM_USB
+   struct udevice *bus;
+
+   for (uclass_first_device(UCLASS_USB, );
+   bus;
+   uclass_next_device()) {
+   struct usb_device *udev;
+   struct udevice *dev;
+
+   device_find_first_child(bus, );
+   if (dev && device_active(dev)) {
+   udev = dev_get_parent_priv(dev);
+   usb_show_subtree(udev);
+   }
+   }
+#else
+   struct usb_device *udev;
+   int i;
+
+   for (i = 0; i < USB_MAX_DEVICE; i++) {
+   udev = usb_get_dev_index(i);
+   if (udev == NULL)
+   break;
+   if (udev->parent == NULL)
+   usb_show_subtree(udev);
+   }
+#endif
+}
+
 static int usb_test(struct usb_device *dev, int port, char* arg)
 {
int mode;
@@ -631,30 +662,7 @@ static int do_usb(cmd_tbl_t *cmdtp, int flag, int argc, 
char * const argv[])
}
if (strncmp(argv[1], "tree", 4) == 0) {
puts("USB device tree:\n");
-#ifdef CONFIG_DM_USB
-   struct udevice *bus;
-
-   for (uclass_first_device(UCLASS_USB, );
-bus;
-uclass_next_device()) {
-   struct usb_device *udev;
-   struct udevice *dev;
-
-   device_find_first_child(bus, );
-   if (dev && device_active(dev)) {
-   udev = dev_get_parent_priv(dev);
-   usb_show_tree(udev);
-   }
-   }
-#else
-   for (i = 0; i < USB_MAX_DEVICE; i++) {
-   udev = usb_get_dev_index(i);
-   if (udev == NULL)
-   break;
-   if (udev->parent == NULL)
-   usb_show_tree(udev);
-   }
-#endif
+   usb_show_tree();
return 0;
}
if (strncmp(argv[1], "inf", 3) == 0) {
diff --git a/include/usb.h b/include/usb.h
index 3d0facb..a09c7f1 100644
--- a/include/usb.h
+++ b/include/usb.h
@@ -957,4 +957,12 @@ int usb_emul_find(struct udevice *bus, ulong pipe, struct 
udevice **emulp);
  */
 void usb_emul_reset(struct udevice *dev);
 
+/**
+ * usb_show_tree() - show the USB device tree
+ *
+ * This shows a list of active USB devices along with basic information about
+ * each.
+ */
+void usb_show_tree(void);
+
 #endif /*_USB_H_ */
-- 
2.6.0.rc2.230.g3dd15c0

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


[U-Boot] [PATCH v2 16/26] Revert "dm: Export device_remove_children / device_unbind_children"

2015-11-08 Thread Simon Glass
This reverts commit bb52b367f6ca4a3a918e77737f4ff6a1089912d9.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 drivers/core/device-remove.c | 22 ++
 include/dm/device-internal.h | 26 --
 2 files changed, 18 insertions(+), 30 deletions(-)

diff --git a/drivers/core/device-remove.c b/drivers/core/device-remove.c
index bd6d406..e1714b2 100644
--- a/drivers/core/device-remove.c
+++ b/drivers/core/device-remove.c
@@ -18,7 +18,16 @@
 #include 
 #include 
 
-int device_unbind_children(struct udevice *dev)
+/**
+ * device_chld_unbind() - Unbind all device's children from the device
+ *
+ * On error, the function continues to unbind all children, and reports the
+ * first error.
+ *
+ * @dev:   The device that is to be stripped of its children
+ * @return 0 on success, -ve on error
+ */
+static int device_chld_unbind(struct udevice *dev)
 {
struct udevice *pos, *n;
int ret, saved_ret = 0;
@@ -34,7 +43,12 @@ int device_unbind_children(struct udevice *dev)
return saved_ret;
 }
 
-int device_remove_children(struct udevice *dev)
+/**
+ * device_chld_remove() - Stop all device's children
+ * @dev:   The device whose children are to be removed
+ * @return 0 on success, -ve on error
+ */
+static int device_chld_remove(struct udevice *dev)
 {
struct udevice *pos, *n;
int ret;
@@ -73,7 +87,7 @@ int device_unbind(struct udevice *dev)
return ret;
}
 
-   ret = device_unbind_children(dev);
+   ret = device_chld_unbind(dev);
if (ret)
return ret;
 
@@ -153,7 +167,7 @@ int device_remove(struct udevice *dev)
if (ret)
return ret;
 
-   ret = device_remove_children(dev);
+   ret = device_chld_remove(dev);
if (ret)
goto err;
 
diff --git a/include/dm/device-internal.h b/include/dm/device-internal.h
index 322d35a..9388870 100644
--- a/include/dm/device-internal.h
+++ b/include/dm/device-internal.h
@@ -107,32 +107,6 @@ int device_unbind(struct udevice *dev);
 static inline int device_unbind(struct udevice *dev) { return 0; }
 #endif
 
-/**
- * device_remove_children() - Stop all device's children
- * @dev:   The device whose children are to be removed
- * @return 0 on success, -ve on error
- */
-#if CONFIG_IS_ENABLED(DM_DEVICE_REMOVE)
-int device_remove_children(struct udevice *dev);
-#else
-static inline int device_remove_children(struct udevice *dev) { return 0; }
-#endif
-
-/**
- * device_unbind_children() - Unbind all device's children from the device
- *
- * On error, the function continues to unbind all children, and reports the
- * first error.
- *
- * @dev:   The device that is to be stripped of its children
- * @return 0 on success, -ve on error
- */
-#if CONFIG_IS_ENABLED(DM_DEVICE_REMOVE)
-int device_unbind_children(struct udevice *dev);
-#else
-static inline int device_unbind_children(struct udevice *dev) { return 0; }
-#endif
-
 #if CONFIG_IS_ENABLED(DM_DEVICE_REMOVE)
 void device_free(struct udevice *dev);
 #else
-- 
2.6.0.rc2.230.g3dd15c0

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


[U-Boot] [PATCH v2 14/26] Revert "dm: usb: Rename usb_find_child to usb_find_emul_child"

2015-11-08 Thread Simon Glass
This reverts commit 9b510df703d282effba4f56ac567aa8011d56e6b.

We want to avoid having the USB stack rely on unbind.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 drivers/usb/host/usb-uclass.c | 19 ++-
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/host/usb-uclass.c b/drivers/usb/host/usb-uclass.c
index 7f6a9a6..838d05a 100644
--- a/drivers/usb/host/usb-uclass.c
+++ b/drivers/usb/host/usb-uclass.c
@@ -494,14 +494,15 @@ error:
 }
 
 /**
- * usb_find_emul_child() - Find an existing device for emulated devices
+ * usb_find_child() - Find an existing device which matches our needs
+ *
+ *
  */
-static int usb_find_emul_child(struct udevice *parent,
-  struct usb_device_descriptor *desc,
-  struct usb_interface_descriptor *iface,
-  struct udevice **devp)
+static int usb_find_child(struct udevice *parent,
+ struct usb_device_descriptor *desc,
+ struct usb_interface_descriptor *iface,
+ struct udevice **devp)
 {
-#ifdef CONFIG_SANDBOX
struct udevice *dev;
 
*devp = NULL;
@@ -520,7 +521,7 @@ static int usb_find_emul_child(struct udevice *parent,
return 0;
}
}
-#endif
+
return -ENOENT;
 }
 
@@ -580,8 +581,8 @@ int usb_scan_device(struct udevice *parent, int port,
debug("read_descriptor for '%s': ret=%d\n", parent->name, ret);
if (ret)
return ret;
-   ret = usb_find_emul_child(parent, >descriptor, iface, );
-   debug("** usb_find_emul_child returns %d\n", ret);
+   ret = usb_find_child(parent, >descriptor, iface, );
+   debug("** usb_find_child returns %d\n", ret);
if (ret) {
if (ret != -ENOENT)
return ret;
-- 
2.6.0.rc2.230.g3dd15c0

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


[U-Boot] [PATCH v2] nios2: add 10m50 devboard support

2015-11-08 Thread Thomas Chou
Add 10m50 devboard support. It is based on the Golden Hardware
Reference Design (GHRD), available at,

http://rocketboards.org/foswiki/view/Documentation/
AlteraMAX1010M50RevCDevelopmentKitLinuxSetup

Though we supported only one nios2-generic board in the past. Now,
with the removal of the nios2-generic board dir, adding new nios2
boards to u-boot is easier than before. It should be helpful to
add those boards supported in Linux mainline. There are only two
such nios2 boards, the 3c120 devboard and 10m50 devboard. The
nios2-generic is actually 3c120, and should restore the name. The
10m50 is this one.

Signed-off-by: Thomas Chou 
---
v2
  change memory alllocation macros.
  add altera_qspi support.

 arch/nios2/dts/10m50_devboard.dts | 267 ++
 configs/10m50_defconfig   |  26 
 include/configs/10m50_devboard.h  | 103 +++
 3 files changed, 396 insertions(+)
 create mode 100644 arch/nios2/dts/10m50_devboard.dts
 create mode 100644 configs/10m50_defconfig
 create mode 100644 include/configs/10m50_devboard.h

diff --git a/arch/nios2/dts/10m50_devboard.dts 
b/arch/nios2/dts/10m50_devboard.dts
new file mode 100644
index 000..e89dbb2
--- /dev/null
+++ b/arch/nios2/dts/10m50_devboard.dts
@@ -0,0 +1,267 @@
+/*
+ *  Copyright (C) 2015 Altera Corporation
+ *
+ * This file is generated by sopc2dts.
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+/dts-v1/;
+
+/ {
+   model = "Altera NiosII Max10";
+   compatible = "altr,niosii-max10";
+   #address-cells = <1>;
+   #size-cells = <1>;
+
+   cpus {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   cpu: cpu@0 {
+   device_type = "cpu";
+   compatible = "altr,nios2-1.1";
+   reg = <0x>;
+   interrupt-controller;
+   #interrupt-cells = <1>;
+   altr,exception-addr = <0xc8000120>;
+   altr,fast-tlb-miss-addr = <0xc100>;
+   altr,has-div = <1>;
+   altr,has-initda = <1>;
+   altr,has-mmu = <1>;
+   altr,has-mul = <1>;
+   altr,implementation = "fast";
+   altr,pid-num-bits = <8>;
+   altr,reset-addr = <0xd400>;
+   altr,tlb-num-entries = <256>;
+   altr,tlb-num-ways = <16>;
+   altr,tlb-ptr-sz = <8>;
+   clock-frequency = <7500>;
+   dcache-line-size = <32>;
+   dcache-size = <32768>;
+   icache-line-size = <32>;
+   icache-size = <32768>;
+   };
+   };
+
+   memory {
+   device_type = "memory";
+   reg = <0x0800 0x0800>,
+   <0x 0x0400>;
+   };
+
+   sopc0: sopc@0 {
+   device_type = "soc";
+   ranges;
+   #address-cells = <1>;
+   #size-cells = <1>;
+   compatible = "altr,avalon", "simple-bus";
+   bus-frequency = <7500>;
+
+   jtag_uart: serial@18001530 {
+   compatible = "altr,juart-1.0";
+   reg = <0x18001530 0x0008>;
+   interrupt-parent = <>;
+   interrupts = <7>;
+   };
+
+   a_16550_uart_0: serial@18001600 {
+   compatible = "altr,16550-FIFO32", "ns16550a";
+   reg = <0x18001600 0x0200>;
+   interrupt-parent = <>;
+   interrupts = <1>;
+   auto-flow-control = <1>;
+   clock-frequency = <5000>;
+   fifo-size = <32>;
+   reg-io-width = <4>;
+   reg-shift = <2>;
+   };
+
+   ext_flash: quadspi@0x180014a0 {
+   compatible = "altr,quadspi-1.0";
+   reg = <0x180014a0 0x0020>,
+   <0x1400 0x0400>;
+   reg-names = "avl_csr", "avl_mem";
+   interrupt-parent = <>;
+   interrupts = <4>;
+   #address-cells = <1>;
+   #size-cells = <0>;
+   flash0: nor0@0 {
+   compatible = "micron,n25q512a";
+   #address-cells = <1>;
+   #size-cells = <1>;
+   };
+   };
+
+   sysid: sysid@18001528 {
+   compatible = "altr,sysid-1.0";
+   reg = <0x18001528 0x0008>;
+   };
+
+   rgmii_0_eth_tse_0: ethernet@400 {
+  

[U-Boot] [PATCH v2 00/26] usb: Drop requirement for USB unbinding, add tests

2015-11-08 Thread Simon Glass
There was quite a bit of discussion about the change that required the
unbinding of USB devices for the subsystem to function correctly. E.g.

https://patchwork.ozlabs.org/patch/485637/

The key issue is the usb_get_dev_index() function which is not a good API
for driver model. We can drop use of this function once everything is
converted to driver model. Then I believe the problems raised by Hans go
away. For now we can add a deprecation warning on the function.

It is easy to convert USB keyboards to driver model. This series includes
a patch for that.

This series also includes reverts for the three commits which as discussed
I would like to drop. U-Boot should be able to run normally and exit without
unbinding anything.

Also included are some tests for the 'usb tree' command. To make this work,
console recording is implemented.

Finally, a USB keyboard driver is provided for sandbox, so that this part
of the stack can be tested automatically.

Changes in v2:
- Add various patches to support USB keyboards and additional tests

Simon Glass (26):
  sandbox: Add a way to skip time delays
  dm: usb: Avoid time delays in sandbox tests
  Move console definitions into a new console.h file
  Drop config.h header from display_options.c
  Add a circular memory buffer implementation
  console: Add a console buffer
  sandbox: Enable console recording and silent console
  test: Record and silence console in tests
  usb: Refactor USB tree output code for testing
  dm: core: Add safe device iteration macros
  sandbox: usb: Allow dynamic emulated USB device descriptors
  sandbox: usb: Allow up to 4 emulated devices on a hub
  sandbox: usb: Allow finding a USB emulator for a device
  Revert "dm: usb: Rename usb_find_child to usb_find_emul_child"
  Revert "dm: usb: Use device_unbind_children to clean up usb devs on
stop"
  Revert "dm: Export device_remove_children / device_unbind_children"
  dm: usb: Deprecate usb_get_dev_index()
  dm: usb: Remove inactive children after a bus scan
  dm: test: usb: Add tests for the 'usb tree' command
  dm: test: usb: Add a test for device reordering
  usb: Drop unused code in usb_kbd.c
  usb: Avoid open-coded USB constants in usb_kbd.c
  usb: sandbox: Add support for interrupt operations
  usb: sandbox: Add a USB emulation driver
  sandbox: Enable USB keyboard
  dm: test: usb: sandbox: Add keyboard tests for sandbox

 arch/blackfin/lib/cmd_cache_dump.c |   1 +
 arch/powerpc/cpu/mpc8260/ether_fcc.c   |   1 +
 arch/powerpc/cpu/mpc8260/i2c.c |   1 +
 arch/powerpc/cpu/mpc8xx/i2c.c  |   1 +
 arch/sandbox/cpu/cpu.c |   5 +-
 arch/sandbox/cpu/start.c   |   8 +
 arch/sandbox/cpu/state.c   |  14 ++
 arch/sandbox/dts/test.dts  |  19 +-
 arch/sandbox/include/asm/state.h   |  20 ++
 arch/sandbox/include/asm/test.h|   2 +
 arch/sh/lib/board.c|   1 +
 arch/sparc/lib/board.c |   1 +
 board/Arcturus/ucp1020/spl.c   |   1 +
 board/astro/mcf5373l/fpga.c|   1 +
 board/cobra5272/flash.c|   1 +
 board/esd/common/cmd_loadpci.c |   1 +
 board/esd/cpci405/cpci405.c|   1 +
 board/esd/pmc405de/pmc405de.c  |   1 +
 board/esd/pmc440/cmd_pmc440.c  |   1 +
 board/esd/pmc440/pmc440.c  |   1 +
 board/esd/vme8349/caddy.c  |   1 +
 board/freescale/b4860qds/spl.c |   1 +
 board/freescale/c29xpcie/spl.c |   1 +
 board/freescale/mpc8569mds/mpc8569mds.c|   1 +
 board/freescale/p1010rdb/spl.c |   1 +
 board/freescale/p1022ds/spl.c  |   1 +
 board/freescale/p1_p2_rdb_pc/spl.c |   1 +
 board/freescale/t102xqds/spl.c |   1 +
 board/freescale/t102xrdb/spl.c |   1 +
 board/freescale/t104xrdb/spl.c |   1 +
 board/freescale/t208xqds/spl.c |   1 +
 board/freescale/t208xrdb/spl.c |   1 +
 board/freescale/t4qds/spl.c|   1 +
 board/freescale/t4rdb/spl.c|   1 +
 board/gdsys/common/cmd_ioloop.c|   1 +
 board/inka4x0/inkadiag.c   |   1 +
 board/lwmon5/kbd.c |   1 +
 board/mpl/common/kbd.c |   1 +
 board/mpl/pati/pati.c  |   1 +
 board/renesas/sh7785lcr/selfcheck.c|   1 +
 board/tqc/tqm5200/cmd_stk52xx.c|   1 +
 board/tqc/tqm5200/tqm5200.c|   1 +
 board/xes/xpedite1000/xpedite1000.c|   1 +
 common/Kconfig |  28 +++
 common/autoboot.c  |   1 +
 common/board_f.c   |  11 +
 common/board_r.c   |  11 +
 common/cli.c   |   1 +
 common/cli_hush.c  |   1 +
 common/cli_simple.c|   1 +
 

[U-Boot] [PATCH v2 05/26] Add a circular memory buffer implementation

2015-11-08 Thread Simon Glass
This will be used to support console recording. It provides for a circular
buffer which can be written at the head and read from the tail. It supports
avoiding data copying by providing raw access to the data.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 include/membuff.h | 246 ++
 lib/Makefile  |   1 +
 lib/membuff.c | 390 ++
 3 files changed, 637 insertions(+)
 create mode 100644 include/membuff.h
 create mode 100644 lib/membuff.c

diff --git a/include/membuff.h b/include/membuff.h
new file mode 100644
index 000..78918e7
--- /dev/null
+++ b/include/membuff.h
@@ -0,0 +1,246 @@
+/*
+ * Copyright (c) 2015 Google, Inc
+ * Written by Simon Glass 
+ *
+ * Copyright (c) 1992 Simon Glass
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#ifndef _MEMBUFF_H
+#define _MEMBUFF_H
+
+/**
+ * @struct membuff: holds the state of a membuff - it is used for input and
+ * output buffers. The buffer extends from @start to (@start + @size - 1).
+ * Data in the buffer extends from @tail to @head: it is written in at
+ * @head and read out from @tail. The membuff is empty when @head == @tail
+ * and full when adding another character would make @head == @tail. We
+ * therefore waste one character in the membuff to avoid having an extra flag
+ * to determine whether (when @head == @tail) the membuff is empty or full.
+ *
+ * xx  data
+ * ..  empty
+ *
+ * ..
+ * ^   ^
+ * tailhead
+ *
+ * xx
+ * ^   ^
+ * headtail
+ */
+struct membuff {
+   char *start;/** the start of the buffer */
+   char *end;  /** the end of the buffer (start + length) */
+   char *head; /** current buffer head */
+   char *tail; /** current buffer tail */
+};
+
+/**
+ * membuff_purge() - reset a membuff to the empty state
+ *
+ * Initialise head and tail pointers so that the membuff becomes empty.
+ *
+ * @mb: membuff to purge
+ */
+void membuff_purge(struct membuff *mb);
+
+/**
+ * membuff_putraw() - find out where bytes can be written
+ *
+ * Work out where in the membuff some data could be written. Return a pointer
+ * to the address and the number of bytes which can be written there. If
+ * @update is true, the caller must then write the data immediately, since
+ * the membuff is updated as if the write has been done,
+ *
+ * Note that because the spare space in a membuff may not be contiguous, this
+ * function may not return @maxlen even if there is enough space in the
+ * membuff. However, by calling this function twice (with @update == true),
+ * you will get access to all the spare space.
+ *
+ * @mb: membuff to adjust
+ * @maxlen: the number of bytes we want to write
+ * @update: true to update the membuff as if the write happened, false to not
+ * @data: the address data can be written to
+ * @return number of bytes which can be written
+ */
+int membuff_putraw(struct membuff *mb, int maxlen, bool update, char **data);
+
+/**
+ * membuff_getraw() - find and return a pointer to available bytes
+ *
+ * Returns a pointer to any valid input data in the given membuff and
+ * optionally marks it as read. Note that not all input data may not be
+ * returned, since data is not necessarily contiguous in the membuff. However,
+ * if you call this function twice (with @update == true) you are guaranteed
+ * to get all available data, in at most two installments.
+ *
+ * @mb: membuff to adjust
+ * @maxlen: maximum number of bytes to get
+ * @update: true to update the membuff as if the bytes have been read (use
+ * false to check bytes without reading them)
+ * @data: returns address of data in input membuff
+ * @return the number of bytes available at *@data
+ */
+int membuff_getraw(struct membuff *mb, int maxlen, bool update, char **data);
+
+/**
+ * membuff_putbyte() - Writes a byte to a membuff
+ *
+ * @mb: membuff to adjust
+ * @ch: byte to write
+ * @return true on success, false if membuff is full
+ */
+bool membuff_putbyte(struct membuff *mb, int ch);
+
+/**
+ * @mb: membuff to adjust
+ * membuff_getbyte() - Read a byte from the membuff
+ * @return the byte read, or -1 if the membuff is empty
+ */
+int membuff_getbyte(struct membuff *mb);
+
+/**
+ * membuff_peekbyte() - check the next available byte
+ *
+ * Return the next byte which membuff_getbyte() would return, without
+ * removing it from the membuff.
+ *
+ * @mb: membuff to adjust
+ * @return the byte peeked, or -1 if the membuff is empty
+ */
+int membuff_peekbyte(struct membuff *mb);
+
+/**
+ * membuff_get() - get data from a membuff
+ *
+ * Copies any available data (up to @maxlen bytes) to @buff and removes it
+ * from the membuff.
+ *
+ * @mb: membuff to adjust
+ * @Buff: 

[U-Boot] [PATCH v2 02/26] dm: usb: Avoid time delays in sandbox tests

2015-11-08 Thread Simon Glass
Currently the USB tests take around two seconds to run. Remove these
unnecessary time delays so that the tests run quickly.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 common/usb_hub.c| 10 +-
 test/dm/test-main.c |  2 ++
 test/dm/usb.c   |  3 +++
 3 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/common/usb_hub.c b/common/usb_hub.c
index a92c9fb..e1de813 100644
--- a/common/usb_hub.c
+++ b/common/usb_hub.c
@@ -31,6 +31,9 @@
 #include 
 #include 
 #include 
+#ifdef CONFIG_SANDBOX
+#include 
+#endif
 #include 
 #include 
 
@@ -466,7 +469,12 @@ static int usb_hub_configure(struct usb_device *dev)
unsigned short portstatus, portchange;
int ret;
ulong start = get_timer(0);
+   uint delay = CONFIG_SYS_HZ;
 
+#ifdef CONFIG_SANDBOX
+   if (state_get_skip_delays())
+   delay = 0;
+#endif
 #ifdef CONFIG_DM_USB
debug("\n\nScanning '%s' port %d\n", dev->dev->name, i + 1);
 #else
@@ -498,7 +506,7 @@ static int usb_hub_configure(struct usb_device *dev)
if (portstatus & USB_PORT_STAT_CONNECTION)
break;
 
-   } while (get_timer(start) < CONFIG_SYS_HZ * 1);
+   } while (get_timer(start) < delay);
 
if (ret < 0)
continue;
diff --git a/test/dm/test-main.c b/test/dm/test-main.c
index 0e43ab9..a36a9c0 100644
--- a/test/dm/test-main.c
+++ b/test/dm/test-main.c
@@ -9,6 +9,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -113,6 +114,7 @@ static int dm_test_main(const char *test_name)
ut_assertok(dm_scan_fdt(gd->fdt_blob, false));
 
test->func(uts);
+   state_set_skip_delays(false);
 
ut_assertok(dm_test_destroy(uts));
}
diff --git a/test/dm/usb.c b/test/dm/usb.c
index 9939d83..4300bbd 100644
--- a/test/dm/usb.c
+++ b/test/dm/usb.c
@@ -8,6 +8,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 
@@ -35,6 +37,7 @@ static int dm_test_usb_flash(struct unit_test_state *uts)
block_dev_desc_t *dev_desc;
char cmp[1024];
 
+   state_set_skip_delays(true);
ut_assertok(usb_init());
ut_assertok(uclass_get_device(UCLASS_MASS_STORAGE, 0, ));
ut_assertok(get_device("usb", "0", _desc));
-- 
2.6.0.rc2.230.g3dd15c0

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


[U-Boot] [PATCH v2 01/26] sandbox: Add a way to skip time delays

2015-11-08 Thread Simon Glass
Some tests are slow due to delays which are unnecessary on sandbox. The
worst offender is USB where we lose two seconds. Add a way to disable time
delays.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 arch/sandbox/cpu/cpu.c   |  5 -
 arch/sandbox/cpu/state.c | 14 ++
 arch/sandbox/include/asm/state.h | 19 +++
 3 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/arch/sandbox/cpu/cpu.c b/arch/sandbox/cpu/cpu.c
index 3a7f5a0..196f3e1 100644
--- a/arch/sandbox/cpu/cpu.c
+++ b/arch/sandbox/cpu/cpu.c
@@ -37,7 +37,10 @@ void sandbox_exit(void)
 /* delay x useconds */
 void __udelay(unsigned long usec)
 {
-   os_usleep(usec);
+   struct sandbox_state *state = state_get_current();
+
+   if (!state->skip_delays)
+   os_usleep(usec);
 }
 
 int cleanup_before_linux(void)
diff --git a/arch/sandbox/cpu/state.c b/arch/sandbox/cpu/state.c
index 7e5d03e..d2a7dc9 100644
--- a/arch/sandbox/cpu/state.c
+++ b/arch/sandbox/cpu/state.c
@@ -337,6 +337,20 @@ struct sandbox_state *state_get_current(void)
return state;
 }
 
+void state_set_skip_delays(bool skip_delays)
+{
+   struct sandbox_state *state = state_get_current();
+
+   state->skip_delays = skip_delays;
+}
+
+bool state_get_skip_delays(void)
+{
+   struct sandbox_state *state = state_get_current();
+
+   return state->skip_delays;
+}
+
 int state_init(void)
 {
state = _state;
diff --git a/arch/sandbox/include/asm/state.h b/arch/sandbox/include/asm/state.h
index 2bd28f6..e876ba2 100644
--- a/arch/sandbox/include/asm/state.h
+++ b/arch/sandbox/include/asm/state.h
@@ -63,6 +63,7 @@ struct sandbox_state {
enum reset_t last_reset;/* Last reset type */
bool reset_allowed[RESET_COUNT];/* Allowed reset types */
enum state_terminal_raw term_raw;   /* Terminal raw/cooked */
+   bool skip_delays;   /* Ignore any time delays (for test) */
 
/* Pointer to information for each SPI bus/cs */
struct sandbox_spi_info spi[CONFIG_SANDBOX_SPI_MAX_BUS]
@@ -185,6 +186,24 @@ int sandbox_write_state(struct sandbox_state *state, const 
char *fname);
 int state_setprop(int node, const char *prop_name, const void *data, int size);
 
 /**
+ * Control skipping of time delays
+ *
+ * Some tests have unnecessay time delays (e.g. USB). Allow these to be
+ * skipped to speed up testing
+ *
+ * @param skip_delays  true to skip delays from now on, false to honour delay
+ * requests
+ */
+void state_set_skip_delays(bool skip_delays);
+
+/**
+ * See if delays should be skipped
+ *
+ * @return true if delays should be skipped, false if they should be honoured
+ */
+bool state_get_skip_delays(void);
+
+/**
  * Initialize the test system state
  */
 int state_init(void);
-- 
2.6.0.rc2.230.g3dd15c0

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


[U-Boot] [PATCH v2 04/26] Drop config.h header from display_options.c

2015-11-08 Thread Simon Glass
Since common.h will always include this automatically, it is not needed.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 lib/display_options.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/lib/display_options.c b/lib/display_options.c
index 4f2961f..29343fc 100644
--- a/lib/display_options.c
+++ b/lib/display_options.c
@@ -5,7 +5,6 @@
  * SPDX-License-Identifier:GPL-2.0+
  */
 
-#include 
 #include 
 #include 
 #include 
-- 
2.6.0.rc2.230.g3dd15c0

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


[U-Boot] [PATCH v2 21/26] usb: Drop unused code in usb_kbd.c

2015-11-08 Thread Simon Glass
This was missed in the conversion to driver model.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 common/usb_kbd.c | 30 --
 1 file changed, 30 deletions(-)

diff --git a/common/usb_kbd.c b/common/usb_kbd.c
index 5a90f84..1d85212 100644
--- a/common/usb_kbd.c
+++ b/common/usb_kbd.c
@@ -541,35 +541,6 @@ int drv_usb_kbd_init(void)
int error, i;
 
debug("%s: Probing for keyboard\n", __func__);
-#ifdef CONFIG_DM_USB
-   /*
-* TODO: We should add U_BOOT_USB_DEVICE() declarations to each USB
-* keyboard driver and then most of this file can be removed.
-*/
-   struct udevice *bus;
-   struct uclass *uc;
-   int ret;
-
-   ret = uclass_get(UCLASS_USB, );
-   if (ret)
-   return ret;
-   uclass_foreach_dev(bus, uc) {
-   for (i = 0; i < USB_MAX_DEVICE; i++) {
-   struct usb_device *dev;
-
-   dev = usb_get_dev_index(bus, i); /* get device */
-   debug("i=%d, %p\n", i, dev);
-   if (!dev)
-   break; /* no more devices available */
-
-   error = probe_usb_keyboard(dev);
-   if (!error)
-   return 1;
-   if (error && error != -ENOENT)
-   return error;
-   } /* for */
-   }
-#else
/* Scan all USB Devices */
for (i = 0; i < USB_MAX_DEVICE; i++) {
struct usb_device *dev;
@@ -588,7 +559,6 @@ int drv_usb_kbd_init(void)
if (error && error != -ENOENT)
return error;
}
-#endif
 
/* No USB Keyboard found */
return -1;
-- 
2.6.0.rc2.230.g3dd15c0

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


[U-Boot] [PATCH v2 19/26] dm: test: usb: Add tests for the 'usb tree' command

2015-11-08 Thread Simon Glass
Add tests that this command produces the right output, even when a rescan
results in a device disappearing from the bus.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 arch/sandbox/dts/test.dts |  14 -
 test/dm/usb.c | 156 ++
 2 files changed, 169 insertions(+), 1 deletion(-)

diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index e2c4971..52749c0 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -307,12 +307,24 @@
compatible = "sandbox,usb-hub";
#address-cells = <1>;
#size-cells = <0>;
-   flash-stick {
+   flash-stick@0 {
reg = <0>;
compatible = "sandbox,usb-flash";
sandbox,filepath = "testflash.bin";
};
 
+   flash-stick@1 {
+   reg = <1>;
+   compatible = "sandbox,usb-flash";
+   sandbox,filepath = "testflash1.bin";
+   };
+
+   flash-stick@2 {
+   reg = <2>;
+   compatible = "sandbox,usb-flash";
+   sandbox,filepath = "testflash2.bin";
+   };
+
};
};
};
diff --git a/test/dm/usb.c b/test/dm/usb.c
index ccc07d5..721d3ad 100644
--- a/test/dm/usb.c
+++ b/test/dm/usb.c
@@ -12,8 +12,11 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
+DECLARE_GLOBAL_DATA_PTR;
+
 /* Test that sandbox USB works correctly */
 static int dm_test_usb_base(struct unit_test_state *uts)
 {
@@ -52,3 +55,156 @@ static int dm_test_usb_flash(struct unit_test_state *uts)
return 0;
 }
 DM_TEST(dm_test_usb_flash, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
+/* test that we can handle multiple storage devices */
+static int dm_test_usb_multi(struct unit_test_state *uts)
+{
+   struct udevice *dev;
+
+   state_set_skip_delays(true);
+   ut_assertok(usb_init());
+   ut_assertok(uclass_get_device(UCLASS_MASS_STORAGE, 0, ));
+   ut_assertok(uclass_get_device(UCLASS_MASS_STORAGE, 1, ));
+   ut_assertok(uclass_get_device(UCLASS_MASS_STORAGE, 2, ));
+
+   return 0;
+}
+DM_TEST(dm_test_usb_multi, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
+static int count_usb_devices(void)
+{
+   struct udevice *hub;
+   struct uclass *uc;
+   int count = 0;
+   int ret;
+
+   ret = uclass_get(UCLASS_USB_HUB, );
+   if (ret)
+   return ret;
+
+   uclass_foreach_dev(hub, uc) {
+   struct udevice *dev;
+
+   count++;
+   for (device_find_first_child(hub, );
+dev;
+device_find_next_child()) {
+   count++;
+   }
+   }
+
+   return count;
+}
+
+/* test that we can remove an emulated device and it is then not found */
+static int dm_test_usb_remove(struct unit_test_state *uts)
+{
+   struct udevice *dev, *emul;
+
+   /* Scan and check that all devices are present */
+   state_set_skip_delays(true);
+   ut_assertok(usb_init());
+   ut_assertok(uclass_get_device(UCLASS_MASS_STORAGE, 0, ));
+   ut_assertok(uclass_get_device(UCLASS_MASS_STORAGE, 1, ));
+   ut_assertok(uclass_get_device(UCLASS_MASS_STORAGE, 2, ));
+   ut_asserteq(5, count_usb_devices());
+   ut_assertok(usb_stop());
+   ut_asserteq(5, count_usb_devices());
+
+   /* Remove the second emulation device */
+   ut_assertok(uclass_find_device_by_name(UCLASS_USB_EMUL, "flash-stick@1",
+  ));
+   ut_assertok(device_unbind(dev));
+
+   /* Rescan - only the first and third should be present */
+   ut_assertok(usb_init());
+   ut_assertok(uclass_get_device(UCLASS_MASS_STORAGE, 0, ));
+   ut_assertok(usb_emul_find_for_dev(dev, ));
+   ut_asserteq_str("flash-stick@0", emul->name);
+   ut_assertok(uclass_get_device(UCLASS_MASS_STORAGE, 1, ));
+   ut_assertok(usb_emul_find_for_dev(dev, ));
+   ut_asserteq_str("flash-stick@2", emul->name);
+
+   ut_asserteq(-ENODEV, uclass_get_device(UCLASS_MASS_STORAGE, 2, ));
+
+   ut_asserteq(4, count_usb_devices());
+   ut_assertok(usb_stop());
+   ut_asserteq(4, count_usb_devices());
+
+   return 0;
+}
+DM_TEST(dm_test_usb_remove, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
+const char usb_tree_base[] =
+"  1  Hub (12 Mb/s, 100mA)\n"
+"  |  sandbox hub 2345\n"
+"  |\n"
+"  |\b+-2  Mass Storage (12 Mb/s, 100mA)\n"
+"  |sandbox flash 

[U-Boot] [PATCH v2 24/26] usb: sandbox: Add a USB emulation driver

2015-11-08 Thread Simon Glass
Add a simple USB keyboard driver for sandbox. It provides a function to
'load' it with input data, which it will then stream through to the normal
U-Boot input subsystem. When the input data is exhausted, the keyboard stops
providing data.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 arch/sandbox/include/asm/test.h |   2 +
 drivers/usb/emul/Makefile   |   1 +
 drivers/usb/emul/sandbox_keyb.c | 241 
 include/linux/usb/ch9.h |  20 
 4 files changed, 264 insertions(+)
 create mode 100644 drivers/usb/emul/sandbox_keyb.c

diff --git a/arch/sandbox/include/asm/test.h b/arch/sandbox/include/asm/test.h
index d3c7851..224b0eb 100644
--- a/arch/sandbox/include/asm/test.h
+++ b/arch/sandbox/include/asm/test.h
@@ -86,4 +86,6 @@ long sandbox_i2c_rtc_set_offset(struct udevice *dev, bool 
use_system_time,
  */
 long sandbox_i2c_rtc_get_set_base_time(struct udevice *dev, long base_time);
 
+int sandbox_usb_keyb_add_string(struct udevice *dev, const char *str);
+
 #endif
diff --git a/drivers/usb/emul/Makefile b/drivers/usb/emul/Makefile
index 8fd83d5..b64ac6d 100644
--- a/drivers/usb/emul/Makefile
+++ b/drivers/usb/emul/Makefile
@@ -7,4 +7,5 @@
 
 obj-$(CONFIG_USB_EMUL) += sandbox_flash.o
 obj-$(CONFIG_USB_EMUL) += sandbox_hub.o
+obj-$(CONFIG_USB_EMUL) += sandbox_keyb.o
 obj-$(CONFIG_USB_EMUL) += usb-emul-uclass.o
diff --git a/drivers/usb/emul/sandbox_keyb.c b/drivers/usb/emul/sandbox_keyb.c
new file mode 100644
index 000..2735985
--- /dev/null
+++ b/drivers/usb/emul/sandbox_keyb.c
@@ -0,0 +1,241 @@
+/*
+ * (C) Copyright 2015 Google, Inc
+ * Written by Simon Glass 
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
+
+/*
+ * This driver emulates a USB keyboard using the USB HID specification (boot
+ * protocol)
+ */
+
+enum {
+   SANDBOX_KEYB_EP_IN  = 1,/* endpoints */
+};
+
+enum cmd_phase {
+   PHASE_START,
+   PHASE_DATA,
+   PHASE_STATUS,
+};
+
+enum {
+   STRINGID_MANUFACTURER = 1,
+   STRINGID_PRODUCT,
+   STRINGID_SERIAL,
+
+   STRINGID_COUNT,
+};
+
+/**
+ * struct sandbox_keyb_priv - private state for this driver
+ *
+ */
+struct sandbox_keyb_priv {
+   struct membuff in;
+};
+
+struct sandbox_keyb_plat {
+   struct usb_string keyb_strings[STRINGID_COUNT];
+};
+
+static struct usb_device_descriptor keyb_device_desc = {
+   .bLength =  sizeof(keyb_device_desc),
+   .bDescriptorType =  USB_DT_DEVICE,
+
+   .bcdUSB =   __constant_cpu_to_le16(0x0100),
+
+   .bDeviceClass = 0,
+   .bDeviceSubClass =  0,
+   .bDeviceProtocol =  0,
+
+   .idVendor = __constant_cpu_to_le16(0x1234),
+   .idProduct =__constant_cpu_to_le16(0x5679),
+   .iManufacturer =STRINGID_MANUFACTURER,
+   .iProduct = STRINGID_PRODUCT,
+   .iSerialNumber =STRINGID_SERIAL,
+   .bNumConfigurations =   1,
+};
+
+static struct usb_config_descriptor keyb_config0 = {
+   .bLength= sizeof(keyb_config0),
+   .bDescriptorType= USB_DT_CONFIG,
+
+   /* wTotalLength is set up by usb-emul-uclass */
+   .bNumInterfaces = 2,
+   .bConfigurationValue= 0,
+   .iConfiguration = 0,
+   .bmAttributes   = 1 << 7 | 1 << 5,
+   .bMaxPower  = 50,
+};
+
+static struct usb_interface_descriptor keyb_interface0 = {
+   .bLength= sizeof(keyb_interface0),
+   .bDescriptorType= USB_DT_INTERFACE,
+
+   .bInterfaceNumber   = 0,
+   .bAlternateSetting  = 0,
+   .bNumEndpoints  = 1,
+   .bInterfaceClass= USB_CLASS_HID,
+   .bInterfaceSubClass = USB_SUB_HID_BOOT,
+   .bInterfaceProtocol = USB_PROT_HID_KEYBOARD,
+   .iInterface = 0,
+};
+
+static struct usb_class_hid_descriptor keyb_report0 = {
+   .bLength= sizeof(keyb_report0),
+   .bDescriptorType= USB_DT_HID,
+   .bcdCDC = 0x101,
+   .bCountryCode   = 0,
+   .bNumDescriptors= 1,
+   .bDescriptorType0   = USB_DT_HID_REPORT,
+   .wDescriptorLength0 = 0x3f,
+};
+
+static struct usb_endpoint_descriptor keyb_endpoint0_in = {
+   .bLength= USB_DT_ENDPOINT_SIZE,
+   .bDescriptorType= USB_DT_ENDPOINT,
+
+   .bEndpointAddress   = SANDBOX_KEYB_EP_IN | USB_ENDPOINT_DIR_MASK,
+   .bmAttributes   = USB_ENDPOINT_XFER_BULK |
+   USB_ENDPOINT_XFER_ISOC,
+   .wMaxPacketSize = __constant_cpu_to_le16(8),
+   .bInterval  = 0xa,
+};
+
+static struct usb_interface_descriptor keyb_interface1 = {
+   .bLength= sizeof(keyb_interface1),
+   

[U-Boot] [PATCH v2 26/26] dm: test: usb: sandbox: Add keyboard tests for sandbox

2015-11-08 Thread Simon Glass
Add a test that verifies that USB keyboards work correctly on sandbox.
This verifies some additional parts of the USB stack.

Signed-off-by: Simon Glass 
---

Changes in v2:
- Add various patches to support USB keyboards and additional tests

 arch/sandbox/dts/test.dts |  5 +
 test/dm/usb.c | 31 +++
 2 files changed, 36 insertions(+)

diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index 52749c0..b6d9a15 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -325,6 +325,11 @@
sandbox,filepath = "testflash2.bin";
};
 
+   keyb@3 {
+   reg = <3>;
+   compatible = "sandbox,usb-keyb";
+   };
+
};
};
};
diff --git a/test/dm/usb.c b/test/dm/usb.c
index fb193e8..7d6b644 100644
--- a/test/dm/usb.c
+++ b/test/dm/usb.c
@@ -10,6 +10,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -258,3 +259,33 @@ static int dm_test_usb_tree_reorder(struct unit_test_state 
*uts)
return 0;
 }
 DM_TEST(dm_test_usb_tree_reorder, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
+static int dm_test_usb_keyb(struct unit_test_state *uts)
+{
+   struct udevice *dev;
+
+   state_set_skip_delays(true);
+   ut_assertok(usb_init());
+
+   /* Initially there should be no characters */
+   ut_asserteq(0, tstc());
+
+   ut_assertok(uclass_get_device_by_name(UCLASS_USB_EMUL, "keyb",
+ ));
+
+   /*
+* Add a string to the USB keyboard buffer - it should appear in
+* stdin
+*/
+   ut_assertok(sandbox_usb_keyb_add_string(dev, "ab"));
+   ut_asserteq(1, tstc());
+   ut_asserteq('a', getc());
+   ut_asserteq(1, tstc());
+   ut_asserteq('b', getc());
+   ut_asserteq(0, tstc());
+
+   ut_assertok(usb_stop());
+
+   return 0;
+}
+DM_TEST(dm_test_usb_keyb, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
-- 
2.6.0.rc2.230.g3dd15c0

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


[U-Boot] [RFC PATCH v2 10/11] net: IPv6 documentation

2015-11-08 Thread Chris Packham
Signed-off-by: Chris Packham 
---

Changes in v2: None

 README  |  3 +++
 doc/README.ipv6 | 32 
 2 files changed, 35 insertions(+)
 create mode 100644 doc/README.ipv6

diff --git a/README b/README
index ef8d437..64b431d 100644
--- a/README
+++ b/README
@@ -1110,6 +1110,7 @@ The following options need to be configured:
CONFIG_CMD_MTDPARTS * MTD partition support
CONFIG_CMD_NAND * NAND support
CONFIG_CMD_NETbootp, tftpboot, rarpboot
+   CONFIG_CMD_NET6 * tftpboot6
CONFIG_CMD_NFSNFS support
CONFIG_CMD_PCA953X  * PCA953x I2C gpio commands
CONFIG_CMD_PCA953X_INFO * PCA953x I2C gpio info command
@@ -1117,6 +1118,8 @@ The following options need to be configured:
CONFIG_CMD_PCMCIA   * PCMCIA support
CONFIG_CMD_PING * send ICMP ECHO_REQUEST to network
  host
+   CONFIG_CMD_PING6* send ICMPv6 ECHO_REQUEST to network
+ host
CONFIG_CMD_PORTIO   * Port I/O
CONFIG_CMD_READ * Read raw data from partition
CONFIG_CMD_REGINFO  * Register dump
diff --git a/doc/README.ipv6 b/doc/README.ipv6
new file mode 100644
index 000..0537246
--- /dev/null
+++ b/doc/README.ipv6
@@ -0,0 +1,32 @@
+IPv6 Support in U-boot
+--
+IPv6 support in U-boot can be considered experimental. The commands
+currently supported are tftpboot6 and ping6.
+
+The following environment variables are used
+- ip6addr - IPv6 address of the device
+- gatewayip6 - IPv6 address of the default gateway
+- serverip6 - IPv6 of the tftp server
+
+Configuration
+-
+The following configuration option needs to be selected to support IPv6.
+- CONFIG_CMD_NET6
+Optionally the following can also be selected to enable the ping6
+command.
+- CONFIG_CMD_PING6
+
+TFTP Server Configuration
+-
+At the time of writing U-boot has been tested against tftp-hpa
+(https://www.kernel.org/pub/software/network/tftp/) the default Debian
+package sets TFTP_ADDRESS=0.0.0.0:69 (in /etc/default/tftpd-hpa) to
+support both IPv4 and IPv6 this need to be changed to ':69'.
+
+Ethernet Driver Requirements
+
+For IPv6 to operate correctly the Ethernet device needs to support
+transmission and reception of L2 multicast packets. Transmission is
+usually not a problem. To receive multicast packets the driver needs to
+enable promiscuous mode (some devices have the option of just enabling
+promiscuous multicast reception).
-- 
2.5.3

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


[U-Boot] [RFC PATCH v2 07/11] net: IPv6 support

2015-11-08 Thread Chris Packham
Adds basic support for IPv6. Neighbor discovery and ping6 are the only
things supported at the moment.

Helped-by: Hanna Hawa  [endian & alignment fixes]
Signed-off-by: Chris Packham 

---
Now we have something functional. With this and the next patch you can
do something like 'setenv ipaddr6 3ffe::1/64' and 'ping6 3ffe::2' should
work.

I seem to have a problem that when you send a ping6 for a non-existent
address that ends up stuck and the next non-ipv6 net operation tries to
resolve it. I suspect this is because the pending neighbor discovery
information isn't cleaned up properly, I need to look into that.

Changes in v2:
- split ping6 support into separate patch
- split environment variables into separate patch
- change ip6_ndisc_* to ndisc_*, fix CamelCase

 include/net.h  |   1 +
 include/net6.h | 194 +
 net/Makefile   |   2 +
 net/ndisc.c| 266 ++
 net/ndisc.h|  25 +
 net/net.c  |  38 +++-
 net/net6.c | 299 +
 7 files changed, 823 insertions(+), 2 deletions(-)
 create mode 100644 net/ndisc.c
 create mode 100644 net/ndisc.h

diff --git a/include/net.h b/include/net.h
index e8bd2b7..8b7c878 100644
--- a/include/net.h
+++ b/include/net.h
@@ -316,6 +316,7 @@ struct vlan_ethernet_hdr {
 #define VLAN_ETHER_HDR_SIZE(sizeof(struct vlan_ethernet_hdr))
 
 #define PROT_IP0x0800  /* IP protocol  
*/
+#define PROT_IP60x86DD  /* IPv6 protocol   */
 #define PROT_ARP   0x0806  /* IP ARP protocol  */
 #define PROT_RARP  0x8035  /* IP ARP protocol  */
 #define PROT_VLAN  0x8100  /* IEEE 802.1q protocol */
diff --git a/include/net6.h b/include/net6.h
index a41eb87..ff97c39 100644
--- a/include/net6.h
+++ b/include/net6.h
@@ -22,6 +22,16 @@ struct in6_addr {
 #define s6_addr32  in6_u.u6_addr32
 };
 
+#define IN6ADDRSZ  sizeof(struct in6_addr)
+#define INETHADDRSZsizeof(net_ethaddr)
+
+#define IPV6_ADDRSCOPE_INTF0x01
+#define IPV6_ADDRSCOPE_LINK0x02
+#define IPV6_ADDRSCOPE_AMDIN   0x04
+#define IPV6_ADDRSCOPE_SITE0x05
+#define IPV6_ADDRSCOPE_ORG 0x08
+#define IPV6_ADDRSCOPE_GLOBAL  0x0E
+
 /**
  * struct ipv6hdr - Internet Protocol V6 (IPv6) header.
  *
@@ -45,6 +55,145 @@ struct ip6_hdr {
struct in6_addr daddr;
 };
 
+#define IP6_HDR_SIZE (sizeof(struct ip6_hdr))
+
+/* Handy for static initialisations of struct in6_addr, atlhough the
+ * c99 '= { 0 }' idiom might work depending on you compiler. */
+#define ZERO_IPV6_ADDR { { { 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x00, 0x00 } } }
+
+#define IPV6_LINK_LOCAL_PREFIX 0xfe80
+
+enum {
+   __ND_OPT_PREFIX_INFO_END= 0,
+   ND_OPT_SOURCE_LL_ADDR   = 1,
+   ND_OPT_TARGET_LL_ADDR   = 2,
+   ND_OPT_PREFIX_INFO  = 3,
+   ND_OPT_REDIRECT_HDR = 4,
+   ND_OPT_MTU  = 5,
+   __ND_OPT_MAX
+};
+
+/* ICMPv6 */
+#define IPPROTO_ICMPV6 58
+/* hop limit for neighbour discovery packets */
+#define IPV6_NDISC_HOPLIMIT 255
+#define NDISC_TIMEOUT  5000UL
+#define NDISC_TIMEOUT_COUNT 3
+
+struct icmp6hdr {
+   __u8icmp6_type;
+#define IPV6_ICMP_ECHO_REQUEST 128
+#define IPV6_ICMP_ECHO_REPLY   129
+#define IPV6_NDISC_ROUTER_SOLICITATION 133
+#define IPV6_NDISC_ROUTER_ADVERTISEMENT134
+#define IPV6_NDISC_NEIGHBOUR_SOLICITATION  135
+#define IPV6_NDISC_NEIGHBOUR_ADVERTISEMENT 136
+#define IPV6_NDISC_REDIRECT137
+   __u8icmp6_code;
+   __be16  icmp6_cksum;
+
+   union {
+   __be32  un_data32[1];
+   __be16  un_data16[2];
+   __u8un_data8[4];
+
+   struct icmpv6_echo {
+   __be16  identifier;
+   __be16  sequence;
+   } u_echo;
+
+   struct icmpv6_nd_advt {
+#if defined(__LITTLE_ENDIAN_BITFIELD)
+   __be32  reserved:5,
+   override:1,
+   solicited:1,
+   router:1,
+   reserved2:24;
+#elif defined(__BIG_ENDIAN_BITFIELD)
+   __be32  router:1,
+   solicited:1,
+   override:1,
+   reserved:29;
+#else
+#error "Please fix "
+#endif
+   } u_nd_advt;
+
+   struct icmpv6_nd_ra {
+  

[U-Boot] [RFC PATCH v2 09/11] net: TFTP over IPv6

2015-11-08 Thread Chris Packham
Add support for UDP/TFTP over IPv6. To support specifying an server IPv6
address in the command square brackets must be used to separate the
address from the filename. e.g
  tftpboot6 [2001:db8::1]:zImage

Signed-off-by: Chris Packham 
---

Changes in v2: None

 common/Kconfig   |  9 
 common/cmd_net.c | 13 
 include/net.h|  2 +-
 include/net6.h   |  4 
 net/net.c|  3 +++
 net/net6.c   | 64 
 net/tftp.c   | 58 ++
 7 files changed, 152 insertions(+), 1 deletion(-)

diff --git a/common/Kconfig b/common/Kconfig
index b1effc6..5914328 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -400,6 +400,15 @@ config CMD_NET
  bootp - boot image via network using BOOTP/TFTP protocol
  tftpboot - boot image via network using TFTP protocol
 
+config CMD_NET6
+   bool "ipv6 commands"
+   select NET
+   select NET6
+   default n
+   help
+ IPv6 network commands
+ tftpboot6 - boot image via network using TFTP protocol
+
 config CMD_TFTPPUT
bool "tftp put"
help
diff --git a/common/cmd_net.c b/common/cmd_net.c
index 271f91d..47b56ee 100644
--- a/common/cmd_net.c
+++ b/common/cmd_net.c
@@ -42,6 +42,19 @@ U_BOOT_CMD(
"[loadAddress] [[hostIPaddr:]bootfilename]"
 );
 
+#ifdef CONFIG_CMD_NET6
+int do_tftpb6(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+   return netboot_common(TFTP6, cmdtp, argc, argv);
+}
+
+U_BOOT_CMD(
+   tftpboot6,  3,  1,  do_tftpb6,
+   "boot image via network using TFTP protocol",
+   "[loadAddress] [[hostIP6Addr]:][bootfilename]"
+);
+#endif
+
 #ifdef CONFIG_CMD_TFTPPUT
 int do_tftpput(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
diff --git a/include/net.h b/include/net.h
index 6a9832c..69e6a17 100644
--- a/include/net.h
+++ b/include/net.h
@@ -525,7 +525,7 @@ extern int  net_restart_wrap;   /* Tried all 
network devices */
 
 enum proto_t {
BOOTP, RARP, ARP, TFTPGET, DHCP, PING, PING6, DNS, NFS, CDP, NETCONS,
-   SNTP, TFTPSRV, TFTPPUT, LINKLOCAL
+   SNTP, TFTPSRV, TFTPPUT, TFTP6, LINKLOCAL
 };
 
 extern charnet_boot_file_name[1024];/* Boot File name */
diff --git a/include/net6.h b/include/net6.h
index ff97c39..7ae1777 100644
--- a/include/net6.h
+++ b/include/net6.h
@@ -246,6 +246,10 @@ void ping6_start(void);
 void ping6_receive(struct ethernet_hdr *et, struct ip6_hdr *ip6,
  int len);
 
+/* Transmit UDP packet using IPv6, performing neighbour discovery if needed */
+int net_send_udp_packet6(uchar *ether, struct in6_addr *dest,
+   int dport, int sport, int len);
+
 /* handler for incoming IPv6 echo packet */
 void net_ip6_handler(struct ethernet_hdr *et, struct ip6_hdr *ip6,
int len);
diff --git a/net/net.c b/net/net.c
index ca24673..2b0d17e 100644
--- a/net/net.c
+++ b/net/net.c
@@ -453,6 +453,9 @@ restart:
 #ifdef CONFIG_CMD_TFTPPUT
case TFTPPUT:
 #endif
+#ifdef CONFIG_CMD_NET6
+   case TFTP6:
+#endif
/* always use ARP to get server ethernet address */
tftp_start(protocol);
break;
diff --git a/net/net6.c b/net/net6.c
index 8f0c721..5b8a003 100644
--- a/net/net6.c
+++ b/net/net6.c
@@ -342,6 +342,50 @@ ip6_add_hdr(uchar *xip, struct in6_addr *src, struct 
in6_addr *dest,
return sizeof(struct ip6_hdr);
 }
 
+int
+net_send_udp_packet6(uchar *ether, struct in6_addr *dest, int dport, int 
sport, int len)
+{
+   uchar *pkt;
+   struct udp_hdr *udp;
+
+   udp = (struct udp_hdr *)((uchar *)net_tx_packet + net_eth_hdr_size() + 
IP6_HDR_SIZE);
+
+   udp->udp_dst = htons(dport);
+   udp->udp_src = htons(sport);
+   udp->udp_len = htons(len + UDP_HDR_SIZE);
+   /* checksum */
+   udp->udp_xsum = 0;
+   udp->udp_xsum = csum_ipv6_magic(_ip6, dest, len + UDP_HDR_SIZE,
+   IPPROTO_UDP, csum_partial((__u8 *)udp, len + UDP_HDR_SIZE, 0));
+
+   /* if MAC address was not discovered yet, save the packet and do 
neighbour discovery */
+   if (memcmp(ether, net_null_ethaddr, 6) == 0) {
+   net_copy_ip6(_nd_sol_packet_ip6, dest);
+   net_nd_packet_mac = ether;
+
+   pkt = net_nd_tx_packet;
+   pkt += net_set_ether(pkt, net_nd_packet_mac, PROT_IP6);
+   pkt += ip6_add_hdr(pkt, _ip6, dest, IPPROTO_UDP, 64, len + 
UDP_HDR_SIZE);
+   memcpy(pkt, (uchar *)udp, len + UDP_HDR_SIZE);
+
+   /* size of the waiting packet */
+   net_nd_tx_packet_size = (pkt - net_nd_tx_packet) + UDP_HDR_SIZE 
+ len;
+
+   /* and do the neighbor solicitation */
+   net_nd_try = 1;
+   net_nd_timer_start = get_timer(0);
+   

[U-Boot] [RFC PATCH v2 08/11] net: Add ping6 command and implementation

2015-11-08 Thread Chris Packham
Signed-off-by: Chris Packham 

---

Changes in v2:
- split ping6 support into it's own patch

 common/Kconfig   |   6 +++
 common/cmd_net.c |  28 ++
 include/net.h|   4 +-
 net/net6.c   |   7 
 net/ping6.c  | 111 +++
 5 files changed, 154 insertions(+), 2 deletions(-)
 create mode 100644 net/ping6.c

diff --git a/common/Kconfig b/common/Kconfig
index 0388a6c..b1effc6 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -431,6 +431,12 @@ config CMD_PING
help
  Send ICMP ECHO_REQUEST to network host
 
+config CMD_PING6
+   bool "ping6"
+   depends on CMD_NET6
+   help
+ Send ICMPv6 ECHO_REQUEST to network host
+
 config CMD_CDP
bool "cdp"
help
diff --git a/common/cmd_net.c b/common/cmd_net.c
index b2f3c7b..271f91d 100644
--- a/common/cmd_net.c
+++ b/common/cmd_net.c
@@ -11,6 +11,7 @@
 #include 
 #include 
 #include 
+#include 
 
 static int netboot_common(enum proto_t, cmd_tbl_t *, int, char * const []);
 
@@ -284,6 +285,33 @@ U_BOOT_CMD(
 );
 #endif
 
+#ifdef CONFIG_CMD_PING6
+int do_ping6(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+   if (argc < 2)
+   return -1;
+
+   if (string_to_ip6(argv[1], _ping_ip6) != 0)
+   return CMD_RET_USAGE;
+
+   if (net_loop(PING6) < 0) {
+   printf("ping6 failed; host %pI6c is not alive\n",
+  _ping_ip6);
+   return 1;
+   }
+
+   printf("host %pI6c is alive\n", _ping_ip6);
+
+   return 0;
+}
+
+U_BOOT_CMD(
+   ping6,  2,  1,  do_ping6,
+   "send ICMPv6 ECHO_REQUEST to network host",
+   "pingAddress"
+);
+#endif /* CONFIG_CMD_PING6 */
+
 #if defined(CONFIG_CMD_CDP)
 
 static void cdp_update_env(void)
diff --git a/include/net.h b/include/net.h
index 8b7c878..6a9832c 100644
--- a/include/net.h
+++ b/include/net.h
@@ -524,8 +524,8 @@ extern ushort   net_native_vlan;/* Our 
Native VLAN */
 extern int net_restart_wrap;   /* Tried all network devices */
 
 enum proto_t {
-   BOOTP, RARP, ARP, TFTPGET, DHCP, PING, DNS, NFS, CDP, NETCONS, SNTP,
-   TFTPSRV, TFTPPUT, LINKLOCAL
+   BOOTP, RARP, ARP, TFTPGET, DHCP, PING, PING6, DNS, NFS, CDP, NETCONS,
+   SNTP, TFTPSRV, TFTPPUT, LINKLOCAL
 };
 
 extern charnet_boot_file_name[1024];/* Boot File name */
diff --git a/net/net6.c b/net/net6.c
index 955a089..8f0c721 100644
--- a/net/net6.c
+++ b/net/net6.c
@@ -370,6 +370,13 @@ void net_ip6_handler(struct ethernet_hdr *et, struct 
ip6_hdr *ip6, int len)
return;
 
switch (icmp->icmp6_type) {
+#ifdef CONFIG_CMD_PING6
+   case IPV6_ICMP_ECHO_REQUEST:
+   case IPV6_ICMP_ECHO_REPLY:
+   ping6_receive(et, ip6, len);
+   break;
+#endif /* CONFIG_CMD_PING6 */
+
case IPV6_NDISC_NEIGHBOUR_SOLICITATION:
case IPV6_NDISC_NEIGHBOUR_ADVERTISEMENT:
ndisc_receive(et, ip6, len);
diff --git a/net/ping6.c b/net/ping6.c
new file mode 100644
index 000..34796c6
--- /dev/null
+++ b/net/ping6.c
@@ -0,0 +1,111 @@
+/*
+ * net/ping6.c
+ *
+ * (C) Copyright 2013 Allied Telesis Labs NZ
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+#define DEBUG
+#include 
+#include 
+#include 
+#include "ndisc.h"
+
+static ushort seq_no;
+
+/* the ipv6 address to ping */
+struct in6_addr net_ping_ip6;
+
+int
+ip6_make_ping(uchar *eth_dst_addr, struct in6_addr *neigh_addr, uchar *pkt)
+{
+   struct echo_msg *msg;
+   __u16 len;
+   uchar *pkt_old = pkt;
+
+   len = sizeof(struct echo_msg);
+
+   pkt += net_set_ether(pkt, eth_dst_addr, PROT_IP6);
+   pkt += ip6_add_hdr(pkt, _ip6, neigh_addr, IPPROTO_ICMPV6,
+  IPV6_NDISC_HOPLIMIT, len);
+
+   /* ICMPv6 - Echo */
+   msg = (struct echo_msg *)pkt;
+   msg->icmph.icmp6_type = IPV6_ICMP_ECHO_REQUEST;
+   msg->icmph.icmp6_code = 0;
+   msg->icmph.icmp6_cksum = 0;
+   msg->icmph.icmp6_identifier = 0;
+   msg->icmph.icmp6_sequence = htons(seq_no++);
+   msg->id = msg->icmph.icmp6_identifier;  /* these seem redundant */
+   msg->sequence = msg->icmph.icmp6_sequence;
+
+   /* checksum */
+   msg->icmph.icmp6_cksum = csum_ipv6_magic(_ip6, neigh_addr, len,
+IPPROTO_ICMPV6,
+csum_partial((__u8 *)msg, len, 
0));
+
+   pkt += len;
+
+   return pkt - pkt_old;
+}
+
+int ping6_send(void)
+{
+   uchar *pkt;
+   static uchar mac[6];
+
+   /* always send neighbor solicit */
+
+   memcpy(mac, net_null_ethaddr, 6);
+
+   net_nd_sol_packet_ip6 = net_ping_ip6;
+   net_nd_packet_mac = mac;
+
+   pkt = net_nd_tx_packet;
+   pkt += ip6_make_ping(mac, _ping_ip6, pkt);
+
+   /* size of 

[U-Boot] [RFC PATCH v2 04/11] lib: net_utils: add string_to_ip6

2015-11-08 Thread Chris Packham
string_to_ip6 parses an IPv6 address from a string. Parsing v6 addresses
is a bit more complicated than parsing v4 because there are a number of
different formats that can be used.

Signed-off-by: Chris Packham 

---
I'm sure the parsing can be better and done in less code with only a
single pass but I haven't yet figured it out. The main problem is that
"::" can represent a variable number of contiguous ":" so when
parsing "::" we can't tell how many half words to skip.

Changes in v2:
- Wrap code in CONFIG_NET6

 include/net6.h  |   3 ++
 lib/net_utils.c | 121 
 2 files changed, 124 insertions(+)

diff --git a/include/net6.h b/include/net6.h
index 1b82c25..a41eb87 100644
--- a/include/net6.h
+++ b/include/net6.h
@@ -58,4 +58,7 @@ static inline int ipv6_addr_is_isatap(const struct in6_addr 
*a)
return (a->s6_addr32[2] | htonl(0x0200)) == htonl(0x02005EFE);
 }
 
+/* Convert a string to an ipv6 address */
+int string_to_ip6(const char *s, struct in6_addr *addr);
+
 #endif /* __NET6_H__ */
diff --git a/lib/net_utils.c b/lib/net_utils.c
index f148b8a..7422c27 100644
--- a/lib/net_utils.c
+++ b/lib/net_utils.c
@@ -11,6 +11,8 @@
  */
 
 #include 
+#include 
+#include 
 
 struct in_addr string_to_ip(const char *s)
 {
@@ -39,3 +41,122 @@ struct in_addr string_to_ip(const char *s)
addr.s_addr = htonl(addr.s_addr);
return addr;
 }
+
+#ifdef CONFIG_NET6
+/**
+ * Parses an struct in6_addr from the given string. IPv6 address parsing is a 
bit
+ * more complicated than v4 due to the flexible format and some of the special
+ * cases (e.g. v4 mapped).
+ *
+ * Examples of valid strings:
+ *   2001:db8::0:1234:1
+ *   2001:0db8:::::1234:0001
+ *   ::1
+ *   :::192.168.1.1
+ *
+ * Examples of invalid strings
+ *   2001:db8::0::0  (:: can only appear once)
+ *   2001:db8:192.168.1.1::1 (v4 part can only appear at the end)
+ *   192.168.1.1 (we don't implicity map v4)
+ */
+int string_to_ip6(const char *strpt, struct in6_addr *addrpt)
+{
+   int colon_count = 0;
+   int found_double_colon = 0;
+   int xstart = 0; /* first zero (double colon) */
+   int len = 7;/* num words the double colon represents */
+   int i;
+   const char *s = strpt;
+   struct in_addr zero_ip = {.s_addr = 0};
+
+   if (strpt == NULL)
+   return -1;
+
+   /* First pass, verify the syntax and locate the double colon */
+   for (;;) {
+   while (isxdigit((int)*s))
+   s++;
+   if (*s == '\0')
+   break;
+   if (*s != ':') {
+   if (*s == '.' && len >= 2) {
+   struct in_addr v4;
+   while (s != strpt && *(s - 1) != ':')
+   --s;
+   v4 = string_to_ip(s);
+   if (memcmp(_ip, ,
+  sizeof(struct in_addr) != 0)) {
+   len -= 2;
+   break;
+   }
+   }
+   /* This could be a valid address */
+   break;
+   }
+   if (s == strpt) {
+   /* The address begins with a colon */
+   if (*++s != ':')
+   /* Must start with a double colon or a number */
+   goto out_err;
+   } else {
+   s++;
+   if (found_double_colon)
+   len--;
+   else
+   xstart++;
+   }
+
+   if (*s == ':') {
+   if (found_double_colon)
+   /* Two double colons are not allowed */
+   goto out_err;
+   found_double_colon = 1;
+   len -= xstart;
+   s++;
+   }
+
+   if (++colon_count == 7)
+   /* Found all colons */
+   break;
+   }
+
+   if (colon_count == 0)
+   goto out_err;
+   if (*--s == ':')
+   len++;
+
+   /* Second pass, read the address */
+   s = strpt;
+   for (i = 0; i < 8; i++) {
+   int val = 0;
+   char *end;
+
+   if (found_double_colon && i >= xstart && i < xstart + len) {
+   addrpt->s6_addr16[i] = 0;
+   continue;
+   }
+   while (*s == ':')
+   s++;
+
+   if (i == 6 && isdigit((int)*s)) {
+   struct in_addr v4 = string_to_ip(s);
+   if 

[U-Boot] [RFC PATCH v2 05/11] net: add definition of udp_hdr

2015-11-08 Thread Chris Packham
UDP is the same over IPv4 as it is over other protocols (i.e. IPv6) add
a definition of just the UDP header independent of the IPv4 header that
it may or may not be combined with.

Signed-off-by: Chris Packham 
---
Ideally struct ip_udp_hdr would be defined as

  struct ip_udp_hdr {
  struct ip_hdr  ip;
  struct udp_hdr udp;
  };

Implementing this touches more code that I really want to at this
point. Some of the code that currently uses struct ip_udp_hdr could
probably just use struct ip_hdr instead but some care would need to be
taken to much such a change.

Changes in v2: None

 include/net.h | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/include/net.h b/include/net.h
index ebed29a..e8bd2b7 100644
--- a/include/net.h
+++ b/include/net.h
@@ -348,6 +348,18 @@ struct ip_hdr {
 #define IP_HDR_SIZE(sizeof(struct ip_hdr))
 
 /*
+ * UDP header.
+ */
+struct udp_hdr {
+   __be16  udp_src;/* UDP source port  */
+   __be16  udp_dst;/* UDP destination port */
+   __be16  udp_len;/* Length of UDP packet */
+   __be16  udp_xsum;   /* Checksum */
+};
+
+#define UDP_HDR_SIZE   (sizeof(struct udp_hdr))
+
+/*
  * Internet Protocol (IP) + UDP header.
  */
 struct ip_udp_hdr {
@@ -368,7 +380,6 @@ struct ip_udp_hdr {
 };
 
 #define IP_UDP_HDR_SIZE(sizeof(struct ip_udp_hdr))
-#define UDP_HDR_SIZE   (IP_UDP_HDR_SIZE - IP_HDR_SIZE)
 
 /*
  * Address Resolution Protocol (ARP) header.
-- 
2.5.3

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


[U-Boot] [RFC PATCH v2 11/11] net: e1000 enable multicast reception

2015-11-08 Thread Chris Packham
IPv6 neighbor discovery uses various multicast addresses to send the
request and receive the response. For neighbor discovery to work
properly in U-boot the Ethernet device needs to support joining/leaving
various L2 multicast groups or it needs to support multicast/promiscuous
mode. For the sake of simplicity the latter approach has been taken. The
e1000 hardware has slightly finer grained control in that it is possible
to enable support for multicast-promiscuous mode separately from unicast
so the extra traffic received is less.

Signed-off-by: Chris Packham 

---
Drivers that support multicast reception have it enabled/disabled with
CONFIG_MCAST_TFTP. It wouldn't be too hard to create a separate
CONFIG_MCAST that is selected by enabling CONFIG_MCAST_TFTP or
CONFIG_NET6.

Changes in v2: None

 drivers/net/e1000.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/e1000.c b/drivers/net/e1000.c
index 2ba03ed..d19a9de 100644
--- a/drivers/net/e1000.c
+++ b/drivers/net/e1000.c
@@ -5090,6 +5090,11 @@ e1000_setup_rctl(struct e1000_hw *hw)
rctl &= ~(E1000_RCTL_SZ_4096);
rctl |= E1000_RCTL_SZ_2048;
rctl &= ~(E1000_RCTL_BSEX | E1000_RCTL_LPE);
+
+#ifdef CONFIG_NET6
+   rctl |= E1000_RCTL_MPE;
+#endif
+
E1000_WRITE_REG(hw, RCTL, rctl);
 }
 
-- 
2.5.3

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


Re: [U-Boot] [PATCH V2 0/5] Add support for additional splash screen locations

2015-11-08 Thread Nikita Kiryanov
Ping!

On Thu, Oct 29, 2015 at 11:54:39AM +0200, Nikita Kiryanov wrote:
> This series adds the following functionality to the splash_source library:
> - load splash image from filesystem formatted usb storage
> - load splash image from filesystem formatted mmc storage
> - load splash image from filesystem formatted sata storage
> 
> Finally, use the new features on cm-fx6.
> 
> Changes in V2:
>   - Rebased over current mainline.
>   - Added "splashfile" env variable to select splash file name 
> dynamically.
> Also available: default value "splash.bmp"
>   - Added documentation for the feature.
>   - Refactored device initialization code so that #ifdefs are outside of
> the functions. This affects patches 3 and 4.
> 
> Cc: Igor Grinberg 
> Cc: Tom Rini 
> 
> Nikita Kiryanov (5):
>   splash_source: rename *_read() to *_read_raw()
>   splash_source: add support for filesystem formatted mmc
>   splash_source: add support for filesystem formatted usb
>   splash_source: add support for filesystem formatted sata
>   arm: mx6: cm-fx6: add splash locations to cm-fx6
> 
>  board/compulab/cm_fx6/cm_fx6.c |  19 +++
>  board/compulab/cm_t35/cm_t35.c |   1 +
>  common/splash_source.c | 125 
> +
>  doc/README.splashprepare   |   5 ++
>  include/splash.h   |  10 
>  5 files changed, 150 insertions(+), 10 deletions(-)
> 
> -- 
> 1.9.1
> 
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot