spl: Change PAD_TO to CONFIG_SPL_PAD_TO

This was already used by some SPL targets, and allows the pad amount to
be specified by board config headers rather than only in makefile
fragments.

Also supply a pad-to of zero if the variable is undefined.  It works
without this, but this avoids relying on undocumented behavior.

Signed-off-by: Scott Wood <scottwood@freescale.com>
Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
powerpc/mpc83xx: add support for new SPL

This adds arch support for PPC mpc83xx to boot "minimal" (4K) SPLs
using the new infrastructure.

Existing nand_spl targets are updated to deal with the name change
from nand_init.c to spl_minimal.c (as in theory this isn't limited
to NAND anymore).

Signed-off-by: Scott Wood <scottwood@freescale.com>
Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
powerpc/mpc83xx: convert MPC8313ERDB to new-SPL

This converts MPC8313ERDB NAND boot to use the new SPL infrastructure.

Signed-off-by: Scott Wood <scottwood@freescale.com>
Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
MIPS: bootm.c: use debug macro to print debug message

The '## Transferring control ...' message is printed
only if DEBUG is enabled. Get rid of the 'ifdef DEBUG'
statement and use the debug macro instead.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
MIPS: bootm.c: separate linux jump code

Move the actual jump code into a separate function.
This make the code reusable for bootm subcommands.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Cc: Daniel Schwierzeck <daniel.schwierzeck@googlemail.com>
MIPS: bootm.c: separate environment initialization

Move the environment initialization code into a
separate function. This make the code reusable
for bootm subcommands.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Cc: Daniel Schwierzeck <daniel.schwierzeck@googlemail.com>
MIPS: bootm.c: add support for 'prep' and 'go' subcommands

The bootm command supports subcommands since long time
however those subcommands are not yet usable on MIPS.

The patch is based on the ARM implementation, and it adds
support for the 'prep' and 'go' subcommands only.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Cc: Daniel Schwierzeck <daniel.schwierzeck@googlemail.com>
MIPS: qemu-mips: fix a typo in README

The 'Limitations & comments' section refers to the
'-m mips' switch which is not valid. The '-m' switch
can be used for setting the virtual RAM size:

    $qemu-system-mips --help | grep '^-m '
    -m megs         set virtual RAM size to megs MB [default=128]
    $

The correct switch for specifying the machine type is '-M'.
Fix the text to refer to that.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Cc: Daniel Schwierzeck <daniel.schwierzeck@googlemail.com>
Cc: Vlad Lungu <vlad.lungu@windriver.com>
MIPS: qemu-mips: add '-M mips' switch to the example usage command

Using the example command from the README file does
not work as expected. qemu shows a text similar to
the one below and it hangs.

    $ qemu-system-mips -L . -nographic
    Could not open option rom 'pxe-pcnet.rom': No such file or directory
    qemu-system-mips: pci_add_option_rom: failed to find romfile "vgabios-cirrus.bin"
    qemu: terminating on signal 15 from pid 19726

This happens because qemu emulates a Malta board by
default if the machine type is not defined explicitely
on the command line.

For a working test, the '-M mips' switch is required:

    $ qemu-system-mips -M mips -L . -nographic
    Could not open option rom 'vgabios.bin': No such file or directory

    U-Boot 2013.01-rc2-00132-g1e8e648-dirty (Jan 08 2013 - 09:06:42)

    Board: Qemu -M mips CPU: 24Kf proc_id=0x19300
    DRAM:  128 MiB
    ## Unknown flash on Bank 1 - Size = 0x00000000 = 0 MB
    Flash: 0 Bytes
    *** Warning - bad CRC, using default environment

    In:    serial
    Out:   serial
    Err:   serial
    Net:   NE2000
    Hit any key to stop autoboot:  0
    qemu-mips #

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Cc: Daniel Schwierzeck <daniel.schwierzeck@googlemail.com>
Cc: Vlad Lungu <vlad.lungu@windriver.com>
MIPS: qemu-mips: update and fix example usage in README

By now U-Boot supports Qemu MIPS for little and big endian
as well as 32 bit and 64 bit. Update and fix the example usage
in the README to reflect this.

Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
README.qemu-mips: move README file from board to doc directory

Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
README.mips: update known issues and TODOs

Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
Merge remote-tracking branch 'mpc83xx/next'
MIPS: use inline directive for __in*s functions

All other IO accessor functions are using the
'inline' directive. Use that also for the __in*s
to make it consistent with the other variants.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Cc: Daniel Schwierzeck <daniel.schwierzeck@googlemail.com>
MIPS: convert IO port accessor functions to 'static inline'

