[U-Boot] [RFC PATCH 0/22] Introduce driver model serial uclass

Simon Glass sjg at chromium.org
Sat May 24 23:20:59 CEST 2014


This series adds support for a serial uclass, enabling serial drivers to be
converted to use driver model.

Unfortunately this is quite a complicated process for a number of reasons:

- serial is used before relocation, but driver model does not support this
- stdio member functions are not passed a device pointer, but driver model
    requires this (so does serial, but it uses an ugly work-around)
- driver model requires malloc() but this is not available before
  relocation
- for sandbox, if something goes wrong with the console, we still need to
  get an error message out through the fallback console

So this series includes quite a few patches to address the above, as well
as the serial uclass and an implementation for sandbox.

The early malloc() implementation uses a very simple region of memory which
it doles out as needed. This means that driver model can start up with very
little memory usage, and no overhead for malloc() itself except for space
wasted due to alignment. With a 32-bit machine and just a serial port set
as a pre-reloc device (plus the mandatory root device), the usage is 176
bytes.

If you have limited time, please take a look at least at the uclass patch
which is 'dm: Add a uclass for serial devices' (see include/serial.h).

The series is based on the Tegra GPIO series v3. You can get this tree in
a rough unfinished form from u-boot-x86.git branch us-gpioe.

Note: This series is for comments only as there are some build errors for
certain boards.


Simon Glass (22):
  stdio: Remove redundant code around stdio_register() calls
  stdio: Pass device pointer to stdio methods
  dm: Make sure that the root device is probed
  dm: Provide a way to shut down driver model
  sandbox: Remove all drivers before exit
  dm: Tidy up four minor code nits
  dm: Allow drivers to be marked 'before relocation'
  dm: Use '*' to indicate a device is activated
  Remove form-feeds from dlmalloc.c
  Add a simple malloc() implementation for pre-relocation
  sandbox: config: Enable pre-relocation malloc()
  dm: Support driver model prior to relocation
  stdio: Provide functions to add/remove devices using stdio_dev
  console: Remove vprintf() optimisation for sandbox
  Add a flag indicating when the serial console is ready
  dm: Add a way to indicate a preferred device within a uclass
  dm: Expand and improve the device lifecycle docs
  dm: Add a uclass for serial devices
  Set up stdio earlier when using driver model
  sandbox: Convert serial driver to use driver model
  sandbox: serial: Support a coloured console
  sandbox: dts: Add a serial console node

 README                            |  16 +++
 arch/blackfin/cpu/jtag-console.c  |  10 +-
 arch/powerpc/cpu/mpc512x/serial.c |  10 +-
 arch/powerpc/cpu/mpc8xx/video.c   |   6 +-
 arch/sandbox/cpu/cpu.c            |   4 +
 arch/sandbox/dts/sandbox.dts      |  11 ++
 arch/x86/lib/video.c              |   8 +-
 board/bf527-ezkit/video.c         |  10 --
 board/bf548-ezkit/video.c         |  10 --
 board/cm-bf548/video.c            |  10 --
 board/mpl/common/kbd.c            |   6 +-
 board/mpl/common/kbd.h            |   6 +-
 board/mpl/pati/pati.c             |   8 +-
 board/netphone/phone_console.c    |  16 +--
 board/nokia/rx51/rx51.c           |   6 +-
 board/rbc823/kbd.c                |   8 +-
 common/board_f.c                  |  42 ++++++++
 common/board_r.c                  |  28 +++--
 common/cmd_log.c                  |  11 +-
 common/console.c                  |  24 ++---
 common/dlmalloc.c                 |  81 ++++++++++----
 common/lcd.c                      |  14 ++-
 common/stdio.c                    |  63 ++++++++---
 common/usb_kbd.c                  |   6 +-
 doc/driver-model/README.txt       | 220 +++++++++++++++++++++++++++++++++++---
 drivers/core/device.c             |  11 +-
 drivers/core/lists.c              |   6 +-
 drivers/core/root.c               |  22 +++-
 drivers/core/uclass.c             |  15 ++-
 drivers/input/cros_ec_keyb.c      |   6 +-
 drivers/input/i8042.c             |   4 +-
 drivers/input/keyboard.c          |   6 +-
 drivers/input/tegra-kbc.c         |   6 +-
 drivers/misc/cbmem_console.c      |   6 +-
 drivers/net/netconsole.c          |  10 +-
 drivers/serial/Makefile           |   4 +
 drivers/serial/sandbox.c          | 140 +++++++++++++++++++-----
 drivers/serial/serial-uclass.c    | 161 ++++++++++++++++++++++++++++
 drivers/serial/serial.c           |  55 ++++++++--
 drivers/serial/usbtty.c           |   8 +-
 drivers/video/cfb_console.c       |   8 +-
 include/asm-generic/global_data.h |   7 ++
 include/common.h                  |   5 +
 include/configs/ELPPC.h           |   4 +-
 include/configs/MHPC.h            |   4 +-
 include/configs/jadecpu.h         |   4 +-
 include/configs/nokia_rx51.h      |   5 +-
 include/configs/sandbox.h         |   7 ++
 include/dm/device-internal.h      |   6 +-
 include/dm/device.h               |  10 +-
 include/dm/lists.h                |  22 +++-
 include/dm/root.h                 |  18 +++-
 include/dm/uclass-id.h            |   1 +
 include/dm/uclass-internal.h      |   3 +-
 include/dm/uclass.h               |  21 +++-
 include/i8042.h                   |   6 +-
 include/serial.h                  |  90 ++++++++++++++++
 include/stdio_dev.h               |  17 +--
 include/video.h                   |   8 +-
 test/dm/cmd_dm.c                  |  11 +-
 test/dm/core.c                    |  49 +++++++--
 test/dm/test-driver.c             |  11 ++
 test/dm/test-fdt.c                |  34 +++++-
 test/dm/test-main.c               |   4 +-
 test/dm/test.dts                  |  12 +++
 65 files changed, 1186 insertions(+), 275 deletions(-)
 create mode 100644 drivers/serial/serial-uclass.c

-- 
1.9.1.423.g4596e3a



More information about the U-Boot mailing list