[U-Boot] [PATCH] dm: usb.h: Always declare usb func. prototypes when CONFIG_DM_USB=y

2015-06-06 Thread Hans de Goede
When CONFIG_DM_USB=y the various usb functions are available regardless of
any controller drivers being enabled, so always the usb function prototypes
when CONFIG_DM_USB=y.

This fixes compile warnings due to missing prototypes on ARCHs where
the ARCH Kconfig always enables CONFIG_DM_USB and various usb drivers.

One could argue that in the case of no controllers CONFIG_DM_USB should not
be set, but this problem is typically seen during bringup of boards which
do actually have usb controllers.

Signed-off-by: Hans de Goede hdego...@redhat.com
---
 include/usb.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/usb.h b/include/usb.h
index c709ce2..54ad33a 100644
--- a/include/usb.h
+++ b/include/usb.h
@@ -180,7 +180,7 @@ enum usb_init_type {
defined(CONFIG_USB_MUSB_DSPS) || defined(CONFIG_USB_MUSB_AM35X) || \
defined(CONFIG_USB_MUSB_OMAP2PLUS) || defined(CONFIG_USB_MUSB_SUNXI) || 
\
defined(CONFIG_USB_XHCI) || defined(CONFIG_USB_DWC2) || \
-   defined(CONFIG_USB_EMUL)
+   defined(CONFIG_USB_EMUL) || defined(CONFIG_DM_USB)
 
 int usb_lowlevel_init(int index, enum usb_init_type init, void **controller);
 int usb_lowlevel_stop(int index);
-- 
2.4.2

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


Re: [U-Boot] [PATCH v3 3/3] mmc: Protect `mmc_initialize` from initilizing mmc multiple times

2015-06-06 Thread Hans de Goede

Hi,

On 29-05-15 16:55, Daniel Kochmański wrote:

`mmc_initialize` might be called from various places and initializing
list head of `mmc_devices` can lead to memory leaks.

Signed-off-by: Daniel Kochmański dkochman...@turtle-solutions.eu
CC: Roy Spliet r.spl...@ultimaker.com
Cc: Ian Campbell i...@hellion.org.uk
Cc: Hans De Goede hdego...@redhat.com
CC: Pantelis Antoniou pa...@antoniou-consulting.com


Thanks I've merged this one into u-boot-sunxi/next, for inclusion
into u-boot v2015.10, I've fixed a few typos in the commit message
and clarified the commit message a bit.

Pantelis, since this is an mmc patch may we have your ack for this
one please? It is a dep for some sunxi changes so it is probably
easiest if I just merge it through the sunxi tree.

Some background, we are adding support for booting from nand,
and as such we need to make spl_boot_device() for sunxi
smarter. The sunxi BROM does not communicate where it has
loaded the SPL from, so we simply retrace it steps trying
mmc0 first and looking for a valid bootsignature there.

This means calling mmc_initialize() from spl_boot_device()
and if spl_boot_device() then finds a boot signature
and returns BOOT_DEVICE_MMC1, then later on
spl_mmc_load_image() will call mmc_initialize() a second
time, this patch protects against this second call and
turns the second call into a nop.

Regards,

Hans




---
  drivers/mmc/mmc.c | 5 +
  1 file changed, 5 insertions(+)

diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 79e6fee..2959bde 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -1758,6 +1758,11 @@ static void do_preinit(void)

  int mmc_initialize(bd_t *bis)
  {
+   static int initialized = 0;
+   if (initialized)/* Avoid initializing mmc multiple times */
+   return 0;
+   initialized = 1;
+
INIT_LIST_HEAD (mmc_devices);
cur_dev_num = 0;



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


Re: [U-Boot] Please pull u-boot-dm

2015-06-06 Thread Tom Rini
On Fri, Jun 05, 2015 at 08:20:29AM -0600, Simon Glass wrote:

 Hi Tom,
 
 This includes some fixes and tidy-ups, mostly for sandbox.
 
 
 The following changes since commit d8abb46b37fadff0349adb376df6d3ecd09ee7d1:
 
   board/BuR/common: fix netconsole (2015-06-02 12:58:51 -0400)
 
 are available in the git repository at:
 
   git://git.denx.de/u-boot-dm.git
 
 for you to fetch changes up to d9a607f2bd4315c9e370aa358ea9168d615a48fc:
 
   gpio: fix typos in GPIO header (2015-06-04 03:38:05 -0600)
 

Applied to u-boot/master, thanks!

-- 
Tom


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


[U-Boot] Please pull u-boot-sunxi master

2015-06-06 Thread Hans de Goede

Hi Tom,

Please pull u-boot-sunxi/master into master for a number of
bugfixes and a sync of the sunxi dts files with the upstream
kernel.

Note this pull-req also includes the patch for setting
CONFIG_CMD_NET and CONFIG_CMD_SETEXPR to y by default, I know
that is still being discussed, but this patch is necessary to
fix build-failures on a number of boards which did not get
CONFIG_CMD_NET and CONFIG_CMD_SETEXPR set to y by the initial
patches introducing CONFIG_CMD_NET and CONFIG_CMD_SETEXPR,
and the bulk of the patch is removing CONFIG_CMD_NET and
CONFIG_CMD_SETEXPR from all the sunxi defconfigs, which is
something which will need to be done anyways no matter
how we end up solving this.

The following changes since commit d8abb46b37fadff0349adb376df6d3ecd09ee7d1:

  board/BuR/common: fix netconsole (2015-06-02 12:58:51 -0400)

are available in the git repository at:

  http://git.denx.de/u-boot-sunxi.git master

for you to fetch changes up to 277af820b5207d43473869da2c86412d2b51d461:

  sunxi: Select CONFIG_CMD_NET and CONFIG_CMD_SETEXPR by default (2015-06-05 
21:09:14 +0200)


Hans de Goede (8):
  sunxi: mmc: Enable pull-up on card-detect gpio pin
  sunxi: usb_phy: Swap check for disconnect threshold
  sunxi: Add new Mele_A1000G_quad defconfig
  sunxi: gpio: Add allwinner,sun8i-a33-pinctrl
  sunxi: Sync dts files with the linux kernel
  sunxi: Rename Astar_MID756 to Et_q8_v1_6 to match kernel dts name
  sunxi: Add a proper dts file for the ga10h a33 based tablet
  sunxi: Select CONFIG_CMD_NET and CONFIG_CMD_SETEXPR by default

 arch/arm/cpu/armv7/sunxi/usb_phy.c |   6 +-
 arch/arm/dts/Makefile  |   5 +-
 arch/arm/dts/sun4i-a10-a1000.dts   |  11 +-
 arch/arm/dts/sun4i-a10-ba10-tvbox.dts  |  11 +-
 arch/arm/dts/sun4i-a10-chuwi-v7-cw0825.dts |   5 -
 arch/arm/dts/sun4i-a10-cubieboard.dts  |  14 +-
 arch/arm/dts/sun4i-a10-gemei-g9.dts|   5 -
 arch/arm/dts/sun4i-a10-hackberry.dts   |  11 +-
 arch/arm/dts/sun4i-a10-hyundai-a7hd.dts|   5 -
 arch/arm/dts/sun4i-a10-inet97fv2.dts   |   5 -
 arch/arm/dts/sun4i-a10-jesurun-q5.dts  |  11 +-
 arch/arm/dts/sun4i-a10-marsboard.dts   |  12 +-
 arch/arm/dts/sun4i-a10-mini-xplus.dts  |   9 +-
 arch/arm/dts/sun4i-a10-mk802.dts   |   5 -
 arch/arm/dts/sun4i-a10-mk802ii.dts |   5 -
 arch/arm/dts/sun4i-a10-olinuxino-lime.dts  |   9 +-
 arch/arm/dts/sun4i-a10-pcduino.dts |   9 +-
 arch/arm/dts/sun4i-a10.dtsi| 146 +++--
 arch/arm/dts/sun5i-a10s-auxtek-t004.dts|   5 -
 arch/arm/dts/sun5i-a10s-mk802.dts  |   5 -
 arch/arm/dts/sun5i-a10s-olinuxino-micro.dts|   9 +-
 arch/arm/dts/sun5i-a10s-r7-tv-dongle.dts   |   5 -
 arch/arm/dts/sun5i-a10s.dtsi   |  43 +-
 arch/arm/dts/sun5i-a13-hsg-h702.dts|   5 -
 arch/arm/dts/sun5i-a13-olinuxino-micro.dts |   5 -
 arch/arm/dts/sun5i-a13-olinuxino.dts   |   5 -
 arch/arm/dts/sun5i-a13-utoo-p66.dts|  27 +-
 arch/arm/dts/sun5i-a13.dtsi|  36 +-
 arch/arm/dts/sun5i.dtsi|  74 ++-
 arch/arm/dts/sun6i-a31-app4-evb1.dts   |   5 -
 arch/arm/dts/sun6i-a31-colombus.dts|   5 -
 arch/arm/dts/sun6i-a31-hummingbird.dts |   5 -
 arch/arm/dts/sun6i-a31-i7.dts  |   5 -
 arch/arm/dts/sun6i-a31-m9.dts  |   5 -
 arch/arm/dts/sun6i-a31-mele-a1000g-quad.dts| 149 +
 arch/arm/dts/sun6i-a31.dtsi|  57 +-
 arch/arm/dts/sun6i-a31s-cs908.dts  |   5 -
 arch/arm/dts/sun6i-a31s.dtsi   |   5 -
 arch/arm/dts/sun7i-a20-bananapi.dts|  11 +-
 arch/arm/dts/sun7i-a20-bananapro.dts   |  17 +-
 arch/arm/dts/sun7i-a20-cubieboard2.dts |   7 +-
 arch/arm/dts/sun7i-a20-cubietruck.dts  |   7 +-
 arch/arm/dts/sun7i-a20-hummingbird.dts |  10 +-
 arch/arm/dts/sun7i-a20-i12-tvbox.dts   |   7 +-
 arch/arm/dts/sun7i-a20-m3.dts  |   7 +-
 arch/arm/dts/sun7i-a20-mk808c.dts  | 111 +++-
 arch/arm/dts/sun7i-a20-olinuxino-lime.dts  |   5 -
 arch/arm/dts/sun7i-a20-olinuxino-lime2.dts |   5 -
 arch/arm/dts/sun7i-a20-olinuxino-micro.dts |  11 +-
 arch/arm/dts/sun7i-a20-orangepi-mini.dts   |   7 +-
 arch/arm/dts/sun7i-a20-orangepi.dts|   7 +-
 arch/arm/dts/sun7i-a20-pcduino3-nano.dts   |   7 +-
 arch/arm/dts/sun7i-a20-pcduino3.dts|   7 +-
 arch/arm/dts/sun7i-a20-wexler-tab7200.dts  |   5 -
 arch/arm/dts/sun7i-a20.dtsi| 210 

Re: [U-Boot] image-fit: Fix compiler warning in fit_conf_print()

2015-06-06 Thread Tom Rini
On Fri, May 29, 2015 at 03:09:48PM +0200, Hans de Goede wrote:

 This fixes the following compiler warning:
 
 In file included from tools/common/image-fit.c:1:0:
 ./tools/../common/image-fit.c: In function ‘fit_conf_print’:
 ./tools/../common/image-fit.c:1470:27: warning: logical not is only applied
  to the left hand side of comparison [-Wlogical-not-parentheses]
 (const char **)uname)  0;
 
 Signed-off-by: Hans de Goede hdego...@redhat.com

Applied to u-boot/master, thanks!

-- 
Tom


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


Re: [U-Boot] Please pull u-boot-fdt

2015-06-06 Thread Tom Rini
On Fri, Jun 05, 2015 at 10:08:53AM -0600, Simon Glass wrote:

 Hi Tom,
 
 A few things I found in patchwork.
 
 
 The following changes since commit d8abb46b37fadff0349adb376df6d3ecd09ee7d1:
 
   board/BuR/common: fix netconsole (2015-06-02 12:58:51 -0400)
 
 are available in the git repository at:
 
   git://git.denx.de/u-boot-fdt.git
 
 for you to fetch changes up to 3c4c142e5deed2a9362e65e45372044652ac57b5:
 
   fdt: Documentation for a few support functions aside their
 prototypes (2015-06-05 08:32:58 -0600)
 

Applied to u-boot/master, thanks!

-- 
Tom


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


Re: [U-Boot] Please pull u-boot-x86

2015-06-06 Thread Tom Rini
On Fri, Jun 05, 2015 at 08:18:31AM -0600, Simon Glass wrote:

 Hi Tom,
 
 This includes QEMU support, PIRQ routing using device tree and pinctrl
 using device tree.
 
 
 The following changes since commit d8abb46b37fadff0349adb376df6d3ecd09ee7d1:
 
   board/BuR/common: fix netconsole (2015-06-02 12:58:51 -0400)
 
 are available in the git repository at:
 
   git://git.denx.de/u-boot-x86.git
 
 for you to fetch changes up to 5d3c2c542dd8878fece0ea96edde125635b492ff:
 
   x86: minnowmax: initialize the pin-muxing from device tree
 (2015-06-04 03:32:23 -0600)
 

Applied to u-boot/master, thanks!

-- 
Tom


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


Re: [U-Boot] Please pull u-boot-sunxi master

2015-06-06 Thread Tom Rini
On Sat, Jun 06, 2015 at 11:29:54AM +0200, Hans de Goede wrote:

 Hi Tom,
 
 Please pull u-boot-sunxi/master into master for a number of
 bugfixes and a sync of the sunxi dts files with the upstream
 kernel.
 
 Note this pull-req also includes the patch for setting
 CONFIG_CMD_NET and CONFIG_CMD_SETEXPR to y by default, I know
 that is still being discussed, but this patch is necessary to
 fix build-failures on a number of boards which did not get
 CONFIG_CMD_NET and CONFIG_CMD_SETEXPR set to y by the initial
 patches introducing CONFIG_CMD_NET and CONFIG_CMD_SETEXPR,
 and the bulk of the patch is removing CONFIG_CMD_NET and
 CONFIG_CMD_SETEXPR from all the sunxi defconfigs, which is
 something which will need to be done anyways no matter
 how we end up solving this.
 
 The following changes since commit d8abb46b37fadff0349adb376df6d3ecd09ee7d1:
 
   board/BuR/common: fix netconsole (2015-06-02 12:58:51 -0400)
 
 are available in the git repository at:
 
   http://git.denx.de/u-boot-sunxi.git master
 
 for you to fetch changes up to 277af820b5207d43473869da2c86412d2b51d461:
 
   sunxi: Select CONFIG_CMD_NET and CONFIG_CMD_SETEXPR by default (2015-06-05 
 21:09:14 +0200)
 

Applied to u-boot/master, thanks!

-- 
Tom


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


Re: [U-Boot] image-fit: Fix compiler warning in fit_conf_print()

2015-06-06 Thread Hans de Goede

Hi All,

On 29-05-15 15:09, Hans de Goede wrote:

This fixes the following compiler warning:

In file included from tools/common/image-fit.c:1:0:
./tools/../common/image-fit.c: In function ‘fit_conf_print’:
./tools/../common/image-fit.c:1470:27: warning: logical not is only applied
  to the left hand side of comparison [-Wlogical-not-parentheses]
 (const char **)uname)  0;