The currently used 'extern inline' directive causes
the following compiler warnings if CONFIG_SWAP_IO_SPACE
is defined:

  <...>/include/asm/io.h:345:1: warning: '__fswab32' is static but used in inline function '__outlc_p' which is not static [enabled by default]
  <...>/include/asm/io.h:345:1: warning: '__fswab32' is static but used in inline function '__outl_p' which is not static [enabled by default]
  <...>/include/asm/io.h:345:1: warning: '__fswab32' is static but used in inline function '__outlc' which is not static [enabled by default]
  <...>/include/asm/io.h:345:1: warning: '__fswab32' is static but used in inline function '__outl' which is not static [enabled by default]
  <...>/include/asm/io.h:344:1: warning: '__fswab16' is static but used in inline function '__outwc_p' which is not static [enabled by default]
  <...>/include/asm/io.h:344:1: warning: '__fswab16' is static but used in inline function '__outw_p' which is not static [enabled by default]
  <...>/include/asm/io.h:344:1: warning: '__fswab16' is static but used in inline function '__outwc' which is not static [enabled by default]
  <...>/include/asm/io.h:344:1: warning: '__fswab16' is static but used in inline function '__outw' which is not static [enabled by default]
  <...>/include/asm/io.h:341:1: warning: '__fswab32' is static but used in inline function '__inlc_p' which is not static [enabled by default]
  <...>/include/asm/io.h:341:1: warning: '__fswab32' is static but used in inline function '__inl_p' which is not static [enabled by default]
  <...>/include/asm/io.h:341:1: warning: '__fswab32' is static but used in inline function '__inlc' which is not static [enabled by default]
  <...>/include/asm/io.h:341:1: warning: '__fswab32' is static but used in inline function '__inl' which is not static [enabled by default]
  <...>/include/asm/io.h:340:1: warning: '__fswab16' is static but used in inline function '__inwc_p' which is not static [enabled by default]
  <...>/include/asm/io.h:340:1: warning: '__fswab16' is static but used in inline function '__inw_p' which is not static [enabled by default]
  <...>/include/asm/io.h:340:1: warning: '__fswab16' is static but used in inline function '__inwc' which is not static [enabled by default]
  <...>/include/asm/io.h:340:1: warning: '__fswab16' is static but used in inline function '__inw' which is not static [enabled by default]

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Cc: Daniel Schwierzeck <daniel.schwierzeck@googlemail.com>
MIPS: start{, 64}.S: fill branch delay slots with NOP instructions

The romReserved and romExcHandle handlers are
accessed by a branch instruction however the
delay slots of those instructions are not filled.

Because the start.S uses the 'noreorder' directive,
the assembler will not fill the delay slots either,
and leads to the following assembly code:

  0000056c <romReserved>:
   56c:   1000ffff        b       56c <romReserved>

  00000570 <romExcHandle>:
   570:   1000ffff        b       570 <romExcHandle>

In the resulting code, the second branch instruction
is placed into the delay slot of the first branch
instruction, which is not allowed on the MIPS
architecture.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Cc: Daniel Schwierzeck <daniel.schwierzeck@googlemail.com>
MIPS: start.S: fix boundary check in relocate_code

The loop code copies more data with one than
necessary due to the 'ble' instuction. Use the
'blt' instruction instead to fix that.

Due to the lack of suitable hardware the Xburst
specific code is compile tested only. However the
change is quite obvious.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Cc: Daniel Schwierzeck <daniel.schwierzeck@googlemail.com>
MIPS: start.S: set sp register directly

The current code uses two instructions to load
the stack pointer into the 'sp' register.

This results in the following assembly code:

    468:   3c088040        lui     t0,0x8040
    46c:   251d0000        addiu   sp,t0,0

The first instuction loads the stack pointer into
the 't0' register then the value of the 'sp' register
is computed by adding zero to the value of the 't0'
register. The same issue present on the 64-bit version
as well:

    56c:   3c0c8040        lui     t0,0x8040
    570:   659d0000        daddiu  sp,t0,0

Change the code to load the stack pointer directly
into the 'sp' register. The generated code is functionally
equivalent to the previous version but it is simpler.

  32-bit:
    468:   3c1d8040        lui     sp,0x8040

  64-bit:
    56c:   3c1d8040        lui     sp,0x8040

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Cc: Daniel Schwierzeck <daniel.schwierzeck@googlemail.com>
MIPS: start.S: save reused arguments earlier in relocate_code

Save the reused parameters at the beginning
of the 'relocate_code' function. This makes
the function a bit more readable.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Cc: Daniel Schwierzeck <daniel.schwierzeck@googlemail.com>
MIPS: start.S: simplify relocation offset calculation

The current code uses four instructions and a
temporary register to calculate the relocation
offset and to adjust the gp register.

The relocation offset can be calculated directly
from the CONFIG_SYS_MONITOR_BASE constant and from
the destination address. The resulting offset can
be used to adjust the gp pointer.

This approach makes the code a bit simpler because
it needs two instructions only.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Cc: Daniel Schwierzeck <daniel.schwierzeck@googlemail.com>