1. 23 Jul, 2014 23 commits
    • Simon Glass's avatar
      dm: Introduce device sequence numbering · 5a66a8ff
      Simon Glass authored
      
      
      In U-Boot it is pretty common to number devices from 0 and access them
      on the command line using this numbering. While it may come to pass that
      we will move away from this numbering, the possibility seems remote at
      present.
      
      Given that devices within a uclass will have an implied numbering, it
      makes sense to build this into driver model as a core feature. The cost
      is fairly small in terms of code and data space.
      
      With each uclass having numbered devices we can ask for SPI port 0 or
      serial port 1 and receive a single device.
      
      Devices typically request a sequence number using aliases in the device
      tree. These are resolved when the device is probed, to deal with conflicts.
      Sequence numbers need not be sequential and holes are permitted.
      
      At present there is no support for sequence numbers using static platform
      data. It could easily be added to 'struct driver_info' if needed, but it
      seems better to add features as we find a use for them, and the use of -1
      to mean 'no sequence' makes the default value somewhat painful.
      Signed-off-by: default avatarSimon Glass <sjg@chromium.org>
      5a66a8ff
    • Simon Glass's avatar
      dm: Avoid activating devices in 'dm uclass' command · 4e8bc211
      Simon Glass authored
      
      
      This command currently activates devices as it lists them. This is not
      desirable since it changes the system state. Fix it and avoid printing
      a newline if there are no devices in a uclass.
      Signed-off-by: default avatarSimon Glass <sjg@chromium.org>
      4e8bc211
    • Simon Glass's avatar
      dm: Move device display into its own function · fffa24d7
      Simon Glass authored
      
      
      The device display for 'dm tree' and 'dm uclass' is mostly the same, so
      move it into a common function.
      Signed-off-by: default avatarSimon Glass <sjg@chromium.org>
      fffa24d7
    • Simon Glass's avatar
      fdt: Add a function to get the alias sequence of a node · 5c33c9fd
      Simon Glass authored
      
      
      Aliases are used to provide U-Boot's numbering of devices, such as:
      
      aliases {
      	spi0 = "/spi@12330000";
      }
      
      spi@12330000 {
      	...
      }
      
      This tells us that the SPI controller at 12330000 is considered to be the
      first SPI controller (SPI 0). So we have a numbering for the SPI node.
      
      Add a function that returns the numbering for a node assume that it exists
      in the list of aliases.
      Signed-off-by: default avatarSimon Glass <sjg@chromium.org>
      5c33c9fd
    • Simon Glass's avatar
      dm: Move uclass error checking/probing into a function · 9ca296a1
      Simon Glass authored
      
      
      Several functions will use this same pattern, so bring it into a function.
      Signed-off-by: default avatarSimon Glass <sjg@chromium.org>
      9ca296a1
    • Simon Glass's avatar
      Add a flag indicating when the serial console is ready · 093f79ab
      Simon Glass authored
      
      
      For sandbox we have a fallback console which is used very early in
      U-Boot, before serial drivers are available. Rather than try to guess
      when to switch to the real console, add a flag so we can be sure. This
      makes sure that sandbox can always output a panic() message, for example,
      and avoids silent failure (which is very annoying in sandbox).
      Signed-off-by: default avatarSimon Glass <sjg@chromium.org>
      093f79ab
    • Simon Glass's avatar
      console: Remove vprintf() optimisation for sandbox · 7793ac96
      Simon Glass authored
      
      
      If the console is not present, we try to reduce overhead by stopping any
      output in vprintf(), before it gets to putc(). This is of dubious merit
      in general, but in the case of sandbox it is incorrect since we have a
      fallback console which reports errors very early in U-Boot. If this is
      defeated U-Boot can hang or exit with no indication of what is wrong.
      
      Remove the optimisation for sandbox.
      Signed-off-by: default avatarSimon Glass <sjg@chromium.org>
      7793ac96
    • Simon Glass's avatar
      stdio: Provide functions to add/remove devices using stdio_dev · d97143a6
      Simon Glass authored
      
      
      The current functions for adding and removing devices require a device name.
      This is not convenient for driver model, which wants to store a pointer to
      the relevant device. Add new functions which provide this feature and adjust
      the old ones to call these.
      Signed-off-by: default avatarSimon Glass <sjg@chromium.org>
      d97143a6
    • Simon Glass's avatar
      dm: Support driver model prior to relocation · ab7cd627
      Simon Glass authored
      
      
      Initialise devices marked 'pre-reloc' and make them available prior to
      relocation. Note that this requires pre-reloc malloc() to be available.
      Signed-off-by: default avatarSimon Glass <sjg@chromium.org>
      ab7cd627
    • Simon Glass's avatar
      dm: Allow drivers to be marked 'before relocation' · 00606d7e
      Simon Glass authored
      
      
      Driver model currently only operates after relocation is complete. In this
      state U-Boot typically has a small amount of memory available. In adding
      support for driver model prior to relocation we must try to use as little
      memory as possible.
      
      In addition, on some machines the memory has not be inited and/or the CPU
      is not running at full speed or the data cache is off. These can reduce
      execution performance, so the less initialisation that is done before
      relocation the better.
      
      An immediately-obvious improvement is to only initialise drivers which are
      actually going to be used before relocation. On many boards the only such
      driver is a serial UART, so this provides a very large potential benefit.
      
      Allow drivers to mark themselves as 'pre-reloc' which means that they will
      be initialised prior to relocation. This can be done either with a driver
      flag or with a 'dm,pre-reloc' device tree property.
      
      To support this, the various dm scanning function now take a 'pre_reloc_only'
      parameter which indicates that only drivers marked pre-reloc should be
      bound.
      Signed-off-by: default avatarSimon Glass <sjg@chromium.org>
      00606d7e
    • Simon Glass's avatar
      sandbox: Remove all drivers before exit · 61336833
      Simon Glass authored
      
      
      Drivers are supposed to be able to close down cleanly. To set a good example,
      make sandbox shut down its driver model drivers and remove them before exit.
      
      It may be desirable to do the same more generally once driver model is more
      widely-used. This could be done during bootm, before U-Boot jumps to the OS.
      It seems far too early to make this change.
      Signed-off-by: default avatarSimon Glass <sjg@chromium.org>
      61336833
    • Simon Glass's avatar
      dm: Provide a way to shut down driver model · 9adbd7a1
      Simon Glass authored
      
      
      Add a new method which removes and unbinds all drivers.
      Signed-off-by: default avatarSimon Glass <sjg@chromium.org>
      Acked-by: default avatarMarek Vasut <marex@denx.de>
      9adbd7a1
    • Simon Glass's avatar
      dm: Make sure that the root device is probed · 7497812d
      Simon Glass authored
      
      
      The root device should be probed just like any other device. The effect of
      this is to mark the device as activated, so that it can be removed (along
      with its children) if required.
      Signed-off-by: default avatarSimon Glass <sjg@chromium.org>
      Acked-by: default avatarMarek Vasut <marex@denx.de>
      7497812d
    • Simon Glass's avatar
      stdio: Pass device pointer to stdio methods · 709ea543
      Simon Glass authored
      
      
      At present stdio device functions do not get any clue as to which stdio
      device is being acted on. Some implementations go to great lengths to work
      around this, such as defining a whole separate set of functions for each
      possible device.
      
      For driver model we need to associate a stdio_dev with a device. It doesn't
      seem possible to continue with this work-around approach.
      
      Instead, add a stdio_dev pointer to each of the stdio member functions.
      
      Note: The serial drivers have the same problem, but it is not strictly
      necessary to fix that to get driver model running. Also, if we convert
      serial over to driver model the problem will go away.
      
      Code size increases by 244 bytes for Thumb2 and 428 for PowerPC.
      
      22: stdio: Pass device pointer to stdio methods
             arm: (for 2/2 boards)  all +244.0  bss -4.0  text +248.0
         powerpc: (for 1/1 boards)  all +428.0  text +428.0
      Signed-off-by: default avatarSimon Glass <sjg@chromium.org>
      Acked-by: default avatarMarek Vasut <marex@denx.de>
      Reviewed-by: default avatarMarek Vasut <marex@denx.de>
      709ea543
    • Simon Glass's avatar
      stdio: Remove redundant code around stdio_register() calls · 91d0be1d
      Simon Glass authored
      
      
      There is no point in setting a structure's memory to NULL when it has
      already been zeroed with memset().
      
      Also, there is no need to create a stub function for stdio to call - if the
      function is NULL it will not be called.
      
      This is a clean-up, with no change in functionality.
      Signed-off-by: default avatarSimon Glass <sjg@chromium.org>
      Acked-by: default avatarMarek Vasut <marex@denx.de>
      91d0be1d
    • Simon Glass's avatar
      dm: Use an explicit expect value in core tests · eb9ef5fe
      Simon Glass authored
      
      
      Rather than reusing the 'reg' property, use an explicit property for the
      expected ping value used in testing.
      Signed-off-by: default avatarSimon Glass <sjg@chromium.org>
      eb9ef5fe
    • Simon Glass's avatar
      dm: gpio: Don't use the driver model uclass for SPL · 5b9765c7
      Simon Glass authored
      
      
      Driver model does not support SPL yet, so we should not use the GPIO
      uclass for SPL.
      Signed-off-by: default avatarSimon Glass <sjg@chromium.org>
      5b9765c7
    • Simon Glass's avatar
      sandbox: Always enable malloc debug · 6d7601e7
      Simon Glass authored
      
      
      Tun on DEBUG in malloc(). This adds code space and slows things down but
      for sandbox this is acceptable. We gain the ability to check for memory
      leaks in tests.
      Signed-off-by: default avatarSimon Glass <sjg@chromium.org>
      6d7601e7
    • Simon Glass's avatar
      sandbox: config: Enable pre-relocation malloc() · b53e94b1
      Simon Glass authored
      
      
      Enable this for sandbox so that we will be able to use driver model before
      relocation.
      Signed-off-by: default avatarSimon Glass <sjg@chromium.org>
      b53e94b1
    • Simon Glass's avatar
      sandbox: Support pre-relocation malloc() · 29afe9e6
      Simon Glass authored
      
      
      Set up and zero global data before board_init_f() is called so that we can
      remove the need for CONFIG_SYS_GENERIC_GLOBAL_DATA.
      Signed-off-by: default avatarSimon Glass <sjg@chromium.org>
      29afe9e6
    • Simon Glass's avatar
      Add a simple malloc() implementation for pre-relocation · d59476b6
      Simon Glass authored
      
      
      If we are to have driver model before relocation we need to support some
      way of calling memory allocation routines.
      
      The standard malloc() is pretty complicated:
      
      1. It uses some BSS memory for its state, and BSS is not available before
      relocation
      
      2. It supports algorithms for reducing memory fragmentation and improving
      performace of free(). Before relocation we could happily just not support
      free().
      
      3. It includes about 4KB of code (Thumb 2) and 1KB of data. However since
      this has been loaded anyway this is not really a problem.
      
      The simplest way to support pre-relocation malloc() is to reserve an area
      of memory and allocate it in increasing blocks as needed. This
      implementation does this.
      
      To enable it, you need to define the size of the malloc() pool as described
      in the README. It will be located above the pre-relocation stack on
      supported architectures.
      
      Note that this implementation is only useful on machines which have some
      memory available before dram_init() is called - this includes those that
      do no DRAM init (like tegra) and those that do it in SPL (quite a few
      boards). Enabling driver model preior to relocation for the rest of the
      boards is left for a later exercise.
      Signed-off-by: default avatarSimon Glass <sjg@chromium.org>
      d59476b6
    • Simon Glass's avatar
      sandbox: Set up global data before board_init_f() · 4d94dfa0
      Simon Glass authored
      
      
      At present sandbox defines CONFIG_SYS_GENERIC_GLOBAL_DATA, meaning that
      the global_data pointer is set up in board_init_f().
      
      If we set up and zero the global data before calling board_init_f() then we
      don't need to define CONFIG_SYS_GENERIC_GLOBAL_DATA.
      
      Make this change to simplify the init process.
      Signed-off-by: default avatarSimon Glass <sjg@chromium.org>
      4d94dfa0
    • Simon Glass's avatar
      Remove form-feeds from dlmalloc.c · d93041a4
      Simon Glass authored
      
      
      These don't really serve any purpose in the modern age. On the other hand
      they show up as annoying control characters in my editor, which then happily
      removes them.
      
      I believe we can drop these characters from the file.
      Signed-off-by: default avatarSimon Glass <sjg@chromium.org>
      d93041a4
  2. 22 Jul, 2014 17 commits