ping? it would be nice to get this fixed, as it is the only compiler warning
I see when building u-boot.

Tom, can you pick this one up directly perhaps?

Regards,

Hans




Signed-off-by: Hans de Goede hdego...@redhat.com
---
  common/image-fit.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/image-fit.c b/common/image-fit.c
index 4bd8fea..28f7aa8 100644
--- a/common/image-fit.c
+++ b/common/image-fit.c
@@ -1464,10 +1464,10 @@ void fit_conf_print(const void *fit, int noffset, const 
char *p)

/* Print out all of the specified loadables */
for (loadables_index = 0;
-!fdt_get_string_index(fit, noffset,
+fdt_get_string_index(fit, noffset,
FIT_LOADABLE_PROP,
loadables_index,
-   (const char **)uname)  0;
+   (const char **)uname) == 0;
 loadables_index++)
{
if (loadables_index == 0) {


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


Re: [U-Boot] [PATCH 0/6] Remove sh boards that we have no tool-chain for.

2015-06-06 Thread Masahiro Yamada
Hi Joe,



2015-05-11 17:40 GMT+09:00 Phil Edworthy phil.edwor...@renesas.com:
 Hi Joe,

 -Original Message-
 From: U-Boot [mailto:u-boot-boun...@lists.denx.de] On Behalf Of Joe
 Hershberger
 Sent: 10 May 2015 21:23
 To: u-boot@lists.denx.de
 Cc: Rob Herring; Thierry Reding; Stephen Warren; Joe Hershberger; Hisashi
 Nakamura; Masahiro Yamada; Tom Rini; York Sun; Stefan Roese
 Subject: [U-Boot] [PATCH 0/6] Remove sh boards that we have no tool-chain 
 for.


 These 6 boards are the last that cannot be built with a public
 configuration of tool-chains. Remove them. This includes the SH2 and SH3
 cpus, which are the actual cause for not being able to build these
 boards.
 I haven't been keeping an eye on the ml, so didn't see the mails about this. 
 For the sh2a boards, the last toolchain I used was an old CodeSourcery one 
 from 2011 that can be downloaded from 
 http://sourcery.mentor.com/public/gnu_toolchain/sh-uclinux/

 They can always be added back if the situation changes.
 I haven't built any sh2a targets for years and I suspect no one else has 
 either, sh3 is probably even less used. Personally, I think it makes sense to 
 remove all support for sh2a and sh3 now.


I attended an interesting talk at LinuxCon Japan 2015.

I realized there is on-going movement to leverage patent-free sh2 processor.

Visit this for the abstract:
http://lccojapan2015.sched.org/event/860288ccda595208a5d7337d31c6075c?iframe=now=i:0;sidebar=yesbg=no#.VXLwxlXtlBd


I recommend to keep sh2 support for U-Boot now and keep an eye on this activity.


Anyway, you can build all the sh2 boards with the sourcery toolchain,
so your motivation to delete them is lost.


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


Re: [U-Boot] [PATCH v3 1/3] sunxi: Create helper function veryfing valid boot signature on MMC

2015-06-06 Thread Hans de Goede

Hi,

On 29-05-15 16:55, Daniel Kochmański wrote:

This patch extracts checking for valid SD card eGON.BT0 signature from
`board_mmc_init` into function `sunxi_mmc_has_egon_boot_signature`.

Buffer for mmc sector is allocated and freed at runtime. `panic` is
triggered on malloc failure.

Signed-off-by: Daniel Kochmański dkochman...@turtle-solutions.eu
CC: Roy Spliet r.spl...@ultimaker.com
Cc: Ian Campbell i...@hellion.org.uk
Cc: Hans De Goede hdego...@redhat.com


Thanks, pushed with a small bug-fix to u-boot-sunxi/next for merging into
v2015.10 .

Regards,

Hans



---
  arch/arm/include/asm/arch-sunxi/mmc.h |  1 +
  board/sunxi/board.c   |  8 ++--
  drivers/mmc/sunxi_mmc.c   | 17 +
  3 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/arch/arm/include/asm/arch-sunxi/mmc.h 
b/arch/arm/include/asm/arch-sunxi/mmc.h
index cb52e64..3da360b 100644
--- a/arch/arm/include/asm/arch-sunxi/mmc.h
+++ b/arch/arm/include/asm/arch-sunxi/mmc.h
@@ -127,4 +127,5 @@ struct sunxi_mmc {
  #define SUNXI_MMC_COMMON_RESET(1  18)

  struct mmc *sunxi_mmc_init(int sdc_no);
+int sunxi_mmc_has_egon_boot_signature(struct mmc *mmc);
  #endif /* _SUNXI_MMC_H */
diff --git a/board/sunxi/board.c b/board/sunxi/board.c
index 3f23f26..dc95431 100644
--- a/board/sunxi/board.c
+++ b/board/sunxi/board.c
@@ -302,12 +302,8 @@ int board_mmc_init(bd_t *bis)
 * Both mmc0 and mmc2 are bootable, figure out where we're booting
 * from. Try mmc0 first, just like the brom does.
 */
-   if (mmc_getcd(mmc0)  mmc_init(mmc0) == 0 
-   mmc0-block_dev.block_read(0, 16, 1, buf) == 1) {
-   buf[12] = 0;
-   if (strcmp(buf[4], eGON.BT0) == 0)
-   return 0;
-   }
+   if (sunxi_mmc_has_egon_boot_signature(mmc0))
+   return 0;

/* no bootable card in mmc0, so we must be booting from mmc2, swap */
mmc0-block_dev.dev = 1;
diff --git a/drivers/mmc/sunxi_mmc.c b/drivers/mmc/sunxi_mmc.c
index bb08147..ef3e84c 100644
--- a/drivers/mmc/sunxi_mmc.c
+++ b/drivers/mmc/sunxi_mmc.c
@@ -431,6 +431,23 @@ static int sunxi_mmc_getcd(struct mmc *mmc)
return !gpio_get_value(cd_pin);
  }

+int sunxi_mmc_has_egon_boot_signature(struct mmc *mmc)
+{
+   char *buf = malloc(512);
+   int valid_signature = 0;
+
+   if (buf == NULL)
+   panic(Failed to allocate memory\n);
+
+   if (mmc_getcd(mmc)  mmc_init(mmc) == 0 
+   mmc-block_dev.block_read(0, 16, 1, buf) == 1 
+   strncmp(buf[4], eGON.BT0, 8) == 0)
+   valid_signature = 1;
+
+   free(buf);
+   return valid_signature;
+}
+
  static const struct mmc_ops sunxi_mmc_ops = {
.send_cmd   = sunxi_mmc_send_cmd,
.set_ios= sunxi_mmc_set_ios,


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


Re: [U-Boot] [PATCH v3 2/3] sunxi/spl: Detect at runtime where from SPL was read

2015-06-06 Thread Hans de Goede

Hi,

On 29-05-15 16:55, Daniel Kochmański wrote:

Make possible using single `u-boot-sunxi-with-spl.bin` binary for both NAND
memory and SD card. Detection where SPL was read from is implemented in
`spl_boot_device`.

V2:
- Move signature verification to helper function
- Avoid unnecessary condition nesting

V3:
- Further simplification of conditions
- Move reassigning mmc block.dev numbers from `board_mmc_init` to
   `spl_boot_device`
- If signature wasn't found on mmc0 and SPL_NAND_SUPPORT isn't enabled
   don't assume mmc2 is a valid boot device - check for egon signature
   first

Signed-off-by: Daniel Kochmański dkochman...@turtle-solutions.eu
CC: Roy Spliet r.spl...@ultimaker.com
Cc: Ian Campbell i...@hellion.org.uk
Cc: Hans De Goede hdego...@redhat.com


Thanks, pushed with a few small coding style fixes (braces placement) to
u-boot-sunxi/next for merging into v2015.10 .

Regards,

Hans



---
  arch/arm/cpu/armv7/sunxi/board.c | 63 ++--
  1 file changed, 41 insertions(+), 22 deletions(-)

diff --git a/arch/arm/cpu/armv7/sunxi/board.c b/arch/arm/cpu/armv7/sunxi/board.c
index a82c8b9..c06922c 100644
--- a/arch/arm/cpu/armv7/sunxi/board.c
+++ b/arch/arm/cpu/armv7/sunxi/board.c
@@ -11,6 +11,7 @@
   */

  #include common.h
+#include mmc.h
  #include i2c.h
  #include serial.h
  #ifdef CONFIG_SPL_BUILD
@@ -22,6 +23,7 @@
  #include asm/arch/gpio.h
  #include asm/arch/sys_proto.h
  #include asm/arch/timer.h
+#include asm/arch/mmc.h

  #include linux/compiler.h

@@ -117,26 +119,18 @@ void s_init(void)
  }

  #ifdef CONFIG_SPL_BUILD
+DECLARE_GLOBAL_DATA_PTR;
+
  /* The sunxi internal brom will try to loader external bootloader
   * from mmc0, nand flash, mmc2.
- *
- * Unfortunately we can't check how SPL was loaded so assume it's
- * always the first SD/MMC controller, unless it was explicitly
- * stated that SPL is on nand flash.
   */
  u32 spl_boot_device(void)
  {
-#if defined(CONFIG_SPL_NAND_SUPPORT)
+   struct mmc *mmc0, *mmc1;
/*
-* This is compile time configuration informing SPL, that it
-* was loaded from nand flash.
-*/
-   return BOOT_DEVICE_NAND;
-#else
-   /*
-* When booting from the SD card, the eGON.BT0 signature is expected
-* to be found in memory at the address 0x0004 (see the mksunxiboot
-* tool, which generates this header).
+* When booting from the SD card or NAND memory, the eGON.BT0
+* signature is expected to be found in memory at the address 0x0004
+* (see the mksunxiboot tool, which generates this header).
 *
 * When booting in the FEL mode over USB, this signature is patched in
 * memory and replaced with something else by the 'fel' tool. This other
@@ -144,16 +138,41 @@ u32 spl_boot_device(void)
 * valid bootable SD card image (because the BROM would refuse to
 * execute the SPL in this case).
 *
-* This branch is just making a decision at runtime whether to load
-* the main u-boot binary from the SD card (if the eGON.BT0 signature
-* is found) or return to the FEL code in the BROM to wait and receive
-* the main u-boot binary over USB.
+* This checks for the signature and if it is not found returns to
+* the FEL code in the BROM to wait and receive the main u-boot
+* binary over USB. If it is found, it determines where SPL was
+* read from.
 */
-   if (readl(4) == 0x4E4F4765  readl(8) == 0x3054422E) /* eGON.BT0 */
-   return BOOT_DEVICE_MMC1;
-   else
+   if (readl(4) != 0x4E4F4765 || readl(8) != 0x3054422E) /* eGON.BT0 */
return BOOT_DEVICE_BOARD;
-#endif
+
+   /* The BROM will try to boot from mmc0 first, so try that first. */
+   mmc_initialize(gd-bd);
+   mmc0 = find_mmc_device(0);
+   if (sunxi_mmc_has_egon_boot_signature(mmc0))
+   return BOOT_DEVICE_MMC1;
+
+   /* Fallback to booting NAND if enabled. */
+   if (IS_ENABLED(CONFIG_SPL_NAND_SUPPORT))
+   return BOOT_DEVICE_NAND;
+
+   if (IS_ENABLED(CONFIG_MMC_SUNXI_SLOT_EXTRA) 
+   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;
+   return BOOT_DEVICE_MMC2
+   }
+   }
+
+   panic(Could not determine boot source\n);
+   return -1;  /* Never reached */
  }

  /* No confirmation data available in SPL yet. Hardcode bootmode */


___
U-Boot mailing list

Re: [U-Boot] [RFC] Sunxi NAND support for U-Boot

2015-06-06 Thread Hans de Goede

Hi Roy,

Thanks for your work on this!

On 05-06-15 13:52, Roy Spliet wrote:

Following up on earlier SPL patches, here a series based on Yassin Jaffer's
work to bring NAND support to U-boot. RFC because I know that the sunxi nand
configuration options are dependent on a work-in-progress by Daniel - trying
to deliver a single SPL for both MMC and NAND boot.


I've just tested Daniel's patches on a board with an eMMC, fixed 2 small bugs
related to eMMC handling and merged them into u-boot-sunxi/next.

So it would probably be best to base your next version of the patches on
top of u-boot-sunxi/next which other then having Daniel's patches is
following u-boot/master atm.


Given I have spent the past few weeks learning how Boris' original driver
works, I have probably grown a bit blind for potentially existing issues.
Please provide plenty of feedback so I can bring this in good shape.

Patches tested on an Olimex Lime with 4GB Hynix nand. Has a partition as
defined in sunxi-common.h with two UBIFS partitions (boot, rootfs) set up in
Linux. To me it feels self-explanatory how to set this up, but I've spent the
last few weeks full-time on this, implying my view of the world and how it
revolves around MTD is rather distorted. Feel free to ask directed questions
if you desire assistance in setting up and/or testing.


From the sunxi side these patches look good, I've one quite minor nitpick which
I will explain in a reply to the patch in question. I think the most work here
is getting the generic mtd patches ready and accepted by Scott Wood (the u-boot
mtd maintainer), so please coordinate this further with him.

Once those bits are in I'm more then happy to merge the sunxi side of things.

As for merging the mtd bits, since the u-boot mtd code is somewhat of a copy
of the Linux mtd code it may be best to simply sync the existing mtd code
up with the upstream kernel mtd code, and work on getting the missing mtd
bits merged into the upstream kernel first, and then merge the changes
back into the u-boot mtd code, that assumes that the u-boot mtd code still
is somewhat in sync with the kernel code atm though, and from your comments
I'm getting the impression that it is not...

Anyways I will leave figuring this out between you and Scott. Note that we
could use some help with upstreaming the kernel bits regardless of this.
If you plan to work on this, please coordinate with Boris as Boris will
likely start working on the mtd kernel code again soonish.

Regards,

Hans


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


[U-Boot] [PATCH 1/2] net: Improve 88E151x PHY initialization

2015-06-06 Thread Clemens Gruber
- The EEE fixup magic should also be enabled for RGMII
- Improved comments

Signed-off-by: Clemens Gruber clemens.gru...@pqgruber.com
Cc: Joe Hershberger joe.hershber...@ni.com
Cc: Hao Zhang hzh...@ti.com
Cc: Michal Simek michal.si...@xilinx.com
---
 drivers/net/phy/marvell.c | 37 +++--
 1 file changed, 23 insertions(+), 14 deletions(-)

diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
index 9437c3b..cff5c87 100644
--- a/drivers/net/phy/marvell.c
+++ b/drivers/net/phy/marvell.c
@@ -303,24 +303,33 @@ static int m88e1518_config(struct phy_device *phydev)
 * As per Marvell Release Notes - Alaska 88E1510/88E1518/88E1512
 * /88E1514 Rev A0, Errata Section 3.1
 */
+
+   /* EEE initialization */
+   phy_write(phydev, MDIO_DEVAD_NONE, 22, 0x00ff);
+   phy_write(phydev, MDIO_DEVAD_NONE, 17, 0x214B);
+   phy_write(phydev, MDIO_DEVAD_NONE, 16, 0x2144);
+   phy_write(phydev, MDIO_DEVAD_NONE, 17, 0x0C28);
+   phy_write(phydev, MDIO_DEVAD_NONE, 16, 0x2146);
+   phy_write(phydev, MDIO_DEVAD_NONE, 17, 0xB233);
+   phy_write(phydev, MDIO_DEVAD_NONE, 16, 0x214D);
+   phy_write(phydev, MDIO_DEVAD_NONE, 17, 0xCC0C);
+   phy_write(phydev, MDIO_DEVAD_NONE, 16, 0x2159);
+   phy_write(phydev, MDIO_DEVAD_NONE, 22, 0x);
+
+   /* SGMII-to-Copper mode initialization */
if (phydev-interface == PHY_INTERFACE_MODE_SGMII) {
-   phy_write(phydev, MDIO_DEVAD_NONE, 22, 0x00ff); /* page 0xff */
-   phy_write(phydev, MDIO_DEVAD_NONE, 17, 0x214B);
-   phy_write(phydev, MDIO_DEVAD_NONE, 16, 0x2144);
-   phy_write(phydev, MDIO_DEVAD_NONE, 17, 0x0C28);
-   phy_write(phydev, MDIO_DEVAD_NONE, 16, 0x2146);
-   phy_write(phydev, MDIO_DEVAD_NONE, 17, 0xB233);
-   phy_write(phydev, MDIO_DEVAD_NONE, 16, 0x214D);
-   phy_write(phydev, MDIO_DEVAD_NONE, 17, 0xCC0C);
-   phy_write(phydev, MDIO_DEVAD_NONE, 16, 0x2159);
-   phy_write(phydev, MDIO_DEVAD_NONE, 22, 0x); /* reg page 0 */
-   phy_write(phydev, MDIO_DEVAD_NONE, 22, 18);/* reg page 18 */
-   /* Write HWCFG_MODE = SGMII to Copper */
+   /* Select page 18 */
+   phy_write(phydev, MDIO_DEVAD_NONE, 22, 18);
+
+   /* In reg 20, write MODE[2:0] = 0x1 (SGMII to Copper) */
m88e1518_phy_writebits(phydev, 20, 0, 3, 1);
 
-   /* Phy reset */
+   /* PHY reset is necessary after changing MODE[2:0] */
m88e1518_phy_writebits(phydev, 20, 15, 1, 1);
-   phy_write(phydev, MDIO_DEVAD_NONE, 22, 0); /* reg page 18 */
+
+   /* Reset page selection */
+   phy_write(phydev, MDIO_DEVAD_NONE, 22, 0);
+
udelay(100);
}
 
-- 
2.4.2

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


[U-Boot] [PATCH 2/2] net: Add support for Marvell 88E1510 PHY

2015-06-06 Thread Clemens Gruber
Support the 88E1510 PHY which is very similar to the 88E1518.
I also set the INTn output and configured the LEDs.

Signed-off-by: Clemens Gruber clemens.gru...@pqgruber.com
Cc: Joe Hershberger joe.hershber...@ni.com
Cc: Hao Zhang hzh...@ti.com
Cc: Michal Simek michal.si...@xilinx.com

---
This replaces the previously sent patch
http://patchwork.ozlabs.org/patch/478488/
---
 drivers/net/phy/marvell.c | 30 ++
 1 file changed, 30 insertions(+)

diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
index cff5c87..eab1558 100644
--- a/drivers/net/phy/marvell.c
+++ b/drivers/net/phy/marvell.c
@@ -336,6 +336,25 @@ static int m88e1518_config(struct phy_device *phydev)
return m88es_config(phydev);
 }
 
+/* Marvell 88E1510 */
+static int m88e1510_config(struct phy_device *phydev)
+{
+   /* Select page 3 */
+   phy_write(phydev, MDIO_DEVAD_NONE, 22, 3);
+
+   /* Enable INTn output on LED[2] */
+   m88e1518_phy_writebits(phydev, 18, 7, 1, 1);
+
+   /* Configure LEDs */
+   m88e1518_phy_writebits(phydev, 16, 0, 4, 3); /* LED[0]:0011 (ACT) */
+   m88e1518_phy_writebits(phydev, 16, 4, 4, 6); /* LED[1]:0110 (LINK) */
+
+   /* Reset page selection */
+   phy_write(phydev, MDIO_DEVAD_NONE, 22, 0);
+
+   return m88e1518_config(phydev);
+}
+
 /* Marvell 88E1118 */
 static int m88e1118_config(struct phy_device *phydev)
 {
@@ -548,6 +567,16 @@ static struct phy_driver M88E1149S_driver = {
.shutdown = genphy_shutdown,
 };
 
+static struct phy_driver M88E1510_driver = {
+   .name = Marvell 88E1510,
+   .uid = 0x1410dd0,
+   .mask = 0xff0,
+   .features = PHY_GBIT_FEATURES,
+   .config = m88e1510_config,
+   .startup = m88e1011s_startup,
+   .shutdown = genphy_shutdown,
+};
+
 static struct phy_driver M88E1518_driver = {
.name = Marvell 88E1518,
.uid = 0x1410dd1,
@@ -578,6 +607,7 @@ int phy_marvell_init(void)
phy_register(M88E1118R_driver);
phy_register(M88ES_driver);
phy_register(M88E1011S_driver);
+   phy_register(M88E1510_driver);
phy_register(M88E1518_driver);
 
return 0;
-- 
2.4.2

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


[U-Boot] [PATCH 0/2] net: Support Marvell 88E1510 and fix 88E151x init

2015-06-06 Thread Clemens Gruber
Hi,

I improved the Errata fixup for Marvell 88E151x Ethernet PHYs and
added support for the 88E1510 which is very similar to the 88E1518.
I also configured the LEDs and the INTn output for the 88E1510.

Best regards,
Clemens Gruber

Clemens Gruber (2):
  net: Improve 88E151x PHY initialization
  net: Add support for Marvell 88E1510 PHY

 drivers/net/phy/marvell.c | 67 +--
 1 file changed, 53 insertions(+), 14 deletions(-)

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


Re: [U-Boot] [PATCH v3 follow-up 3/3] sunxi: Remove redundant check from `board_mmc_init` for signature

2015-06-06 Thread Hans de Goede

Hi,

On 29-05-15 17:21, Daniel Kochmański wrote:

Removes checking for signature on mmc devices, because it is done on
`spl_boot_device`. This is follow-up patch to V3.


We actually still need the swapping in this code-path in u-boot proper, so
as to make sure that when booting from an emmc we make the emmc mmc dev 0
and thus search there first for things like boot.scr and extlinux.conf.

So I've merged this patch in a modified form adding a
#if !defined(CONFIG_SPL_BUILD around the code block in question, rather
then completely removing it, and updating the comments to match.

Regards,

Hans







Signed-off-by: Daniel Kochmański dkochman...@turtle-solutions.eu
CC: Roy Spliet r.spl...@ultimaker.com
Cc: Ian Campbell i...@hellion.org.uk
Cc: Hans De Goede hdego...@redhat.com
---
  board/sunxi/board.c | 13 -
  1 file changed, 13 deletions(-)

diff --git a/board/sunxi/board.c b/board/sunxi/board.c
index dc95431..a14096e 100644
--- a/board/sunxi/board.c
+++ b/board/sunxi/board.c
@@ -297,19 +297,6 @@ int board_mmc_init(bd_t *bis)
return -1;
  #endif

-#if CONFIG_MMC_SUNXI_SLOT == 0  CONFIG_MMC_SUNXI_SLOT_EXTRA == 2
-   /*
-* Both mmc0 and mmc2 are bootable, figure out where we're booting
-* from. Try mmc0 first, just like the brom does.
-*/
-   if (sunxi_mmc_has_egon_boot_signature(mmc0))
-   return 0;
-
-   /* no bootable card in mmc0, so we must be booting from mmc2, swap */
-   mmc0-block_dev.dev = 1;
-   mmc1-block_dev.dev = 0;
-#endif
-
return 0;
  }
  #endif


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


Re: [U-Boot] [RFC 09/11] sunxi/nand: Enable UBI and NAND commands

2015-06-06 Thread Hans de Goede

Hi,

On 05-06-15 13:52, Roy Spliet wrote:

Signed-off-by: Roy Spliet r.spl...@ultimaker.com
---
  board/sunxi/Kconfig|  8 +++-
  drivers/mtd/Makefile   |  1 +
  include/configs/sunxi-common.h | 33 +
  3 files changed, 29 insertions(+), 13 deletions(-)

diff --git a/board/sunxi/Kconfig b/board/sunxi/Kconfig
index cf58d73..37bbd0f 100644
--- a/board/sunxi/Kconfig
+++ b/board/sunxi/Kconfig
@@ -269,17 +269,15 @@ config MMC_SUNXI_SLOT_EXTRA
slot or emmc on mmc1 - mmc3. Setting this to 1, 2 or 3 will enable
support for this.

-config SPL_NAND_SUPPORT
-   bool SPL/NAND mode support
+config NAND_SUNXI
+   bool NAND support
depends on SPL
default n
---help---
  This enables support for booting from NAND internal
  memory. U-Boot SPL doesn't detect where is it load from,
  therefore this option is needed to properly load image from
- flash. Option also disables MMC functionality on U-Boot due to
- initialization errors encountered, when both controllers are
- enabled.
+ flash.

  config USB0_VBUS_PIN
string Vbus enable pin for usb0 (otg)
diff --git a/drivers/mtd/Makefile b/drivers/mtd/Makefile
index 5467a95..124b0f9 100644
--- a/drivers/mtd/Makefile
+++ b/drivers/mtd/Makefile
@@ -18,3 +18,4 @@ obj-$(CONFIG_FTSMC020) += ftsmc020.o
  obj-$(CONFIG_FLASH_CFI_LEGACY) += jedec_flash.o
  obj-$(CONFIG_MW_EEPROM) += mw_eeprom.o
  obj-$(CONFIG_ST_SMI) += st_smi.o
+obj-$(CONFIG_MTD_UBI) += ubi/
diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h
index cce0441..ec28c40 100644
--- a/include/configs/sunxi-common.h
+++ b/include/configs/sunxi-common.h
@@ -113,7 +113,7 @@
  #endif

  /* 4MB of malloc() pool */
-#define CONFIG_SYS_MALLOC_LEN  (CONFIG_ENV_SIZE + (4  20))
+#define CONFIG_SYS_MALLOC_LEN  (CONFIG_ENV_SIZE + (64  20))

  /*
   * Miscellaneous configurable options


Please update the comment about malloc_pool size to match :)

Regards,

Hans



@@ -326,10 +326,31 @@ extern int soft_i2c_gpio_scl;
  #define CONFIG_ENV_IS_NOWHERE
  #endif

-#ifdef CONFIG_SPL_NAND_SUPPORT
+#ifdef CONFIG_NAND_SUNXI
+#ifndef CONFIG_NAND_SUNXI_GPC_PORTS
+#error No NAND GPC ports defined, NAND unsupported
+#endif /* CONFIG_NAND_SUNXI_GPC_PORTS */
  #define CONFIG_NAND
  #define CONFIG_SYS_NAND_SELF_INIT
-#define CONFIG_NAND_SUNXI
+#define CONFIG_SYS_MAX_NAND_DEVICE 8
+
+#define CONFIG_SYS_NAND_ONFI_DETECTION
+
+/* Requirements for UBI */
+#define CONFIG_RBTREE
+#define CONFIG_LZO
+#define CONFIG_CMD_MTDPARTS
+#define CONFIG_CMD_UBI
+#define CONFIG_CMD_UBIFS
+#define CONFIG_MTD_DEVICE
+
+#define CONFIG_SPL_NAND_SUPPORT
+
+#define CONFIG_MTD_PARTITIONS
+/*
+#define CONFIG_MTD_DEBUG
+#define CONFIG_MTD_DEBUG_VERBOSE   MTD_DEBUG_LEVEL3
+*/
  #define CONFIG_CMD_SPL_WRITE_SIZE 0x000400
  #define CONFIG_SYS_NAND_U_BOOT_OFFS   0x008000

@@ -338,11 +359,7 @@ extern int soft_i2c_gpio_scl;
  #define CONFIG_NAND_SUNXI_ECC_STEP1024
  #define CONFIG_NAND_SUNXI_ECC_STRENGTH40
  #define CONFIG_NAND_SUNXI_ADDR_CYCLES 5
-
-#ifndef CONFIG_NAND_SUNXI_GPC_PORTS
-#error No NAND GPC ports defined, NAND unsupported
-#endif
-#endif /* CONFIG_SPL_NAND_SUPPORT */
+#endif /* CONFIG_NAND_SUNXI */

  #define CONFIG_MISC_INIT_R
  #define CONFIG_SYS_CONSOLE_IS_IN_ENV


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


Re: [U-Boot] [RFC 09/11] sunxi/nand: Enable UBI and NAND commands

2015-06-06 Thread Ian Campbell
On Sat, 2015-06-06 at 17:13 +0200, Hans de Goede wrote:
  @@ -113,7 +113,7 @@
#endif
 
/* 4MB of malloc() pool */
  -#define CONFIG_SYS_MALLOC_LEN  (CONFIG_ENV_SIZE + (4  20))
  +#define CONFIG_SYS_MALLOC_LEN  (CONFIG_ENV_SIZE + (64  20))
 
/*
 * Miscellaneous configurable options
 
 Please update the comment about malloc_pool size to match :)

...and explain in the commit log why this needs increasing as part of
this change.

Ian.

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


Re: [U-Boot] [RFC] Sunxi NAND support for U-Boot

2015-06-06 Thread Hans de Goede

Hi,

On 05-06-15 13:52, Roy Spliet wrote:

Following up on earlier SPL patches, here a series based on Yassin Jaffer's
work to bring NAND support to U-boot. RFC because I know that the sunxi nand
configuration options are dependent on a work-in-progress by Daniel - trying
to deliver a single SPL for both MMC and NAND boot.
Given I have spent the past few weeks learning how Boris' original driver
works, I have probably grown a bit blind for potentially existing issues.
Please provide plenty of feedback so I can bring this in good shape.

Patches tested on an Olimex Lime with 4GB Hynix nand. Has a partition as
defined in sunxi-common.h with two UBIFS partitions (boot, rootfs) set up in
Linux. To me it feels self-explanatory how to set this up, but I've spent the
last few weeks full-time on this, implying my view of the world and how it
revolves around MTD is rather distorted. Feel free to ask directed questions
if youdesire assistance in setting up and/or testing.


p.s.

If you want me to I can merge this, or the next version into my sunxi-wip
branch so that people can play with it. Chances are I will do that anyways
one of these days to play with it myself.

Talking about playing with this, can you provide a quick step by step on
howto setup the ubifs stuff under Linux, assuming a kernel + dts with
working nand support are present ?

Regards,

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


[U-Boot] [PATCH v3 3/3] x86: fsp: Move FspInitEntry call to board_init_f()

2015-06-06 Thread Bin Meng
The call to FspInitEntry is done in arch/x86/lib/fsp/fsp_car.S so far.
It worked pretty well but looks not that good. Apart from doing too
much work than just enabling CAR, it cannot read the configuration
data from device tree at that time. Now we want to move it a little
bit later as part of init_sequence_f[] being called by board_init_f().
This way it looks and works better in the U-Boot initialization path.

Due to FSP's design, after calling FspInitEntry it will not return to
its caller, instead it jumps to a continuation function which is given
by bootloader with a new stack in system memory. The original stack in
the CAR is gone, but its content is perserved by FSP and described by
a bootloader temporary memory HOB. Technically we can recover anything
we had before in the previous stack, but that is way too complicated.
To make life much easier, in the FSP continuation routine we just
simply call fsp_init_done() and jump back to car_init_ret() to redo
the whole board_init_f() initialization, but this time with a non-zero
HOB list pointer saved in U-Boot's global data so that we can bypass
the FspInitEntry for the second time.

Signed-off-by: Bin Meng bmeng...@gmail.com
Acked-by: Simon Glass s...@chromium.org
Tested-by: Andrew Bradford andrew.bradf...@kodakalaris.com
Tested-by: Simon Glass s...@chromium.org

---

Changes in v3:
- Remove #ifdef around x86_fsp_init() declaration

Changes in v2: None

 arch/x86/cpu/start.S  |  6 +-
 arch/x86/include/asm/u-boot-x86.h |  3 +++
 arch/x86/lib/fsp/fsp_car.S| 26 +-
 arch/x86/lib/fsp/fsp_common.c |  8 
 common/board_f.c  |  3 +++
 5 files changed, 24 insertions(+), 22 deletions(-)

diff --git a/arch/x86/cpu/start.S b/arch/x86/cpu/start.S
index 2e5f9da..00e585e 100644
--- a/arch/x86/cpu/start.S
+++ b/arch/x86/cpu/start.S
@@ -116,12 +116,16 @@ car_init_ret:
rep stosb
 
 #ifdef CONFIG_HAVE_FSP
+   test%esi, %esi
+   jz  skip_hob
+
/* Store HOB list */
movl%esp, %edx
addl$GD_HOB_LIST, %edx
movl%esi, (%edx)
-#endif
 
+skip_hob:
+#endif
/* Setup first parameter to setup_gdt, pointer to global_data */
movl%esp, %eax
 
diff --git a/arch/x86/include/asm/u-boot-x86.h 
b/arch/x86/include/asm/u-boot-x86.h
index 3c6ee29..4dae365 100644
--- a/arch/x86/include/asm/u-boot-x86.h
+++ b/arch/x86/include/asm/u-boot-x86.h
@@ -56,6 +56,9 @@ u32 isa_map_rom(u32 bus_addr, int size);
 /* arch/x86/lib/... */
 int video_bios_init(void);
 
+/* arch/x86/lib/fsp/... */
+int x86_fsp_init(void);
+
 void   board_init_f_r_trampoline(ulong) __attribute__ ((noreturn));
 void   board_init_f_r(void) __attribute__ ((noreturn));
 
diff --git a/arch/x86/lib/fsp/fsp_car.S b/arch/x86/lib/fsp/fsp_car.S
index 5e09568..afbf3f9 100644
--- a/arch/x86/lib/fsp/fsp_car.S
+++ b/arch/x86/lib/fsp/fsp_car.S
@@ -56,28 +56,10 @@ temp_ram_init_ret:
 
/* stack grows down from top of CAR */
movl%edx, %esp
+   subl$4, %esp
 
-   /*
-* TODO:
-*
-* According to FSP architecture spec, the fsp_init() will not return
-* to its caller, instead it requires the bootloader to provide a
-* so-called continuation function to pass into the FSP as a parameter
-* of fsp_init, and fsp_init() will call that continuation function
-* directly.
-*
-* The call to fsp_init() may need to be moved out of the car_init()
-* to cpu_init_f() with the help of some inline assembly codes.
-* Note there is another issue that fsp_init() will setup another stack
-* using the fsp_init parameter stack_top after DRAM is initialized,
-* which means any data on the previous stack (on the CAR) gets lost
-* (ie: U-Boot global_data). FSP is supposed to support such scenario,
-* however it does not work. This should be revisited in the future.
-*/
-   movl$CONFIG_FSP_TEMP_RAM_ADDR, %eax
-   xorl%edx, %edx
-   xorl%ecx, %ecx
-   callfsp_init
+   xor %esi, %esi
+   jmp car_init_done
 
 .global fsp_init_done
 fsp_init_done:
@@ -86,6 +68,8 @@ fsp_init_done:
 * Save eax to esi temporarily.
 */
movl%eax, %esi
+
+car_init_done:
/*
 * Re-initialize the ebp (BIST) to zero, as we already reach here
 * which means we passed BIST testing before.
diff --git a/arch/x86/lib/fsp/fsp_common.c b/arch/x86/lib/fsp/fsp_common.c
index 001494d..5b25632 100644
--- a/arch/x86/lib/fsp/fsp_common.c
+++ b/arch/x86/lib/fsp/fsp_common.c
@@ -46,3 +46,11 @@ void board_final_cleanup(void)
 
return;
 }
+
+int x86_fsp_init(void)
+{
+   if (!gd-arch.hob_list)
+   fsp_init(CONFIG_FSP_TEMP_RAM_ADDR, BOOT_FULL_CONFIG, NULL);
+
+   return 0;
+}
diff --git a/common/board_f.c b/common/board_f.c
index fbbad1b..21be26f 100644
--- a/common/board_f.c
+++ 

[U-Boot] [PATCH v3 2/3] x86: fsp: Load GDT before calling FspInitEntry

2015-06-06 Thread Bin Meng
Currently the FSP execution environment GDT is setup by U-Boot in
arch/x86/cpu/start16.S, which works pretty well. But if we try to
move the FspInitEntry call a little bit later to better fit into
U-Boot's initialization sequence, FSP will fail to bring up the AP
due to #GP fault as AP's GDT is duplicated from BSP whose GDT is
now moved into CAR, and unfortunately FSP calls AP initialization
after it disables the CAR. So basically the BSP's GDT still refers
to the one in the CAR, whose content is no longer available, so
when AP starts up and loads its segment register, it blows up.

To resolve this, we load GDT before calling into FspInitEntry.
The GDT is the same one used in arch/x86/cpu/start16.S, which is
in the ROM and exists forever.

Signed-off-by: Bin Meng bmeng...@gmail.com
Tested-by: Andrew Bradford andrew.bradf...@kodakalaris.com
Tested-by: Simon Glass s...@chromium.org

---

Changes in v3:
- Rename gdt in arch/x86/cpu/start16.S to gdt_rom
- Change 'extern u32 gdt' to 'extern char gdt_rom[]'
- Add comments to setup_fsp_gdt()

Changes in v2:
- Use CONFIG_RESET_SEG_START to avoid duplication

 arch/x86/cpu/cpu.c| 20 
 arch/x86/cpu/start16.S|  5 +++--
 arch/x86/include/asm/u-boot-x86.h |  7 +++
 arch/x86/lib/fsp/fsp_support.c|  3 +++
 4 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/arch/x86/cpu/cpu.c b/arch/x86/cpu/cpu.c
index bb4a110..b6c585a 100644
--- a/arch/x86/cpu/cpu.c
+++ b/arch/x86/cpu/cpu.c
@@ -164,6 +164,26 @@ void setup_gdt(gd_t *id, u64 *gdt_addr)
load_fs(X86_GDT_ENTRY_32BIT_FS);
 }
 
+#ifdef CONFIG_HAVE_FSP
+/*
+ * Setup FSP execution environment GDT
+ *
+ * Per Intel FSP external architecture specification, before calling any FSP
+ * APIs, we need make sure the system is in flat 32-bit mode and both the code
+ * and data selectors should have full 4GB access range. Here we reuse the one
+ * we used in arch/x86/cpu/start16.S, and reload the segement registers.
+ */
+void setup_fsp_gdt(void)
+{
+   load_gdt((const u64 *)(gdt_rom + CONFIG_RESET_SEG_START), 4);
+   load_ds(X86_GDT_ENTRY_32BIT_DS);
+   load_ss(X86_GDT_ENTRY_32BIT_DS);
+   load_es(X86_GDT_ENTRY_32BIT_DS);
+   load_fs(X86_GDT_ENTRY_32BIT_DS);
+   load_gs(X86_GDT_ENTRY_32BIT_DS);
+}
+#endif
+
 int __weak x86_cleanup_before_linux(void)
 {
 #ifdef CONFIG_BOOTSTAGE_STASH
diff --git a/arch/x86/cpu/start16.S b/arch/x86/cpu/start16.S
index 826e2b4..5eb17f1 100644
--- a/arch/x86/cpu/start16.S
+++ b/arch/x86/cpu/start16.S
@@ -71,11 +71,12 @@ idt_ptr:
 */
 gdt_ptr:
.word   0x1f/* limit (31 bytes = 4 GDT entries - 1) */
-   .long   BOOT_SEG + gdt  /* base */
+   .long   BOOT_SEG + gdt_rom  /* base */
 
/* Some CPUs are picky about GDT alignment... */
.align  16
-gdt:
+.globl gdt_rom
+gdt_rom:
/*
 * The GDT table ...
 *
diff --git a/arch/x86/include/asm/u-boot-x86.h 
b/arch/x86/include/asm/u-boot-x86.h
index d1d21ed..3c6ee29 100644
--- a/arch/x86/include/asm/u-boot-x86.h
+++ b/arch/x86/include/asm/u-boot-x86.h
@@ -8,12 +8,19 @@
 #ifndef _U_BOOT_I386_H_
 #define _U_BOOT_I386_H_1
 
+extern char gdt_rom[];
+
 /* cpu/.../cpu.c */
 int arch_cpu_init(void);
 int x86_cpu_init_f(void);
 int cpu_init_f(void);
 void init_gd(gd_t *id, u64 *gdt_addr);
 void setup_gdt(gd_t *id, u64 *gdt_addr);
+/*
+ * Setup FSP execution environment GDT to use the one we used in
+ * arch/x86/cpu/start16.S and reload the segment registers.
+ */
+void setup_fsp_gdt(void);
 int init_cache(void);
 int cleanup_before_linux(void);
 
diff --git a/arch/x86/lib/fsp/fsp_support.c b/arch/x86/lib/fsp/fsp_support.c
index 5809235..4585166 100644
--- a/arch/x86/lib/fsp/fsp_support.c
+++ b/arch/x86/lib/fsp/fsp_support.c
@@ -173,6 +173,9 @@ void fsp_init(u32 stack_top, u32 boot_mode, void *nvs_buf)
 
post_code(POST_PRE_MRC);
 
+   /* Load GDT for FSP */
+   setup_fsp_gdt();
+
/*
 * Use ASM code to ensure the register value in EAX  ECX
 * will be passed into BlContinuationFunc
-- 
1.8.2.1

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


[U-Boot] [PATCH v3 1/3] x86: Add Kconfig options to be used by arch/x86/cpu/config.mk

2015-06-06 Thread Bin Meng
Add RESET_SEG_START, RESET_SEG_SIZE and RESET_VEC_LOC Kconfig options
and make arch/x86/cpu/config.mk use these options.

Signed-off-by: Bin Meng bmeng...@gmail.com
Acked-by: Simon Glass s...@chromium.org
Tested-by: Andrew Bradford andrew.bradf...@kodakalaris.com
Tested-by: Simon Glass s...@chromium.org

---

Changes in v3: None
Changes in v2:
- New patch to add Kconfig options to be used by arch/x86/cpu/config.mk

 arch/x86/Kconfig   | 15 +++
 arch/x86/cpu/config.mk |  6 +++---
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 3506ba2..78996d0 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -75,6 +75,21 @@ config X86_RESET_VECTOR
bool
default n
 
+config RESET_SEG_START
+   hex
+   depends on X86_RESET_VECTOR
+   default 0x
+
+config RESET_SEG_SIZE
+   hex
+   depends on X86_RESET_VECTOR
+   default 0x1
+
+config RESET_VEC_LOC
+   hex
+   depends on X86_RESET_VECTOR
+   default 0xfff0
+
 config SYS_X86_START16
hex
depends on X86_RESET_VECTOR
diff --git a/arch/x86/cpu/config.mk b/arch/x86/cpu/config.mk
index 4c4d0c7..1263221 100644
--- a/arch/x86/cpu/config.mk
+++ b/arch/x86/cpu/config.mk
@@ -10,8 +10,8 @@ CROSS_COMPILE ?= i386-linux-
 PLATFORM_CPPFLAGS += -D__I386__
 
 # DO NOT MODIFY THE FOLLOWING UNLESS YOU REALLY KNOW WHAT YOU ARE DOING!
-LDPPFLAGS += -DRESET_SEG_START=0x
-LDPPFLAGS += -DRESET_SEG_SIZE=0x1
-LDPPFLAGS += -DRESET_VEC_LOC=0xfff0
+LDPPFLAGS += -DRESET_SEG_START=$(CONFIG_RESET_SEG_START)
+LDPPFLAGS += -DRESET_SEG_SIZE=$(CONFIG_RESET_SEG_SIZE)
+LDPPFLAGS += -DRESET_VEC_LOC=$(CONFIG_RESET_VEC_LOC)
 LDPPFLAGS += -DSTART_16=$(CONFIG_SYS_X86_START16)
 LDPPFLAGS += -DRESET_BASE=CONFIG_SYS_TEXT_BASE + (CONFIG_SYS_MONITOR_LEN - 
RESET_SEG_SIZE)
-- 
1.8.2.1

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


Re: [U-Boot] [PATCH v3] mx6_common: Fix LOADADDR and SYS_TEXT_BASE for MX6SL and MX6SX

2015-06-06 Thread Fabio Estevam
Hi Stefano,

On Thu, May 28, 2015 at 12:54 PM, Vincent Stehlé
vincent.ste...@laposte.net wrote:
 On 05/28/2015 05:33 PM, Fabio Estevam wrote:
 ..
 Build tested only

 Hi Fabio,

 Thank you for that fix. I did not realize you had a patch on-going
 when sending mine; sorry. Your solution is cleaner and more generic than
 mine anyway :)

 This works fine for me and does indeed repair the boot on i.MX6 SoloX
 Sabre SD.

 Tested-by: Vincent Stehlé vincent.ste...@laposte.net

Can this one be applied so that we can have mx6solo and mx6solox booting again?

Thanks,

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


Re: [U-Boot] [PATCH v3] mx6_common: Fix LOADADDR and SYS_TEXT_BASE for MX6SL and MX6SX

2015-06-06 Thread Fabio Estevam
Forgot to add Stefano on Cc.

On Sat, Jun 6, 2015 at 4:11 PM, Fabio Estevam feste...@gmail.com wrote:
 Hi Stefano,

 On Thu, May 28, 2015 at 12:54 PM, Vincent Stehlé
 vincent.ste...@laposte.net wrote:
 On 05/28/2015 05:33 PM, Fabio Estevam wrote:
 ..
 Build tested only

 Hi Fabio,

 Thank you for that fix. I did not realize you had a patch on-going
 when sending mine; sorry. Your solution is cleaner and more generic than
 mine anyway :)

 This works fine for me and does indeed repair the boot on i.MX6 SoloX
 Sabre SD.

 Tested-by: Vincent Stehlé vincent.ste...@laposte.net

 Can this one be applied so that we can have mx6solo and mx6solox booting 
 again?

 Thanks,

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