All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 00/45] Various fixes and improvements
@ 2018-10-01 18:22 Simon Glass
  2018-10-01 18:22 ` [U-Boot] [PATCH 01/45] dm: core: Alloc uclass-private data to be cache-aligned Simon Glass
                   ` (84 more replies)
  0 siblings, 85 replies; 106+ messages in thread
From: Simon Glass @ 2018-10-01 18:22 UTC (permalink / raw)
  To: u-boot

This series collects together a large number of small patches that I have
been fiddling with for a while. At lot of them relate to SPL and TPL and
updating Chromium OS verified boot to work on U-Boot.


Simon Glass (45):
  dm: core: Alloc uclass-private data to be cache-aligned
  dm: core: Update some functions to use const
  dm: core: Add a function to find the first inactive child
  dm: core: Update ofnode to read binman-style flash entry
  sf: Avoid allocating memory on every read operation
  spl: input: Allow input in SPL and TPL
  Makefile: Add a warning if SPL/TPL cannot be built
  spl: misc: Allow misc drivers in SPL and TPL
  blk: Support block drivers in TPL
  Kconfig: Convert CONFIG_RTC_MC146818 to Kconfig
  rtc: Allow use of RTC in SPL and TPL
  fdt: Document the fact that dtc is now built
  doc: Update docs for device tree in SPL, TPL
  fdt: Allow indicating a node is for U-Boot proper only
  tpm: Add support for SPL and TPL
  serial: Allow serial to be absent in TPL
  fdt: Allow libfdt in TPL
  cros: Update cros_ec code to use struct udevice
  cros: Adjust board_get_cros_ec_dev() to return a udevice
  dm: spi: Add logging of some return values
  fdt: Remove fdtdec_decode_region() function
  video: Adjust video_clear() to return an error
  tpm: Use livetree and allow children
  tpm: Tidy up logging in tpm-common.c
  tpm: Add a few new commands for v1
  binman: Move to three-digit test-file numbers
  binman: Add a test for Intel reference code
  log: Add comments to the rest of the log categories
  malloc_simple: Add logging of allocations
  Add a header file for strings
  Rename GPT_HEADER_SIGNATURE to avoid conflict
  cros: Update ec_commands to latest version
  x86: Update mtrr functions to allow leaving cache alone
  cros_ec: Update cros_ec_read_hash() to specify the image
  cros_ec: Add support for v3 messages on LPC
  test: panel: Add a test for the panel uclass
  panel: Expand the backlight support
  ctags: Minor changes to fix ctags output
  fdt: Allow C++ comments in link scripts and DT files
  pci: Add a little more debugging to pci_rom
  sysreset: Tidy up a few comments and logging
  sysreset: Add a way to find the last reset
  video: at91: Adjust vidconsole_position_cursor() to use char pos
  video: Tidy up a few comments in video.o
  dtoc: Fix the value of SetInt()

 Makefile                                      |    2 +-
 arch/sandbox/dts/sandbox.dts                  |   20 +-
 arch/sandbox/dts/sandbox64.dts                |   20 +-
 arch/sandbox/dts/sandbox_pmic.dtsi            |    2 +-
 arch/sandbox/dts/test.dts                     |   20 +-
 arch/sandbox/include/asm/test.h               |   15 +
 arch/x86/cpu/mtrr.c                           |   31 +-
 arch/x86/include/asm/mtrr.h                   |    6 +-
 board/atmel/common/video_display.c            |    5 +-
 cmd/cros_ec.c                                 |   31 +-
 cmd/tpm_test.c                                |   15 -
 cmd/x86/mtrr.c                                |    8 +-
 common/cros_ec.c                              |    4 +-
 common/malloc_simple.c                        |   58 +-
 configs/edison_defconfig                      |    1 +
 configs/malta_defconfig                       |    1 +
 disk/part_efi.c                               |    6 +-
 doc/README.fdt-control                        |   16 +-
 doc/driver-model/README.txt                   |    7 +-
 drivers/block/Kconfig                         |   12 +
 drivers/block/Makefile                        |    2 +-
 drivers/core/device.c                         |   45 +-
 drivers/core/of_extra.c                       |   27 +-
 drivers/core/ofnode.c                         |    2 +
 drivers/input/Kconfig                         |   48 +
 drivers/input/Makefile                        |   11 +-
 drivers/input/input.c                         |    5 +-
 drivers/misc/Kconfig                          |   72 +
 drivers/misc/Makefile                         |    9 +-
 drivers/misc/cros_ec.c                        |  178 +-
 drivers/misc/cros_ec_lpc.c                    |   33 +
 drivers/misc/cros_ec_sandbox.c                |    8 +-
 drivers/mtd/spi/sf-uclass.c                   |    6 +-
 drivers/mtd/spi/sf_probe.c                    |    2 +-
 drivers/mtd/spi/spi_flash.c                   |   17 +-
 drivers/pci/pci_rom.c                         |    4 +-
 drivers/pwm/sandbox_pwm.c                     |   25 +
 drivers/rtc/Kconfig                           |   26 +
 drivers/rtc/Makefile                          |    2 +-
 drivers/rtc/rtc-uclass.c                      |    1 +
 drivers/serial/Kconfig                        |   10 +
 drivers/serial/serial-uclass.c                |    4 +
 drivers/spi/spi-uclass.c                      |    6 +-
 drivers/sysreset/sysreset-uclass.c            |   34 +-
 drivers/sysreset/sysreset_sandbox.c           |   12 +
 drivers/tpm/Makefile                          |    2 +-
 drivers/tpm/tpm-uclass.c                      |    7 +-
 drivers/tpm/tpm_tis_lpc.c                     |    2 +-
 drivers/video/backlight-uclass.c              |   10 +
 drivers/video/panel-uclass.c                  |   18 +
 drivers/video/pwm_backlight.c                 |  186 +-
 drivers/video/simple_panel.c                  |   20 +-
 drivers/video/tegra124/sor.c                  |    3 +-
 drivers/video/vidconsole-uclass.c             |    2 +
 drivers/video/video-uclass.c                  |    4 +-
 include/backlight.h                           |   25 +
 include/configs/edison.h                      |    1 -
 include/configs/malta.h                       |    1 -
 include/cros_ec.h                             |   72 +-
 include/dm/device.h                           |   39 +-
 include/dm/of_extra.h                         |    3 +-
 include/dm/uclass.h                           |    3 +
 include/ec_commands.h                         | 4324 ++++++++++++++---
 include/fdtdec.h                              |   45 -
 include/linux/compiler-gcc.h                  |    6 +-
 include/log.h                                 |   12 +-
 include/malloc.h                              |    1 +
 include/panel.h                               |   22 +-
 include/part_efi.h                            |    2 +-
 include/string.h                              |    1 +
 include/sysreset.h                            |   34 +-
 include/tpm-v1.h                              |   28 +
 include/video.h                               |    7 +-
 lib/Kconfig                                   |   32 +
 lib/Makefile                                  |   10 +-
 lib/fdtdec.c                                  |   83 -
 lib/hang.c                                    |    5 +-
 lib/tpm-common.c                              |   10 +-
 lib/tpm-v1.c                                  |   68 +-
 scripts/Makefile.spl                          |    9 +-
 scripts/config_whitelist.txt                  |    1 -
 test/dm/Makefile                              |    1 +
 test/dm/core.c                                |   31 +
 test/dm/ofnode.c                              |   16 +
 test/dm/panel.c                               |   79 +
 test/dm/sysreset.c                            |   20 +-
 tools/binman/entry_test.py                    |    2 +-
 tools/binman/fdt_test.py                      |    4 +-
 tools/binman/ftest.py                         |  231 +-
 .../test/{01_invalid.dts => 001_invalid.dts}  |    0
 ..._missing_node.dts => 002_missing_node.dts} |    0
 .../test/{03_empty.dts => 003_empty.dts}      |    0
 ...nvalid_entry.dts => 004_invalid_entry.dts} |    0
 .../test/{05_simple.dts => 005_simple.dts}    |    0
 .../{06_dual_image.dts => 006_dual_image.dts} |    0
 .../{07_bad_align.dts => 007_bad_align.dts}   |    0
 .../binman/test/{08_pack.dts => 008_pack.dts} |    0
 .../{09_pack_extra.dts => 009_pack_extra.dts} |    0
 ...n_power2.dts => 010_pack_align_power2.dts} |    0
 ...er2.dts => 011_pack_align_size_power2.dts} |    0
 ...k_inv_align.dts => 012_pack_inv_align.dts} |    0
 ..._align.dts => 013_pack_inv_size_align.dts} |    0
 ..._pack_overlap.dts => 014_pack_overlap.dts} |    0
 ...ack_overflow.dts => 015_pack_overflow.dts} |    0
 ...erflow.dts => 016_pack_image_overflow.dts} |    0
 ...image_size.dts => 017_pack_image_size.dts} |    0
 ...age_align.dts => 018_pack_image_align.dts} |    0
 ...align.dts => 019_pack_inv_image_align.dts} |    0
 ...ts => 020_pack_inv_image_align_power2.dts} |    0
 .../{21_image_pad.dts => 021_image_pad.dts}   |    0
 .../{22_image_name.dts => 022_image_name.dts} |    0
 .../binman/test/{23_blob.dts => 023_blob.dts} |    0
 .../test/{24_sorted.dts => 024_sorted.dts}    |    0
 ...k_zero_size.dts => 025_pack_zero_size.dts} |    0
 ...u_boot_dtb.dts => 026_pack_u_boot_dtb.dts} |    0
 ...b_no_size.dts => 027_pack_4gb_no_size.dts} |    0
 ...b_outside.dts => 028_pack_4gb_outside.dts} |    0
 .../test/{29_x86-rom.dts => 029_x86-rom.dts}  |    0
 ...no-desc.dts => 030_x86-rom-me-no-desc.dts} |    0
 .../{31_x86-rom-me.dts => 031_x86-rom-me.dts} |    0
 .../{32_intel-vga.dts => 032_intel-vga.dts}   |    0
 ...33_x86-start16.dts => 033_x86-start16.dts} |    0
 .../{34_x86_ucode.dts => 034_x86_ucode.dts}   |    0
 ...gle_ucode.dts => 035_x86_single_ucode.dts} |    0
 .../{36_u_boot_img.dts => 036_u_boot_img.dts} |    0
 ..._x86_no_ucode.dts => 037_x86_no_ucode.dts} |    0
 ...ode.dts => 038_x86_ucode_missing_node.dts} |    0
 ...e2.dts => 039_x86_ucode_missing_node2.dts} |    0
 ...age.dts => 040_x86_ucode_not_in_image.dts} |    0
 ..._pos_size.dts => 041_unknown_pos_size.dts} |    0
 .../{42_intel-fsp.dts => 042_intel-fsp.dts}   |    0
 .../{43_intel-cmc.dts => 043_intel-cmc.dts}   |    0
 ...l_ucode.dts => 044_x86_optional_ucode.dts} |    0
 .../{45_prop_test.dts => 045_prop_test.dts}   |    0
 .../{46_intel-vbt.dts => 046_intel-vbt.dts}   |    0
 ...47_spl_bss_pad.dts => 047_spl_bss_pad.dts} |    0
 ...tart16-spl.dts => 048_x86-start16-spl.dts} |    0
 ...86_ucode_spl.dts => 049_x86_ucode_spl.dts} |    0
 .../{50_intel_mrc.dts => 050_intel_mrc.dts}   |    0
 ...oot_spl_dtb.dts => 051_u_boot_spl_dtb.dts} |    0
 ...spl_nodtb.dts => 052_u_boot_spl_nodtb.dts} |    0
 .../test/{53_symbols.dts => 053_symbols.dts}  |    0
 ..._unit_address.dts => 054_unit_address.dts} |    0
 .../{55_sections.dts => 055_sections.dts}     |    0
 ...56_name_prefix.dts => 056_name_prefix.dts} |    0
 ..._contents.dts => 057_unknown_contents.dts} |    0
 ....dts => 058_x86_ucode_spl_needs_retry.dts} |    0
 ...59_change_size.dts => 059_change_size.dts} |    0
 .../{60_fdt_update.dts => 060_fdt_update.dts} |    0
 ..._update_bad.dts => 061_fdt_update_bad.dts} |    0
 .../{62_entry_args.dts => 062_entry_args.dts} |    0
 ...missing.dts => 063_entry_args_missing.dts} |    0
 ...quired.dts => 064_entry_args_required.dts} |    0
 ...ts => 065_entry_args_unknown_datatype.dts} |    0
 .../binman/test/{66_text.dts => 066_text.dts} |    0
 .../binman/test/{67_fmap.dts => 067_fmap.dts} |    0
 ...d_by_arg.dts => 068_blob_named_by_arg.dts} |    0
 .../binman/test/{69_fill.dts => 069_fill.dts} |    0
 ..._fill_no_size.dts => 070_fill_no_size.dts} |    0
 tools/binman/test/{71_gbb.dts => 071_gbb.dts} |    0
 ...bb_too_small.dts => 072_gbb_too_small.dts} |    0
 ...73_gbb_no_size.dts => 073_gbb_no_size.dts} |    0
 .../test/{74_vblock.dts => 074_vblock.dts}    |    0
 ..._content.dts => 075_vblock_no_content.dts} |    0
 ...phandle.dts => 076_vblock_bad_phandle.dts} |    0
 ...bad_entry.dts => 077_vblock_bad_entry.dts} |    0
 .../{78_u_boot_tpl.dts => 078_u_boot_tpl.dts} |    0
 .../{79_uses_pos.dts => 079_uses_pos.dts}     |    0
 .../{80_fill_empty.dts => 080_fill_empty.dts} |    0
 ...tart16-tpl.dts => 081_x86-start16-tpl.dts} |    0
 ..._update_all.dts => 082_fdt_update_all.dts} |    0
 .../{83_compress.dts => 083_compress.dts}     |    0
 .../test/{84_files.dts => 084_files.dts}      |    0
 ...es_compress.dts => 085_files_compress.dts} |    0
 .../{86_files_none.dts => 086_files_none.dts} |    0
 ...o_pattern.dts => 087_files_no_pattern.dts} |    0
 ...88_expand_size.dts => 088_expand_size.dts} |    0
 ...d_size_bad.dts => 089_expand_size_bad.dts} |    0
 .../binman/test/{90_hash.dts => 090_hash.dts} |    0
 ..._hash_no_algo.dts => 091_hash_no_algo.dts} |    0
 ...ash_bad_algo.dts => 092_hash_bad_algo.dts} |    0
 ...86_tpl_ucode.dts => 093_x86_tpl_ucode.dts} |    0
 .../{94_fmap_x86.dts => 094_fmap_x86.dts}     |    0
 ...6_section.dts => 095_fmap_x86_section.dts} |    0
 tools/binman/test/{96_elf.dts => 096_elf.dts} |    0
 .../{97_elf_strip.dts => 097_elf_strip.dts}   |    0
 ..._hash_section.dts => 099_hash_section.dts} |    0
 tools/binman/test/100_intel_refcode.dts       |   14 +
 tools/dtoc/fdt.py                             |    2 +-
 189 files changed, 5038 insertions(+), 1329 deletions(-)
 create mode 100644 include/string.h
 create mode 100644 test/dm/panel.c
 rename tools/binman/test/{01_invalid.dts => 001_invalid.dts} (100%)
 rename tools/binman/test/{02_missing_node.dts => 002_missing_node.dts} (100%)
 rename tools/binman/test/{03_empty.dts => 003_empty.dts} (100%)
 rename tools/binman/test/{04_invalid_entry.dts => 004_invalid_entry.dts} (100%)
 rename tools/binman/test/{05_simple.dts => 005_simple.dts} (100%)
 rename tools/binman/test/{06_dual_image.dts => 006_dual_image.dts} (100%)
 rename tools/binman/test/{07_bad_align.dts => 007_bad_align.dts} (100%)
 rename tools/binman/test/{08_pack.dts => 008_pack.dts} (100%)
 rename tools/binman/test/{09_pack_extra.dts => 009_pack_extra.dts} (100%)
 rename tools/binman/test/{10_pack_align_power2.dts => 010_pack_align_power2.dts} (100%)
 rename tools/binman/test/{11_pack_align_size_power2.dts => 011_pack_align_size_power2.dts} (100%)
 rename tools/binman/test/{12_pack_inv_align.dts => 012_pack_inv_align.dts} (100%)
 rename tools/binman/test/{13_pack_inv_size_align.dts => 013_pack_inv_size_align.dts} (100%)
 rename tools/binman/test/{14_pack_overlap.dts => 014_pack_overlap.dts} (100%)
 rename tools/binman/test/{15_pack_overflow.dts => 015_pack_overflow.dts} (100%)
 rename tools/binman/test/{16_pack_image_overflow.dts => 016_pack_image_overflow.dts} (100%)
 rename tools/binman/test/{17_pack_image_size.dts => 017_pack_image_size.dts} (100%)
 rename tools/binman/test/{18_pack_image_align.dts => 018_pack_image_align.dts} (100%)
 rename tools/binman/test/{19_pack_inv_image_align.dts => 019_pack_inv_image_align.dts} (100%)
 rename tools/binman/test/{20_pack_inv_image_align_power2.dts => 020_pack_inv_image_align_power2.dts} (100%)
 rename tools/binman/test/{21_image_pad.dts => 021_image_pad.dts} (100%)
 rename tools/binman/test/{22_image_name.dts => 022_image_name.dts} (100%)
 rename tools/binman/test/{23_blob.dts => 023_blob.dts} (100%)
 rename tools/binman/test/{24_sorted.dts => 024_sorted.dts} (100%)
 rename tools/binman/test/{25_pack_zero_size.dts => 025_pack_zero_size.dts} (100%)
 rename tools/binman/test/{26_pack_u_boot_dtb.dts => 026_pack_u_boot_dtb.dts} (100%)
 rename tools/binman/test/{27_pack_4gb_no_size.dts => 027_pack_4gb_no_size.dts} (100%)
 rename tools/binman/test/{28_pack_4gb_outside.dts => 028_pack_4gb_outside.dts} (100%)
 rename tools/binman/test/{29_x86-rom.dts => 029_x86-rom.dts} (100%)
 rename tools/binman/test/{30_x86-rom-me-no-desc.dts => 030_x86-rom-me-no-desc.dts} (100%)
 rename tools/binman/test/{31_x86-rom-me.dts => 031_x86-rom-me.dts} (100%)
 rename tools/binman/test/{32_intel-vga.dts => 032_intel-vga.dts} (100%)
 rename tools/binman/test/{33_x86-start16.dts => 033_x86-start16.dts} (100%)
 rename tools/binman/test/{34_x86_ucode.dts => 034_x86_ucode.dts} (100%)
 rename tools/binman/test/{35_x86_single_ucode.dts => 035_x86_single_ucode.dts} (100%)
 rename tools/binman/test/{36_u_boot_img.dts => 036_u_boot_img.dts} (100%)
 rename tools/binman/test/{37_x86_no_ucode.dts => 037_x86_no_ucode.dts} (100%)
 rename tools/binman/test/{38_x86_ucode_missing_node.dts => 038_x86_ucode_missing_node.dts} (100%)
 rename tools/binman/test/{39_x86_ucode_missing_node2.dts => 039_x86_ucode_missing_node2.dts} (100%)
 rename tools/binman/test/{40_x86_ucode_not_in_image.dts => 040_x86_ucode_not_in_image.dts} (100%)
 rename tools/binman/test/{41_unknown_pos_size.dts => 041_unknown_pos_size.dts} (100%)
 rename tools/binman/test/{42_intel-fsp.dts => 042_intel-fsp.dts} (100%)
 rename tools/binman/test/{43_intel-cmc.dts => 043_intel-cmc.dts} (100%)
 rename tools/binman/test/{44_x86_optional_ucode.dts => 044_x86_optional_ucode.dts} (100%)
 rename tools/binman/test/{45_prop_test.dts => 045_prop_test.dts} (100%)
 rename tools/binman/test/{46_intel-vbt.dts => 046_intel-vbt.dts} (100%)
 rename tools/binman/test/{47_spl_bss_pad.dts => 047_spl_bss_pad.dts} (100%)
 rename tools/binman/test/{48_x86-start16-spl.dts => 048_x86-start16-spl.dts} (100%)
 rename tools/binman/test/{49_x86_ucode_spl.dts => 049_x86_ucode_spl.dts} (100%)
 rename tools/binman/test/{50_intel_mrc.dts => 050_intel_mrc.dts} (100%)
 rename tools/binman/test/{51_u_boot_spl_dtb.dts => 051_u_boot_spl_dtb.dts} (100%)
 rename tools/binman/test/{52_u_boot_spl_nodtb.dts => 052_u_boot_spl_nodtb.dts} (100%)
 rename tools/binman/test/{53_symbols.dts => 053_symbols.dts} (100%)
 rename tools/binman/test/{54_unit_address.dts => 054_unit_address.dts} (100%)
 rename tools/binman/test/{55_sections.dts => 055_sections.dts} (100%)
 rename tools/binman/test/{56_name_prefix.dts => 056_name_prefix.dts} (100%)
 rename tools/binman/test/{57_unknown_contents.dts => 057_unknown_contents.dts} (100%)
 rename tools/binman/test/{58_x86_ucode_spl_needs_retry.dts => 058_x86_ucode_spl_needs_retry.dts} (100%)
 rename tools/binman/test/{59_change_size.dts => 059_change_size.dts} (100%)
 rename tools/binman/test/{60_fdt_update.dts => 060_fdt_update.dts} (100%)
 rename tools/binman/test/{61_fdt_update_bad.dts => 061_fdt_update_bad.dts} (100%)
 rename tools/binman/test/{62_entry_args.dts => 062_entry_args.dts} (100%)
 rename tools/binman/test/{63_entry_args_missing.dts => 063_entry_args_missing.dts} (100%)
 rename tools/binman/test/{64_entry_args_required.dts => 064_entry_args_required.dts} (100%)
 rename tools/binman/test/{65_entry_args_unknown_datatype.dts => 065_entry_args_unknown_datatype.dts} (100%)
 rename tools/binman/test/{66_text.dts => 066_text.dts} (100%)
 rename tools/binman/test/{67_fmap.dts => 067_fmap.dts} (100%)
 rename tools/binman/test/{68_blob_named_by_arg.dts => 068_blob_named_by_arg.dts} (100%)
 rename tools/binman/test/{69_fill.dts => 069_fill.dts} (100%)
 rename tools/binman/test/{70_fill_no_size.dts => 070_fill_no_size.dts} (100%)
 rename tools/binman/test/{71_gbb.dts => 071_gbb.dts} (100%)
 rename tools/binman/test/{72_gbb_too_small.dts => 072_gbb_too_small.dts} (100%)
 rename tools/binman/test/{73_gbb_no_size.dts => 073_gbb_no_size.dts} (100%)
 rename tools/binman/test/{74_vblock.dts => 074_vblock.dts} (100%)
 rename tools/binman/test/{75_vblock_no_content.dts => 075_vblock_no_content.dts} (100%)
 rename tools/binman/test/{76_vblock_bad_phandle.dts => 076_vblock_bad_phandle.dts} (100%)
 rename tools/binman/test/{77_vblock_bad_entry.dts => 077_vblock_bad_entry.dts} (100%)
 rename tools/binman/test/{78_u_boot_tpl.dts => 078_u_boot_tpl.dts} (100%)
 rename tools/binman/test/{79_uses_pos.dts => 079_uses_pos.dts} (100%)
 rename tools/binman/test/{80_fill_empty.dts => 080_fill_empty.dts} (100%)
 rename tools/binman/test/{81_x86-start16-tpl.dts => 081_x86-start16-tpl.dts} (100%)
 rename tools/binman/test/{82_fdt_update_all.dts => 082_fdt_update_all.dts} (100%)
 rename tools/binman/test/{83_compress.dts => 083_compress.dts} (100%)
 rename tools/binman/test/{84_files.dts => 084_files.dts} (100%)
 rename tools/binman/test/{85_files_compress.dts => 085_files_compress.dts} (100%)
 rename tools/binman/test/{86_files_none.dts => 086_files_none.dts} (100%)
 rename tools/binman/test/{87_files_no_pattern.dts => 087_files_no_pattern.dts} (100%)
 rename tools/binman/test/{88_expand_size.dts => 088_expand_size.dts} (100%)
 rename tools/binman/test/{89_expand_size_bad.dts => 089_expand_size_bad.dts} (100%)
 rename tools/binman/test/{90_hash.dts => 090_hash.dts} (100%)
 rename tools/binman/test/{91_hash_no_algo.dts => 091_hash_no_algo.dts} (100%)
 rename tools/binman/test/{92_hash_bad_algo.dts => 092_hash_bad_algo.dts} (100%)
 rename tools/binman/test/{93_x86_tpl_ucode.dts => 093_x86_tpl_ucode.dts} (100%)
 rename tools/binman/test/{94_fmap_x86.dts => 094_fmap_x86.dts} (100%)
 rename tools/binman/test/{95_fmap_x86_section.dts => 095_fmap_x86_section.dts} (100%)
 rename tools/binman/test/{96_elf.dts => 096_elf.dts} (100%)
 rename tools/binman/test/{97_elf_strip.dts => 097_elf_strip.dts} (100%)
 rename tools/binman/test/{99_hash_section.dts => 099_hash_section.dts} (100%)
 create mode 100644 tools/binman/test/100_intel_refcode.dts

-- 
2.19.0.605.g01d371f741-goog

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 01/45] dm: core: Alloc uclass-private data to be cache-aligned
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
@ 2018-10-01 18:22 ` Simon Glass
  2018-10-01 18:22 ` [U-Boot] [PATCH 02/45] dm: core: Update some functions to use const Simon Glass
                   ` (83 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: Simon Glass @ 2018-10-01 18:22 UTC (permalink / raw)
  To: u-boot

There is no reason why this feature should not be supported for uclass-
private data. Update the code accordingly.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/core/device.c | 3 ++-
 include/dm/uclass.h   | 3 +++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/core/device.c b/drivers/core/device.c
index feed43c8c3e..73c99d1a65a 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -331,7 +331,8 @@ int device_probe(struct udevice *dev)
 	/* Allocate private data if requested and not reentered */
 	size = dev->uclass->uc_drv->per_device_auto_alloc_size;
 	if (size && !dev->uclass_priv) {
-		dev->uclass_priv = calloc(1, size);
+		dev->uclass_priv = alloc_priv(size,
+					      dev->uclass->uc_drv->flags);
 		if (!dev->uclass_priv) {
 			ret = -ENOMEM;
 			goto fail;
diff --git a/include/dm/uclass.h b/include/dm/uclass.h
index 6e7c1cd3e8b..eebf2d5614c 100644
--- a/include/dm/uclass.h
+++ b/include/dm/uclass.h
@@ -44,6 +44,9 @@ struct udevice;
 /* Members of this uclass sequence themselves with aliases */
 #define DM_UC_FLAG_SEQ_ALIAS			(1 << 0)
 
+/* Same as DM_FLAG_ALLOC_PRIV_DMA */
+#define DM_UC_FLAG_ALLOC_PRIV_DMA		(1 << 5)
+
 /**
  * struct uclass_driver - Driver for the uclass
  *
-- 
2.19.0.605.g01d371f741-goog

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 02/45] dm: core: Update some functions to use const
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
  2018-10-01 18:22 ` [U-Boot] [PATCH 01/45] dm: core: Alloc uclass-private data to be cache-aligned Simon Glass
@ 2018-10-01 18:22 ` Simon Glass
  2018-10-01 18:22 ` [U-Boot] [PATCH 03/45] dm: core: Add a function to find the first inactive child Simon Glass
                   ` (82 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: Simon Glass @ 2018-10-01 18:22 UTC (permalink / raw)
  To: u-boot

Quite a few functions do not actually modify the device that is passed in.
Update the function signatures to reflect that.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/core/device.c | 24 ++++++++++++------------
 include/dm/device.h   | 24 ++++++++++++------------
 2 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/drivers/core/device.c b/drivers/core/device.c
index 73c99d1a65a..a9e5906e7cd 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -442,7 +442,7 @@ fail:
 	return ret;
 }
 
-void *dev_get_platdata(struct udevice *dev)
+void *dev_get_platdata(const struct udevice *dev)
 {
 	if (!dev) {
 		dm_warn("%s: null device\n", __func__);
@@ -452,7 +452,7 @@ void *dev_get_platdata(struct udevice *dev)
 	return dev->platdata;
 }
 
-void *dev_get_parent_platdata(struct udevice *dev)
+void *dev_get_parent_platdata(const struct udevice *dev)
 {
 	if (!dev) {
 		dm_warn("%s: null device\n", __func__);
@@ -462,7 +462,7 @@ void *dev_get_parent_platdata(struct udevice *dev)
 	return dev->parent_platdata;
 }
 
-void *dev_get_uclass_platdata(struct udevice *dev)
+void *dev_get_uclass_platdata(const struct udevice *dev)
 {
 	if (!dev) {
 		dm_warn("%s: null device\n", __func__);
@@ -472,7 +472,7 @@ void *dev_get_uclass_platdata(struct udevice *dev)
 	return dev->uclass_platdata;
 }
 
-void *dev_get_priv(struct udevice *dev)
+void *dev_get_priv(const struct udevice *dev)
 {
 	if (!dev) {
 		dm_warn("%s: null device\n", __func__);
@@ -482,7 +482,7 @@ void *dev_get_priv(struct udevice *dev)
 	return dev->priv;
 }
 
-void *dev_get_uclass_priv(struct udevice *dev)
+void *dev_get_uclass_priv(const struct udevice *dev)
 {
 	if (!dev) {
 		dm_warn("%s: null device\n", __func__);
@@ -492,7 +492,7 @@ void *dev_get_uclass_priv(struct udevice *dev)
 	return dev->uclass_priv;
 }
 
-void *dev_get_parent_priv(struct udevice *dev)
+void *dev_get_parent_priv(const struct udevice *dev)
 {
 	if (!dev) {
 		dm_warn("%s: null device\n", __func__);
@@ -681,17 +681,17 @@ int device_find_next_child(struct udevice **devp)
 	return 0;
 }
 
-struct udevice *dev_get_parent(struct udevice *child)
+struct udevice *dev_get_parent(const struct udevice *child)
 {
 	return child->parent;
 }
 
-ulong dev_get_driver_data(struct udevice *dev)
+ulong dev_get_driver_data(const struct udevice *dev)
 {
 	return dev->driver_data;
 }
 
-const void *dev_get_driver_ops(struct udevice *dev)
+const void *dev_get_driver_ops(const struct udevice *dev)
 {
 	if (!dev || !dev->driver->ops)
 		return NULL;
@@ -699,12 +699,12 @@ const void *dev_get_driver_ops(struct udevice *dev)
 	return dev->driver->ops;
 }
 
-enum uclass_id device_get_uclass_id(struct udevice *dev)
+enum uclass_id device_get_uclass_id(const struct udevice *dev)
 {
 	return dev->uclass->uc_drv->id;
 }
 
-const char *dev_get_uclass_name(struct udevice *dev)
+const char *dev_get_uclass_name(const struct udevice *dev)
 {
 	if (!dev)
 		return NULL;
@@ -712,7 +712,7 @@ const char *dev_get_uclass_name(struct udevice *dev)
 	return dev->uclass->uc_drv->name;
 }
 
-bool device_has_children(struct udevice *dev)
+bool device_has_children(const struct udevice *dev)
 {
 	return !list_empty(&dev->child_head);
 }
diff --git a/include/dm/device.h b/include/dm/device.h
index 9812d86f08b..f873fc66e12 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -270,7 +270,7 @@ struct driver {
  * @dev		Device to check
  * @return platform data, or NULL if none
  */
-void *dev_get_platdata(struct udevice *dev);
+void *dev_get_platdata(const struct udevice *dev);
 
 /**
  * dev_get_parent_platdata() - Get the parent platform data for a device
@@ -280,7 +280,7 @@ void *dev_get_platdata(struct udevice *dev);
  * @dev		Device to check
  * @return parent's platform data, or NULL if none
  */
-void *dev_get_parent_platdata(struct udevice *dev);
+void *dev_get_parent_platdata(const struct udevice *dev);
 
 /**
  * dev_get_uclass_platdata() - Get the uclass platform data for a device
@@ -290,7 +290,7 @@ void *dev_get_parent_platdata(struct udevice *dev);
  * @dev		Device to check
  * @return uclass's platform data, or NULL if none
  */
-void *dev_get_uclass_platdata(struct udevice *dev);
+void *dev_get_uclass_platdata(const struct udevice *dev);
 
 /**
  * dev_get_priv() - Get the private data for a device
@@ -300,7 +300,7 @@ void *dev_get_uclass_platdata(struct udevice *dev);
  * @dev		Device to check
  * @return private data, or NULL if none
  */
-void *dev_get_priv(struct udevice *dev);
+void *dev_get_priv(const struct udevice *dev);
 
 /**
  * dev_get_parent_priv() - Get the parent private data for a device
@@ -314,7 +314,7 @@ void *dev_get_priv(struct udevice *dev);
  * @dev		Device to check
  * @return parent data, or NULL if none
  */
-void *dev_get_parent_priv(struct udevice *dev);
+void *dev_get_parent_priv(const struct udevice *dev);
 
 /**
  * dev_get_uclass_priv() - Get the private uclass data for a device
@@ -324,7 +324,7 @@ void *dev_get_parent_priv(struct udevice *dev);
  * @dev		Device to check
  * @return private uclass data for this device, or NULL if none
  */
-void *dev_get_uclass_priv(struct udevice *dev);
+void *dev_get_uclass_priv(const struct udevice *dev);
 
 /**
  * struct dev_get_parent() - Get the parent of a device
@@ -332,7 +332,7 @@ void *dev_get_uclass_priv(struct udevice *dev);
  * @child:	Child to check
  * @return parent of child, or NULL if this is the root device
  */
-struct udevice *dev_get_parent(struct udevice *child);
+struct udevice *dev_get_parent(const struct udevice *child);
 
 /**
  * dev_get_driver_data() - get the driver data used to bind a device
@@ -359,7 +359,7 @@ struct udevice *dev_get_parent(struct udevice *child);
  * @dev:	Device to check
  * @return driver data (0 if none is provided)
  */
-ulong dev_get_driver_data(struct udevice *dev);
+ulong dev_get_driver_data(const struct udevice *dev);
 
 /**
  * dev_get_driver_ops() - get the device's driver's operations
@@ -370,7 +370,7 @@ ulong dev_get_driver_data(struct udevice *dev);
  * @dev:	Device to check
  * @return void pointer to driver's operations or NULL for NULL-dev or NULL-ops
  */
-const void *dev_get_driver_ops(struct udevice *dev);
+const void *dev_get_driver_ops(const struct udevice *dev);
 
 /**
  * device_get_uclass_id() - return the uclass ID of a device
@@ -378,7 +378,7 @@ const void *dev_get_driver_ops(struct udevice *dev);
  * @dev:	Device to check
  * @return uclass ID for the device
  */
-enum uclass_id device_get_uclass_id(struct udevice *dev);
+enum uclass_id device_get_uclass_id(const struct udevice *dev);
 
 /**
  * dev_get_uclass_name() - return the uclass name of a device
@@ -388,7 +388,7 @@ enum uclass_id device_get_uclass_id(struct udevice *dev);
  * @dev:	Device to check
  * @return  pointer to the uclass name for the device
  */
-const char *dev_get_uclass_name(struct udevice *dev);
+const char *dev_get_uclass_name(const struct udevice *dev);
 
 /**
  * device_get_child() - Get the child of a device by index
@@ -525,7 +525,7 @@ int device_find_next_child(struct udevice **devp);
  * @dev:	Device to check
  * @return true if the device has one or more children
  */
-bool device_has_children(struct udevice *dev);
+bool device_has_children(const struct udevice *dev);
 
 /**
  * device_has_active_children() - check if a device has any active children
-- 
2.19.0.605.g01d371f741-goog

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 03/45] dm: core: Add a function to find the first inactive child
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
  2018-10-01 18:22 ` [U-Boot] [PATCH 01/45] dm: core: Alloc uclass-private data to be cache-aligned Simon Glass
  2018-10-01 18:22 ` [U-Boot] [PATCH 02/45] dm: core: Update some functions to use const Simon Glass
@ 2018-10-01 18:22 ` Simon Glass
  2018-10-01 18:22 ` [U-Boot] [PATCH 04/45] dm: core: Update ofnode to read binman-style flash entry Simon Glass
                   ` (81 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: Simon Glass @ 2018-10-01 18:22 UTC (permalink / raw)
  To: u-boot

Some devices have children and want to press an existing inactive child
into service when needed. Add a function to help with this.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/core/device.c | 18 ++++++++++++++++++
 include/dm/device.h   | 15 +++++++++++++++
 test/dm/core.c        | 31 +++++++++++++++++++++++++++++++
 3 files changed, 64 insertions(+)

diff --git a/drivers/core/device.c b/drivers/core/device.c
index a9e5906e7cd..5176aa3f866 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -681,6 +681,24 @@ int device_find_next_child(struct udevice **devp)
 	return 0;
 }
 
+int device_find_first_inactive_child(struct udevice *parent,
+				     enum uclass_id uclass_id,
+				     struct udevice **devp)
+{
+	struct udevice *dev;
+
+	*devp = NULL;
+	list_for_each_entry(dev, &parent->child_head, sibling_node) {
+		if (!device_active(dev) &&
+		    device_get_uclass_id(dev) == uclass_id) {
+			*devp = dev;
+			return 0;
+		}
+	}
+
+	return -ENODEV;
+}
+
 struct udevice *dev_get_parent(const struct udevice *child)
 {
 	return child->parent;
diff --git a/include/dm/device.h b/include/dm/device.h
index f873fc66e12..847934425bb 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -519,6 +519,21 @@ int device_find_first_child(struct udevice *parent, struct udevice **devp);
  */
 int device_find_next_child(struct udevice **devp);
 
+/**
+ * device_find_first_inactive_child() - Find the first inactive child
+ *
+ * This is used to locate an existing child of a device which is of a given
+ * uclass.
+ *
+ * @parent:	Parent device to search
+ * @uclass_id:	Uclass to look for
+ * @devp:	Returns device found, if any
+ * @return 0 if found, else -ENODEV
+ */
+int device_find_first_inactive_child(struct udevice *parent,
+				     enum uclass_id uclass_id,
+				     struct udevice **devp);
+
 /**
  * device_has_children() - check if a device has any children
  *
diff --git a/test/dm/core.c b/test/dm/core.c
index c15a8406c09..260f6494a2e 100644
--- a/test/dm/core.c
+++ b/test/dm/core.c
@@ -870,3 +870,34 @@ static int dm_test_uclass_names(struct unit_test_state *uts)
 	return 0;
 }
 DM_TEST(dm_test_uclass_names, DM_TESTF_SCAN_PDATA);
+
+static int dm_test_inactive_child(struct unit_test_state *uts)
+{
+	struct dm_test_state *dms = uts->priv;
+	struct udevice *parent, *dev1, *dev2;
+
+	/* Skip the behaviour in test_post_probe() */
+	dms->skip_post_probe = 1;
+
+	ut_assertok(uclass_first_device_err(UCLASS_TEST, &parent));
+
+	/*
+	 * Create a child but do not activate it. Calling the function again
+	 * should return the same child.
+	 */
+	ut_asserteq(-ENODEV, device_find_first_inactive_child(parent,
+							UCLASS_TEST, &dev1));
+	ut_assertok(device_bind_ofnode(parent, DM_GET_DRIVER(test_drv),
+				       "test_child", 0, ofnode_null(), &dev1));
+
+	ut_assertok(device_find_first_inactive_child(parent, UCLASS_TEST,
+						     &dev2));
+	ut_asserteq_ptr(dev1, dev2);
+
+	ut_assertok(device_probe(dev1));
+	ut_asserteq(-ENODEV, device_find_first_inactive_child(parent,
+							UCLASS_TEST, &dev2));
+
+	return 0;
+}
+DM_TEST(dm_test_inactive_child, DM_TESTF_SCAN_PDATA);
-- 
2.19.0.605.g01d371f741-goog

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 04/45] dm: core: Update ofnode to read binman-style flash entry
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (2 preceding siblings ...)
  2018-10-01 18:22 ` [U-Boot] [PATCH 03/45] dm: core: Add a function to find the first inactive child Simon Glass
@ 2018-10-01 18:22 ` Simon Glass
  2018-10-01 18:22 ` [U-Boot] [PATCH 05/45] sf: Avoid allocating memory on every read operation Simon Glass
                   ` (80 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: Simon Glass @ 2018-10-01 18:22 UTC (permalink / raw)
  To: u-boot

At present ofnode_read_fmap_entry() reads a flash map entry in a format
which is not supported by binman. To allow use to use binman-format
descriptions, update this function.

Also add a simple test.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 arch/sandbox/dts/sandbox.dts   | 20 ++++++++++----------
 arch/sandbox/dts/sandbox64.dts | 20 ++++++++++----------
 drivers/core/of_extra.c        | 27 +++++++++++++++++++--------
 drivers/misc/cros_ec.c         | 33 +++++++++++++++++----------------
 include/dm/of_extra.h          |  3 ++-
 test/dm/ofnode.c               | 16 ++++++++++++++++
 6 files changed, 74 insertions(+), 45 deletions(-)

diff --git a/arch/sandbox/dts/sandbox.dts b/arch/sandbox/dts/sandbox.dts
index 1aa0f8eef53..1b00fbebd78 100644
--- a/arch/sandbox/dts/sandbox.dts
+++ b/arch/sandbox/dts/sandbox.dts
@@ -18,7 +18,7 @@
 		stdout-path = "/serial";
 	};
 
-	cros_ec: cros-ec at 0 {
+	cros_ec: cros-ec {
 		reg = <0 0>;
 		compatible = "google,cros-ec-sandbox";
 
@@ -26,23 +26,23 @@
 		 * This describes the flash memory within the EC. Note
 		 * that the STM32L flash erases to 0, not 0xff.
 		 */
-		#address-cells = <1>;
-		#size-cells = <1>;
-		flash at 8000000 {
-			reg = <0x08000000 0x20000>;
+		flash {
+			image-pos = <0x08000000>;
+			size = <0x20000>;
 			erase-value = <0>;
-			#address-cells = <1>;
-			#size-cells = <1>;
 
 			/* Information for sandbox */
 			ro {
-				reg = <0 0xf000>;
+				image-pos = <0>;
+				size = <0xf000>;
 			};
 			wp-ro {
-				reg = <0xf000 0x1000>;
+				image-pos = <0xf000>;
+				size = <0x1000>;
 			};
 			rw {
-				reg = <0x10000 0x10000>;
+				image-pos = <0x10000>;
+				size = <0x10000>;
 			};
 		};
 	};
diff --git a/arch/sandbox/dts/sandbox64.dts b/arch/sandbox/dts/sandbox64.dts
index 9e65d2fda3d..6ecaaad13d8 100644
--- a/arch/sandbox/dts/sandbox64.dts
+++ b/arch/sandbox/dts/sandbox64.dts
@@ -17,7 +17,7 @@
 		stdout-path = "/serial";
 	};
 
-	cros_ec: cros-ec at 0 {
+	cros_ec: cros-ec {
 		reg = <0 0 0 0>;
 		compatible = "google,cros-ec-sandbox";
 
@@ -25,23 +25,23 @@
 		 * This describes the flash memory within the EC. Note
 		 * that the STM32L flash erases to 0, not 0xff.
 		 */
-		#address-cells = <1>;
-		#size-cells = <1>;
-		flash at 8000000 {
-			reg = <0x08000000 0x20000>;
+		flash {
+			image-pos = <0x08000000>;
+			size = <0x20000>;
 			erase-value = <0>;
-			#address-cells = <1>;
-			#size-cells = <1>;
 
 			/* Information for sandbox */
 			ro {
-				reg = <0 0xf000>;
+				image-pos = <0>;
+				size = <0xf000>;
 			};
 			wp-ro {
-				reg = <0xf000 0x1000>;
+				image-pos = <0xf000>;
+				size = <0x1000>;
 			};
 			rw {
-				reg = <0x10000 0x10000>;
+				image-pos = <0x10000>;
+				size = <0x10000>;
 			};
 		};
 	};
diff --git a/drivers/core/of_extra.c b/drivers/core/of_extra.c
index aa48917dddf..f1f393c3598 100644
--- a/drivers/core/of_extra.c
+++ b/drivers/core/of_extra.c
@@ -13,19 +13,30 @@
 int ofnode_read_fmap_entry(ofnode node, struct fmap_entry *entry)
 {
 	const char *prop;
-	u32 reg[2];
 
-	if (ofnode_read_u32_array(node, "reg", reg, 2)) {
-		debug("Node '%s' has bad/missing 'reg' property\n",
+	if (ofnode_read_u32(node, "image-pos", &entry->offset)) {
+		debug("Node '%s' has bad/missing 'image-pos' property\n",
 		      ofnode_get_name(node));
-		return -log_ret(ENOENT);
+		return log_ret(-ENOENT);
+	}
+	if (ofnode_read_u32(node, "size", &entry->length)) {
+		debug("Node '%s' has bad/missing 'size' property\n",
+		      ofnode_get_name(node));
+		return log_ret(-ENOENT);
 	}
-	entry->offset = reg[0];
-	entry->length = reg[1];
 	entry->used = ofnode_read_s32_default(node, "used", entry->length);
 	prop = ofnode_read_string(node, "compress");
-	entry->compress_algo = prop && !strcmp(prop, "lzo") ?
-		FMAP_COMPRESS_LZO : FMAP_COMPRESS_NONE;
+	if (prop) {
+		if (!strcmp(prop, "lz4"))
+			entry->compress_algo = FMAP_COMPRESS_LZ4;
+		else
+			return log_msg_ret("Unknown compression algo",
+					   -EINVAL);
+	} else {
+		entry->compress_algo = FMAP_COMPRESS_NONE;
+	}
+	entry->unc_length = ofnode_read_s32_default(node, "uncomp-size",
+						    entry->length);
 	prop = ofnode_read_string(node, "hash");
 	if (prop)
 		entry->hash_size = strlen(prop);
diff --git a/drivers/misc/cros_ec.c b/drivers/misc/cros_ec.c
index 6f299d407a4..c5ac03d027d 100644
--- a/drivers/misc/cros_ec.c
+++ b/drivers/misc/cros_ec.c
@@ -263,8 +263,8 @@ static int send_command(struct cros_ec_dev *dev, uint8_t cmd, int cmd_version,
  * @return number of bytes in response, or -ve on error
  */
 static int ec_command_inptr(struct cros_ec_dev *dev, uint8_t cmd,
-		int cmd_version, const void *dout, int dout_len, uint8_t **dinp,
-		int din_len)
+			    int cmd_version, const void *dout, int dout_len,
+			    uint8_t **dinp, int din_len)
 {
 	uint8_t *din = NULL;
 	int len;
@@ -409,7 +409,7 @@ int cros_ec_read_build_info(struct cros_ec_dev *dev, char **strp)
 }
 
 int cros_ec_read_current_image(struct cros_ec_dev *dev,
-		enum ec_current_image *image)
+			       enum ec_current_image *image)
 {
 	struct ec_response_get_version *r;
 
@@ -422,7 +422,7 @@ int cros_ec_read_current_image(struct cros_ec_dev *dev,
 }
 
 static int cros_ec_wait_on_hash_done(struct cros_ec_dev *dev,
-				  struct ec_response_vboot_hash *hash)
+				     struct ec_response_vboot_hash *hash)
 {
 	struct ec_params_vboot_hash p;
 	ulong start;
@@ -446,7 +446,7 @@ static int cros_ec_wait_on_hash_done(struct cros_ec_dev *dev,
 
 
 int cros_ec_read_hash(struct cros_ec_dev *dev,
-		struct ec_response_vboot_hash *hash)
+		      struct ec_response_vboot_hash *hash)
 {
 	struct ec_params_vboot_hash p;
 	int rv;
@@ -515,7 +515,7 @@ static int cros_ec_invalidate_hash(struct cros_ec_dev *dev)
 }
 
 int cros_ec_reboot(struct cros_ec_dev *dev, enum ec_reboot_cmd cmd,
-		uint8_t flags)
+		   uint8_t flags)
 {
 	struct ec_params_reboot_ec p;
 
@@ -601,8 +601,8 @@ int cros_ec_clear_host_events(struct cros_ec_dev *dev, uint32_t events)
 }
 
 int cros_ec_flash_protect(struct cros_ec_dev *dev,
-		       uint32_t set_mask, uint32_t set_flags,
-		       struct ec_response_flash_protect *resp)
+			  uint32_t set_mask, uint32_t set_flags,
+			  struct ec_response_flash_protect *resp)
 {
 	struct ec_params_flash_protect params;
 
@@ -742,7 +742,8 @@ int cros_ec_flash_erase(struct cros_ec_dev *dev, uint32_t offset, uint32_t size)
  * @return 0 if ok, -1 on error
  */
 static int cros_ec_flash_write_block(struct cros_ec_dev *dev,
-		const uint8_t *data, uint32_t offset, uint32_t size)
+				     const uint8_t *data, uint32_t offset,
+				     uint32_t size)
 {
 	struct ec_params_flash_write *p;
 	int ret;
@@ -802,7 +803,7 @@ static int cros_ec_data_is_erased(const uint32_t *data, int size)
  * @param info Pointer to output flash info struct
  */
 int cros_ec_read_flashinfo(struct cros_ec_dev *dev,
-			  struct ec_response_flash_info *info)
+			   struct ec_response_flash_info *info)
 {
 	int ret;
 
@@ -815,7 +816,7 @@ int cros_ec_read_flashinfo(struct cros_ec_dev *dev,
 }
 
 int cros_ec_flash_write(struct cros_ec_dev *dev, const uint8_t *data,
-		     uint32_t offset, uint32_t size)
+			uint32_t offset, uint32_t size)
 {
 	uint32_t burst = cros_ec_flash_write_burst_size(dev);
 	uint32_t end, off;
@@ -832,7 +833,7 @@ int cros_ec_flash_write(struct cros_ec_dev *dev, const uint8_t *data,
 		/* If the data is empty, there is no point in programming it */
 		todo = min(end - off, burst);
 		if (dev->optimise_flash_write &&
-				cros_ec_data_is_erased((uint32_t *)data, todo))
+		    cros_ec_data_is_erased((uint32_t *)data, todo))
 			continue;
 
 		ret = cros_ec_flash_write_block(dev, data, off, todo);
@@ -859,7 +860,7 @@ int cros_ec_flash_write(struct cros_ec_dev *dev, const uint8_t *data,
  * @return 0 if ok, -1 on error
  */
 static int cros_ec_flash_read_block(struct cros_ec_dev *dev, uint8_t *data,
-				 uint32_t offset, uint32_t size)
+				    uint32_t offset, uint32_t size)
 {
 	struct ec_params_flash_read p;
 
@@ -871,7 +872,7 @@ static int cros_ec_flash_read_block(struct cros_ec_dev *dev, uint8_t *data,
 }
 
 int cros_ec_flash_read(struct cros_ec_dev *dev, uint8_t *data, uint32_t offset,
-		    uint32_t size)
+		       uint32_t size)
 {
 	uint32_t burst = cros_ec_flash_write_burst_size(dev);
 	uint32_t end, off;
@@ -888,8 +889,8 @@ int cros_ec_flash_read(struct cros_ec_dev *dev, uint8_t *data, uint32_t offset,
 	return 0;
 }
 
-int cros_ec_flash_update_rw(struct cros_ec_dev *dev,
-			 const uint8_t *image, int image_size)
+int cros_ec_flash_update_rw(struct cros_ec_dev *dev, const uint8_t *image,
+			    int image_size)
 {
 	uint32_t rw_offset, rw_size;
 	int ret;
diff --git a/include/dm/of_extra.h b/include/dm/of_extra.h
index 97988b66632..ca15df21b06 100644
--- a/include/dm/of_extra.h
+++ b/include/dm/of_extra.h
@@ -11,7 +11,7 @@
 
 enum fmap_compress_t {
 	FMAP_COMPRESS_NONE,
-	FMAP_COMPRESS_LZO,
+	FMAP_COMPRESS_LZ4,
 };
 
 enum fmap_hash_t {
@@ -26,6 +26,7 @@ struct fmap_entry {
 	uint32_t length;
 	uint32_t used;			/* Number of bytes used in region */
 	enum fmap_compress_t compress_algo;	/* Compression type */
+	uint32_t unc_length;			/* Uncompressed length */
 	enum fmap_hash_t hash_algo;		/* Hash algorithm */
 	const uint8_t *hash;			/* Hash value */
 	int hash_size;				/* Hash size */
diff --git a/test/dm/ofnode.c b/test/dm/ofnode.c
index 907d1ddbdb6..745de50c7ba 100644
--- a/test/dm/ofnode.c
+++ b/test/dm/ofnode.c
@@ -2,6 +2,7 @@
 
 #include <common.h>
 #include <dm.h>
+#include <dm/of_extra.h>
 #include <dm/test.h>
 #include <test/ut.h>
 
@@ -42,3 +43,18 @@ static int dm_test_ofnode_by_prop_value(struct unit_test_state *uts)
 	return 0;
 }
 DM_TEST(dm_test_ofnode_by_prop_value, DM_TESTF_SCAN_FDT);
+
+static int dm_test_ofnode_fmap(struct unit_test_state *uts)
+{
+	struct fmap_entry entry;
+	ofnode node;
+
+	node = ofnode_path("/cros-ec/flash");
+	ut_assert(ofnode_valid(node));
+	ut_assertok(ofnode_read_fmap_entry(node, &entry));
+	ut_asserteq(0x08000000, entry.offset);
+	ut_asserteq(0x20000, entry.length);
+
+	return 0;
+}
+DM_TEST(dm_test_ofnode_fmap, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
-- 
2.19.0.605.g01d371f741-goog

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 05/45] sf: Avoid allocating memory on every read operation
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (3 preceding siblings ...)
  2018-10-01 18:22 ` [U-Boot] [PATCH 04/45] dm: core: Update ofnode to read binman-style flash entry Simon Glass
@ 2018-10-01 18:22 ` Simon Glass
  2018-10-01 18:22 ` [U-Boot] [PATCH 06/45] spl: input: Allow input in SPL and TPL Simon Glass
                   ` (79 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: Simon Glass @ 2018-10-01 18:22 UTC (permalink / raw)
  To: u-boot

At present spi_flash_cmd_read_ops() allocates and frees a few bytes of
memory every time it is called. It is faster to use the stack for this
and this is now supported by the minimum GCC version required by U-Boot.

Remove the allocation and use a variable-sized array instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/mtd/spi/spi_flash.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c
index c1591242591..7113c855fe4 100644
--- a/drivers/mtd/spi/spi_flash.c
+++ b/drivers/mtd/spi/spi_flash.c
@@ -468,7 +468,7 @@ int spi_flash_cmd_read_ops(struct spi_flash *flash, u32 offset,
 		size_t len, void *data)
 {
 	struct spi_slave *spi = flash->spi;
-	u8 *cmd, cmdsz;
+	u8 cmdsz;
 	u32 remain_len, read_len, read_addr;
 	int bank_sel = 0;
 	int ret = -1;
@@ -488,11 +488,7 @@ int spi_flash_cmd_read_ops(struct spi_flash *flash, u32 offset,
 	}
 
 	cmdsz = SPI_FLASH_CMD_LEN + flash->dummy_byte;
-	cmd = calloc(1, cmdsz);
-	if (!cmd) {
-		debug("SF: Failed to allocate cmd\n");
-		return -ENOMEM;
-	}
+	u8 cmd[cmdsz];
 
 	cmd[0] = flash->read_cmd;
 	while (len) {
@@ -535,7 +531,6 @@ int spi_flash_cmd_read_ops(struct spi_flash *flash, u32 offset,
 	ret = clean_bar(flash);
 #endif
 
-	free(cmd);
 	return ret;
 }
 
-- 
2.19.0.605.g01d371f741-goog

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 06/45] spl: input: Allow input in SPL and TPL
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (4 preceding siblings ...)
  2018-10-01 18:22 ` [U-Boot] [PATCH 05/45] sf: Avoid allocating memory on every read operation Simon Glass
@ 2018-10-01 18:22 ` Simon Glass
  2018-10-01 18:22 ` [U-Boot] [PATCH 07/45] Makefile: Add a warning if SPL/TPL cannot be built Simon Glass
                   ` (78 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: Simon Glass @ 2018-10-01 18:22 UTC (permalink / raw)
  To: u-boot

In some cases it is necessary to read the keyboard in early phases of
U-Boot. Update the config to allow this.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/input/Kconfig  | 48 ++++++++++++++++++++++++++++++++++++++++++
 drivers/input/Makefile | 11 ++++++----
 drivers/input/input.c  |  5 ++++-
 3 files changed, 59 insertions(+), 5 deletions(-)

diff --git a/drivers/input/Kconfig b/drivers/input/Kconfig
index 7ffb949f12d..7afdafed948 100644
--- a/drivers/input/Kconfig
+++ b/drivers/input/Kconfig
@@ -1,3 +1,16 @@
+config INPUT
+	bool "Enable input subsystem"
+	depends on DM
+	default y
+
+config SPL_INPUT
+	bool "Enable input subsystem for SPL"
+	depends on SPL_DM
+
+config TPL_INPUT
+	bool "Enable input subsystem for TPL"
+	depends on TPL_DM
+
 config DM_KEYBOARD
 	bool "Enable driver model keyboard support"
 	depends on DM
@@ -7,8 +20,43 @@ config DM_KEYBOARD
 	  includes methods to start/stop the device, check for available
 	  input and update LEDs if the keyboard has them.
 
+config SPL_DM_KEYBOARD
+	bool "Enable driver model keyboard support"
+	depends on SPL_DM
+	help
+	  This adds a uclass for keyboards and implements keyboard support
+	  using driver model. The API is implemented by keyboard.h and
+	  includes methods to start/stop the device, check for available
+	  input and update LEDs if the keyboard has them.
+
+config TPL_DM_KEYBOARD
+	bool "Enable driver model keyboard support"
+	depends on TPL_DM
+	help
+	  This adds a uclass for keyboards and implements keyboard support
+	  using driver model. The API is implemented by keyboard.h and
+	  includes methods to start/stop the device, check for available
+	  input and update LEDs if the keyboard has them.
+
 config CROS_EC_KEYB
 	bool "Enable Chrome OS EC keyboard support"
+	depends on INPUT
+	help
+	  Most ARM Chromebooks use an EC to provide access to the keyboard.
+	  Messages are used to request key scans from the EC and these are
+	  then decoded into keys by this driver.
+
+config SPL_CROS_EC_KEYB
+	bool "Enable Chrome OS EC keyboard support in SPL"
+	depends on SPL_INPUT
+	help
+	  Most ARM Chromebooks use an EC to provide access to the keyboard.
+	  Messages are used to request key scans from the EC and these are
+	  then decoded into keys by this driver.
+
+config TPL_CROS_EC_KEYB
+	bool "Enable Chrome OS EC keyboard support in TPL"
+	depends on TPL_INPUT
 	help
 	  Most ARM Chromebooks use an EC to provide access to the keyboard.
 	  Messages are used to request key scans from the EC and these are
diff --git a/drivers/input/Makefile b/drivers/input/Makefile
index d13baf3576a..fd56d7b3492 100644
--- a/drivers/input/Makefile
+++ b/drivers/input/Makefile
@@ -3,12 +3,15 @@
 # (C) Copyright 2000-2007
 # Wolfgang Denk, DENX Software Engineering, wd at denx.de.
 
-obj-$(CONFIG_DM_KEYBOARD) += keyboard-uclass.o
+obj-y += input.o
+obj-$(CONFIG_$(SPL_TPL_)CROS_EC_KEYB) += cros_ec_keyb.o
+obj-$(CONFIG_$(SPL_TPL_)OF_CONTROL) += key_matrix.o
+obj-$(CONFIG_$(SPL_TPL_)DM_KEYBOARD) += keyboard-uclass.o
+
+ifndef CONFIG_SPL_BUILD
 
 obj-$(CONFIG_I8042_KEYB) += i8042.o
 obj-$(CONFIG_TEGRA_KEYBOARD) += tegra-kbc.o
 obj-$(CONFIG_TWL4030_INPUT) += twl4030.o
 obj-$(CONFIG_TWL6030_INPUT) += twl6030.o
-obj-$(CONFIG_CROS_EC_KEYB) += cros_ec_keyb.o
-obj-y += input.o
-obj-$(CONFIG_$(SPL_)OF_CONTROL) += key_matrix.o
+endif
diff --git a/drivers/input/input.c b/drivers/input/input.c
index 29620a9e279..4f514dba56d 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -652,7 +652,7 @@ int input_stdio_register(struct stdio_dev *dev)
 	int error;
 
 	error = stdio_register(dev);
-
+#if !defined(CONFIG_SPL_BUILD) || CONFIG_IS_ENABLED(ENV_SUPPORT)
 	/* check if this is the standard input device */
 	if (!error && strcmp(env_get("stdin"), dev->name) == 0) {
 		/* reassign the console */
@@ -660,6 +660,9 @@ int input_stdio_register(struct stdio_dev *dev)
 				console_assign(stdin, dev->name))
 			return -1;
 	}
+#else
+	error = error;
+#endif
 
 	return 0;
 }
-- 
2.19.0.605.g01d371f741-goog

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 07/45] Makefile: Add a warning if SPL/TPL cannot be built
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (5 preceding siblings ...)
  2018-10-01 18:22 ` [U-Boot] [PATCH 06/45] spl: input: Allow input in SPL and TPL Simon Glass
@ 2018-10-01 18:22 ` Simon Glass
  2018-10-01 18:22 ` [U-Boot] [PATCH 08/45] spl: misc: Allow misc drivers in SPL and TPL Simon Glass
                   ` (77 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: Simon Glass @ 2018-10-01 18:22 UTC (permalink / raw)
  To: u-boot

At present the build fails in strange ways if CONFIG_SPL is defined by
CONFIG_SUPPORT_SPL is not. Add a warning for this case as it can be very
confusing to debug.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 scripts/Makefile.spl | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/scripts/Makefile.spl b/scripts/Makefile.spl
index e494d185e4b..c71497ff008 100644
--- a/scripts/Makefile.spl
+++ b/scripts/Makefile.spl
@@ -45,6 +45,13 @@ SPL_ :=
 SPL_TPL_ :=
 endif
 
+ifeq ($(obj)$(CONFIG_SUPPORT_SPL),spl)
+$(error You cannot build SPL without enabling CONFIG_SUPPORT_SPL)
+endif
+ifeq ($(obj)$(CONFIG_SUPPORT_TPL),tpl)
+$(error You cannot build TPL without enabling CONFIG_SUPPORT_TPL)
+endif
+
 include $(srctree)/config.mk
 include $(srctree)/arch/$(ARCH)/Makefile
 
-- 
2.19.0.605.g01d371f741-goog

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 08/45] spl: misc: Allow misc drivers in SPL and TPL
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (6 preceding siblings ...)
  2018-10-01 18:22 ` [U-Boot] [PATCH 07/45] Makefile: Add a warning if SPL/TPL cannot be built Simon Glass
@ 2018-10-01 18:22 ` Simon Glass
  2018-10-01 18:22 ` [U-Boot] [PATCH 09/45] blk: Support block drivers in TPL Simon Glass
                   ` (76 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: Simon Glass @ 2018-10-01 18:22 UTC (permalink / raw)
  To: u-boot

In some cases it is necessary to read the keyboard in early phases of
U-Boot. The cros_ec keyboard is kept in the misc directory. Update the
config to allow this.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/misc/Kconfig  | 72 +++++++++++++++++++++++++++++++++++++++++++
 drivers/misc/Makefile |  9 +++---
 2 files changed, 77 insertions(+), 4 deletions(-)

diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index b0fb73f6926..08ac16e0389 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -13,6 +13,24 @@ config MISC
 	  set of generic read, write and ioctl methods may be used to
 	  access the device.
 
+config SPL_MISC
+	bool "Enable Driver Model for Misc drivers in SPL"
+	depends on SPL_DM
+	help
+	  Enable driver model for miscellaneous devices. This class is
+	  used only for those do not fit other more general classes. A
+	  set of generic read, write and ioctl methods may be used to
+	  access the device.
+
+config TPL_MISC
+	bool "Enable Driver Model for Misc drivers in TPL"
+	depends on TPL_DM
+	help
+	  Enable driver model for miscellaneous devices. This class is
+	  used only for those do not fit other more general classes. A
+	  set of generic read, write and ioctl methods may be used to
+	  access the device.
+
 config ALTERA_SYSID
 	bool "Altera Sysid support"
 	depends on MISC
@@ -60,6 +78,24 @@ config CROS_EC
 	  control access to the battery and main PMIC depending on the
 	  device. You can use the 'crosec' command to access it.
 
+config SPL_CROS_EC
+	bool "Enable Chrome OS EC in SPL"
+	help
+	  Enable access to the Chrome OS EC in SPL. This is a separate
+	  microcontroller typically available on a SPI bus on Chromebooks. It
+	  provides access to the keyboard, some internal storage and may
+	  control access to the battery and main PMIC depending on the
+	  device. You can use the 'crosec' command to access it.
+
+config TPL_CROS_EC
+	bool "Enable Chrome OS EC in TPL"
+	help
+	  Enable access to the Chrome OS EC in TPL. This is a separate
+	  microcontroller typically available on a SPI bus on Chromebooks. It
+	  provides access to the keyboard, some internal storage and may
+	  control access to the battery and main PMIC depending on the
+	  device. You can use the 'crosec' command to access it.
+
 config CROS_EC_I2C
 	bool "Enable Chrome OS EC I2C driver"
 	depends on CROS_EC
@@ -78,6 +114,24 @@ config CROS_EC_LPC
 	  through a legacy port interface, so on x86 machines the main
 	  function of the EC is power and thermal management.
 
+config SPL_CROS_EC_LPC
+	bool "Enable Chrome OS EC LPC driver in SPL"
+	depends on CROS_EC
+	help
+	  Enable I2C access to the Chrome OS EC. This is used on x86
+	  Chromebooks such as link and falco. The keyboard is provided
+	  through a legacy port interface, so on x86 machines the main
+	  function of the EC is power and thermal management.
+
+config TPL_CROS_EC_LPC
+	bool "Enable Chrome OS EC LPC driver in TPL"
+	depends on CROS_EC
+	help
+	  Enable I2C access to the Chrome OS EC. This is used on x86
+	  Chromebooks such as link and falco. The keyboard is provided
+	  through a legacy port interface, so on x86 machines the main
+	  function of the EC is power and thermal management.
+
 config CROS_EC_SANDBOX
 	bool "Enable Chrome OS EC sandbox driver"
 	depends on CROS_EC && SANDBOX
@@ -87,6 +141,24 @@ config CROS_EC_SANDBOX
 	  EC flash read/write/erase support and a few other things. It is
 	  enough to perform a Chrome OS verified boot on sandbox.
 
+config SPL_CROS_EC_SANDBOX
+	bool "Enable Chrome OS EC sandbox driver in SPL"
+	depends on SPL_CROS_EC && SANDBOX
+	help
+	  Enable a sandbox emulation of the Chrome OS EC in SPL. This supports
+	  keyboard (use the -l flag to enable the LCD), verified boot context,
+	  EC flash read/write/erase support and a few other things. It is
+	  enough to perform a Chrome OS verified boot on sandbox.
+
+config TPL_CROS_EC_SANDBOX
+	bool "Enable Chrome OS EC sandbox driver in TPL"
+	depends on TPL_CROS_EC && SANDBOX
+	help
+	  Enable a sandbox emulation of the Chrome OS EC in TPL. This supports
+	  keyboard (use the -l flag to enable the LCD), verified boot context,
+	  EC flash read/write/erase support and a few other things. It is
+	  enough to perform a Chrome OS verified boot on sandbox.
+
 config CROS_EC_SPI
 	bool "Enable Chrome OS EC SPI driver"
 	depends on CROS_EC
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index acf24c44fa9..9b92e61bfa8 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -3,17 +3,18 @@
 # (C) Copyright 2000-2007
 # Wolfgang Denk, DENX Software Engineering, wd at denx.de.
 
-obj-$(CONFIG_MISC) += misc-uclass.o
+obj-$(CONFIG_$(SPL_TPL_)CROS_EC) += cros_ec.o
+obj-$(CONFIG_$(SPL_TPL_)CROS_EC_SANDBOX) += cros_ec_sandbox.o
+obj-$(CONFIG_$(SPL_TPL_)CROS_EC_LPC) += cros_ec_lpc.o
+
+obj-$(CONFIG_$(SPL_TPL_)MISC) += misc-uclass.o
 obj-$(CONFIG_ALI152X) += ali512x.o
 obj-$(CONFIG_ALTERA_SYSID) += altera_sysid.o
 obj-$(CONFIG_ATSHA204A) += atsha204a-i2c.o
 obj-$(CONFIG_DS4510)  += ds4510.o
 obj-$(CONFIG_CBMEM_CONSOLE) += cbmem_console.o
 ifndef CONFIG_SPL_BUILD
-obj-$(CONFIG_CROS_EC) += cros_ec.o
-obj-$(CONFIG_CROS_EC_LPC) += cros_ec_lpc.o
 obj-$(CONFIG_CROS_EC_I2C) += cros_ec_i2c.o
-obj-$(CONFIG_CROS_EC_SANDBOX) += cros_ec_sandbox.o
 obj-$(CONFIG_CROS_EC_SPI) += cros_ec_spi.o
 endif
 obj-$(CONFIG_FSL_IIM) += fsl_iim.o
-- 
2.19.0.605.g01d371f741-goog

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 09/45] blk: Support block drivers in TPL
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (7 preceding siblings ...)
  2018-10-01 18:22 ` [U-Boot] [PATCH 08/45] spl: misc: Allow misc drivers in SPL and TPL Simon Glass
@ 2018-10-01 18:22 ` Simon Glass
  2018-10-01 18:22 ` [U-Boot] [PATCH 10/45] Kconfig: Convert CONFIG_RTC_MC146818 to Kconfig Simon Glass
                   ` (75 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: Simon Glass @ 2018-10-01 18:22 UTC (permalink / raw)
  To: u-boot

At present it is not possible to enable/disable block drivers in TPL. This
is needed to provide sandbox support. Add a Kconfig option and adjust the
Makefile.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/block/Kconfig  | 12 ++++++++++++
 drivers/block/Makefile |  2 +-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
index f9502b36bac..33f4aa24185 100644
--- a/drivers/block/Kconfig
+++ b/drivers/block/Kconfig
@@ -27,6 +27,18 @@ config SPL_BLK
 	  be partitioned into several areas, called 'partitions' in U-Boot.
 	  A filesystem can be placed in each partition.
 
+config TPL_BLK
+	bool "Support block devices in TPL"
+	depends on TPL_DM && BLK
+	default y
+	help
+	  Enable support for block devices, such as SCSI, MMC and USB
+	  flash sticks. These provide a block-level interface which permits
+	  reading, writing and (in some cases) erasing blocks. Block
+	  devices often have a partition table which allows the device to
+	  be partitioned into several areas, called 'partitions' in U-Boot.
+	  A filesystem can be placed in each partition.
+
 config BLOCK_CACHE
 	bool "Use block device cache"
 	depends on BLK
diff --git a/drivers/block/Makefile b/drivers/block/Makefile
index 0e80ce94058..055d42f7d4a 100644
--- a/drivers/block/Makefile
+++ b/drivers/block/Makefile
@@ -11,4 +11,4 @@ endif
 
 obj-$(CONFIG_IDE) += ide.o
 obj-$(CONFIG_SANDBOX) += sandbox.o
-obj-$(CONFIG_$(SPL_)BLOCK_CACHE) += blkcache.o
+obj-$(CONFIG_$(SPL_TPL_)BLOCK_CACHE) += blkcache.o
-- 
2.19.0.605.g01d371f741-goog

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 10/45] Kconfig: Convert CONFIG_RTC_MC146818 to Kconfig
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (8 preceding siblings ...)
  2018-10-01 18:22 ` [U-Boot] [PATCH 09/45] blk: Support block drivers in TPL Simon Glass
@ 2018-10-01 18:22 ` Simon Glass
  2018-10-01 18:22 ` [U-Boot] [PATCH 11/45] rtc: Allow use of RTC in SPL and TPL Simon Glass
                   ` (74 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: Simon Glass @ 2018-10-01 18:22 UTC (permalink / raw)
  To: u-boot

Move this option to Kconfig and tidy up the two boards which use it.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 configs/edison_defconfig     | 1 +
 configs/malta_defconfig      | 1 +
 drivers/rtc/Kconfig          | 8 ++++++++
 include/configs/edison.h     | 1 -
 include/configs/malta.h      | 1 -
 scripts/config_whitelist.txt | 1 -
 6 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/configs/edison_defconfig b/configs/edison_defconfig
index f0f3449464c..eb9f9a089f1 100644
--- a/configs/edison_defconfig
+++ b/configs/edison_defconfig
@@ -33,6 +33,7 @@ CONFIG_CPU=y
 CONFIG_DFU_MMC=y
 CONFIG_DFU_RAM=y
 CONFIG_DM_PCI_COMPAT=y
+CONFIG_RTC_MC146818=y
 CONFIG_USB_DWC3_GADGET=y
 CONFIG_USB_GADGET=y
 CONFIG_USB_GADGET_MANUFACTURER="Intel"
diff --git a/configs/malta_defconfig b/configs/malta_defconfig
index 585440584ee..8265daec8e7 100644
--- a/configs/malta_defconfig
+++ b/configs/malta_defconfig
@@ -22,4 +22,5 @@ CONFIG_DEFAULT_DEVICE_TREE="mti,malta"
 CONFIG_ENV_IS_IN_FLASH=y
 CONFIG_MTD_NOR_FLASH=y
 CONFIG_PCI=y
+CONFIG_RTC_MC146818=y
 CONFIG_SYS_NS16550=y
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 54365092ec4..97cf7d84dfa 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -68,4 +68,12 @@ config RTC_S35392A
 	help
 	  Enable s35392a driver which provides rtc get and set function.
 
+config RTC_MC146818
+	bool "Enable MC146818 driver"
+	help
+	  This is a widely used real-time clock chip originally by Motorola
+	  and now available from NXP. It includes a battery-backed real-time
+	  clock with a wide array of features and 50 bytes of general-purpose,
+	  battery-backed RAM. The driver supports access to the clock and RAM.
+
 endmenu
diff --git a/include/configs/edison.h b/include/configs/edison.h
index 476f5e38b4b..86c584d73dc 100644
--- a/include/configs/edison.h
+++ b/include/configs/edison.h
@@ -48,6 +48,5 @@
 
 /* RTC */
 #define CONFIG_SYS_ISA_IO_BASE_ADDRESS	0
-#define CONFIG_RTC_MC146818
 
 #endif
diff --git a/include/configs/malta.h b/include/configs/malta.h
index ba3639d177e..520b9870601 100644
--- a/include/configs/malta.h
+++ b/include/configs/malta.h
@@ -19,7 +19,6 @@
 #define CONFIG_PCNET_79C973
 #define PCNET_HAS_PROM
 
-#define CONFIG_RTC_MC146818
 #define CONFIG_SYS_ISA_IO_BASE_ADDRESS	0
 
 /*
diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt
index 96d3f75750b..a588dd12a03 100644
--- a/scripts/config_whitelist.txt
+++ b/scripts/config_whitelist.txt
@@ -1673,7 +1673,6 @@ CONFIG_RTC_IMXDI
 CONFIG_RTC_M41T11
 CONFIG_RTC_M41T62
 CONFIG_RTC_MC13XXX
-CONFIG_RTC_MC146818
 CONFIG_RTC_MCFRRTC
 CONFIG_RTC_MCP79411
 CONFIG_RTC_MXS
-- 
2.19.0.605.g01d371f741-goog

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 11/45] rtc: Allow use of RTC in SPL and TPL
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (9 preceding siblings ...)
  2018-10-01 18:22 ` [U-Boot] [PATCH 10/45] Kconfig: Convert CONFIG_RTC_MC146818 to Kconfig Simon Glass
@ 2018-10-01 18:22 ` Simon Glass
  2018-10-11 19:21   ` [U-Boot] [U-Boot,11/45] " Heinrich Schuchardt
  2018-10-01 18:22 ` [U-Boot] [PATCH 12/45] fdt: Document the fact that dtc is now built Simon Glass
                   ` (73 subsequent siblings)
  84 siblings, 1 reply; 106+ messages in thread
From: Simon Glass @ 2018-10-01 18:22 UTC (permalink / raw)
  To: u-boot

Add Kconfig options so that the RTC can be used in SPL and TPL. This is
helpful for accessing the contents of CMOS RAM, for example.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/rtc/Kconfig      | 18 ++++++++++++++++++
 drivers/rtc/Makefile     |  2 +-
 drivers/rtc/rtc-uclass.c |  1 +
 3 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 97cf7d84dfa..bcc01b135e5 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -13,6 +13,24 @@ config DM_RTC
 	  drivers to perform the actual functions. See rtc.h for a
 	  description of the API.
 
+config SPL_DM_RTC
+	bool "Enable Driver Model for RTC drivers in SPL"
+	depends on SPL_DM
+	help
+	  Enable drver model for real-time-clock drivers. The RTC uclass
+	  then provides the rtc_get()/rtc_set() interface, delegating to
+	  drivers to perform the actual functions. See rtc.h for a
+	  description of the API.
+
+config TPL_DM_RTC
+	bool "Enable Driver Model for RTC drivers in TPL"
+	depends on TPL_DM
+	help
+	  Enable drver model for real-time-clock drivers. The RTC uclass
+	  then provides the rtc_get()/rtc_set() interface, delegating to
+	  drivers to perform the actual functions. See rtc.h for a
+	  description of the API.
+
 config RTC_PCF2127
 	bool "Enable PCF2127 driver"
 	depends on DM_RTC
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index 513e3ffc079..1724602f1cb 100644
--- a/drivers/rtc/Makefile
+++ b/drivers/rtc/Makefile
@@ -4,7 +4,7 @@
 # Wolfgang Denk, DENX Software Engineering, wd at denx.de.
 #ccflags-y += -DDEBUG
 
-obj-$(CONFIG_DM_RTC) += rtc-uclass.o
+obj-$(CONFIG_$(SPL_TPL_)DM_RTC) += rtc-uclass.o
 
 obj-$(CONFIG_RTC_AT91SAM9_RTT) += at91sam9_rtt.o
 obj-y += date.o
diff --git a/drivers/rtc/rtc-uclass.c b/drivers/rtc/rtc-uclass.c
index c676f0ff359..a0a238aedda 100644
--- a/drivers/rtc/rtc-uclass.c
+++ b/drivers/rtc/rtc-uclass.c
@@ -122,4 +122,5 @@ int rtc_write32(struct udevice *dev, unsigned int reg, u32 value)
 UCLASS_DRIVER(rtc) = {
 	.name		= "rtc",
 	.id		= UCLASS_RTC,
+	.post_bind	= dm_scan_fdt_dev,
 };
-- 
2.19.0.605.g01d371f741-goog

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 12/45] fdt: Document the fact that dtc is now built
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (10 preceding siblings ...)
  2018-10-01 18:22 ` [U-Boot] [PATCH 11/45] rtc: Allow use of RTC in SPL and TPL Simon Glass
@ 2018-10-01 18:22 ` Simon Glass
  2018-10-01 18:22 ` [U-Boot] [PATCH 13/45] doc: Update docs for device tree in SPL, TPL Simon Glass
                   ` (72 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: Simon Glass @ 2018-10-01 18:22 UTC (permalink / raw)
  To: u-boot

This documentation is out of date now that U-Boot builds dtc
automatically. Update it.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 doc/README.fdt-control | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/doc/README.fdt-control b/doc/README.fdt-control
index 634a10616fc..88c04692f74 100644
--- a/doc/README.fdt-control
+++ b/doc/README.fdt-control
@@ -56,7 +56,11 @@ In case you are wondering, OF stands for Open Firmware.
 Tools
 -----
 
-To use this feature you will need to get the device tree compiler here:
+To use this feature you will need to get the device tree compiler. This is
+provided by U-Boot automatically. If you have a system version of dtc
+(typically in the 'device-tree-compiler' package), it is currently not used.
+
+If you want to build your own dtc, it is kept here:
 
 	git://git.kernel.org/pub/scm/utils/dtc/dtc.git
 
-- 
2.19.0.605.g01d371f741-goog

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 13/45] doc: Update docs for device tree in SPL, TPL
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (11 preceding siblings ...)
  2018-10-01 18:22 ` [U-Boot] [PATCH 12/45] fdt: Document the fact that dtc is now built Simon Glass
@ 2018-10-01 18:22 ` Simon Glass
  2018-10-01 18:22 ` [U-Boot] [PATCH 14/45] fdt: Allow indicating a node is for U-Boot proper only Simon Glass
                   ` (71 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: Simon Glass @ 2018-10-01 18:22 UTC (permalink / raw)
  To: u-boot

Make a few small updates to indicate that device tree can be used in SPL
and TPL.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 doc/README.fdt-control      | 10 ++++++++++
 doc/driver-model/README.txt |  3 ++-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/doc/README.fdt-control b/doc/README.fdt-control
index 88c04692f74..d6ab7bf5706 100644
--- a/doc/README.fdt-control
+++ b/doc/README.fdt-control
@@ -174,6 +174,16 @@ After board configuration is done, fdt supported u-boot can be build in two ways
     $ make DEVICE_TREE=<dts-file-name>
 
 
+Relocation, SPL and TPL
+-----------------------
+
+U-Boot can be divided into three phases: TPL, SPL and U-Boot proper.
+
+The full device tree is available to U-Boot proper, but normally only a subset
+(or none at all) is available to TPL and SPL. See 'Pre-Relocation Support' and
+'SPL Support' in doc/driver-model/README.txt for more details.
+
+
 Limitations
 -----------
 
diff --git a/doc/driver-model/README.txt b/doc/driver-model/README.txt
index e949ff63bae..6085f927dea 100644
--- a/doc/driver-model/README.txt
+++ b/doc/driver-model/README.txt
@@ -832,7 +832,8 @@ Pre-Relocation Support
 For pre-relocation we simply call the driver model init function. Only
 drivers marked with DM_FLAG_PRE_RELOC or the device tree
 'u-boot,dm-pre-reloc' flag are initialised prior to relocation. This helps
-to reduce the driver model overhead.
+to reduce the driver model overhead. This flag applies to SPL and TPL as
+well, if device tree is enabled there.
 
 It is possible to limit this to specific relocation steps, by using
 the more specialized 'u-boot,dm-spl' and 'u-boot,dm-tpl' flags
-- 
2.19.0.605.g01d371f741-goog

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 14/45] fdt: Allow indicating a node is for U-Boot proper only
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (12 preceding siblings ...)
  2018-10-01 18:22 ` [U-Boot] [PATCH 13/45] doc: Update docs for device tree in SPL, TPL Simon Glass
@ 2018-10-01 18:22 ` Simon Glass
  2018-10-01 18:22 ` [U-Boot] [PATCH 15/45] tpm: Add support for SPL and TPL Simon Glass
                   ` (70 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: Simon Glass @ 2018-10-01 18:22 UTC (permalink / raw)
  To: u-boot

At present it is not possible to specify that a node should be used before
relocation (in U-Boot proper) without it also ending up in SPL and TPL
device trees. Add a new "u-boot,dm-pre-proper" boolean property for this.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 doc/driver-model/README.txt | 4 +++-
 drivers/core/ofnode.c       | 2 ++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/doc/driver-model/README.txt b/doc/driver-model/README.txt
index 6085f927dea..36541630a27 100644
--- a/doc/driver-model/README.txt
+++ b/doc/driver-model/README.txt
@@ -837,7 +837,9 @@ well, if device tree is enabled there.
 
 It is possible to limit this to specific relocation steps, by using
 the more specialized 'u-boot,dm-spl' and 'u-boot,dm-tpl' flags
-in the devicetree.
+in the device tree node. For U-Boot proper you can use 'u-boot,dm-pre-proper'
+which means that it will be processed (and a driver bound) in U-Boot proper
+prior to relocation, but will not be available in SPL or TPL.
 
 Then post relocation we throw that away and re-init driver model again.
 For drivers which require some sort of continuity between pre- and
diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c
index 1e354803b06..825ffc27496 100644
--- a/drivers/core/ofnode.c
+++ b/drivers/core/ofnode.c
@@ -695,6 +695,8 @@ bool ofnode_pre_reloc(ofnode node)
 {
 	if (ofnode_read_bool(node, "u-boot,dm-pre-reloc"))
 		return true;
+	if (ofnode_read_bool(node, "u-boot,dm-pre-proper"))
+		return true;
 
 #ifdef CONFIG_TPL_BUILD
 	if (ofnode_read_bool(node, "u-boot,dm-tpl"))
-- 
2.19.0.605.g01d371f741-goog

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 15/45] tpm: Add support for SPL and TPL
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (13 preceding siblings ...)
  2018-10-01 18:22 ` [U-Boot] [PATCH 14/45] fdt: Allow indicating a node is for U-Boot proper only Simon Glass
@ 2018-10-01 18:22 ` Simon Glass
  2018-10-01 18:22 ` [U-Boot] [PATCH 16/45] serial: Allow serial to be absent in TPL Simon Glass
                   ` (69 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: Simon Glass @ 2018-10-01 18:22 UTC (permalink / raw)
  To: u-boot

At present the tpm can only be used in U-Boot proper. Updated it to work
in SPL and TPL also.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/tpm/Makefile |  2 +-
 lib/Kconfig          | 22 ++++++++++++++++++++++
 lib/Makefile         | 10 +++++++---
 3 files changed, 30 insertions(+), 4 deletions(-)

diff --git a/drivers/tpm/Makefile b/drivers/tpm/Makefile
index af473ef662e..94c337b8ed3 100644
--- a/drivers/tpm/Makefile
+++ b/drivers/tpm/Makefile
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0+
 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
 
-obj-$(CONFIG_TPM) += tpm-uclass.o
+obj-$(CONFIG_$(SPL_TPL_)TPM) += tpm-uclass.o
 
 obj-$(CONFIG_TPM_ATMEL_TWI) += tpm_atmel_twi.o
 obj-$(CONFIG_TPM_TIS_INFINEON) += tpm_tis_infineon.o
diff --git a/lib/Kconfig b/lib/Kconfig
index 622f3c26c33..b711d62d32f 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -185,6 +185,28 @@ config TPM
 	  for the low-level TPM interface, but only one TPM is supported at
 	  a time by the TPM library.
 
+config SPL_TPM
+	bool "Trusted Platform Module (TPM) Support in SPL"
+	depends on SPL_DM
+	help
+	  This enables support for TPMs which can be used to provide security
+	  features for your board. The TPM can be connected via LPC or I2C
+	  and a sandbox TPM is provided for testing purposes. Use the 'tpm'
+	  command to interactive the TPM. Driver model support is provided
+	  for the low-level TPM interface, but only one TPM is supported at
+	  a time by the TPM library.
+
+config TPL_TPM
+	bool "Trusted Platform Module (TPM) Support in TPL"
+	depends on TPL_DM
+	help
+	  This enables support for TPMs which can be used to provide security
+	  features for your board. The TPM can be connected via LPC or I2C
+	  and a sandbox TPM is provided for testing purposes. Use the 'tpm'
+	  command to interactive the TPM. Driver model support is provided
+	  for the low-level TPM interface, but only one TPM is supported at
+	  a time by the TPM library.
+
 endmenu
 
 menu "Android Verified Boot"
diff --git a/lib/Makefile b/lib/Makefile
index f1696448506..fb6944128aa 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -45,14 +45,18 @@ obj-$(CONFIG_PHYSMEM) += physmem.o
 obj-y += qsort.o
 obj-y += rc4.o
 obj-$(CONFIG_SUPPORT_EMMC_RPMB) += sha256.o
-obj-$(CONFIG_TPM) += tpm-common.o
-obj-$(CONFIG_TPM_V1) += tpm-v1.o
-obj-$(CONFIG_TPM_V2) += tpm-v2.o
 obj-$(CONFIG_RBTREE)	+= rbtree.o
 obj-$(CONFIG_BITREVERSE) += bitrev.o
 obj-y += list_sort.o
 endif
 
+obj-$(CONFIG_$(SPL_TPL_)TPM) += tpm-common.o
+ifeq ($(CONFIG_$(SPL_TPL_)TPM),y)
+obj-y += crc8.o
+obj-$(CONFIG_TPM_V1) += tpm-v1.o
+obj-$(CONFIG_TPM_V2) += tpm-v2.o
+endif
+
 obj-$(CONFIG_RSA) += rsa/
 obj-$(CONFIG_SHA1) += sha1.o
 obj-$(CONFIG_SHA256) += sha256.o
-- 
2.19.0.605.g01d371f741-goog

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 16/45] serial: Allow serial to be absent in TPL
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (14 preceding siblings ...)
  2018-10-01 18:22 ` [U-Boot] [PATCH 15/45] tpm: Add support for SPL and TPL Simon Glass
@ 2018-10-01 18:22 ` Simon Glass
  2018-10-01 18:22 ` [U-Boot] [PATCH 17/45] fdt: Allow libfdt " Simon Glass
                   ` (68 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: Simon Glass @ 2018-10-01 18:22 UTC (permalink / raw)
  To: u-boot

At present this option applies to SPL, but it should be available in TPL
also, and separately. Change to using CONFIG_IS_ENABLED(), add a new
Kconfig option and fix up hang().

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/serial/Kconfig         | 10 ++++++++++
 drivers/serial/serial-uclass.c |  4 ++++
 lib/hang.c                     |  5 +++--
 3 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index 83f8c94d028..597db4b9cbb 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -53,6 +53,16 @@ config SPL_SERIAL_PRESENT
 	  This option enables the full UART in SPL, so if is it disabled,
 	  the full UART driver will be omitted, thus saving space.
 
+config TPL_SERIAL_PRESENT
+	bool "Provide a serial driver in TPL"
+	depends on DM_SERIAL
+	default y
+	help
+	  In very space-constrained devices even the full UART driver is too
+	  large. In this case the debug UART can still be used in some cases.
+	  This option enables the full UART in TPL, so if is it disabled,
+	  the full UART driver will be omitted, thus saving space.
+
 # Logic to allow us to use the imply keyword to set what the default port
 # should be.  The default is otherwise 1.
 config CONS_INDEX_0
diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c
index ffdcae09318..e50f0aa8510 100644
--- a/drivers/serial/serial-uclass.c
+++ b/drivers/serial/serial-uclass.c
@@ -26,6 +26,7 @@ static const unsigned long baudrate_table[] = CONFIG_SYS_BAUDRATE_TABLE;
 #error "Serial is required before relocation - define CONFIG_$(SPL_)SYS_MALLOC_F_LEN to make this work"
 #endif
 
+#if CONFIG_IS_ENABLED(SERIAL_PRESENT)
 static int serial_check_stdout(const void *blob, struct udevice **devp)
 {
 	int node;
@@ -150,12 +151,15 @@ static void serial_find_console_or_panic(void)
 	panic_str("No serial driver found");
 #endif
 }
+#endif /* CONFIG_SERIAL_PRESENT */
 
 /* Called prior to relocation */
 int serial_init(void)
 {
+#if CONFIG_IS_ENABLED(SERIAL_PRESENT)
 	serial_find_console_or_panic();
 	gd->flags |= GD_FLG_SERIAL_READY;
+#endif
 
 	return 0;
 }
diff --git a/lib/hang.c b/lib/hang.c
index bf56f4c662a..c5a78694be6 100644
--- a/lib/hang.c
+++ b/lib/hang.c
@@ -20,8 +20,9 @@
  */
 void hang(void)
 {
-#if !defined(CONFIG_SPL_BUILD) || (defined(CONFIG_SPL_LIBCOMMON_SUPPORT) && \
-		defined(CONFIG_SPL_SERIAL_SUPPORT))
+#if !defined(CONFIG_SPL_BUILD) || \
+		(CONFIG_IS_ENABLED(LIBCOMMON_SUPPORT) && \
+		 CONFIG_IS_ENABLED(SERIAL_SUPPORT))
 	puts("### ERROR ### Please RESET the board ###\n");
 #endif
 	bootstage_error(BOOTSTAGE_ID_NEED_RESET);
-- 
2.19.0.605.g01d371f741-goog

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 17/45] fdt: Allow libfdt in TPL
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (15 preceding siblings ...)
  2018-10-01 18:22 ` [U-Boot] [PATCH 16/45] serial: Allow serial to be absent in TPL Simon Glass
@ 2018-10-01 18:22 ` Simon Glass
  2018-10-01 18:22 ` [U-Boot] [PATCH 18/45] cros: Update cros_ec code to use struct udevice Simon Glass
                   ` (67 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: Simon Glass @ 2018-10-01 18:22 UTC (permalink / raw)
  To: u-boot

In some cases (e.g. sandbox with verified boot) it is useful to support
libfdt in TPL. Update the Kconfig to handle this.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 lib/Kconfig | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/lib/Kconfig b/lib/Kconfig
index b711d62d32f..ccab426e121 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -353,6 +353,16 @@ config SPL_OF_LIBFDT
 	  particular compatible nodes. The library operates on a flattened
 	  version of the device tree.
 
+config TPL_OF_LIBFDT
+	bool "Enable the FDT library for TPL"
+	default y if TPL_OF_CONTROL
+	help
+	  This enables the FDT library (libfdt). It provides functions for
+	  accessing binary device tree images in memory, such as adding and
+	  removing nodes and properties, scanning through the tree and finding
+	  particular compatible nodes. The library operates on a flattened
+	  version of the device tree.
+
 config FDT_FIXUP_PARTITIONS
 	bool "overwrite MTD partitions in DTS through defined in 'mtdparts'"
 	depends on OF_LIBFDT
-- 
2.19.0.605.g01d371f741-goog

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 18/45] cros: Update cros_ec code to use struct udevice
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (16 preceding siblings ...)
  2018-10-01 18:22 ` [U-Boot] [PATCH 17/45] fdt: Allow libfdt " Simon Glass
@ 2018-10-01 18:22 ` Simon Glass
  2018-10-01 18:22 ` [U-Boot] [PATCH 19/45] cros: Adjust board_get_cros_ec_dev() to return a udevice Simon Glass
                   ` (66 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: Simon Glass @ 2018-10-01 18:22 UTC (permalink / raw)
  To: u-boot

At present we pass around a private pointer to specify the cros_ec device.
With driver model it makes more sense to pass the device. Update the code
to do this.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 cmd/cros_ec.c                  |  24 +++---
 drivers/misc/cros_ec.c         | 147 +++++++++++++++++----------------
 drivers/misc/cros_ec_sandbox.c |   4 +-
 drivers/tpm/tpm-uclass.c       |   6 +-
 include/cros_ec.h              |  66 +++++++--------
 5 files changed, 122 insertions(+), 125 deletions(-)

diff --git a/cmd/cros_ec.c b/cmd/cros_ec.c
index 60c87838fdf..fb369a4e329 100644
--- a/cmd/cros_ec.c
+++ b/cmd/cros_ec.c
@@ -49,7 +49,7 @@ static int cros_ec_decode_region(int argc, char * const argv[])
  * @return 0 for ok, 1 for a usage error or -ve for ec command error
  *	(negative EC_RES_...)
  */
-static int do_read_write(struct cros_ec_dev *dev, int is_write, int argc,
+static int do_read_write(struct udevice *dev, int is_write, int argc,
 			 char * const argv[])
 {
 	uint32_t offset, size = -1U, region_size;
@@ -94,8 +94,7 @@ static int do_read_write(struct cros_ec_dev *dev, int is_write, int argc,
 
 static int do_cros_ec(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
-	struct cros_ec_dev *dev;
-	struct udevice *udev;
+	struct udevice *dev;
 	const char *cmd;
 	int ret = 0;
 
@@ -105,10 +104,10 @@ static int do_cros_ec(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	cmd = argv[1];
 	if (0 == strcmp("init", cmd)) {
 		/* Remove any existing device */
-		ret = uclass_find_device(UCLASS_CROS_EC, 0, &udev);
+		ret = uclass_find_device(UCLASS_CROS_EC, 0, &dev);
 		if (!ret)
-			device_remove(udev, DM_REMOVE_NORMAL);
-		ret = uclass_get_device(UCLASS_CROS_EC, 0, &udev);
+			device_remove(dev, DM_REMOVE_NORMAL);
+		ret = uclass_get_device(UCLASS_CROS_EC, 0, &dev);
 		if (ret) {
 			printf("Could not init cros_ec device (err %d)\n", ret);
 			return 1;
@@ -116,12 +115,11 @@ static int do_cros_ec(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 		return 0;
 	}
 
-	ret = uclass_get_device(UCLASS_CROS_EC, 0, &udev);
+	ret = uclass_get_device(UCLASS_CROS_EC, 0, &dev);
 	if (ret) {
 		printf("Cannot get cros-ec device (err=%d)\n", ret);
 		return 1;
 	}
-	dev = dev_get_uclass_priv(udev);
 	if (0 == strcmp("id", cmd)) {
 		char id[MSG_BYTES];
 
@@ -262,7 +260,8 @@ static int do_cros_ec(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 		unsigned long result;
 
 		if (argc <= 2) {
-			ret = cros_ec_read_vbnvcontext(dev, block);
+			ret = cros_ec_read_nvdata(dev, block,
+						  EC_VBNV_BLOCK_SIZE);
 			if (!ret) {
 				printf("vbnv_block: ");
 				for (i = 0; i < EC_VBNV_BLOCK_SIZE; i++)
@@ -288,7 +287,8 @@ static int do_cros_ec(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 				strict_strtoul(buf, 16, &result);
 				block[i] = result;
 			}
-			ret = cros_ec_write_vbnvcontext(dev, block);
+			ret = cros_ec_write_nvdata(dev, block,
+						   EC_VBNV_BLOCK_SIZE);
 		}
 		if (ret) {
 			debug("%s: Could not %s VbNvContext\n", __func__,
@@ -336,9 +336,9 @@ static int do_cros_ec(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 			state = simple_strtoul(argv[3], &endp, 10);
 			if (*argv[3] == 0 || *endp != 0)
 				return CMD_RET_USAGE;
-			ret = cros_ec_set_ldo(udev, index, state);
+			ret = cros_ec_set_ldo(dev, index, state);
 		} else {
-			ret = cros_ec_get_ldo(udev, index, &state);
+			ret = cros_ec_get_ldo(dev, index, &state);
 			if (!ret) {
 				printf("LDO%d: %s\n", index,
 				       state == EC_LDO_STATE_ON ?
diff --git a/drivers/misc/cros_ec.c b/drivers/misc/cros_ec.c
index c5ac03d027d..a92806c46c9 100644
--- a/drivers/misc/cros_ec.c
+++ b/drivers/misc/cros_ec.c
@@ -83,15 +83,15 @@ int cros_ec_calc_checksum(const uint8_t *data, int size)
  * @param dout_len      Size of output data in bytes
  * @return packet size in bytes, or <0 if error.
  */
-static int create_proto3_request(struct cros_ec_dev *dev,
+static int create_proto3_request(struct cros_ec_dev *cdev,
 				 int cmd, int cmd_version,
 				 const void *dout, int dout_len)
 {
-	struct ec_host_request *rq = (struct ec_host_request *)dev->dout;
+	struct ec_host_request *rq = (struct ec_host_request *)cdev->dout;
 	int out_bytes = dout_len + sizeof(*rq);
 
 	/* Fail if output size is too big */
-	if (out_bytes > (int)sizeof(dev->dout)) {
+	if (out_bytes > (int)sizeof(cdev->dout)) {
 		debug("%s: Cannot send %d bytes\n", __func__, dout_len);
 		return -EC_RES_REQUEST_TRUNCATED;
 	}
@@ -108,9 +108,9 @@ static int create_proto3_request(struct cros_ec_dev *dev,
 	memcpy(rq + 1, dout, dout_len);
 
 	/* Write checksum field so the entire packet sums to 0 */
-	rq->checksum = (uint8_t)(-cros_ec_calc_checksum(dev->dout, out_bytes));
+	rq->checksum = (uint8_t)(-cros_ec_calc_checksum(cdev->dout, out_bytes));
 
-	cros_ec_dump_data("out", cmd, dev->dout, out_bytes);
+	cros_ec_dump_data("out", cmd, cdev->dout, out_bytes);
 
 	/* Return size of request packet */
 	return out_bytes;
@@ -123,12 +123,12 @@ static int create_proto3_request(struct cros_ec_dev *dev,
  * @param din_len       Maximum size of response in bytes
  * @return maximum expected number of bytes in response, or <0 if error.
  */
-static int prepare_proto3_response_buffer(struct cros_ec_dev *dev, int din_len)
+static int prepare_proto3_response_buffer(struct cros_ec_dev *cdev, int din_len)
 {
 	int in_bytes = din_len + sizeof(struct ec_host_response);
 
 	/* Fail if input size is too big */
-	if (in_bytes > (int)sizeof(dev->din)) {
+	if (in_bytes > (int)sizeof(cdev->din)) {
 		debug("%s: Cannot receive %d bytes\n", __func__, din_len);
 		return -EC_RES_RESPONSE_TOO_BIG;
 	}
@@ -197,7 +197,7 @@ static int handle_proto3_response(struct cros_ec_dev *dev,
 	return rs->data_len;
 }
 
-static int send_command_proto3(struct cros_ec_dev *dev,
+static int send_command_proto3(struct cros_ec_dev *cdev,
 			       int cmd, int cmd_version,
 			       const void *dout, int dout_len,
 			       uint8_t **dinp, int din_len)
@@ -207,23 +207,24 @@ static int send_command_proto3(struct cros_ec_dev *dev,
 	int rv;
 
 	/* Create request packet */
-	out_bytes = create_proto3_request(dev, cmd, cmd_version,
+	out_bytes = create_proto3_request(cdev, cmd, cmd_version,
 					  dout, dout_len);
 	if (out_bytes < 0)
 		return out_bytes;
 
 	/* Prepare response buffer */
-	in_bytes = prepare_proto3_response_buffer(dev, din_len);
+	in_bytes = prepare_proto3_response_buffer(cdev, din_len);
 	if (in_bytes < 0)
 		return in_bytes;
 
-	ops = dm_cros_ec_get_ops(dev->dev);
-	rv = ops->packet ? ops->packet(dev->dev, out_bytes, in_bytes) : -ENOSYS;
+	ops = dm_cros_ec_get_ops(cdev->dev);
+	rv = ops->packet ? ops->packet(cdev->dev, out_bytes, in_bytes) :
+			-ENOSYS;
 	if (rv < 0)
 		return rv;
 
 	/* Process the response */
-	return handle_proto3_response(dev, dinp, din_len);
+	return handle_proto3_response(cdev, dinp, din_len);
 }
 
 static int send_command(struct cros_ec_dev *dev, uint8_t cmd, int cmd_version,
@@ -262,15 +263,16 @@ static int send_command(struct cros_ec_dev *dev, uint8_t cmd, int cmd_version,
  * @param din_len       Maximum size of response in bytes
  * @return number of bytes in response, or -ve on error
  */
-static int ec_command_inptr(struct cros_ec_dev *dev, uint8_t cmd,
+static int ec_command_inptr(struct udevice *dev, uint8_t cmd,
 			    int cmd_version, const void *dout, int dout_len,
 			    uint8_t **dinp, int din_len)
 {
+	struct cros_ec_dev *cdev = dev_get_uclass_priv(dev);
 	uint8_t *din = NULL;
 	int len;
 
-	len = send_command(dev, cmd, cmd_version, dout, dout_len,
-				&din, din_len);
+	len = send_command(cdev, cmd, cmd_version, dout, dout_len, &din,
+			   din_len);
 
 	/* If the command doesn't complete, wait a while */
 	if (len == -EC_RES_IN_PROGRESS) {
@@ -283,9 +285,9 @@ static int ec_command_inptr(struct cros_ec_dev *dev, uint8_t cmd,
 			int ret;
 
 			mdelay(50);	/* Insert some reasonable delay */
-			ret = send_command(dev, EC_CMD_GET_COMMS_STATUS, 0,
-					NULL, 0,
-					(uint8_t **)&resp, sizeof(*resp));
+			ret = send_command(cdev, EC_CMD_GET_COMMS_STATUS, 0,
+					   NULL, 0,
+					   (uint8_t **)&resp, sizeof(*resp));
 			if (ret < 0)
 				return ret;
 
@@ -298,8 +300,8 @@ static int ec_command_inptr(struct cros_ec_dev *dev, uint8_t cmd,
 
 		/* OK it completed, so read the status response */
 		/* not sure why it was 0 for the last argument */
-		len = send_command(dev, EC_CMD_RESEND_RESPONSE, 0,
-				NULL, 0, &din, din_len);
+		len = send_command(cdev, EC_CMD_RESEND_RESPONSE, 0, NULL, 0,
+				   &din, din_len);
 	}
 
 	debug("%s: len=%d, din=%p\n", __func__, len, din);
@@ -328,7 +330,7 @@ static int ec_command_inptr(struct cros_ec_dev *dev, uint8_t cmd,
  * @param din_len       Maximum size of response in bytes
  * @return number of bytes in response, or -ve on error
  */
-static int ec_command(struct cros_ec_dev *dev, uint8_t cmd, int cmd_version,
+static int ec_command(struct udevice *dev, uint8_t cmd, int cmd_version,
 		      const void *dout, int dout_len,
 		      void *din, int din_len)
 {
@@ -337,7 +339,7 @@ static int ec_command(struct cros_ec_dev *dev, uint8_t cmd, int cmd_version,
 
 	assert((din_len == 0) || din);
 	len = ec_command_inptr(dev, cmd, cmd_version, dout, dout_len,
-			&in_buffer, din_len);
+			       &in_buffer, din_len);
 	if (len > 0) {
 		/*
 		 * If we were asked to put it somewhere, do so, otherwise just
@@ -353,16 +355,14 @@ static int ec_command(struct cros_ec_dev *dev, uint8_t cmd, int cmd_version,
 
 int cros_ec_scan_keyboard(struct udevice *dev, struct mbkp_keyscan *scan)
 {
-	struct cros_ec_dev *cdev = dev_get_uclass_priv(dev);
-
-	if (ec_command(cdev, EC_CMD_MKBP_STATE, 0, NULL, 0, scan,
+ 	if (ec_command(dev, EC_CMD_MKBP_STATE, 0, NULL, 0, scan,
 		       sizeof(scan->data)) != sizeof(scan->data))
 		return -1;
 
 	return 0;
 }
 
-int cros_ec_read_id(struct cros_ec_dev *dev, char *id, int maxlen)
+int cros_ec_read_id(struct udevice *dev, char *id, int maxlen)
 {
 	struct ec_response_get_version *r;
 
@@ -388,8 +388,8 @@ int cros_ec_read_id(struct cros_ec_dev *dev, char *id, int maxlen)
 	return 0;
 }
 
-int cros_ec_read_version(struct cros_ec_dev *dev,
-		       struct ec_response_get_version **versionp)
+int cros_ec_read_version(struct udevice *dev,
+			 struct ec_response_get_version **versionp)
 {
 	if (ec_command_inptr(dev, EC_CMD_GET_VERSION, 0, NULL, 0,
 			(uint8_t **)versionp, sizeof(**versionp))
@@ -399,7 +399,7 @@ int cros_ec_read_version(struct cros_ec_dev *dev,
 	return 0;
 }
 
-int cros_ec_read_build_info(struct cros_ec_dev *dev, char **strp)
+int cros_ec_read_build_info(struct udevice *dev, char **strp)
 {
 	if (ec_command_inptr(dev, EC_CMD_GET_BUILD_INFO, 0, NULL, 0,
 			(uint8_t **)strp, EC_PROTO2_MAX_PARAM_SIZE) < 0)
@@ -408,7 +408,7 @@ int cros_ec_read_build_info(struct cros_ec_dev *dev, char **strp)
 	return 0;
 }
 
-int cros_ec_read_current_image(struct cros_ec_dev *dev,
+int cros_ec_read_current_image(struct udevice *dev,
 			       enum ec_current_image *image)
 {
 	struct ec_response_get_version *r;
@@ -421,7 +421,7 @@ int cros_ec_read_current_image(struct cros_ec_dev *dev,
 	return 0;
 }
 
-static int cros_ec_wait_on_hash_done(struct cros_ec_dev *dev,
+static int cros_ec_wait_on_hash_done(struct udevice *dev,
 				     struct ec_response_vboot_hash *hash)
 {
 	struct ec_params_vboot_hash p;
@@ -445,8 +445,7 @@ static int cros_ec_wait_on_hash_done(struct cros_ec_dev *dev,
 }
 
 
-int cros_ec_read_hash(struct cros_ec_dev *dev,
-		      struct ec_response_vboot_hash *hash)
+int cros_ec_read_hash(struct udevice *dev, struct ec_response_vboot_hash *hash)
 {
 	struct ec_params_vboot_hash p;
 	int rv;
@@ -489,7 +488,7 @@ int cros_ec_read_hash(struct cros_ec_dev *dev,
 	return 0;
 }
 
-static int cros_ec_invalidate_hash(struct cros_ec_dev *dev)
+static int cros_ec_invalidate_hash(struct udevice *dev)
 {
 	struct ec_params_vboot_hash p;
 	struct ec_response_vboot_hash *hash;
@@ -514,8 +513,7 @@ static int cros_ec_invalidate_hash(struct cros_ec_dev *dev)
 	return 0;
 }
 
-int cros_ec_reboot(struct cros_ec_dev *dev, enum ec_reboot_cmd cmd,
-		   uint8_t flags)
+int cros_ec_reboot(struct udevice *dev, enum ec_reboot_cmd cmd, uint8_t flags)
 {
 	struct ec_params_reboot_ec p;
 
@@ -555,7 +553,7 @@ int cros_ec_interrupt_pending(struct udevice *dev)
 	return dm_gpio_get_value(&cdev->ec_int);
 }
 
-int cros_ec_info(struct cros_ec_dev *dev, struct ec_response_mkbp_info *info)
+int cros_ec_info(struct udevice *dev, struct ec_response_mkbp_info *info)
 {
 	if (ec_command(dev, EC_CMD_MKBP_INFO, 0, NULL, 0, info,
 		       sizeof(*info)) != sizeof(*info))
@@ -564,7 +562,7 @@ int cros_ec_info(struct cros_ec_dev *dev, struct ec_response_mkbp_info *info)
 	return 0;
 }
 
-int cros_ec_get_host_events(struct cros_ec_dev *dev, uint32_t *events_ptr)
+int cros_ec_get_host_events(struct udevice *dev, uint32_t *events_ptr)
 {
 	struct ec_response_host_event_mask *resp;
 
@@ -583,7 +581,7 @@ int cros_ec_get_host_events(struct cros_ec_dev *dev, uint32_t *events_ptr)
 	return 0;
 }
 
-int cros_ec_clear_host_events(struct cros_ec_dev *dev, uint32_t events)
+int cros_ec_clear_host_events(struct udevice *dev, uint32_t events)
 {
 	struct ec_params_host_event_mask params;
 
@@ -600,8 +598,8 @@ int cros_ec_clear_host_events(struct cros_ec_dev *dev, uint32_t events)
 	return 0;
 }
 
-int cros_ec_flash_protect(struct cros_ec_dev *dev,
-			  uint32_t set_mask, uint32_t set_flags,
+int cros_ec_flash_protect(struct udevice *dev, uint32_t set_mask,
+			  uint32_t set_flags,
 			  struct ec_response_flash_protect *resp)
 {
 	struct ec_params_flash_protect params;
@@ -617,17 +615,18 @@ int cros_ec_flash_protect(struct cros_ec_dev *dev,
 	return 0;
 }
 
-static int cros_ec_check_version(struct cros_ec_dev *dev)
+static int cros_ec_check_version(struct udevice *dev)
 {
+	struct cros_ec_dev *cdev = dev_get_uclass_priv(dev);
 	struct ec_params_hello req;
 	struct ec_response_hello *resp;
 
 	struct dm_cros_ec_ops *ops;
 	int ret;
 
-	ops = dm_cros_ec_get_ops(dev->dev);
+	ops = dm_cros_ec_get_ops(dev);
 	if (ops->check_version) {
-		ret = ops->check_version(dev->dev);
+		ret = ops->check_version(dev);
 		if (ret)
 			return ret;
 	}
@@ -647,7 +646,7 @@ static int cros_ec_check_version(struct cros_ec_dev *dev)
 	 */
 
 	/* Try sending a version 3 packet */
-	dev->protocol_version = 3;
+	cdev->protocol_version = 3;
 	req.in_data = 0;
 	if (ec_command_inptr(dev, EC_CMD_HELLO, 0, &req, sizeof(req),
 			     (uint8_t **)&resp, sizeof(*resp)) > 0) {
@@ -655,9 +654,9 @@ static int cros_ec_check_version(struct cros_ec_dev *dev)
 	}
 
 	/* Try sending a version 2 packet */
-	dev->protocol_version = 2;
+	cdev->protocol_version = 2;
 	if (ec_command_inptr(dev, EC_CMD_HELLO, 0, &req, sizeof(req),
-		       (uint8_t **)&resp, sizeof(*resp)) > 0) {
+			     (uint8_t **)&resp, sizeof(*resp)) > 0) {
 		return 0;
 	}
 
@@ -667,12 +666,12 @@ static int cros_ec_check_version(struct cros_ec_dev *dev)
 	 * version is no longer supported, and we don't know about any new
 	 * protocol versions.
 	 */
-	dev->protocol_version = 0;
+	cdev->protocol_version = 0;
 	printf("%s: ERROR: old EC interface not supported\n", __func__);
 	return -1;
 }
 
-int cros_ec_test(struct cros_ec_dev *dev)
+int cros_ec_test(struct udevice *dev)
 {
 	struct ec_params_hello req;
 	struct ec_response_hello *resp;
@@ -691,7 +690,7 @@ int cros_ec_test(struct cros_ec_dev *dev)
 	return 0;
 }
 
-int cros_ec_flash_offset(struct cros_ec_dev *dev, enum ec_flash_region region,
+int cros_ec_flash_offset(struct udevice *dev, enum ec_flash_region region,
 		      uint32_t *offset, uint32_t *size)
 {
 	struct ec_params_flash_region_info p;
@@ -713,7 +712,7 @@ int cros_ec_flash_offset(struct cros_ec_dev *dev, enum ec_flash_region region,
 	return 0;
 }
 
-int cros_ec_flash_erase(struct cros_ec_dev *dev, uint32_t offset, uint32_t size)
+int cros_ec_flash_erase(struct udevice *dev, uint32_t offset, uint32_t size)
 {
 	struct ec_params_flash_erase p;
 
@@ -741,9 +740,8 @@ int cros_ec_flash_erase(struct cros_ec_dev *dev, uint32_t offset, uint32_t size)
  * @param size		Number of bytes to write
  * @return 0 if ok, -1 on error
  */
-static int cros_ec_flash_write_block(struct cros_ec_dev *dev,
-				     const uint8_t *data, uint32_t offset,
-				     uint32_t size)
+static int cros_ec_flash_write_block(struct udevice *dev, const uint8_t *data,
+				     uint32_t offset, uint32_t size)
 {
 	struct ec_params_flash_write *p;
 	int ret;
@@ -768,7 +766,7 @@ static int cros_ec_flash_write_block(struct cros_ec_dev *dev,
 /**
  * Return optimal flash write burst size
  */
-static int cros_ec_flash_write_burst_size(struct cros_ec_dev *dev)
+static int cros_ec_flash_write_burst_size(struct udevice *dev)
 {
 	return EC_FLASH_WRITE_VER0_SIZE;
 }
@@ -802,7 +800,7 @@ static int cros_ec_data_is_erased(const uint32_t *data, int size)
  * @param dev  Pointer to device
  * @param info Pointer to output flash info struct
  */
-int cros_ec_read_flashinfo(struct cros_ec_dev *dev,
+int cros_ec_read_flashinfo(struct udevice *dev,
 			   struct ec_response_flash_info *info)
 {
 	int ret;
@@ -815,9 +813,10 @@ int cros_ec_read_flashinfo(struct cros_ec_dev *dev,
 	return ret < sizeof(*info) ? -1 : 0;
 }
 
-int cros_ec_flash_write(struct cros_ec_dev *dev, const uint8_t *data,
+int cros_ec_flash_write(struct udevice *dev, const uint8_t *data,
 			uint32_t offset, uint32_t size)
 {
+	struct cros_ec_dev *cdev = dev_get_uclass_priv(dev);
 	uint32_t burst = cros_ec_flash_write_burst_size(dev);
 	uint32_t end, off;
 	int ret;
@@ -832,7 +831,7 @@ int cros_ec_flash_write(struct cros_ec_dev *dev, const uint8_t *data,
 
 		/* If the data is empty, there is no point in programming it */
 		todo = min(end - off, burst);
-		if (dev->optimise_flash_write &&
+		if (cdev->optimise_flash_write &&
 		    cros_ec_data_is_erased((uint32_t *)data, todo))
 			continue;
 
@@ -859,7 +858,7 @@ int cros_ec_flash_write(struct cros_ec_dev *dev, const uint8_t *data,
  * @param size		Number of bytes to read
  * @return 0 if ok, -1 on error
  */
-static int cros_ec_flash_read_block(struct cros_ec_dev *dev, uint8_t *data,
+static int cros_ec_flash_read_block(struct udevice *dev, uint8_t *data,
 				    uint32_t offset, uint32_t size)
 {
 	struct ec_params_flash_read p;
@@ -871,7 +870,7 @@ static int cros_ec_flash_read_block(struct cros_ec_dev *dev, uint8_t *data,
 			  &p, sizeof(p), data, size) >= 0 ? 0 : -1;
 }
 
-int cros_ec_flash_read(struct cros_ec_dev *dev, uint8_t *data, uint32_t offset,
+int cros_ec_flash_read(struct udevice *dev, uint8_t *data, uint32_t offset,
 		       uint32_t size)
 {
 	uint32_t burst = cros_ec_flash_write_burst_size(dev);
@@ -889,7 +888,7 @@ int cros_ec_flash_read(struct cros_ec_dev *dev, uint8_t *data, uint32_t offset,
 	return 0;
 }
 
-int cros_ec_flash_update_rw(struct cros_ec_dev *dev, const uint8_t *image,
+int cros_ec_flash_update_rw(struct udevice *dev, const uint8_t *image,
 			    int image_size)
 {
 	uint32_t rw_offset, rw_size;
@@ -928,26 +927,31 @@ int cros_ec_flash_update_rw(struct cros_ec_dev *dev, const uint8_t *image,
 	return 0;
 }
 
-int cros_ec_read_vbnvcontext(struct cros_ec_dev *dev, uint8_t *block)
+int cros_ec_read_nvdata(struct udevice *dev, uint8_t *block, int size)
 {
 	struct ec_params_vbnvcontext p;
 	int len;
 
+	if (size != EC_VBNV_BLOCK_SIZE)
+		return -EINVAL;
+
 	p.op = EC_VBNV_CONTEXT_OP_READ;
 
 	len = ec_command(dev, EC_CMD_VBNV_CONTEXT, EC_VER_VBNV_CONTEXT,
 			&p, sizeof(p), block, EC_VBNV_BLOCK_SIZE);
 	if (len < EC_VBNV_BLOCK_SIZE)
-		return -1;
+		return -EIO;
 
 	return 0;
 }
 
-int cros_ec_write_vbnvcontext(struct cros_ec_dev *dev, const uint8_t *block)
+int cros_ec_write_nvdata(struct udevice *dev, const uint8_t *block, int size)
 {
 	struct ec_params_vbnvcontext p;
 	int len;
 
+	if (size != EC_VBNV_BLOCK_SIZE)
+		return -EINVAL;
 	p.op = EC_VBNV_CONTEXT_OP_WRITE;
 	memcpy(p.block, block, sizeof(p.block));
 
@@ -961,13 +965,12 @@ int cros_ec_write_vbnvcontext(struct cros_ec_dev *dev, const uint8_t *block)
 
 int cros_ec_set_ldo(struct udevice *dev, uint8_t index, uint8_t state)
 {
-	struct cros_ec_dev *cdev = dev_get_uclass_priv(dev);
 	struct ec_params_ldo_set params;
 
 	params.index = index;
 	params.state = state;
 
-	if (ec_command_inptr(cdev, EC_CMD_LDO_SET, 0, &params, sizeof(params),
+	if (ec_command_inptr(dev, EC_CMD_LDO_SET, 0, &params, sizeof(params),
 			     NULL, 0))
 		return -1;
 
@@ -976,13 +979,12 @@ int cros_ec_set_ldo(struct udevice *dev, uint8_t index, uint8_t state)
 
 int cros_ec_get_ldo(struct udevice *dev, uint8_t index, uint8_t *state)
 {
-	struct cros_ec_dev *cdev = dev_get_uclass_priv(dev);
 	struct ec_params_ldo_get params;
 	struct ec_response_ldo_get *resp;
 
 	params.index = index;
 
-	if (ec_command_inptr(cdev, EC_CMD_LDO_GET, 0, &params, sizeof(params),
+	if (ec_command_inptr(dev, EC_CMD_LDO_GET, 0, &params, sizeof(params),
 			     (uint8_t **)&resp, sizeof(*resp)) !=
 			     sizeof(*resp))
 		return -1;
@@ -1002,12 +1004,12 @@ int cros_ec_register(struct udevice *dev)
 			     GPIOD_IS_IN);
 	cdev->optimise_flash_write = dev_read_bool(dev, "optimise-flash-write");
 
-	if (cros_ec_check_version(cdev)) {
+	if (cros_ec_check_version(dev)) {
 		debug("%s: Could not detect CROS-EC version\n", __func__);
 		return -CROS_EC_ERR_CHECK_VERSION;
 	}
 
-	if (cros_ec_read_id(cdev, id, sizeof(id))) {
+	if (cros_ec_read_id(dev, id, sizeof(id))) {
 		debug("%s: Could not read KBC ID\n", __func__);
 		return -CROS_EC_ERR_READ_ID;
 	}
@@ -1063,7 +1065,6 @@ int cros_ec_decode_ec_flash(struct udevice *dev, struct fdt_cros_ec *config)
 int cros_ec_i2c_tunnel(struct udevice *dev, int port, struct i2c_msg *in,
 		       int nmsgs)
 {
-	struct cros_ec_dev *cdev = dev_get_uclass_priv(dev);
 	union {
 		struct ec_params_i2c_passthru p;
 		uint8_t outbuf[EC_PROTO2_MAX_PARAM_SIZE];
@@ -1113,7 +1114,7 @@ int cros_ec_i2c_tunnel(struct udevice *dev, int port, struct i2c_msg *in,
 		}
 	}
 
-	rv = ec_command(cdev, EC_CMD_I2C_PASSTHRU, 0, p, pdata - (uint8_t *)p,
+	rv = ec_command(dev, EC_CMD_I2C_PASSTHRU, 0, p, pdata - (uint8_t *)p,
 			r, sizeof(*r) + read_len);
 	if (rv < 0)
 		return rv;
diff --git a/drivers/misc/cros_ec_sandbox.c b/drivers/misc/cros_ec_sandbox.c
index 47a9d26c3c7..dedad9b8573 100644
--- a/drivers/misc/cros_ec_sandbox.c
+++ b/drivers/misc/cros_ec_sandbox.c
@@ -491,9 +491,9 @@ int cros_ec_sandbox_packet(struct udevice *udev, int out_bytes, int in_bytes)
 	return in_bytes;
 }
 
-void cros_ec_check_keyboard(struct cros_ec_dev *dev)
+void cros_ec_check_keyboard(struct udevice *dev)
 {
-	struct ec_state *ec = dev_get_priv(dev->dev);
+	struct ec_state *ec = dev_get_priv(dev);
 	ulong start;
 
 	printf("Press keys for EC to detect on reset (ESC=recovery)...");
diff --git a/drivers/tpm/tpm-uclass.c b/drivers/tpm/tpm-uclass.c
index c83f53ab86b..80fa0783d58 100644
--- a/drivers/tpm/tpm-uclass.c
+++ b/drivers/tpm/tpm-uclass.c
@@ -126,8 +126,8 @@ int tpm_xfer(struct udevice *dev, const uint8_t *sendbuf, size_t send_size,
 }
 
 UCLASS_DRIVER(tpm) = {
-	.id             = UCLASS_TPM,
-	.name           = "tpm",
-	.flags          = DM_UC_FLAG_SEQ_ALIAS,
+	.id		= UCLASS_TPM,
+	.name		= "tpm",
+	.flags		= DM_UC_FLAG_SEQ_ALIAS,
 	.per_device_auto_alloc_size	= sizeof(struct tpm_chip_priv),
 };
diff --git a/include/cros_ec.h b/include/cros_ec.h
index 60ecefbd40e..afd99aae946 100644
--- a/include/cros_ec.h
+++ b/include/cros_ec.h
@@ -69,7 +69,7 @@ struct fdt_cros_ec {
  * @param maxlen	Maximum length of the ID field
  * @return 0 if ok, -1 on error
  */
-int cros_ec_read_id(struct cros_ec_dev *dev, char *id, int maxlen);
+int cros_ec_read_id(struct udevice *dev, char *id, int maxlen);
 
 /**
  * Read a keyboard scan from the CROS-EC device
@@ -89,8 +89,8 @@ int cros_ec_scan_keyboard(struct udevice *dev, struct mbkp_keyscan *scan);
  * @param image		Destination for image identifier
  * @return 0 if ok, <0 on error
  */
-int cros_ec_read_current_image(struct cros_ec_dev *dev,
-		enum ec_current_image *image);
+int cros_ec_read_current_image(struct udevice *dev,
+			       enum ec_current_image *image);
 
 /**
  * Read the hash of the CROS-EC device firmware.
@@ -99,8 +99,7 @@ int cros_ec_read_current_image(struct cros_ec_dev *dev,
  * @param hash		Destination for hash information
  * @return 0 if ok, <0 on error
  */
-int cros_ec_read_hash(struct cros_ec_dev *dev,
-		struct ec_response_vboot_hash *hash);
+int cros_ec_read_hash(struct udevice *dev, struct ec_response_vboot_hash *hash);
 
 /**
  * Send a reboot command to the CROS-EC device.
@@ -112,8 +111,7 @@ int cros_ec_read_hash(struct cros_ec_dev *dev,
  * @param flags         Flags for reboot command (EC_REBOOT_FLAG_*)
  * @return 0 if ok, <0 on error
  */
-int cros_ec_reboot(struct cros_ec_dev *dev, enum ec_reboot_cmd cmd,
-		uint8_t flags);
+int cros_ec_reboot(struct udevice *dev, enum ec_reboot_cmd cmd, uint8_t flags);
 
 /**
  * Check if the CROS-EC device has an interrupt pending.
@@ -144,7 +142,7 @@ enum {
  *	expected), -ve if we should have an cros_ec device but failed to find
  *	one, or init failed (-CROS_EC_ERR_...).
  */
-int cros_ec_init(const void *blob, struct cros_ec_dev **cros_ecp);
+int cros_ec_init(const void *blob, struct udevice**cros_ecp);
 
 /**
  * Read information about the keyboard matrix
@@ -152,8 +150,7 @@ int cros_ec_init(const void *blob, struct cros_ec_dev **cros_ecp);
  * @param dev		CROS-EC device
  * @param info		Place to put the info structure
  */
-int cros_ec_info(struct cros_ec_dev *dev,
-		struct ec_response_mkbp_info *info);
+int cros_ec_info(struct udevice *dev, struct ec_response_mkbp_info *info);
 
 /**
  * Read the host event flags
@@ -162,7 +159,7 @@ int cros_ec_info(struct cros_ec_dev *dev,
  * @param events_ptr	Destination for event flags.  Not changed on error.
  * @return 0 if ok, <0 on error
  */
-int cros_ec_get_host_events(struct cros_ec_dev *dev, uint32_t *events_ptr);
+int cros_ec_get_host_events(struct udevice *dev, uint32_t *events_ptr);
 
 /**
  * Clear the specified host event flags
@@ -171,7 +168,7 @@ int cros_ec_get_host_events(struct cros_ec_dev *dev, uint32_t *events_ptr);
  * @param events	Event flags to clear
  * @return 0 if ok, <0 on error
  */
-int cros_ec_clear_host_events(struct cros_ec_dev *dev, uint32_t events);
+int cros_ec_clear_host_events(struct udevice *dev, uint32_t events);
 
 /**
  * Get/set flash protection
@@ -184,9 +181,9 @@ int cros_ec_clear_host_events(struct cros_ec_dev *dev, uint32_t events);
  * @param prot          Destination for updated protection state from EC.
  * @return 0 if ok, <0 on error
  */
-int cros_ec_flash_protect(struct cros_ec_dev *dev,
-		       uint32_t set_mask, uint32_t set_flags,
-		       struct ec_response_flash_protect *resp);
+int cros_ec_flash_protect(struct udevice *dev, uint32_t set_mask,
+			  uint32_t set_flags,
+			  struct ec_response_flash_protect *resp);
 
 
 /**
@@ -195,7 +192,7 @@ int cros_ec_flash_protect(struct cros_ec_dev *dev,
  * @param dev		CROS-EC device
  * @return 0 if ok, <0 if the test failed
  */
-int cros_ec_test(struct cros_ec_dev *dev);
+int cros_ec_test(struct udevice *dev);
 
 /**
  * Update the EC RW copy.
@@ -205,8 +202,8 @@ int cros_ec_test(struct cros_ec_dev *dev);
  * @param imafge_size	content length
  * @return 0 if ok, <0 if the test failed
  */
-int cros_ec_flash_update_rw(struct cros_ec_dev *dev,
-			 const uint8_t  *image, int image_size);
+int cros_ec_flash_update_rw(struct udevice *dev, const uint8_t  *image,
+			    int image_size);
 
 /**
  * Return a pointer to the board's CROS-EC device
@@ -249,8 +246,7 @@ void cros_ec_dump_data(const char *name, int cmd, const uint8_t *data, int len);
  */
 int cros_ec_calc_checksum(const uint8_t *data, int size);
 
-int cros_ec_flash_erase(struct cros_ec_dev *dev, uint32_t offset,
-		uint32_t size);
+int cros_ec_flash_erase(struct udevice *dev, uint32_t offset, uint32_t size);
 
 /**
  * Read data from the flash
@@ -267,8 +263,8 @@ int cros_ec_flash_erase(struct cros_ec_dev *dev, uint32_t offset,
  * @param size		Number of bytes to read
  * @return 0 if ok, -1 on error
  */
-int cros_ec_flash_read(struct cros_ec_dev *dev, uint8_t *data, uint32_t offset,
-		    uint32_t size);
+int cros_ec_flash_read(struct udevice *dev, uint8_t *data, uint32_t offset,
+		       uint32_t size);
 
 /**
  * Read back flash parameters
@@ -278,8 +274,8 @@ int cros_ec_flash_read(struct cros_ec_dev *dev, uint8_t *data, uint32_t offset,
  * @param dev  Pointer to device
  * @param info Pointer to output flash info struct
  */
-int cros_ec_read_flashinfo(struct cros_ec_dev *dev,
-			  struct ec_response_flash_info *info);
+int cros_ec_read_flashinfo(struct udevice *dev,
+			   struct ec_response_flash_info *info);
 
 /**
  * Write data to the flash
@@ -299,8 +295,8 @@ int cros_ec_read_flashinfo(struct cros_ec_dev *dev,
  * @param size		Number of bytes to write
  * @return 0 if ok, -1 on error
  */
-int cros_ec_flash_write(struct cros_ec_dev *dev, const uint8_t *data,
-		     uint32_t offset, uint32_t size);
+int cros_ec_flash_write(struct udevice *dev, const uint8_t *data,
+			uint32_t offset, uint32_t size);
 
 /**
  * Obtain position and size of a flash region
@@ -311,18 +307,18 @@ int cros_ec_flash_write(struct cros_ec_dev *dev, const uint8_t *data,
  * @param size		Returns size of flash region
  * @return 0 if ok, -1 on error
  */
-int cros_ec_flash_offset(struct cros_ec_dev *dev, enum ec_flash_region region,
-		      uint32_t *offset, uint32_t *size);
+int cros_ec_flash_offset(struct udevice *dev, enum ec_flash_region region,
+			 uint32_t *offset, uint32_t *size);
 
 /**
- * Read/write VbNvContext from/to a CROS-EC device.
+ * Read/write non-volatile data from/to a CROS-EC device.
  *
  * @param dev		CROS-EC device
  * @param block		Buffer of VbNvContext to be read/write
  * @return 0 if ok, -1 on error
  */
-int cros_ec_read_vbnvcontext(struct cros_ec_dev *dev, uint8_t *block);
-int cros_ec_write_vbnvcontext(struct cros_ec_dev *dev, const uint8_t *block);
+int cros_ec_read_nvdata(struct udevice *dev, uint8_t *block, int size);
+int cros_ec_write_nvdata(struct udevice *dev, const uint8_t *block, int size);
 
 /**
  * Read the version information for the EC images
@@ -331,8 +327,8 @@ int cros_ec_write_vbnvcontext(struct cros_ec_dev *dev, const uint8_t *block);
  * @param versionp	This is set to point to the version information
  * @return 0 if ok, -1 on error
  */
-int cros_ec_read_version(struct cros_ec_dev *dev,
-		       struct ec_response_get_version **versionp);
+int cros_ec_read_version(struct udevice *dev,
+			 struct ec_response_get_version **versionp);
 
 /**
  * Read the build information for the EC
@@ -341,7 +337,7 @@ int cros_ec_read_version(struct cros_ec_dev *dev,
  * @param versionp	This is set to point to the build string
  * @return 0 if ok, -1 on error
  */
-int cros_ec_read_build_info(struct cros_ec_dev *dev, char **strp);
+int cros_ec_read_build_info(struct udevice *dev, char **strp);
 
 /**
  * Switch on/off a LDO / FET.
@@ -387,7 +383,7 @@ int cros_ec_decode_ec_flash(struct udevice *dev, struct fdt_cros_ec *config);
  *
  * @param ec		CROS-EC device
  */
-void cros_ec_check_keyboard(struct cros_ec_dev *dev);
+void cros_ec_check_keyboard(struct udevice *dev);
 
 struct i2c_msg;
 /*
-- 
2.19.0.605.g01d371f741-goog

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 19/45] cros: Adjust board_get_cros_ec_dev() to return a udevice
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (17 preceding siblings ...)
  2018-10-01 18:22 ` [U-Boot] [PATCH 18/45] cros: Update cros_ec code to use struct udevice Simon Glass
@ 2018-10-01 18:22 ` Simon Glass
  2018-10-01 18:22 ` [U-Boot] [PATCH 20/45] dm: spi: Add logging of some return values Simon Glass
                   ` (65 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: Simon Glass @ 2018-10-01 18:22 UTC (permalink / raw)
  To: u-boot

Rather than returning what is effectively an internal data structure,
return the cros EC device itself.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 common/cros_ec.c  | 4 ++--
 include/cros_ec.h | 4 +---
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/common/cros_ec.c b/common/cros_ec.c
index 1a0caf80dde..4ca15e19d5f 100644
--- a/common/cros_ec.c
+++ b/common/cros_ec.c
@@ -13,7 +13,7 @@
 #include <dm.h>
 #include <errno.h>
 
-struct cros_ec_dev *board_get_cros_ec_dev(void)
+struct udevice *board_get_cros_ec_dev(void)
 {
 	struct udevice *dev;
 	int ret;
@@ -23,7 +23,7 @@ struct cros_ec_dev *board_get_cros_ec_dev(void)
 		debug("%s: Error %d\n", __func__, ret);
 		return NULL;
 	}
-	return dev_get_uclass_priv(dev);
+	return dev;
 }
 
 int cros_ec_get_error(void)
diff --git a/include/cros_ec.h b/include/cros_ec.h
index afd99aae946..5576bcf32ee 100644
--- a/include/cros_ec.h
+++ b/include/cros_ec.h
@@ -208,11 +208,9 @@ int cros_ec_flash_update_rw(struct udevice *dev, const uint8_t  *image,
 /**
  * Return a pointer to the board's CROS-EC device
  *
- * This should be implemented by board files.
- *
  * @return pointer to CROS-EC device, or NULL if none is available
  */
-struct cros_ec_dev *board_get_cros_ec_dev(void);
+struct udevice *board_get_cros_ec_dev(void);
 
 struct dm_cros_ec_ops {
 	int (*check_version)(struct udevice *dev);
-- 
2.19.0.605.g01d371f741-goog

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 20/45] dm: spi: Add logging of some return values
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (18 preceding siblings ...)
  2018-10-01 18:22 ` [U-Boot] [PATCH 19/45] cros: Adjust board_get_cros_ec_dev() to return a udevice Simon Glass
@ 2018-10-01 18:22 ` Simon Glass
  2018-10-01 18:22 ` [U-Boot] [PATCH 21/45] fdt: Remove fdtdec_decode_region() function Simon Glass
                   ` (64 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: Simon Glass @ 2018-10-01 18:22 UTC (permalink / raw)
  To: u-boot

When SPI flash operations fail it is helpful to be able to see the error
codes and where they are generated. Add logging to capture this
information for read operations.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/mtd/spi/sf-uclass.c | 6 +++---
 drivers/mtd/spi/sf_probe.c  | 2 +-
 drivers/mtd/spi/spi_flash.c | 8 ++++----
 drivers/spi/spi-uclass.c    | 6 +++---
 4 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/mtd/spi/sf-uclass.c b/drivers/mtd/spi/sf-uclass.c
index 3858f77a6dd..662525f016f 100644
--- a/drivers/mtd/spi/sf-uclass.c
+++ b/drivers/mtd/spi/sf-uclass.c
@@ -14,18 +14,18 @@ DECLARE_GLOBAL_DATA_PTR;
 
 int spi_flash_read_dm(struct udevice *dev, u32 offset, size_t len, void *buf)
 {
-	return sf_get_ops(dev)->read(dev, offset, len, buf);
+	return log_ret(sf_get_ops(dev)->read(dev, offset, len, buf));
 }
 
 int spi_flash_write_dm(struct udevice *dev, u32 offset, size_t len,
 		       const void *buf)
 {
-	return sf_get_ops(dev)->write(dev, offset, len, buf);
+	return log_ret(sf_get_ops(dev)->write(dev, offset, len, buf));
 }
 
 int spi_flash_erase_dm(struct udevice *dev, u32 offset, size_t len)
 {
-	return sf_get_ops(dev)->erase(dev, offset, len);
+	return log_ret(sf_get_ops(dev)->erase(dev, offset, len));
 }
 
 /*
diff --git a/drivers/mtd/spi/sf_probe.c b/drivers/mtd/spi/sf_probe.c
index 42c7cdedf6f..94fde2ae7a3 100644
--- a/drivers/mtd/spi/sf_probe.c
+++ b/drivers/mtd/spi/sf_probe.c
@@ -97,7 +97,7 @@ static int spi_flash_std_read(struct udevice *dev, u32 offset, size_t len,
 {
 	struct spi_flash *flash = dev_get_uclass_priv(dev);
 
-	return spi_flash_cmd_read_ops(flash, offset, len, buf);
+	return log_ret(spi_flash_cmd_read_ops(flash, offset, len, buf));
 }
 
 static int spi_flash_std_write(struct udevice *dev, u32 offset, size_t len,
diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c
index 7113c855fe4..92300603644 100644
--- a/drivers/mtd/spi/spi_flash.c
+++ b/drivers/mtd/spi/spi_flash.c
@@ -471,14 +471,14 @@ int spi_flash_cmd_read_ops(struct spi_flash *flash, u32 offset,
 	u8 cmdsz;
 	u32 remain_len, read_len, read_addr;
 	int bank_sel = 0;
-	int ret = -1;
+	int ret = 0;
 
 	/* Handle memory-mapped SPI */
 	if (flash->memory_map) {
 		ret = spi_claim_bus(spi);
 		if (ret) {
 			debug("SF: unable to claim SPI bus\n");
-			return ret;
+			return log_ret(ret);
 		}
 		spi_xfer(spi, 0, NULL, NULL, SPI_XFER_MMAP);
 		spi_flash_copy_mmap(data, flash->memory_map + offset, len);
@@ -501,7 +501,7 @@ int spi_flash_cmd_read_ops(struct spi_flash *flash, u32 offset,
 #ifdef CONFIG_SPI_FLASH_BAR
 		ret = write_bar(flash, read_addr);
 		if (ret < 0)
-			return ret;
+			return log_ret(ret);
 		bank_sel = flash->bank_curr;
 #endif
 		remain_len = ((SPI_FLASH_16MB_BOUN << flash->shift) *
@@ -531,7 +531,7 @@ int spi_flash_cmd_read_ops(struct spi_flash *flash, u32 offset,
 	ret = clean_bar(flash);
 #endif
 
-	return ret;
+	return log_ret(ret);
 }
 
 #ifdef CONFIG_SPI_FLASH_SST
diff --git a/drivers/spi/spi-uclass.c b/drivers/spi/spi-uclass.c
index c517d066f69..b84255bd274 100644
--- a/drivers/spi/spi-uclass.c
+++ b/drivers/spi/spi-uclass.c
@@ -63,11 +63,11 @@ int dm_spi_claim_bus(struct udevice *dev)
 		int ret = spi_set_speed_mode(bus, speed, slave->mode);
 
 		if (ret)
-			return ret;
+			return log_ret(ret);
 		slave->speed = speed;
 	}
 
-	return ops->claim_bus ? ops->claim_bus(dev) : 0;
+	return log_ret(ops->claim_bus ? ops->claim_bus(dev) : 0);
 }
 
 void dm_spi_release_bus(struct udevice *dev)
@@ -92,7 +92,7 @@ int dm_spi_xfer(struct udevice *dev, unsigned int bitlen,
 
 int spi_claim_bus(struct spi_slave *slave)
 {
-	return dm_spi_claim_bus(slave->dev);
+	return log_ret(dm_spi_claim_bus(slave->dev));
 }
 
 void spi_release_bus(struct spi_slave *slave)
-- 
2.19.0.605.g01d371f741-goog

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 21/45] fdt: Remove fdtdec_decode_region() function
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (19 preceding siblings ...)
  2018-10-01 18:22 ` [U-Boot] [PATCH 20/45] dm: spi: Add logging of some return values Simon Glass
@ 2018-10-01 18:22 ` Simon Glass
  2018-10-01 18:22 ` [U-Boot] [PATCH 22/45] video: Adjust video_clear() to return an error Simon Glass
                   ` (63 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: Simon Glass @ 2018-10-01 18:22 UTC (permalink / raw)
  To: u-boot

This function is not used in U-Boot now. Remove it along with its 'memory'
version.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 include/fdtdec.h | 45 --------------------------
 lib/fdtdec.c     | 83 ------------------------------------------------
 2 files changed, 128 deletions(-)

diff --git a/include/fdtdec.h b/include/fdtdec.h
index 83be06403d8..c26df50543a 100644
--- a/include/fdtdec.h
+++ b/include/fdtdec.h
@@ -802,23 +802,6 @@ int fdtdec_get_byte_array(const void *blob, int node, const char *prop_name,
 const u8 *fdtdec_locate_byte_array(const void *blob, int node,
 			     const char *prop_name, int count);
 
-/**
- * Look up a property in a node which contains a memory region address and
- * size. Then return a pointer to this address.
- *
- * The property must hold one address with a length. This is only tested on
- * 32-bit machines.
- *
- * @param blob		FDT blob
- * @param node		node to examine
- * @param prop_name	name of property to find
- * @param basep		Returns base address of region
- * @param size		Returns size of region
- * @return 0 if ok, -1 on error (property not found)
- */
-int fdtdec_decode_region(const void *blob, int node, const char *prop_name,
-			 fdt_addr_t *basep, fdt_size_t *sizep);
-
 /**
  * Obtain an indexed resource from a device property.
  *
@@ -849,34 +832,6 @@ int fdt_get_named_resource(const void *fdt, int node, const char *property,
 			   const char *prop_names, const char *name,
 			   struct fdt_resource *res);
 
-/**
- * Decode a named region within a memory bank of a given type.
- *
- * This function handles selection of a memory region. The region is
- * specified as an offset/size within a particular type of memory.
- *
- * The properties used are:
- *
- *	<mem_type>-memory<suffix> for the name of the memory bank
- *	<mem_type>-offset<suffix> for the offset in that bank
- *
- * The property value must have an offset and a size. The function checks
- * that the region is entirely within the memory bank.5
- *
- * @param blob		FDT blob
- * @param node		Node containing the properties (-1 for /config)
- * @param mem_type	Type of memory to use, which is a name, such as
- *			"u-boot" or "kernel".
- * @param suffix	String to append to the memory/offset
- *			property names
- * @param basep		Returns base of region
- * @param sizep		Returns size of region
- * @return 0 if OK, -ive on error
- */
-int fdtdec_decode_memory_region(const void *blob, int node,
-				const char *mem_type, const char *suffix,
-				fdt_addr_t *basep, fdt_size_t *sizep);
-
 /* Display timings from linux include/video/display_timing.h */
 enum display_flags {
 	DISPLAY_FLAGS_HSYNC_LOW		= 1 << 0,
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index 74196ce7f9f..b1b39254bfd 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -922,28 +922,6 @@ char *fdtdec_get_config_string(const void *blob, const char *prop_name)
 	return (char *)nodep;
 }
 
-int fdtdec_decode_region(const void *blob, int node, const char *prop_name,
-			 fdt_addr_t *basep, fdt_size_t *sizep)
-{
-	const fdt_addr_t *cell;
-	int len;
-
-	debug("%s: %s: %s\n", __func__, fdt_get_name(blob, node, NULL),
-	      prop_name);
-	cell = fdt_getprop(blob, node, prop_name, &len);
-	if (!cell || (len < sizeof(fdt_addr_t) * 2)) {
-		debug("cell=%p, len=%d\n", cell, len);
-		return -1;
-	}
-
-	*basep = fdt_addr_to_cpu(*cell);
-	*sizep = fdt_size_to_cpu(cell[1]);
-	debug("%s: base=%08lx, size=%lx\n", __func__, (ulong)*basep,
-	      (ulong)*sizep);
-
-	return 0;
-}
-
 u64 fdtdec_get_number(const fdt32_t *ptr, unsigned int cells)
 {
 	u64 number = 0;
@@ -1002,67 +980,6 @@ int fdt_get_named_resource(const void *fdt, int node, const char *property,
 	return fdt_get_resource(fdt, node, property, index, res);
 }
 
-int fdtdec_decode_memory_region(const void *blob, int config_node,
-				const char *mem_type, const char *suffix,
-				fdt_addr_t *basep, fdt_size_t *sizep)
-{
-	char prop_name[50];
-	const char *mem;
-	fdt_size_t size, offset_size;
-	fdt_addr_t base, offset;
-	int node;
-
-	if (config_node == -1) {
-		config_node = fdt_path_offset(blob, "/config");
-		if (config_node < 0) {
-			debug("%s: Cannot find /config node\n", __func__);
-			return -ENOENT;
-		}
-	}
-	if (!suffix)
-		suffix = "";
-
-	snprintf(prop_name, sizeof(prop_name), "%s-memory%s", mem_type,
-		 suffix);
-	mem = fdt_getprop(blob, config_node, prop_name, NULL);
-	if (!mem) {
-		debug("%s: No memory type for '%s', using /memory\n", __func__,
-		      prop_name);
-		mem = "/memory";
-	}
-
-	node = fdt_path_offset(blob, mem);
-	if (node < 0) {
-		debug("%s: Failed to find node '%s': %s\n", __func__, mem,
-		      fdt_strerror(node));
-		return -ENOENT;
-	}
-
-	/*
-	 * Not strictly correct - the memory may have multiple banks. We just
-	 * use the first
-	 */
-	if (fdtdec_decode_region(blob, node, "reg", &base, &size)) {
-		debug("%s: Failed to decode memory region %s\n", __func__,
-		      mem);
-		return -EINVAL;
-	}
-
-	snprintf(prop_name, sizeof(prop_name), "%s-offset%s", mem_type,
-		 suffix);
-	if (fdtdec_decode_region(blob, config_node, prop_name, &offset,
-				 &offset_size)) {
-		debug("%s: Failed to decode memory region '%s'\n", __func__,
-		      prop_name);
-		return -EINVAL;
-	}
-
-	*basep = base + offset;
-	*sizep = offset_size;
-
-	return 0;
-}
-
 static int decode_timing_property(const void *blob, int node, const char *name,
 				  struct timing_entry *result)
 {
-- 
2.19.0.605.g01d371f741-goog

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 22/45] video: Adjust video_clear() to return an error
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (20 preceding siblings ...)
  2018-10-01 18:22 ` [U-Boot] [PATCH 21/45] fdt: Remove fdtdec_decode_region() function Simon Glass
@ 2018-10-01 18:22 ` Simon Glass
  2018-10-01 19:23   ` Anatolij Gustschin
  2018-10-09 23:55   ` sjg at google.com
  2018-10-01 18:22 ` [U-Boot] [PATCH 23/45] tpm: Use livetree and allow children Simon Glass
                   ` (62 subsequent siblings)
  84 siblings, 2 replies; 106+ messages in thread
From: Simon Glass @ 2018-10-01 18:22 UTC (permalink / raw)
  To: u-boot

All driver-model operation should return an error code. Adjust this
function to do so also.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/video/video-uclass.c | 4 +++-
 include/video.h              | 3 ++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c
index fea0886c415..44dfa71b6f4 100644
--- a/drivers/video/video-uclass.c
+++ b/drivers/video/video-uclass.c
@@ -86,7 +86,7 @@ int video_reserve(ulong *addrp)
 	return 0;
 }
 
-void video_clear(struct udevice *dev)
+int video_clear(struct udevice *dev)
 {
 	struct video_priv *priv = dev_get_uclass_priv(dev);
 
@@ -111,6 +111,8 @@ void video_clear(struct udevice *dev)
 		memset(priv->fb, priv->colour_bg, priv->fb_size);
 		break;
 	}
+
+	return 0;
 }
 
 void video_set_default_colors(struct video_priv *priv)
diff --git a/include/video.h b/include/video.h
index cd5558f86eb..ab416c1cfac 100644
--- a/include/video.h
+++ b/include/video.h
@@ -120,8 +120,9 @@ int video_reserve(ulong *addrp);
  * video_clear() - Clear a device's frame buffer to background color.
  *
  * @dev:	Device to clear
+ * @return 0
  */
-void video_clear(struct udevice *dev);
+int video_clear(struct udevice *dev);
 
 /**
  * video_sync() - Sync a device's frame buffer with its hardware
-- 
2.19.0.605.g01d371f741-goog

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 23/45] tpm: Use livetree and allow children
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (21 preceding siblings ...)
  2018-10-01 18:22 ` [U-Boot] [PATCH 22/45] video: Adjust video_clear() to return an error Simon Glass
@ 2018-10-01 18:22 ` Simon Glass
  2018-10-01 18:22 ` [U-Boot] [PATCH 24/45] tpm: Tidy up logging in tpm-common.c Simon Glass
                   ` (61 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: Simon Glass @ 2018-10-01 18:22 UTC (permalink / raw)
  To: u-boot

Adjust the TPM drivers to use livetree (only one does not). Also,
sometimes TPMs can have child devices if they provide a service to the
system (such as storing secure data), so permit that.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/misc/cros_ec.c    | 6 +++---
 drivers/tpm/tpm-uclass.c  | 1 +
 drivers/tpm/tpm_tis_lpc.c | 2 +-
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/misc/cros_ec.c b/drivers/misc/cros_ec.c
index a92806c46c9..5ccf8ad359b 100644
--- a/drivers/misc/cros_ec.c
+++ b/drivers/misc/cros_ec.c
@@ -263,9 +263,9 @@ static int send_command(struct cros_ec_dev *dev, uint8_t cmd, int cmd_version,
  * @param din_len       Maximum size of response in bytes
  * @return number of bytes in response, or -ve on error
  */
-static int ec_command_inptr(struct udevice *dev, uint8_t cmd,
-			    int cmd_version, const void *dout, int dout_len,
-			    uint8_t **dinp, int din_len)
+static int ec_command_inptr(struct udevice *dev, uint8_t cmd, int cmd_version,
+			    const void *dout, int dout_len, uint8_t **dinp,
+			    int din_len)
 {
 	struct cros_ec_dev *cdev = dev_get_uclass_priv(dev);
 	uint8_t *din = NULL;
diff --git a/drivers/tpm/tpm-uclass.c b/drivers/tpm/tpm-uclass.c
index 80fa0783d58..455f82b1c2b 100644
--- a/drivers/tpm/tpm-uclass.c
+++ b/drivers/tpm/tpm-uclass.c
@@ -129,5 +129,6 @@ UCLASS_DRIVER(tpm) = {
 	.id		= UCLASS_TPM,
 	.name		= "tpm",
 	.flags		= DM_UC_FLAG_SEQ_ALIAS,
+	.post_bind	= dm_scan_fdt_dev,
 	.per_device_auto_alloc_size	= sizeof(struct tpm_chip_priv),
 };
diff --git a/drivers/tpm/tpm_tis_lpc.c b/drivers/tpm/tpm_tis_lpc.c
index 7664bb1a605..e993fd9f833 100644
--- a/drivers/tpm/tpm_tis_lpc.c
+++ b/drivers/tpm/tpm_tis_lpc.c
@@ -164,7 +164,7 @@ static int tpm_tis_lpc_probe(struct udevice *dev)
 	u32 didvid;
 	ulong chip_type = dev_get_driver_data(dev);
 
-	addr = devfdt_get_addr(dev);
+	addr = dev_read_addr(dev);
 	if (addr == FDT_ADDR_T_NONE)
 		return -EINVAL;
 	priv->regs = map_sysmem(addr, 0);
-- 
2.19.0.605.g01d371f741-goog

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 24/45] tpm: Tidy up logging in tpm-common.c
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (22 preceding siblings ...)
  2018-10-01 18:22 ` [U-Boot] [PATCH 23/45] tpm: Use livetree and allow children Simon Glass
@ 2018-10-01 18:22 ` Simon Glass
  2018-10-01 18:22 ` [U-Boot] [PATCH 25/45] tpm: Add a few new commands for v1 Simon Glass
                   ` (60 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: Simon Glass @ 2018-10-01 18:22 UTC (permalink / raw)
  To: u-boot

At present this file uses logging but it should use the new macros. Update
it and add a log message for an error.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 lib/tpm-common.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/lib/tpm-common.c b/lib/tpm-common.c
index 43b530865a0..a440639cec3 100644
--- a/lib/tpm-common.c
+++ b/lib/tpm-common.c
@@ -4,6 +4,8 @@
  * Coypright (c) 2013 Guntermann & Drunck GmbH
  */
 
+#define LOG_CATEGORY UCLASS_TPM
+
 #include <common.h>
 #include <dm.h>
 #include <asm/unaligned.h>
@@ -110,6 +112,8 @@ int unpack_byte_string(const u8 *str, size_t size, const char *format, ...)
 
 		if (offset + length > size) {
 			va_end(args);
+			log_err("Failed to read: size=%d, offset=%x, len=%x\n",
+				size, offset, length);
 			return -1;
 		}
 
@@ -176,10 +180,10 @@ u32 tpm_sendrecv_command(const void *command, void *response, size_t *size_ptr)
 
 	ret = tpm_return_code(response);
 
-	log(LOGC_NONE, LOGL_DEBUG, "TPM response [ret:%d]: ", ret);
+	log_debug("TPM response [ret:%d]: ", ret);
 	for (i = 0; i < response_length; i++)
-		log(LOGC_NONE, LOGL_DEBUG, "%02x ", ((u8 *)response)[i]);
-	log(LOGC_NONE, LOGL_DEBUG, "\n");
+		log_debug("%02x ", ((u8 *)response)[i]);
+	log_debug("\n");
 
 	return ret;
 }
-- 
2.19.0.605.g01d371f741-goog

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 25/45] tpm: Add a few new commands for v1
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (23 preceding siblings ...)
  2018-10-01 18:22 ` [U-Boot] [PATCH 24/45] tpm: Tidy up logging in tpm-common.c Simon Glass
@ 2018-10-01 18:22 ` Simon Glass
  2018-10-01 18:22 ` [U-Boot] [PATCH 26/45] binman: Move to three-digit test-file numbers Simon Glass
                   ` (59 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: Simon Glass @ 2018-10-01 18:22 UTC (permalink / raw)
  To: u-boot

These are needed for the 2018 version of Chromium OS vboot. Add an
implementation for TPM v1, with v2 to come later.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 cmd/tpm_test.c   | 15 -----------
 include/tpm-v1.h | 28 ++++++++++++++++++++
 lib/tpm-v1.c     | 68 +++++++++++++++++++++++++++++++++++++++++++++---
 3 files changed, 93 insertions(+), 18 deletions(-)

diff --git a/cmd/tpm_test.c b/cmd/tpm_test.c
index 35f3c96e3de..f21ad5d3cf9 100644
--- a/cmd/tpm_test.c
+++ b/cmd/tpm_test.c
@@ -62,14 +62,6 @@ static uint32_t tpm_get_flags(uint8_t *disable, uint8_t *deactivated,
 	return 0;
 }
 
-static uint32_t tpm_set_global_lock(void)
-{
-	uint32_t x;
-
-	debug("TPM: Set global lock\n");
-	return tpm_nv_write_value(INDEX0, (uint8_t *)&x, 0);
-}
-
 static uint32_t tpm_nv_write_value_lock(uint32_t index)
 {
 	debug("TPM: Write lock 0x%x\n", index);
@@ -77,13 +69,6 @@ static uint32_t tpm_nv_write_value_lock(uint32_t index)
 	return tpm_nv_write_value(index, NULL, 0);
 }
 
-static uint32_t tpm_nv_set_locked(void)
-{
-	debug("TPM: Set NV locked\n");
-
-	return tpm_nv_define_space(TPM_NV_INDEX_LOCK, 0, 0);
-}
-
 static int tpm_is_owned(void)
 {
 	uint8_t response[TPM_PUBEK_SIZE];
diff --git a/include/tpm-v1.h b/include/tpm-v1.h
index f9ffbb26561..be2eca946fb 100644
--- a/include/tpm-v1.h
+++ b/include/tpm-v1.h
@@ -525,4 +525,32 @@ u32 tpm_find_key_sha1(const u8 auth[20], const u8 pubkey_digest[20],
  */
 u32 tpm_get_random(void *data, u32 count);
 
+/**
+ * tpm_finalise_physical_presence() - Finalise physical presence
+ *
+ * @return return code of the operation (0 = success)
+ */
+u32 tpm_finalise_physical_presence(void);
+
+/**
+ * tpm_nv_set_locked() - lock the non-volatile space
+ *
+ * @return return code of the operation (0 = success)
+ */
+u32 tpm_nv_set_locked(void);
+
+/**
+ * tpm_set_global_lock() - set the global lock
+ *
+ * @return return code of the operation (0 = success)
+ */
+u32 tpm_set_global_lock(void);
+
+/**
+ * tpm_resume() - start up the TPM from resume (after suspend)
+ *
+ * @return return code of the operation (0 = success)
+ */
+u32 tpm_resume(void);
+
 #endif /* __TPM_V1_H */
diff --git a/lib/tpm-v1.c b/lib/tpm-v1.c
index 7aecb24f921..9d45c3d3bf6 100644
--- a/lib/tpm-v1.c
+++ b/lib/tpm-v1.c
@@ -4,6 +4,8 @@
  * Coypright (c) 2013 Guntermann & Drunck GmbH
  */
 
+#define LOG_CATEGORY UCLASS_TPM
+
 #include <common.h>
 #include <dm.h>
 #include <asm/unaligned.h>
@@ -45,6 +47,11 @@ u32 tpm_startup(enum tpm_startup_type mode)
 	return tpm_sendrecv_command(buf, NULL, NULL);
 }
 
+u32 tpm_resume(void)
+{
+	return tpm_startup(TPM_ST_STATE);
+}
+
 u32 tpm_self_test_full(void)
 {
 	const u8 command[10] = {
@@ -61,6 +68,34 @@ u32 tpm_continue_self_test(void)
 	return tpm_sendrecv_command(command, NULL, NULL);
 }
 
+u32 tpm_clear_and_reenable(void)
+{
+	u32 ret;
+
+	log_info("TPM: Clear and re-enable\n");
+	ret = tpm_force_clear();
+	if (ret != TPM_SUCCESS) {
+		log_err("Can't initiate a force clear\n");
+		return ret;
+	}
+
+#if IS_ENABLED(CONFIG_TPM_V1)
+	ret = tpm_physical_enable();
+	if (ret != TPM_SUCCESS) {
+		log_err("TPM: Can't set enabled state\n");
+		return ret;
+	}
+
+	ret = tpm_physical_set_deactivated(0);
+	if (ret != TPM_SUCCESS) {
+		log_err("TPM: Can't set deactivated state\n");
+		return ret;
+	}
+#endif
+
+	return TPM_SUCCESS;
+}
+
 u32 tpm_nv_define_space(u32 index, u32 perm, u32 size)
 {
 	const u8 command[101] = {
@@ -104,6 +139,11 @@ u32 tpm_nv_define_space(u32 index, u32 perm, u32 size)
 	return tpm_sendrecv_command(buf, NULL, NULL);
 }
 
+u32 tpm_nv_set_locked(void)
+{
+	return tpm_nv_define_space(TPM_NV_INDEX_LOCK, 0, 0);
+}
+
 u32 tpm_nv_read_value(u32 index, void *data, u32 count)
 {
 	const u8 command[22] = {
@@ -168,6 +208,13 @@ u32 tpm_nv_write_value(u32 index, const void *data, u32 length)
 	return 0;
 }
 
+uint32_t tpm_set_global_lock(void)
+{
+	u32 x;
+
+	return tpm_nv_write_value(TPM_NV_INDEX_0, (uint8_t *)&x, 0);
+}
+
 u32 tpm_extend(u32 index, const void *in_digest, void *out_digest)
 {
 	const u8 command[34] = {
@@ -243,6 +290,15 @@ u32 tpm_tsc_physical_presence(u16 presence)
 	return tpm_sendrecv_command(buf, NULL, NULL);
 }
 
+u32 tpm_finalise_physical_presence(void)
+{
+	const u8 command[12] = {
+		0x0, 0xc1, 0x0, 0x0, 0x0, 0xc, 0x40, 0x0, 0x0, 0xa, 0x2, 0xa0,
+	};
+
+	return tpm_sendrecv_command(command, NULL, NULL);
+}
+
 u32 tpm_read_pubek(void *data, size_t count)
 {
 	const u8 command[30] = {
@@ -377,13 +433,19 @@ u32 tpm_get_permanent_flags(struct tpm_permanent_flags *pflags)
 	if (err)
 		return err;
 	if (unpack_byte_string(response, response_length, "d",
-			       data_size_offset, &data_size))
+			       data_size_offset, &data_size)) {
+		log_err("Cannot unpack data size\n");
 		return TPM_LIB_ERROR;
-	if (data_size < sizeof(*pflags))
+	}
+	if (data_size < sizeof(*pflags)) {
+		log_err("Data size too small\n");
 		return TPM_LIB_ERROR;
+	}
 	if (unpack_byte_string(response, response_length, "s",
-			       data_offset, pflags, sizeof(*pflags)))
+			       data_offset, pflags, sizeof(*pflags))) {
+		log_err("Cannot unpack pflags\n");
 		return TPM_LIB_ERROR;
+	}
 
 	return 0;
 }
-- 
2.19.0.605.g01d371f741-goog

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 26/45] binman: Move to three-digit test-file numbers
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (24 preceding siblings ...)
  2018-10-01 18:22 ` [U-Boot] [PATCH 25/45] tpm: Add a few new commands for v1 Simon Glass
@ 2018-10-01 18:22 ` Simon Glass
  2018-10-01 18:22 ` [U-Boot] [PATCH 27/45] binman: Add a test for Intel reference code Simon Glass
                   ` (58 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: Simon Glass @ 2018-10-01 18:22 UTC (permalink / raw)
  To: u-boot

We now have 99 tests. Before adding any more, rename everything to three
digits. This helps to preserve the ordering of tests and makes it easier
to find things.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 tools/binman/entry_test.py                    |   2 +-
 tools/binman/fdt_test.py                      |   4 +-
 tools/binman/ftest.py                         | 224 +++++++++---------
 .../test/{01_invalid.dts => 001_invalid.dts}  |   0
 ..._missing_node.dts => 002_missing_node.dts} |   0
 .../test/{03_empty.dts => 003_empty.dts}      |   0
 ...nvalid_entry.dts => 004_invalid_entry.dts} |   0
 .../test/{05_simple.dts => 005_simple.dts}    |   0
 .../{06_dual_image.dts => 006_dual_image.dts} |   0
 .../{07_bad_align.dts => 007_bad_align.dts}   |   0
 .../binman/test/{08_pack.dts => 008_pack.dts} |   0
 .../{09_pack_extra.dts => 009_pack_extra.dts} |   0
 ...n_power2.dts => 010_pack_align_power2.dts} |   0
 ...er2.dts => 011_pack_align_size_power2.dts} |   0
 ...k_inv_align.dts => 012_pack_inv_align.dts} |   0
 ..._align.dts => 013_pack_inv_size_align.dts} |   0
 ..._pack_overlap.dts => 014_pack_overlap.dts} |   0
 ...ack_overflow.dts => 015_pack_overflow.dts} |   0
 ...erflow.dts => 016_pack_image_overflow.dts} |   0
 ...image_size.dts => 017_pack_image_size.dts} |   0
 ...age_align.dts => 018_pack_image_align.dts} |   0
 ...align.dts => 019_pack_inv_image_align.dts} |   0
 ...ts => 020_pack_inv_image_align_power2.dts} |   0
 .../{21_image_pad.dts => 021_image_pad.dts}   |   0
 .../{22_image_name.dts => 022_image_name.dts} |   0
 .../binman/test/{23_blob.dts => 023_blob.dts} |   0
 .../test/{24_sorted.dts => 024_sorted.dts}    |   0
 ...k_zero_size.dts => 025_pack_zero_size.dts} |   0
 ...u_boot_dtb.dts => 026_pack_u_boot_dtb.dts} |   0
 ...b_no_size.dts => 027_pack_4gb_no_size.dts} |   0
 ...b_outside.dts => 028_pack_4gb_outside.dts} |   0
 .../test/{29_x86-rom.dts => 029_x86-rom.dts}  |   0
 ...no-desc.dts => 030_x86-rom-me-no-desc.dts} |   0
 .../{31_x86-rom-me.dts => 031_x86-rom-me.dts} |   0
 .../{32_intel-vga.dts => 032_intel-vga.dts}   |   0
 ...33_x86-start16.dts => 033_x86-start16.dts} |   0
 .../{34_x86_ucode.dts => 034_x86_ucode.dts}   |   0
 ...gle_ucode.dts => 035_x86_single_ucode.dts} |   0
 .../{36_u_boot_img.dts => 036_u_boot_img.dts} |   0
 ..._x86_no_ucode.dts => 037_x86_no_ucode.dts} |   0
 ...ode.dts => 038_x86_ucode_missing_node.dts} |   0
 ...e2.dts => 039_x86_ucode_missing_node2.dts} |   0
 ...age.dts => 040_x86_ucode_not_in_image.dts} |   0
 ..._pos_size.dts => 041_unknown_pos_size.dts} |   0
 .../{42_intel-fsp.dts => 042_intel-fsp.dts}   |   0
 .../{43_intel-cmc.dts => 043_intel-cmc.dts}   |   0
 ...l_ucode.dts => 044_x86_optional_ucode.dts} |   0
 .../{45_prop_test.dts => 045_prop_test.dts}   |   0
 .../{46_intel-vbt.dts => 046_intel-vbt.dts}   |   0
 ...47_spl_bss_pad.dts => 047_spl_bss_pad.dts} |   0
 ...tart16-spl.dts => 048_x86-start16-spl.dts} |   0
 ...86_ucode_spl.dts => 049_x86_ucode_spl.dts} |   0
 .../{50_intel_mrc.dts => 050_intel_mrc.dts}   |   0
 ...oot_spl_dtb.dts => 051_u_boot_spl_dtb.dts} |   0
 ...spl_nodtb.dts => 052_u_boot_spl_nodtb.dts} |   0
 .../test/{53_symbols.dts => 053_symbols.dts}  |   0
 ..._unit_address.dts => 054_unit_address.dts} |   0
 .../{55_sections.dts => 055_sections.dts}     |   0
 ...56_name_prefix.dts => 056_name_prefix.dts} |   0
 ..._contents.dts => 057_unknown_contents.dts} |   0
 ....dts => 058_x86_ucode_spl_needs_retry.dts} |   0
 ...59_change_size.dts => 059_change_size.dts} |   0
 .../{60_fdt_update.dts => 060_fdt_update.dts} |   0
 ..._update_bad.dts => 061_fdt_update_bad.dts} |   0
 .../{62_entry_args.dts => 062_entry_args.dts} |   0
 ...missing.dts => 063_entry_args_missing.dts} |   0
 ...quired.dts => 064_entry_args_required.dts} |   0
 ...ts => 065_entry_args_unknown_datatype.dts} |   0
 .../binman/test/{66_text.dts => 066_text.dts} |   0
 .../binman/test/{67_fmap.dts => 067_fmap.dts} |   0
 ...d_by_arg.dts => 068_blob_named_by_arg.dts} |   0
 .../binman/test/{69_fill.dts => 069_fill.dts} |   0
 ..._fill_no_size.dts => 070_fill_no_size.dts} |   0
 tools/binman/test/{71_gbb.dts => 071_gbb.dts} |   0
 ...bb_too_small.dts => 072_gbb_too_small.dts} |   0
 ...73_gbb_no_size.dts => 073_gbb_no_size.dts} |   0
 .../test/{74_vblock.dts => 074_vblock.dts}    |   0
 ..._content.dts => 075_vblock_no_content.dts} |   0
 ...phandle.dts => 076_vblock_bad_phandle.dts} |   0
 ...bad_entry.dts => 077_vblock_bad_entry.dts} |   0
 .../{78_u_boot_tpl.dts => 078_u_boot_tpl.dts} |   0
 .../{79_uses_pos.dts => 079_uses_pos.dts}     |   0
 .../{80_fill_empty.dts => 080_fill_empty.dts} |   0
 ...tart16-tpl.dts => 081_x86-start16-tpl.dts} |   0
 ..._update_all.dts => 082_fdt_update_all.dts} |   0
 .../{83_compress.dts => 083_compress.dts}     |   0
 .../test/{84_files.dts => 084_files.dts}      |   0
 ...es_compress.dts => 085_files_compress.dts} |   0
 .../{86_files_none.dts => 086_files_none.dts} |   0
 ...o_pattern.dts => 087_files_no_pattern.dts} |   0
 ...88_expand_size.dts => 088_expand_size.dts} |   0
 ...d_size_bad.dts => 089_expand_size_bad.dts} |   0
 .../binman/test/{90_hash.dts => 090_hash.dts} |   0
 ..._hash_no_algo.dts => 091_hash_no_algo.dts} |   0
 ...ash_bad_algo.dts => 092_hash_bad_algo.dts} |   0
 ...86_tpl_ucode.dts => 093_x86_tpl_ucode.dts} |   0
 .../{94_fmap_x86.dts => 094_fmap_x86.dts}     |   0
 ...6_section.dts => 095_fmap_x86_section.dts} |   0
 tools/binman/test/{96_elf.dts => 096_elf.dts} |   0
 .../{97_elf_strip.dts => 097_elf_strip.dts}   |   0
 ..._hash_section.dts => 099_hash_section.dts} |   0
 101 files changed, 115 insertions(+), 115 deletions(-)
 rename tools/binman/test/{01_invalid.dts => 001_invalid.dts} (100%)
 rename tools/binman/test/{02_missing_node.dts => 002_missing_node.dts} (100%)
 rename tools/binman/test/{03_empty.dts => 003_empty.dts} (100%)
 rename tools/binman/test/{04_invalid_entry.dts => 004_invalid_entry.dts} (100%)
 rename tools/binman/test/{05_simple.dts => 005_simple.dts} (100%)
 rename tools/binman/test/{06_dual_image.dts => 006_dual_image.dts} (100%)
 rename tools/binman/test/{07_bad_align.dts => 007_bad_align.dts} (100%)
 rename tools/binman/test/{08_pack.dts => 008_pack.dts} (100%)
 rename tools/binman/test/{09_pack_extra.dts => 009_pack_extra.dts} (100%)
 rename tools/binman/test/{10_pack_align_power2.dts => 010_pack_align_power2.dts} (100%)
 rename tools/binman/test/{11_pack_align_size_power2.dts => 011_pack_align_size_power2.dts} (100%)
 rename tools/binman/test/{12_pack_inv_align.dts => 012_pack_inv_align.dts} (100%)
 rename tools/binman/test/{13_pack_inv_size_align.dts => 013_pack_inv_size_align.dts} (100%)
 rename tools/binman/test/{14_pack_overlap.dts => 014_pack_overlap.dts} (100%)
 rename tools/binman/test/{15_pack_overflow.dts => 015_pack_overflow.dts} (100%)
 rename tools/binman/test/{16_pack_image_overflow.dts => 016_pack_image_overflow.dts} (100%)
 rename tools/binman/test/{17_pack_image_size.dts => 017_pack_image_size.dts} (100%)
 rename tools/binman/test/{18_pack_image_align.dts => 018_pack_image_align.dts} (100%)
 rename tools/binman/test/{19_pack_inv_image_align.dts => 019_pack_inv_image_align.dts} (100%)
 rename tools/binman/test/{20_pack_inv_image_align_power2.dts => 020_pack_inv_image_align_power2.dts} (100%)
 rename tools/binman/test/{21_image_pad.dts => 021_image_pad.dts} (100%)
 rename tools/binman/test/{22_image_name.dts => 022_image_name.dts} (100%)
 rename tools/binman/test/{23_blob.dts => 023_blob.dts} (100%)
 rename tools/binman/test/{24_sorted.dts => 024_sorted.dts} (100%)
 rename tools/binman/test/{25_pack_zero_size.dts => 025_pack_zero_size.dts} (100%)
 rename tools/binman/test/{26_pack_u_boot_dtb.dts => 026_pack_u_boot_dtb.dts} (100%)
 rename tools/binman/test/{27_pack_4gb_no_size.dts => 027_pack_4gb_no_size.dts} (100%)
 rename tools/binman/test/{28_pack_4gb_outside.dts => 028_pack_4gb_outside.dts} (100%)
 rename tools/binman/test/{29_x86-rom.dts => 029_x86-rom.dts} (100%)
 rename tools/binman/test/{30_x86-rom-me-no-desc.dts => 030_x86-rom-me-no-desc.dts} (100%)
 rename tools/binman/test/{31_x86-rom-me.dts => 031_x86-rom-me.dts} (100%)
 rename tools/binman/test/{32_intel-vga.dts => 032_intel-vga.dts} (100%)
 rename tools/binman/test/{33_x86-start16.dts => 033_x86-start16.dts} (100%)
 rename tools/binman/test/{34_x86_ucode.dts => 034_x86_ucode.dts} (100%)
 rename tools/binman/test/{35_x86_single_ucode.dts => 035_x86_single_ucode.dts} (100%)
 rename tools/binman/test/{36_u_boot_img.dts => 036_u_boot_img.dts} (100%)
 rename tools/binman/test/{37_x86_no_ucode.dts => 037_x86_no_ucode.dts} (100%)
 rename tools/binman/test/{38_x86_ucode_missing_node.dts => 038_x86_ucode_missing_node.dts} (100%)
 rename tools/binman/test/{39_x86_ucode_missing_node2.dts => 039_x86_ucode_missing_node2.dts} (100%)
 rename tools/binman/test/{40_x86_ucode_not_in_image.dts => 040_x86_ucode_not_in_image.dts} (100%)
 rename tools/binman/test/{41_unknown_pos_size.dts => 041_unknown_pos_size.dts} (100%)
 rename tools/binman/test/{42_intel-fsp.dts => 042_intel-fsp.dts} (100%)
 rename tools/binman/test/{43_intel-cmc.dts => 043_intel-cmc.dts} (100%)
 rename tools/binman/test/{44_x86_optional_ucode.dts => 044_x86_optional_ucode.dts} (100%)
 rename tools/binman/test/{45_prop_test.dts => 045_prop_test.dts} (100%)
 rename tools/binman/test/{46_intel-vbt.dts => 046_intel-vbt.dts} (100%)
 rename tools/binman/test/{47_spl_bss_pad.dts => 047_spl_bss_pad.dts} (100%)
 rename tools/binman/test/{48_x86-start16-spl.dts => 048_x86-start16-spl.dts} (100%)
 rename tools/binman/test/{49_x86_ucode_spl.dts => 049_x86_ucode_spl.dts} (100%)
 rename tools/binman/test/{50_intel_mrc.dts => 050_intel_mrc.dts} (100%)
 rename tools/binman/test/{51_u_boot_spl_dtb.dts => 051_u_boot_spl_dtb.dts} (100%)
 rename tools/binman/test/{52_u_boot_spl_nodtb.dts => 052_u_boot_spl_nodtb.dts} (100%)
 rename tools/binman/test/{53_symbols.dts => 053_symbols.dts} (100%)
 rename tools/binman/test/{54_unit_address.dts => 054_unit_address.dts} (100%)
 rename tools/binman/test/{55_sections.dts => 055_sections.dts} (100%)
 rename tools/binman/test/{56_name_prefix.dts => 056_name_prefix.dts} (100%)
 rename tools/binman/test/{57_unknown_contents.dts => 057_unknown_contents.dts} (100%)
 rename tools/binman/test/{58_x86_ucode_spl_needs_retry.dts => 058_x86_ucode_spl_needs_retry.dts} (100%)
 rename tools/binman/test/{59_change_size.dts => 059_change_size.dts} (100%)
 rename tools/binman/test/{60_fdt_update.dts => 060_fdt_update.dts} (100%)
 rename tools/binman/test/{61_fdt_update_bad.dts => 061_fdt_update_bad.dts} (100%)
 rename tools/binman/test/{62_entry_args.dts => 062_entry_args.dts} (100%)
 rename tools/binman/test/{63_entry_args_missing.dts => 063_entry_args_missing.dts} (100%)
 rename tools/binman/test/{64_entry_args_required.dts => 064_entry_args_required.dts} (100%)
 rename tools/binman/test/{65_entry_args_unknown_datatype.dts => 065_entry_args_unknown_datatype.dts} (100%)
 rename tools/binman/test/{66_text.dts => 066_text.dts} (100%)
 rename tools/binman/test/{67_fmap.dts => 067_fmap.dts} (100%)
 rename tools/binman/test/{68_blob_named_by_arg.dts => 068_blob_named_by_arg.dts} (100%)
 rename tools/binman/test/{69_fill.dts => 069_fill.dts} (100%)
 rename tools/binman/test/{70_fill_no_size.dts => 070_fill_no_size.dts} (100%)
 rename tools/binman/test/{71_gbb.dts => 071_gbb.dts} (100%)
 rename tools/binman/test/{72_gbb_too_small.dts => 072_gbb_too_small.dts} (100%)
 rename tools/binman/test/{73_gbb_no_size.dts => 073_gbb_no_size.dts} (100%)
 rename tools/binman/test/{74_vblock.dts => 074_vblock.dts} (100%)
 rename tools/binman/test/{75_vblock_no_content.dts => 075_vblock_no_content.dts} (100%)
 rename tools/binman/test/{76_vblock_bad_phandle.dts => 076_vblock_bad_phandle.dts} (100%)
 rename tools/binman/test/{77_vblock_bad_entry.dts => 077_vblock_bad_entry.dts} (100%)
 rename tools/binman/test/{78_u_boot_tpl.dts => 078_u_boot_tpl.dts} (100%)
 rename tools/binman/test/{79_uses_pos.dts => 079_uses_pos.dts} (100%)
 rename tools/binman/test/{80_fill_empty.dts => 080_fill_empty.dts} (100%)
 rename tools/binman/test/{81_x86-start16-tpl.dts => 081_x86-start16-tpl.dts} (100%)
 rename tools/binman/test/{82_fdt_update_all.dts => 082_fdt_update_all.dts} (100%)
 rename tools/binman/test/{83_compress.dts => 083_compress.dts} (100%)
 rename tools/binman/test/{84_files.dts => 084_files.dts} (100%)
 rename tools/binman/test/{85_files_compress.dts => 085_files_compress.dts} (100%)
 rename tools/binman/test/{86_files_none.dts => 086_files_none.dts} (100%)
 rename tools/binman/test/{87_files_no_pattern.dts => 087_files_no_pattern.dts} (100%)
 rename tools/binman/test/{88_expand_size.dts => 088_expand_size.dts} (100%)
 rename tools/binman/test/{89_expand_size_bad.dts => 089_expand_size_bad.dts} (100%)
 rename tools/binman/test/{90_hash.dts => 090_hash.dts} (100%)
 rename tools/binman/test/{91_hash_no_algo.dts => 091_hash_no_algo.dts} (100%)
 rename tools/binman/test/{92_hash_bad_algo.dts => 092_hash_bad_algo.dts} (100%)
 rename tools/binman/test/{93_x86_tpl_ucode.dts => 093_x86_tpl_ucode.dts} (100%)
 rename tools/binman/test/{94_fmap_x86.dts => 094_fmap_x86.dts} (100%)
 rename tools/binman/test/{95_fmap_x86_section.dts => 095_fmap_x86_section.dts} (100%)
 rename tools/binman/test/{96_elf.dts => 096_elf.dts} (100%)
 rename tools/binman/test/{97_elf_strip.dts => 097_elf_strip.dts} (100%)
 rename tools/binman/test/{99_hash_section.dts => 099_hash_section.dts} (100%)

diff --git a/tools/binman/entry_test.py b/tools/binman/entry_test.py
index 17ab2290140..1f7ff5b4e41 100644
--- a/tools/binman/entry_test.py
+++ b/tools/binman/entry_test.py
@@ -25,7 +25,7 @@ class TestEntry(unittest.TestCase):
     def GetNode(self):
         binman_dir = os.path.dirname(os.path.realpath(sys.argv[0]))
         fname = fdt_util.EnsureCompiled(
-            os.path.join(binman_dir,('test/05_simple.dts')))
+            os.path.join(binman_dir,('test/005_simple.dts')))
         dtb = fdt.FdtScan(fname)
         return dtb.GetNode('/binman/u-boot')
 
diff --git a/tools/binman/fdt_test.py b/tools/binman/fdt_test.py
index b9167012d25..ac6f910d3c0 100644
--- a/tools/binman/fdt_test.py
+++ b/tools/binman/fdt_test.py
@@ -36,12 +36,12 @@ class TestFdt(unittest.TestCase):
         node.DeleteProp('data')
 
     def testFdtNormal(self):
-        fname = self.GetCompiled('34_x86_ucode.dts')
+        fname = self.GetCompiled('034_x86_ucode.dts')
         dt = FdtScan(fname)
         self._DeleteProp(dt)
 
     def testFdtNormalProp(self):
-        fname = self.GetCompiled('45_prop_test.dts')
+        fname = self.GetCompiled('045_prop_test.dts')
         dt = FdtScan(fname)
         node = dt.GetNode('/binman/intel-me')
         self.assertEquals('intel-me', node.name)
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index 9f21027bd40..167f56dd060 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -189,7 +189,7 @@ class TestFunctional(unittest.TestCase):
         """Run binman with a given test file
 
         Args:
-            fname: Device-tree source filename to use (e.g. 05_simple.dts)
+            fname: Device-tree source filename to use (e.g. 005_simple.dts)
             debug: True to enable debugging output
             map: True to output map files for the images
             update_dtb: Update the offset and size of each entry in the device
@@ -266,7 +266,7 @@ class TestFunctional(unittest.TestCase):
         Raises an assertion failure if binman returns a non-zero exit code.
 
         Args:
-            fname: Device-tree source filename to use (e.g. 05_simple.dts)
+            fname: Device-tree source filename to use (e.g. 005_simple.dts)
             use_real_dtb: True to use the test file as the contents of
                 the u-boot-dtb entry. Normally this is not needed and the
                 test contents (the U_BOOT_DTB_DATA string) can be used.
@@ -323,7 +323,7 @@ class TestFunctional(unittest.TestCase):
         """Helper function which discards the device-tree binary
 
         Args:
-            fname: Device-tree source filename to use (e.g. 05_simple.dts)
+            fname: Device-tree source filename to use (e.g. 005_simple.dts)
             use_real_dtb: True to use the test file as the contents of
                 the u-boot-dtb entry. Normally this is not needed and the
                 test contents (the U_BOOT_DTB_DATA string) can be used.
@@ -464,7 +464,7 @@ class TestFunctional(unittest.TestCase):
 
     def testBoard(self):
         """Test that we can run it with a specific board"""
-        self._SetupDtb('05_simple.dts', 'sandbox/u-boot.dtb')
+        self._SetupDtb('005_simple.dts', 'sandbox/u-boot.dtb')
         TestFunctional._MakeInputFile('sandbox/u-boot.bin', U_BOOT_DATA)
         result = self._DoBinman('-b', 'sandbox')
         self.assertEqual(0, result)
@@ -491,19 +491,19 @@ class TestFunctional(unittest.TestCase):
         will come from the device-tree compiler (dtc).
         """
         with self.assertRaises(Exception) as e:
-            self._RunBinman('-d', self.TestFile('01_invalid.dts'))
+            self._RunBinman('-d', self.TestFile('001_invalid.dts'))
         self.assertIn("FATAL ERROR: Unable to parse input tree",
                 str(e.exception))
 
     def testMissingNode(self):
         """Test that a device tree without a 'binman' node generates an error"""
         with self.assertRaises(Exception) as e:
-            self._DoBinman('-d', self.TestFile('02_missing_node.dts'))
+            self._DoBinman('-d', self.TestFile('002_missing_node.dts'))
         self.assertIn("does not have a 'binman' node", str(e.exception))
 
     def testEmpty(self):
         """Test that an empty binman node works OK (i.e. does nothing)"""
-        result = self._RunBinman('-d', self.TestFile('03_empty.dts'))
+        result = self._RunBinman('-d', self.TestFile('003_empty.dts'))
         self.assertEqual(0, len(result.stderr))
         self.assertEqual(0, result.return_code)
 
@@ -511,25 +511,25 @@ class TestFunctional(unittest.TestCase):
         """Test that an invalid entry is flagged"""
         with self.assertRaises(Exception) as e:
             result = self._RunBinman('-d',
-                                     self.TestFile('04_invalid_entry.dts'))
+                                     self.TestFile('004_invalid_entry.dts'))
         self.assertIn("Unknown entry type 'not-a-valid-type' in node "
                 "'/binman/not-a-valid-type'", str(e.exception))
 
     def testSimple(self):
         """Test a simple binman with a single file"""
-        data = self._DoReadFile('05_simple.dts')
+        data = self._DoReadFile('005_simple.dts')
         self.assertEqual(U_BOOT_DATA, data)
 
     def testSimpleDebug(self):
         """Test a simple binman run with debugging enabled"""
-        data = self._DoTestFile('05_simple.dts', debug=True)
+        data = self._DoTestFile('005_simple.dts', debug=True)
 
     def testDual(self):
         """Test that we can handle creating two images
 
         This also tests image padding.
         """
-        retcode = self._DoTestFile('06_dual_image.dts')
+        retcode = self._DoTestFile('006_dual_image.dts')
         self.assertEqual(0, retcode)
 
         image = control.images['image1']
@@ -553,13 +553,13 @@ class TestFunctional(unittest.TestCase):
     def testBadAlign(self):
         """Test that an invalid alignment value is detected"""
         with self.assertRaises(ValueError) as e:
-            self._DoTestFile('07_bad_align.dts')
+            self._DoTestFile('007_bad_align.dts')
         self.assertIn("Node '/binman/u-boot': Alignment 23 must be a power "
                       "of two", str(e.exception))
 
     def testPackSimple(self):
         """Test that packing works as expected"""
-        retcode = self._DoTestFile('08_pack.dts')
+        retcode = self._DoTestFile('008_pack.dts')
         self.assertEqual(0, retcode)
         self.assertIn('image', control.images)
         image = control.images['image']
@@ -601,7 +601,7 @@ class TestFunctional(unittest.TestCase):
 
     def testPackExtra(self):
         """Test that extra packing feature works as expected"""
-        retcode = self._DoTestFile('09_pack_extra.dts')
+        retcode = self._DoTestFile('009_pack_extra.dts')
 
         self.assertEqual(0, retcode)
         self.assertIn('image', control.images)
@@ -646,35 +646,35 @@ class TestFunctional(unittest.TestCase):
     def testPackAlignPowerOf2(self):
         """Test that invalid entry alignment is detected"""
         with self.assertRaises(ValueError) as e:
-            self._DoTestFile('10_pack_align_power2.dts')
+            self._DoTestFile('010_pack_align_power2.dts')
         self.assertIn("Node '/binman/u-boot': Alignment 5 must be a power "
                       "of two", str(e.exception))
 
     def testPackAlignSizePowerOf2(self):
         """Test that invalid entry size alignment is detected"""
         with self.assertRaises(ValueError) as e:
-            self._DoTestFile('11_pack_align_size_power2.dts')
+            self._DoTestFile('011_pack_align_size_power2.dts')
         self.assertIn("Node '/binman/u-boot': Alignment size 55 must be a "
                       "power of two", str(e.exception))
 
     def testPackInvalidAlign(self):
         """Test detection of an offset that does not match its alignment"""
         with self.assertRaises(ValueError) as e:
-            self._DoTestFile('12_pack_inv_align.dts')
+            self._DoTestFile('012_pack_inv_align.dts')
         self.assertIn("Node '/binman/u-boot': Offset 0x5 (5) does not match "
                       "align 0x4 (4)", str(e.exception))
 
     def testPackInvalidSizeAlign(self):
         """Test that invalid entry size alignment is detected"""
         with self.assertRaises(ValueError) as e:
-            self._DoTestFile('13_pack_inv_size_align.dts')
+            self._DoTestFile('013_pack_inv_size_align.dts')
         self.assertIn("Node '/binman/u-boot': Size 0x5 (5) does not match "
                       "align-size 0x4 (4)", str(e.exception))
 
     def testPackOverlap(self):
         """Test that overlapping regions are detected"""
         with self.assertRaises(ValueError) as e:
-            self._DoTestFile('14_pack_overlap.dts')
+            self._DoTestFile('014_pack_overlap.dts')
         self.assertIn("Node '/binman/u-boot-align': Offset 0x3 (3) overlaps "
                       "with previous entry '/binman/u-boot' ending at 0x4 (4)",
                       str(e.exception))
@@ -682,20 +682,20 @@ class TestFunctional(unittest.TestCase):
     def testPackEntryOverflow(self):
         """Test that entries that overflow their size are detected"""
         with self.assertRaises(ValueError) as e:
-            self._DoTestFile('15_pack_overflow.dts')
+            self._DoTestFile('015_pack_overflow.dts')
         self.assertIn("Node '/binman/u-boot': Entry contents size is 0x4 (4) "
                       "but entry size is 0x3 (3)", str(e.exception))
 
     def testPackImageOverflow(self):
         """Test that entries which overflow the image size are detected"""
         with self.assertRaises(ValueError) as e:
-            self._DoTestFile('16_pack_image_overflow.dts')
+            self._DoTestFile('016_pack_image_overflow.dts')
         self.assertIn("Section '/binman': contents size 0x4 (4) exceeds section "
                       "size 0x3 (3)", str(e.exception))
 
     def testPackImageSize(self):
         """Test that the image size can be set"""
-        retcode = self._DoTestFile('17_pack_image_size.dts')
+        retcode = self._DoTestFile('017_pack_image_size.dts')
         self.assertEqual(0, retcode)
         self.assertIn('image', control.images)
         image = control.images['image']
@@ -703,7 +703,7 @@ class TestFunctional(unittest.TestCase):
 
     def testPackImageSizeAlign(self):
         """Test that image size alignemnt works as expected"""
-        retcode = self._DoTestFile('18_pack_image_align.dts')
+        retcode = self._DoTestFile('018_pack_image_align.dts')
         self.assertEqual(0, retcode)
         self.assertIn('image', control.images)
         image = control.images['image']
@@ -712,26 +712,26 @@ class TestFunctional(unittest.TestCase):
     def testPackInvalidImageAlign(self):
         """Test that invalid image alignment is detected"""
         with self.assertRaises(ValueError) as e:
-            self._DoTestFile('19_pack_inv_image_align.dts')
+            self._DoTestFile('019_pack_inv_image_align.dts')
         self.assertIn("Section '/binman': Size 0x7 (7) does not match "
                       "align-size 0x8 (8)", str(e.exception))
 
     def testPackAlignPowerOf2(self):
         """Test that invalid image alignment is detected"""
         with self.assertRaises(ValueError) as e:
-            self._DoTestFile('20_pack_inv_image_align_power2.dts')
+            self._DoTestFile('020_pack_inv_image_align_power2.dts')
         self.assertIn("Section '/binman': Alignment size 131 must be a power of "
                       "two", str(e.exception))
 
     def testImagePadByte(self):
         """Test that the image pad byte can be specified"""
         self._SetupSplElf()
-        data = self._DoReadFile('21_image_pad.dts')
+        data = self._DoReadFile('021_image_pad.dts')
         self.assertEqual(U_BOOT_SPL_DATA + (chr(0xff) * 1) + U_BOOT_DATA, data)
 
     def testImageName(self):
         """Test that image files can be named"""
-        retcode = self._DoTestFile('22_image_name.dts')
+        retcode = self._DoTestFile('022_image_name.dts')
         self.assertEqual(0, retcode)
         image = control.images['image1']
         fname = tools.GetOutputFilename('test-name')
@@ -743,33 +743,33 @@ class TestFunctional(unittest.TestCase):
 
     def testBlobFilename(self):
         """Test that generic blobs can be provided by filename"""
-        data = self._DoReadFile('23_blob.dts')
+        data = self._DoReadFile('023_blob.dts')
         self.assertEqual(BLOB_DATA, data)
 
     def testPackSorted(self):
         """Test that entries can be sorted"""
         self._SetupSplElf()
-        data = self._DoReadFile('24_sorted.dts')
+        data = self._DoReadFile('024_sorted.dts')
         self.assertEqual(chr(0) * 1 + U_BOOT_SPL_DATA + chr(0) * 2 +
                          U_BOOT_DATA, data)
 
     def testPackZeroOffset(self):
         """Test that an entry at offset 0 is not given a new offset"""
         with self.assertRaises(ValueError) as e:
-            self._DoTestFile('25_pack_zero_size.dts')
+            self._DoTestFile('025_pack_zero_size.dts')
         self.assertIn("Node '/binman/u-boot-spl': Offset 0x0 (0) overlaps "
                       "with previous entry '/binman/u-boot' ending at 0x4 (4)",
                       str(e.exception))
 
     def testPackUbootDtb(self):
         """Test that a device tree can be added to U-Boot"""
-        data = self._DoReadFile('26_pack_u_boot_dtb.dts')
+        data = self._DoReadFile('026_pack_u_boot_dtb.dts')
         self.assertEqual(U_BOOT_NODTB_DATA + U_BOOT_DTB_DATA, data)
 
     def testPackX86RomNoSize(self):
         """Test that the end-at-4gb property requires a size property"""
         with self.assertRaises(ValueError) as e:
-            self._DoTestFile('27_pack_4gb_no_size.dts')
+            self._DoTestFile('027_pack_4gb_no_size.dts')
         self.assertIn("Section '/binman': Section size must be provided when "
                       "using end-at-4gb", str(e.exception))
 
@@ -784,7 +784,7 @@ class TestFunctional(unittest.TestCase):
     def testPackX86RomOutside(self):
         """Test that the end-at-4gb property checks for offset boundaries"""
         with self.assertRaises(ValueError) as e:
-            self._DoTestFile('28_pack_4gb_outside.dts')
+            self._DoTestFile('028_pack_4gb_outside.dts')
         self.assertIn("Node '/binman/u-boot': Offset 0x0 (0) is outside "
                       "the section starting at 0xffffffe0 (4294967264)",
                       str(e.exception))
@@ -792,7 +792,7 @@ class TestFunctional(unittest.TestCase):
     def testPackX86Rom(self):
         """Test that a basic x86 ROM can be created"""
         self._SetupSplElf()
-        data = self._DoReadFile('29_x86-rom.dts')
+        data = self._DoReadFile('029_x86-rom.dts')
         self.assertEqual(U_BOOT_DATA + chr(0) * 7 + U_BOOT_SPL_DATA +
                          chr(0) * 2, data)
 
@@ -800,31 +800,31 @@ class TestFunctional(unittest.TestCase):
         """Test that an invalid Intel descriptor entry is detected"""
         TestFunctional._MakeInputFile('descriptor.bin', '')
         with self.assertRaises(ValueError) as e:
-            self._DoTestFile('31_x86-rom-me.dts')
+            self._DoTestFile('031_x86-rom-me.dts')
         self.assertIn("Node '/binman/intel-descriptor': Cannot find FD "
                       "signature", str(e.exception))
 
     def testPackX86RomBadDesc(self):
         """Test that the Intel requires a descriptor entry"""
         with self.assertRaises(ValueError) as e:
-            self._DoTestFile('30_x86-rom-me-no-desc.dts')
+            self._DoTestFile('030_x86-rom-me-no-desc.dts')
         self.assertIn("Node '/binman/intel-me': No offset set with "
                       "offset-unset: should another entry provide this correct "
                       "offset?", str(e.exception))
 
     def testPackX86RomMe(self):
         """Test that an x86 ROM with an ME region can be created"""
-        data = self._DoReadFile('31_x86-rom-me.dts')
+        data = self._DoReadFile('031_x86-rom-me.dts')
         self.assertEqual(ME_DATA, data[0x1000:0x1000 + len(ME_DATA)])
 
     def testPackVga(self):
         """Test that an image with a VGA binary can be created"""
-        data = self._DoReadFile('32_intel-vga.dts')
+        data = self._DoReadFile('032_intel-vga.dts')
         self.assertEqual(VGA_DATA, data[:len(VGA_DATA)])
 
     def testPackStart16(self):
         """Test that an image with an x86 start16 region can be created"""
-        data = self._DoReadFile('33_x86-start16.dts')
+        data = self._DoReadFile('033_x86-start16.dts')
         self.assertEqual(X86_START16_DATA, data[:len(X86_START16_DATA)])
 
     def testPackPowerpcMpc85xxBootpgResetvec(self):
@@ -893,7 +893,7 @@ class TestFunctional(unittest.TestCase):
             u-boot.dtb with the microcode removed
             the microcode
         """
-        first, pos_and_size = self._RunMicrocodeTest('34_x86_ucode.dts',
+        first, pos_and_size = self._RunMicrocodeTest('034_x86_ucode.dts',
                                                      U_BOOT_NODTB_DATA)
         self.assertEqual('nodtb with microcode' + pos_and_size +
                          ' somewhere in here', first)
@@ -910,7 +910,7 @@ class TestFunctional(unittest.TestCase):
         # We need the libfdt library to run this test since only that allows
         # finding the offset of a property. This is required by
         # Entry_u_boot_dtb_with_ucode.ObtainContents().
-        data = self._DoReadFile('35_x86_single_ucode.dts', True)
+        data = self._DoReadFile('035_x86_single_ucode.dts', True)
 
         second = data[len(U_BOOT_NODTB_DATA):]
 
@@ -937,27 +937,27 @@ class TestFunctional(unittest.TestCase):
 
     def testUBootImg(self):
         """Test that u-boot.img can be put in a file"""
-        data = self._DoReadFile('36_u_boot_img.dts')
+        data = self._DoReadFile('036_u_boot_img.dts')
         self.assertEqual(U_BOOT_IMG_DATA, data)
 
     def testNoMicrocode(self):
         """Test that a missing microcode region is detected"""
         with self.assertRaises(ValueError) as e:
-            self._DoReadFile('37_x86_no_ucode.dts', True)
+            self._DoReadFile('037_x86_no_ucode.dts', True)
         self.assertIn("Node '/binman/u-boot-dtb-with-ucode': No /microcode "
                       "node found in ", str(e.exception))
 
     def testMicrocodeWithoutNode(self):
         """Test that a missing u-boot-dtb-with-ucode node is detected"""
         with self.assertRaises(ValueError) as e:
-            self._DoReadFile('38_x86_ucode_missing_node.dts', True)
+            self._DoReadFile('038_x86_ucode_missing_node.dts', True)
         self.assertIn("Node '/binman/u-boot-with-ucode-ptr': Cannot find "
                 "microcode region u-boot-dtb-with-ucode", str(e.exception))
 
     def testMicrocodeWithoutNode2(self):
         """Test that a missing u-boot-ucode node is detected"""
         with self.assertRaises(ValueError) as e:
-            self._DoReadFile('39_x86_ucode_missing_node2.dts', True)
+            self._DoReadFile('039_x86_ucode_missing_node2.dts', True)
         self.assertIn("Node '/binman/u-boot-with-ucode-ptr': Cannot find "
             "microcode region u-boot-ucode", str(e.exception))
 
@@ -981,7 +981,7 @@ class TestFunctional(unittest.TestCase):
     def testMicrocodeNotInImage(self):
         """Test that microcode must be placed within the image"""
         with self.assertRaises(ValueError) as e:
-            self._DoReadFile('40_x86_ucode_not_in_image.dts', True)
+            self._DoReadFile('040_x86_ucode_not_in_image.dts', True)
         self.assertIn("Node '/binman/u-boot-with-ucode-ptr': Microcode "
                 "pointer _dt_ucode_base_size at fffffe14 is outside the "
                 "section ranging from 00000000 to 0000002e", str(e.exception))
@@ -990,7 +990,7 @@ class TestFunctional(unittest.TestCase):
         """Test that we can cope with an image without microcode (e.g. qemu)"""
         with open(self.TestFile('u_boot_no_ucode_ptr')) as fd:
             TestFunctional._MakeInputFile('u-boot', fd.read())
-        data, dtb, _, _ = self._DoReadFileDtb('44_x86_optional_ucode.dts', True)
+        data, dtb, _, _ = self._DoReadFileDtb('044_x86_optional_ucode.dts', True)
 
         # Now check the device tree has no microcode
         self.assertEqual(U_BOOT_NODTB_DATA, data[:len(U_BOOT_NODTB_DATA)])
@@ -1006,43 +1006,43 @@ class TestFunctional(unittest.TestCase):
     def testUnknownPosSize(self):
         """Test that microcode must be placed within the image"""
         with self.assertRaises(ValueError) as e:
-            self._DoReadFile('41_unknown_pos_size.dts', True)
+            self._DoReadFile('041_unknown_pos_size.dts', True)
         self.assertIn("Section '/binman': Unable to set offset/size for unknown "
                 "entry 'invalid-entry'", str(e.exception))
 
     def testPackFsp(self):
         """Test that an image with a FSP binary can be created"""
-        data = self._DoReadFile('42_intel-fsp.dts')
+        data = self._DoReadFile('042_intel-fsp.dts')
         self.assertEqual(FSP_DATA, data[:len(FSP_DATA)])
 
     def testPackCmc(self):
         """Test that an image with a CMC binary can be created"""
-        data = self._DoReadFile('43_intel-cmc.dts')
+        data = self._DoReadFile('043_intel-cmc.dts')
         self.assertEqual(CMC_DATA, data[:len(CMC_DATA)])
 
     def testPackVbt(self):
         """Test that an image with a VBT binary can be created"""
-        data = self._DoReadFile('46_intel-vbt.dts')
+        data = self._DoReadFile('046_intel-vbt.dts')
         self.assertEqual(VBT_DATA, data[:len(VBT_DATA)])
 
     def testSplBssPad(self):
         """Test that we can pad SPL's BSS with zeros"""
         # ELF file with a '__bss_size' symbol
         self._SetupSplElf()
-        data = self._DoReadFile('47_spl_bss_pad.dts')
+        data = self._DoReadFile('047_spl_bss_pad.dts')
         self.assertEqual(U_BOOT_SPL_DATA + (chr(0) * 10) + U_BOOT_DATA, data)
 
     def testSplBssPadMissing(self):
         """Test that a missing symbol is detected"""
         self._SetupSplElf('u_boot_ucode_ptr')
         with self.assertRaises(ValueError) as e:
-            self._DoReadFile('47_spl_bss_pad.dts')
+            self._DoReadFile('047_spl_bss_pad.dts')
         self.assertIn('Expected __bss_size symbol in spl/u-boot-spl',
                       str(e.exception))
 
     def testPackStart16Spl(self):
         """Test that an image with an x86 start16 SPL region can be created"""
-        data = self._DoReadFile('48_x86-start16-spl.dts')
+        data = self._DoReadFile('048_x86-start16-spl.dts')
         self.assertEqual(X86_START16_SPL_DATA, data[:len(X86_START16_SPL_DATA)])
 
     def _PackUbootSplMicrocode(self, dts, ucode_second=False):
@@ -1067,7 +1067,7 @@ class TestFunctional(unittest.TestCase):
 
     def testPackUbootSplMicrocode(self):
         """Test that x86 microcode can be handled correctly in SPL"""
-        self._PackUbootSplMicrocode('49_x86_ucode_spl.dts')
+        self._PackUbootSplMicrocode('049_x86_ucode_spl.dts')
 
     def testPackUbootSplMicrocodeReorder(self):
         """Test that order doesn't matter for microcode entries
@@ -1076,22 +1076,22 @@ class TestFunctional(unittest.TestCase):
         u-boot-ucode entry we have not yet seen the u-boot-dtb-with-ucode
         entry, so we reply on binman to try later.
         """
-        self._PackUbootSplMicrocode('58_x86_ucode_spl_needs_retry.dts',
+        self._PackUbootSplMicrocode('058_x86_ucode_spl_needs_retry.dts',
                                     ucode_second=True)
 
     def testPackMrc(self):
         """Test that an image with an MRC binary can be created"""
-        data = self._DoReadFile('50_intel_mrc.dts')
+        data = self._DoReadFile('050_intel_mrc.dts')
         self.assertEqual(MRC_DATA, data[:len(MRC_DATA)])
 
     def testSplDtb(self):
         """Test that an image with spl/u-boot-spl.dtb can be created"""
-        data = self._DoReadFile('51_u_boot_spl_dtb.dts')
+        data = self._DoReadFile('051_u_boot_spl_dtb.dts')
         self.assertEqual(U_BOOT_SPL_DTB_DATA, data[:len(U_BOOT_SPL_DTB_DATA)])
 
     def testSplNoDtb(self):
         """Test that an image with spl/u-boot-spl-nodtb.bin can be created"""
-        data = self._DoReadFile('52_u_boot_spl_nodtb.dts')
+        data = self._DoReadFile('052_u_boot_spl_nodtb.dts')
         self.assertEqual(U_BOOT_SPL_NODTB_DATA, data[:len(U_BOOT_SPL_NODTB_DATA)])
 
     def testSymbols(self):
@@ -1102,7 +1102,7 @@ class TestFunctional(unittest.TestCase):
         self.assertEqual(syms['_binman_u_boot_spl_prop_offset'].address, addr)
 
         self._SetupSplElf('u_boot_binman_syms')
-        data = self._DoReadFile('53_symbols.dts')
+        data = self._DoReadFile('053_symbols.dts')
         sym_values = struct.pack('<LQL', 0x24 + 0, 0x24 + 24, 0x24 + 20)
         expected = (sym_values + U_BOOT_SPL_DATA[16:] + chr(0xff) +
                     U_BOOT_DATA +
@@ -1111,19 +1111,19 @@ class TestFunctional(unittest.TestCase):
 
     def testPackUnitAddress(self):
         """Test that we support multiple binaries with the same name"""
-        data = self._DoReadFile('54_unit_address.dts')
+        data = self._DoReadFile('054_unit_address.dts')
         self.assertEqual(U_BOOT_DATA + U_BOOT_DATA, data)
 
     def testSections(self):
         """Basic test of sections"""
-        data = self._DoReadFile('55_sections.dts')
+        data = self._DoReadFile('055_sections.dts')
         expected = (U_BOOT_DATA + '!' * 12 + U_BOOT_DATA + 'a' * 12 +
                     U_BOOT_DATA + '&' * 4)
         self.assertEqual(expected, data)
 
     def testMap(self):
         """Tests outputting a map of the images"""
-        _, _, map_data, _ = self._DoReadFileDtb('55_sections.dts', map=True)
+        _, _, map_data, _ = self._DoReadFileDtb('055_sections.dts', map=True)
         self.assertEqual('''ImagePos    Offset      Size  Name
 00000000  00000000  00000028  main-section
 00000000   00000000  00000010  section at 0
@@ -1136,7 +1136,7 @@ class TestFunctional(unittest.TestCase):
 
     def testNamePrefix(self):
         """Tests that name prefixes are used"""
-        _, _, map_data, _ = self._DoReadFileDtb('56_name_prefix.dts', map=True)
+        _, _, map_data, _ = self._DoReadFileDtb('056_name_prefix.dts', map=True)
         self.assertEqual('''ImagePos    Offset      Size  Name
 00000000  00000000  00000028  main-section
 00000000   00000000  00000010  section@0
@@ -1148,7 +1148,7 @@ class TestFunctional(unittest.TestCase):
     def testUnknownContents(self):
         """Test that obtaining the contents works as expected"""
         with self.assertRaises(ValueError) as e:
-            self._DoReadFile('57_unknown_contents.dts', True)
+            self._DoReadFile('057_unknown_contents.dts', True)
         self.assertIn("Section '/binman': Internal error: Could not complete "
                 "processing of contents: remaining [<_testing.Entry__testing ",
                 str(e.exception))
@@ -1156,13 +1156,13 @@ class TestFunctional(unittest.TestCase):
     def testBadChangeSize(self):
         """Test that trying to change the size of an entry fails"""
         with self.assertRaises(ValueError) as e:
-            self._DoReadFile('59_change_size.dts', True)
+            self._DoReadFile('059_change_size.dts', True)
         self.assertIn("Node '/binman/_testing': Cannot update entry size from "
                       '2 to 1', str(e.exception))
 
     def testUpdateFdt(self):
         """Test that we can update the device tree with offset/size info"""
-        _, _, _, out_dtb_fname = self._DoReadFileDtb('60_fdt_update.dts',
+        _, _, _, out_dtb_fname = self._DoReadFileDtb('060_fdt_update.dts',
                                                      update_dtb=True)
         dtb = fdt.Fdt(out_dtb_fname)
         dtb.Scan()
@@ -1192,7 +1192,7 @@ class TestFunctional(unittest.TestCase):
     def testUpdateFdtBad(self):
         """Test that we detect when ProcessFdt never completes"""
         with self.assertRaises(ValueError) as e:
-            self._DoReadFileDtb('61_fdt_update_bad.dts', update_dtb=True)
+            self._DoReadFileDtb('061_fdt_update_bad.dts', update_dtb=True)
         self.assertIn('Could not complete processing of Fdt: remaining '
                       '[<_testing.Entry__testing', str(e.exception))
 
@@ -1202,7 +1202,7 @@ class TestFunctional(unittest.TestCase):
             'test-str-arg': 'test1',
             'test-int-arg': '456',
         }
-        self._DoReadFileDtb('62_entry_args.dts', entry_args=entry_args)
+        self._DoReadFileDtb('062_entry_args.dts', entry_args=entry_args)
         self.assertIn('image', control.images)
         entry = control.images['image'].GetEntries()['_testing']
         self.assertEqual('test0', entry.test_str_fdt)
@@ -1215,7 +1215,7 @@ class TestFunctional(unittest.TestCase):
         entry_args = {
             'test-int-arg': '456',
         }
-        self._DoReadFileDtb('63_entry_args_missing.dts', entry_args=entry_args)
+        self._DoReadFileDtb('063_entry_args_missing.dts', entry_args=entry_args)
         entry = control.images['image'].GetEntries()['_testing']
         self.assertEqual('test0', entry.test_str_fdt)
         self.assertEqual(None, entry.test_str_arg)
@@ -1228,14 +1228,14 @@ class TestFunctional(unittest.TestCase):
             'test-int-arg': '456',
         }
         with self.assertRaises(ValueError) as e:
-            self._DoReadFileDtb('64_entry_args_required.dts')
+            self._DoReadFileDtb('064_entry_args_required.dts')
         self.assertIn("Node '/binman/_testing': Missing required "
             'properties/entry args: test-str-arg, test-int-fdt, test-int-arg',
             str(e.exception))
 
     def testEntryArgsInvalidFormat(self):
         """Test that an invalid entry-argument format is detected"""
-        args = ['-d', self.TestFile('64_entry_args_required.dts'), '-ano-value']
+        args = ['-d', self.TestFile('064_entry_args_required.dts'), '-ano-value']
         with self.assertRaises(ValueError) as e:
             self._DoBinman(*args)
         self.assertIn("Invalid entry arguemnt 'no-value'", str(e.exception))
@@ -1246,7 +1246,7 @@ class TestFunctional(unittest.TestCase):
             'test-int-arg': 'abc',
         }
         with self.assertRaises(ValueError) as e:
-            self._DoReadFileDtb('62_entry_args.dts', entry_args=entry_args)
+            self._DoReadFileDtb('062_entry_args.dts', entry_args=entry_args)
         self.assertIn("Node '/binman/_testing': Cannot convert entry arg "
                       "'test-int-arg' (value 'abc') to integer",
             str(e.exception))
@@ -1262,7 +1262,7 @@ class TestFunctional(unittest.TestCase):
             'test-bad-datatype-arg': '12',
         }
         with self.assertRaises(ValueError) as e:
-            self._DoReadFileDtb('65_entry_args_unknown_datatype.dts',
+            self._DoReadFileDtb('065_entry_args_unknown_datatype.dts',
                                 entry_args=entry_args)
         self.assertIn('GetArg() internal error: Unknown data type ',
                       str(e.exception))
@@ -1274,7 +1274,7 @@ class TestFunctional(unittest.TestCase):
             'test-id2': TEXT_DATA2,
             'test-id3': TEXT_DATA3,
         }
-        data, _, _, _ = self._DoReadFileDtb('66_text.dts',
+        data, _, _, _ = self._DoReadFileDtb('066_text.dts',
                                             entry_args=entry_args)
         expected = (TEXT_DATA + chr(0) * (8 - len(TEXT_DATA)) + TEXT_DATA2 +
                     TEXT_DATA3 + 'some text')
@@ -1296,7 +1296,7 @@ class TestFunctional(unittest.TestCase):
 
     def testFmap(self):
         """Basic test of generation of a flashrom fmap"""
-        data = self._DoReadFile('67_fmap.dts')
+        data = self._DoReadFile('067_fmap.dts')
         fhdr, fentries = fmap_util.DecodeFmap(data[32:])
         expected = U_BOOT_DATA + '!' * 12 + U_BOOT_DATA + 'a' * 12
         self.assertEqual(expected, data[:32])
@@ -1330,19 +1330,19 @@ class TestFunctional(unittest.TestCase):
         entry_args = {
             'cros-ec-rw-path': 'ecrw.bin',
         }
-        data, _, _, _ = self._DoReadFileDtb('68_blob_named_by_arg.dts',
+        data, _, _, _ = self._DoReadFileDtb('068_blob_named_by_arg.dts',
                                             entry_args=entry_args)
 
     def testFill(self):
         """Test for an fill entry type"""
-        data = self._DoReadFile('69_fill.dts')
+        data = self._DoReadFile('069_fill.dts')
         expected = 8 * chr(0xff) + 8 * chr(0)
         self.assertEqual(expected, data)
 
     def testFillNoSize(self):
         """Test for an fill entry type with no size"""
         with self.assertRaises(ValueError) as e:
-            self._DoReadFile('70_fill_no_size.dts')
+            self._DoReadFile('070_fill_no_size.dts')
         self.assertIn("'fill' entry must have a size property",
                       str(e.exception))
 
@@ -1363,7 +1363,7 @@ class TestFunctional(unittest.TestCase):
             'keydir': 'devkeys',
             'bmpblk': 'bmpblk.bin',
         }
-        data, _, _, _ = self._DoReadFileDtb('71_gbb.dts', entry_args=entry_args)
+        data, _, _, _ = self._DoReadFileDtb('071_gbb.dts', entry_args=entry_args)
 
         # Since futility
         expected = GBB_DATA + GBB_DATA + 8 * chr(0) + (0x2180 - 16) * chr(0)
@@ -1372,14 +1372,14 @@ class TestFunctional(unittest.TestCase):
     def testGbbTooSmall(self):
         """Test for the Chromium OS Google Binary Block being large enough"""
         with self.assertRaises(ValueError) as e:
-            self._DoReadFileDtb('72_gbb_too_small.dts')
+            self._DoReadFileDtb('072_gbb_too_small.dts')
         self.assertIn("Node '/binman/gbb': GBB is too small",
                       str(e.exception))
 
     def testGbbNoSize(self):
         """Test for the Chromium OS Google Binary Block having a size"""
         with self.assertRaises(ValueError) as e:
-            self._DoReadFileDtb('73_gbb_no_size.dts')
+            self._DoReadFileDtb('073_gbb_no_size.dts')
         self.assertIn("Node '/binman/gbb': GBB must have a fixed size",
                       str(e.exception))
 
@@ -1397,7 +1397,7 @@ class TestFunctional(unittest.TestCase):
         entry_args = {
             'keydir': 'devkeys',
         }
-        data, _, _, _ = self._DoReadFileDtb('74_vblock.dts',
+        data, _, _, _ = self._DoReadFileDtb('074_vblock.dts',
                                             entry_args=entry_args)
         expected = U_BOOT_DATA + VBLOCK_DATA + U_BOOT_DTB_DATA
         self.assertEqual(expected, data)
@@ -1405,21 +1405,21 @@ class TestFunctional(unittest.TestCase):
     def testVblockNoContent(self):
         """Test we detect a vblock which has no content to sign"""
         with self.assertRaises(ValueError) as e:
-            self._DoReadFile('75_vblock_no_content.dts')
+            self._DoReadFile('075_vblock_no_content.dts')
         self.assertIn("Node '/binman/vblock': Vblock must have a 'content' "
                       'property', str(e.exception))
 
     def testVblockBadPhandle(self):
         """Test that we detect a vblock with an invalid phandle in contents"""
         with self.assertRaises(ValueError) as e:
-            self._DoReadFile('76_vblock_bad_phandle.dts')
+            self._DoReadFile('076_vblock_bad_phandle.dts')
         self.assertIn("Node '/binman/vblock': Cannot find node for phandle "
                       '1000', str(e.exception))
 
     def testVblockBadEntry(self):
         """Test that we detect an entry that points to a non-entry"""
         with self.assertRaises(ValueError) as e:
-            self._DoReadFile('77_vblock_bad_entry.dts')
+            self._DoReadFile('077_vblock_bad_entry.dts')
         self.assertIn("Node '/binman/vblock': Cannot find entry for node "
                       "'other'", str(e.exception))
 
@@ -1428,37 +1428,37 @@ class TestFunctional(unittest.TestCase):
         # ELF file with a '__bss_size' symbol
         with open(self.TestFile('bss_data')) as fd:
             TestFunctional._MakeInputFile('tpl/u-boot-tpl', fd.read())
-        data = self._DoReadFile('78_u_boot_tpl.dts')
+        data = self._DoReadFile('078_u_boot_tpl.dts')
         self.assertEqual(U_BOOT_TPL_DATA + U_BOOT_TPL_DTB_DATA, data)
 
     def testUsesPos(self):
         """Test that the 'pos' property cannot be used anymore"""
         with self.assertRaises(ValueError) as e:
-           data = self._DoReadFile('79_uses_pos.dts')
+           data = self._DoReadFile('079_uses_pos.dts')
         self.assertIn("Node '/binman/u-boot': Please use 'offset' instead of "
                       "'pos'", str(e.exception))
 
     def testFillZero(self):
         """Test for an fill entry type with a size of 0"""
-        data = self._DoReadFile('80_fill_empty.dts')
+        data = self._DoReadFile('080_fill_empty.dts')
         self.assertEqual(chr(0) * 16, data)
 
     def testTextMissing(self):
         """Test for a text entry type where there is no text"""
         with self.assertRaises(ValueError) as e:
-            self._DoReadFileDtb('66_text.dts',)
+            self._DoReadFileDtb('066_text.dts',)
         self.assertIn("Node '/binman/text': No value provided for text label "
                       "'test-id'", str(e.exception))
 
     def testPackStart16Tpl(self):
         """Test that an image with an x86 start16 TPL region can be created"""
-        data = self._DoReadFile('81_x86-start16-tpl.dts')
+        data = self._DoReadFile('081_x86-start16-tpl.dts')
         self.assertEqual(X86_START16_TPL_DATA, data[:len(X86_START16_TPL_DATA)])
 
     def testSelectImage(self):
         """Test that we can select which images to build"""
         with test_util.capture_sys_output() as (stdout, stderr):
-            retcode = self._DoTestFile('06_dual_image.dts', images=['image2'])
+            retcode = self._DoTestFile('006_dual_image.dts', images=['image2'])
         self.assertEqual(0, retcode)
         self.assertIn('Skipping images: image1', stdout.getvalue())
 
@@ -1467,7 +1467,7 @@ class TestFunctional(unittest.TestCase):
 
     def testUpdateFdtAll(self):
         """Test that all device trees are updated with offset/size info"""
-        data, _, _, _ = self._DoReadFileDtb('82_fdt_update_all.dts',
+        data, _, _, _ = self._DoReadFileDtb('082_fdt_update_all.dts',
                                             use_real_dtb=True, update_dtb=True)
 
         base_expected = {
@@ -1507,12 +1507,12 @@ class TestFunctional(unittest.TestCase):
     def testUpdateFdtOutput(self):
         """Test that output DTB files are updated"""
         try:
-            data, dtb_data, _, _ = self._DoReadFileDtb('82_fdt_update_all.dts',
+            data, dtb_data, _, _ = self._DoReadFileDtb('082_fdt_update_all.dts',
                     use_real_dtb=True, update_dtb=True, reset_dtbs=False)
 
             # Unfortunately, compiling a source file always results in a file
             # called source.dtb (see fdt_util.EnsureCompiled()). The test
-            # source file (e.g. test/75_fdt_update_all.dts) thus does not enter
+            # source file (e.g. test/075_fdt_update_all.dts) thus does not enter
             # binman as a file called u-boot.dtb. To fix this, copy the file
             # over to the expected place.
             #tools.WriteFile(os.path.join(self._indir, 'u-boot.dtb'),
@@ -1553,7 +1553,7 @@ class TestFunctional(unittest.TestCase):
 
     def testCompress(self):
         """Test compression of blobs"""
-        data, _, _, out_dtb_fname = self._DoReadFileDtb('83_compress.dts',
+        data, _, _, out_dtb_fname = self._DoReadFileDtb('083_compress.dts',
                                             use_real_dtb=True, update_dtb=True)
         dtb = fdt.Fdt(out_dtb_fname)
         dtb.Scan()
@@ -1569,12 +1569,12 @@ class TestFunctional(unittest.TestCase):
 
     def testFiles(self):
         """Test bringing in multiple files"""
-        data = self._DoReadFile('84_files.dts')
+        data = self._DoReadFile('084_files.dts')
         self.assertEqual(FILES_DATA, data)
 
     def testFilesCompress(self):
         """Test bringing in multiple files and compressing them"""
-        data = self._DoReadFile('85_files_compress.dts')
+        data = self._DoReadFile('085_files_compress.dts')
 
         image = control.images['image']
         entries = image.GetEntries()
@@ -1594,20 +1594,20 @@ class TestFunctional(unittest.TestCase):
     def testFilesMissing(self):
         """Test missing files"""
         with self.assertRaises(ValueError) as e:
-            data = self._DoReadFile('86_files_none.dts')
+            data = self._DoReadFile('086_files_none.dts')
         self.assertIn("Node '/binman/files': Pattern \'files/*.none\' matched "
                       'no files', str(e.exception))
 
     def testFilesNoPattern(self):
         """Test missing files"""
         with self.assertRaises(ValueError) as e:
-            data = self._DoReadFile('87_files_no_pattern.dts')
+            data = self._DoReadFile('087_files_no_pattern.dts')
         self.assertIn("Node '/binman/files': Missing 'pattern' property",
                       str(e.exception))
 
     def testExpandSize(self):
         """Test an expanding entry"""
-        data, _, map_data, _ = self._DoReadFileDtb('88_expand_size.dts',
+        data, _, map_data, _ = self._DoReadFileDtb('088_expand_size.dts',
                                                    map=True)
         expect = ('a' * 8 + U_BOOT_DATA +
                   MRC_DATA + 'b' * 1 + U_BOOT_DATA +
@@ -1631,13 +1631,13 @@ class TestFunctional(unittest.TestCase):
         """Test an expanding entry which fails to provide contents"""
         with test_util.capture_sys_output() as (stdout, stderr):
             with self.assertRaises(ValueError) as e:
-                self._DoReadFileDtb('89_expand_size_bad.dts', map=True)
+                self._DoReadFileDtb('089_expand_size_bad.dts', map=True)
         self.assertIn("Node '/binman/_testing': Cannot obtain contents when "
                       'expanding entry', str(e.exception))
 
     def testHash(self):
         """Test hashing of the contents of an entry"""
-        _, _, _, out_dtb_fname = self._DoReadFileDtb('90_hash.dts',
+        _, _, _, out_dtb_fname = self._DoReadFileDtb('090_hash.dts',
                 use_real_dtb=True, update_dtb=True)
         dtb = fdt.Fdt(out_dtb_fname)
         dtb.Scan()
@@ -1648,19 +1648,19 @@ class TestFunctional(unittest.TestCase):
 
     def testHashNoAlgo(self):
         with self.assertRaises(ValueError) as e:
-            self._DoReadFileDtb('91_hash_no_algo.dts', update_dtb=True)
+            self._DoReadFileDtb('091_hash_no_algo.dts', update_dtb=True)
         self.assertIn("Node \'/binman/u-boot\': Missing \'algo\' property for "
                       'hash node', str(e.exception))
 
     def testHashBadAlgo(self):
         with self.assertRaises(ValueError) as e:
-            self._DoReadFileDtb('92_hash_bad_algo.dts', update_dtb=True)
+            self._DoReadFileDtb('092_hash_bad_algo.dts', update_dtb=True)
         self.assertIn("Node '/binman/u-boot': Unknown hash algorithm",
                       str(e.exception))
 
     def testHashSection(self):
         """Test hashing of the contents of an entry"""
-        _, _, _, out_dtb_fname = self._DoReadFileDtb('99_hash_section.dts',
+        _, _, _, out_dtb_fname = self._DoReadFileDtb('099_hash_section.dts',
                 use_real_dtb=True, update_dtb=True)
         dtb = fdt.Fdt(out_dtb_fname)
         dtb.Scan()
@@ -1681,14 +1681,14 @@ class TestFunctional(unittest.TestCase):
         """
         with open(self.TestFile('u_boot_ucode_ptr')) as fd:
             TestFunctional._MakeInputFile('tpl/u-boot-tpl', fd.read())
-        first, pos_and_size = self._RunMicrocodeTest('93_x86_tpl_ucode.dts',
+        first, pos_and_size = self._RunMicrocodeTest('093_x86_tpl_ucode.dts',
                                                      U_BOOT_TPL_NODTB_DATA)
         self.assertEqual('tplnodtb with microc' + pos_and_size +
                          'ter somewhere in here', first)
 
     def testFmapX86(self):
         """Basic test of generation of a flashrom fmap"""
-        data = self._DoReadFile('94_fmap_x86.dts')
+        data = self._DoReadFile('094_fmap_x86.dts')
         fhdr, fentries = fmap_util.DecodeFmap(data[32:])
         expected = U_BOOT_DATA + MRC_DATA + 'a' * (32 - 7)
         self.assertEqual(expected, data[:32])
@@ -1711,7 +1711,7 @@ class TestFunctional(unittest.TestCase):
 
     def testFmapX86Section(self):
         """Basic test of generation of a flashrom fmap"""
-        data = self._DoReadFile('95_fmap_x86_section.dts')
+        data = self._DoReadFile('095_fmap_x86_section.dts')
         expected = U_BOOT_DATA + MRC_DATA + 'b' * (32 - 7)
         self.assertEqual(expected, data[:32])
         fhdr, fentries = fmap_util.DecodeFmap(data[36:])
@@ -1736,20 +1736,20 @@ class TestFunctional(unittest.TestCase):
         self._SetupSplElf()
         with open(self.TestFile('bss_data')) as fd:
             TestFunctional._MakeInputFile('-boot', fd.read())
-        data = self._DoReadFile('96_elf.dts')
+        data = self._DoReadFile('096_elf.dts')
 
     def testElfStripg(self):
         """Basic test of ELF entries"""
         self._SetupSplElf()
         with open(self.TestFile('bss_data')) as fd:
             TestFunctional._MakeInputFile('-boot', fd.read())
-        data = self._DoReadFile('97_elf_strip.dts')
+        data = self._DoReadFile('097_elf_strip.dts')
 
     def testPackOverlapMap(self):
         """Test that overlapping regions are detected"""
         with test_util.capture_sys_output() as (stdout, stderr):
             with self.assertRaises(ValueError) as e:
-                self._DoTestFile('14_pack_overlap.dts', map=True)
+                self._DoTestFile('014_pack_overlap.dts', map=True)
         map_fname = tools.GetOutputFilename('image.map')
         self.assertEqual("Wrote map file '%s' to show errors\n" % map_fname,
                          stdout.getvalue())
diff --git a/tools/binman/test/01_invalid.dts b/tools/binman/test/001_invalid.dts
similarity index 100%
rename from tools/binman/test/01_invalid.dts
rename to tools/binman/test/001_invalid.dts
diff --git a/tools/binman/test/02_missing_node.dts b/tools/binman/test/002_missing_node.dts
similarity index 100%
rename from tools/binman/test/02_missing_node.dts
rename to tools/binman/test/002_missing_node.dts
diff --git a/tools/binman/test/03_empty.dts b/tools/binman/test/003_empty.dts
similarity index 100%
rename from tools/binman/test/03_empty.dts
rename to tools/binman/test/003_empty.dts
diff --git a/tools/binman/test/04_invalid_entry.dts b/tools/binman/test/004_invalid_entry.dts
similarity index 100%
rename from tools/binman/test/04_invalid_entry.dts
rename to tools/binman/test/004_invalid_entry.dts
diff --git a/tools/binman/test/05_simple.dts b/tools/binman/test/005_simple.dts
similarity index 100%
rename from tools/binman/test/05_simple.dts
rename to tools/binman/test/005_simple.dts
diff --git a/tools/binman/test/06_dual_image.dts b/tools/binman/test/006_dual_image.dts
similarity index 100%
rename from tools/binman/test/06_dual_image.dts
rename to tools/binman/test/006_dual_image.dts
diff --git a/tools/binman/test/07_bad_align.dts b/tools/binman/test/007_bad_align.dts
similarity index 100%
rename from tools/binman/test/07_bad_align.dts
rename to tools/binman/test/007_bad_align.dts
diff --git a/tools/binman/test/08_pack.dts b/tools/binman/test/008_pack.dts
similarity index 100%
rename from tools/binman/test/08_pack.dts
rename to tools/binman/test/008_pack.dts
diff --git a/tools/binman/test/09_pack_extra.dts b/tools/binman/test/009_pack_extra.dts
similarity index 100%
rename from tools/binman/test/09_pack_extra.dts
rename to tools/binman/test/009_pack_extra.dts
diff --git a/tools/binman/test/10_pack_align_power2.dts b/tools/binman/test/010_pack_align_power2.dts
similarity index 100%
rename from tools/binman/test/10_pack_align_power2.dts
rename to tools/binman/test/010_pack_align_power2.dts
diff --git a/tools/binman/test/11_pack_align_size_power2.dts b/tools/binman/test/011_pack_align_size_power2.dts
similarity index 100%
rename from tools/binman/test/11_pack_align_size_power2.dts
rename to tools/binman/test/011_pack_align_size_power2.dts
diff --git a/tools/binman/test/12_pack_inv_align.dts b/tools/binman/test/012_pack_inv_align.dts
similarity index 100%
rename from tools/binman/test/12_pack_inv_align.dts
rename to tools/binman/test/012_pack_inv_align.dts
diff --git a/tools/binman/test/13_pack_inv_size_align.dts b/tools/binman/test/013_pack_inv_size_align.dts
similarity index 100%
rename from tools/binman/test/13_pack_inv_size_align.dts
rename to tools/binman/test/013_pack_inv_size_align.dts
diff --git a/tools/binman/test/14_pack_overlap.dts b/tools/binman/test/014_pack_overlap.dts
similarity index 100%
rename from tools/binman/test/14_pack_overlap.dts
rename to tools/binman/test/014_pack_overlap.dts
diff --git a/tools/binman/test/15_pack_overflow.dts b/tools/binman/test/015_pack_overflow.dts
similarity index 100%
rename from tools/binman/test/15_pack_overflow.dts
rename to tools/binman/test/015_pack_overflow.dts
diff --git a/tools/binman/test/16_pack_image_overflow.dts b/tools/binman/test/016_pack_image_overflow.dts
similarity index 100%
rename from tools/binman/test/16_pack_image_overflow.dts
rename to tools/binman/test/016_pack_image_overflow.dts
diff --git a/tools/binman/test/17_pack_image_size.dts b/tools/binman/test/017_pack_image_size.dts
similarity index 100%
rename from tools/binman/test/17_pack_image_size.dts
rename to tools/binman/test/017_pack_image_size.dts
diff --git a/tools/binman/test/18_pack_image_align.dts b/tools/binman/test/018_pack_image_align.dts
similarity index 100%
rename from tools/binman/test/18_pack_image_align.dts
rename to tools/binman/test/018_pack_image_align.dts
diff --git a/tools/binman/test/19_pack_inv_image_align.dts b/tools/binman/test/019_pack_inv_image_align.dts
similarity index 100%
rename from tools/binman/test/19_pack_inv_image_align.dts
rename to tools/binman/test/019_pack_inv_image_align.dts
diff --git a/tools/binman/test/20_pack_inv_image_align_power2.dts b/tools/binman/test/020_pack_inv_image_align_power2.dts
similarity index 100%
rename from tools/binman/test/20_pack_inv_image_align_power2.dts
rename to tools/binman/test/020_pack_inv_image_align_power2.dts
diff --git a/tools/binman/test/21_image_pad.dts b/tools/binman/test/021_image_pad.dts
similarity index 100%
rename from tools/binman/test/21_image_pad.dts
rename to tools/binman/test/021_image_pad.dts
diff --git a/tools/binman/test/22_image_name.dts b/tools/binman/test/022_image_name.dts
similarity index 100%
rename from tools/binman/test/22_image_name.dts
rename to tools/binman/test/022_image_name.dts
diff --git a/tools/binman/test/23_blob.dts b/tools/binman/test/023_blob.dts
similarity index 100%
rename from tools/binman/test/23_blob.dts
rename to tools/binman/test/023_blob.dts
diff --git a/tools/binman/test/24_sorted.dts b/tools/binman/test/024_sorted.dts
similarity index 100%
rename from tools/binman/test/24_sorted.dts
rename to tools/binman/test/024_sorted.dts
diff --git a/tools/binman/test/25_pack_zero_size.dts b/tools/binman/test/025_pack_zero_size.dts
similarity index 100%
rename from tools/binman/test/25_pack_zero_size.dts
rename to tools/binman/test/025_pack_zero_size.dts
diff --git a/tools/binman/test/26_pack_u_boot_dtb.dts b/tools/binman/test/026_pack_u_boot_dtb.dts
similarity index 100%
rename from tools/binman/test/26_pack_u_boot_dtb.dts
rename to tools/binman/test/026_pack_u_boot_dtb.dts
diff --git a/tools/binman/test/27_pack_4gb_no_size.dts b/tools/binman/test/027_pack_4gb_no_size.dts
similarity index 100%
rename from tools/binman/test/27_pack_4gb_no_size.dts
rename to tools/binman/test/027_pack_4gb_no_size.dts
diff --git a/tools/binman/test/28_pack_4gb_outside.dts b/tools/binman/test/028_pack_4gb_outside.dts
similarity index 100%
rename from tools/binman/test/28_pack_4gb_outside.dts
rename to tools/binman/test/028_pack_4gb_outside.dts
diff --git a/tools/binman/test/29_x86-rom.dts b/tools/binman/test/029_x86-rom.dts
similarity index 100%
rename from tools/binman/test/29_x86-rom.dts
rename to tools/binman/test/029_x86-rom.dts
diff --git a/tools/binman/test/30_x86-rom-me-no-desc.dts b/tools/binman/test/030_x86-rom-me-no-desc.dts
similarity index 100%
rename from tools/binman/test/30_x86-rom-me-no-desc.dts
rename to tools/binman/test/030_x86-rom-me-no-desc.dts
diff --git a/tools/binman/test/31_x86-rom-me.dts b/tools/binman/test/031_x86-rom-me.dts
similarity index 100%
rename from tools/binman/test/31_x86-rom-me.dts
rename to tools/binman/test/031_x86-rom-me.dts
diff --git a/tools/binman/test/32_intel-vga.dts b/tools/binman/test/032_intel-vga.dts
similarity index 100%
rename from tools/binman/test/32_intel-vga.dts
rename to tools/binman/test/032_intel-vga.dts
diff --git a/tools/binman/test/33_x86-start16.dts b/tools/binman/test/033_x86-start16.dts
similarity index 100%
rename from tools/binman/test/33_x86-start16.dts
rename to tools/binman/test/033_x86-start16.dts
diff --git a/tools/binman/test/34_x86_ucode.dts b/tools/binman/test/034_x86_ucode.dts
similarity index 100%
rename from tools/binman/test/34_x86_ucode.dts
rename to tools/binman/test/034_x86_ucode.dts
diff --git a/tools/binman/test/35_x86_single_ucode.dts b/tools/binman/test/035_x86_single_ucode.dts
similarity index 100%
rename from tools/binman/test/35_x86_single_ucode.dts
rename to tools/binman/test/035_x86_single_ucode.dts
diff --git a/tools/binman/test/36_u_boot_img.dts b/tools/binman/test/036_u_boot_img.dts
similarity index 100%
rename from tools/binman/test/36_u_boot_img.dts
rename to tools/binman/test/036_u_boot_img.dts
diff --git a/tools/binman/test/37_x86_no_ucode.dts b/tools/binman/test/037_x86_no_ucode.dts
similarity index 100%
rename from tools/binman/test/37_x86_no_ucode.dts
rename to tools/binman/test/037_x86_no_ucode.dts
diff --git a/tools/binman/test/38_x86_ucode_missing_node.dts b/tools/binman/test/038_x86_ucode_missing_node.dts
similarity index 100%
rename from tools/binman/test/38_x86_ucode_missing_node.dts
rename to tools/binman/test/038_x86_ucode_missing_node.dts
diff --git a/tools/binman/test/39_x86_ucode_missing_node2.dts b/tools/binman/test/039_x86_ucode_missing_node2.dts
similarity index 100%
rename from tools/binman/test/39_x86_ucode_missing_node2.dts
rename to tools/binman/test/039_x86_ucode_missing_node2.dts
diff --git a/tools/binman/test/40_x86_ucode_not_in_image.dts b/tools/binman/test/040_x86_ucode_not_in_image.dts
similarity index 100%
rename from tools/binman/test/40_x86_ucode_not_in_image.dts
rename to tools/binman/test/040_x86_ucode_not_in_image.dts
diff --git a/tools/binman/test/41_unknown_pos_size.dts b/tools/binman/test/041_unknown_pos_size.dts
similarity index 100%
rename from tools/binman/test/41_unknown_pos_size.dts
rename to tools/binman/test/041_unknown_pos_size.dts
diff --git a/tools/binman/test/42_intel-fsp.dts b/tools/binman/test/042_intel-fsp.dts
similarity index 100%
rename from tools/binman/test/42_intel-fsp.dts
rename to tools/binman/test/042_intel-fsp.dts
diff --git a/tools/binman/test/43_intel-cmc.dts b/tools/binman/test/043_intel-cmc.dts
similarity index 100%
rename from tools/binman/test/43_intel-cmc.dts
rename to tools/binman/test/043_intel-cmc.dts
diff --git a/tools/binman/test/44_x86_optional_ucode.dts b/tools/binman/test/044_x86_optional_ucode.dts
similarity index 100%
rename from tools/binman/test/44_x86_optional_ucode.dts
rename to tools/binman/test/044_x86_optional_ucode.dts
diff --git a/tools/binman/test/45_prop_test.dts b/tools/binman/test/045_prop_test.dts
similarity index 100%
rename from tools/binman/test/45_prop_test.dts
rename to tools/binman/test/045_prop_test.dts
diff --git a/tools/binman/test/46_intel-vbt.dts b/tools/binman/test/046_intel-vbt.dts
similarity index 100%
rename from tools/binman/test/46_intel-vbt.dts
rename to tools/binman/test/046_intel-vbt.dts
diff --git a/tools/binman/test/47_spl_bss_pad.dts b/tools/binman/test/047_spl_bss_pad.dts
similarity index 100%
rename from tools/binman/test/47_spl_bss_pad.dts
rename to tools/binman/test/047_spl_bss_pad.dts
diff --git a/tools/binman/test/48_x86-start16-spl.dts b/tools/binman/test/048_x86-start16-spl.dts
similarity index 100%
rename from tools/binman/test/48_x86-start16-spl.dts
rename to tools/binman/test/048_x86-start16-spl.dts
diff --git a/tools/binman/test/49_x86_ucode_spl.dts b/tools/binman/test/049_x86_ucode_spl.dts
similarity index 100%
rename from tools/binman/test/49_x86_ucode_spl.dts
rename to tools/binman/test/049_x86_ucode_spl.dts
diff --git a/tools/binman/test/50_intel_mrc.dts b/tools/binman/test/050_intel_mrc.dts
similarity index 100%
rename from tools/binman/test/50_intel_mrc.dts
rename to tools/binman/test/050_intel_mrc.dts
diff --git a/tools/binman/test/51_u_boot_spl_dtb.dts b/tools/binman/test/051_u_boot_spl_dtb.dts
similarity index 100%
rename from tools/binman/test/51_u_boot_spl_dtb.dts
rename to tools/binman/test/051_u_boot_spl_dtb.dts
diff --git a/tools/binman/test/52_u_boot_spl_nodtb.dts b/tools/binman/test/052_u_boot_spl_nodtb.dts
similarity index 100%
rename from tools/binman/test/52_u_boot_spl_nodtb.dts
rename to tools/binman/test/052_u_boot_spl_nodtb.dts
diff --git a/tools/binman/test/53_symbols.dts b/tools/binman/test/053_symbols.dts
similarity index 100%
rename from tools/binman/test/53_symbols.dts
rename to tools/binman/test/053_symbols.dts
diff --git a/tools/binman/test/54_unit_address.dts b/tools/binman/test/054_unit_address.dts
similarity index 100%
rename from tools/binman/test/54_unit_address.dts
rename to tools/binman/test/054_unit_address.dts
diff --git a/tools/binman/test/55_sections.dts b/tools/binman/test/055_sections.dts
similarity index 100%
rename from tools/binman/test/55_sections.dts
rename to tools/binman/test/055_sections.dts
diff --git a/tools/binman/test/56_name_prefix.dts b/tools/binman/test/056_name_prefix.dts
similarity index 100%
rename from tools/binman/test/56_name_prefix.dts
rename to tools/binman/test/056_name_prefix.dts
diff --git a/tools/binman/test/57_unknown_contents.dts b/tools/binman/test/057_unknown_contents.dts
similarity index 100%
rename from tools/binman/test/57_unknown_contents.dts
rename to tools/binman/test/057_unknown_contents.dts
diff --git a/tools/binman/test/58_x86_ucode_spl_needs_retry.dts b/tools/binman/test/058_x86_ucode_spl_needs_retry.dts
similarity index 100%
rename from tools/binman/test/58_x86_ucode_spl_needs_retry.dts
rename to tools/binman/test/058_x86_ucode_spl_needs_retry.dts
diff --git a/tools/binman/test/59_change_size.dts b/tools/binman/test/059_change_size.dts
similarity index 100%
rename from tools/binman/test/59_change_size.dts
rename to tools/binman/test/059_change_size.dts
diff --git a/tools/binman/test/60_fdt_update.dts b/tools/binman/test/060_fdt_update.dts
similarity index 100%
rename from tools/binman/test/60_fdt_update.dts
rename to tools/binman/test/060_fdt_update.dts
diff --git a/tools/binman/test/61_fdt_update_bad.dts b/tools/binman/test/061_fdt_update_bad.dts
similarity index 100%
rename from tools/binman/test/61_fdt_update_bad.dts
rename to tools/binman/test/061_fdt_update_bad.dts
diff --git a/tools/binman/test/62_entry_args.dts b/tools/binman/test/062_entry_args.dts
similarity index 100%
rename from tools/binman/test/62_entry_args.dts
rename to tools/binman/test/062_entry_args.dts
diff --git a/tools/binman/test/63_entry_args_missing.dts b/tools/binman/test/063_entry_args_missing.dts
similarity index 100%
rename from tools/binman/test/63_entry_args_missing.dts
rename to tools/binman/test/063_entry_args_missing.dts
diff --git a/tools/binman/test/64_entry_args_required.dts b/tools/binman/test/064_entry_args_required.dts
similarity index 100%
rename from tools/binman/test/64_entry_args_required.dts
rename to tools/binman/test/064_entry_args_required.dts
diff --git a/tools/binman/test/65_entry_args_unknown_datatype.dts b/tools/binman/test/065_entry_args_unknown_datatype.dts
similarity index 100%
rename from tools/binman/test/65_entry_args_unknown_datatype.dts
rename to tools/binman/test/065_entry_args_unknown_datatype.dts
diff --git a/tools/binman/test/66_text.dts b/tools/binman/test/066_text.dts
similarity index 100%
rename from tools/binman/test/66_text.dts
rename to tools/binman/test/066_text.dts
diff --git a/tools/binman/test/67_fmap.dts b/tools/binman/test/067_fmap.dts
similarity index 100%
rename from tools/binman/test/67_fmap.dts
rename to tools/binman/test/067_fmap.dts
diff --git a/tools/binman/test/68_blob_named_by_arg.dts b/tools/binman/test/068_blob_named_by_arg.dts
similarity index 100%
rename from tools/binman/test/68_blob_named_by_arg.dts
rename to tools/binman/test/068_blob_named_by_arg.dts
diff --git a/tools/binman/test/69_fill.dts b/tools/binman/test/069_fill.dts
similarity index 100%
rename from tools/binman/test/69_fill.dts
rename to tools/binman/test/069_fill.dts
diff --git a/tools/binman/test/70_fill_no_size.dts b/tools/binman/test/070_fill_no_size.dts
similarity index 100%
rename from tools/binman/test/70_fill_no_size.dts
rename to tools/binman/test/070_fill_no_size.dts
diff --git a/tools/binman/test/71_gbb.dts b/tools/binman/test/071_gbb.dts
similarity index 100%
rename from tools/binman/test/71_gbb.dts
rename to tools/binman/test/071_gbb.dts
diff --git a/tools/binman/test/72_gbb_too_small.dts b/tools/binman/test/072_gbb_too_small.dts
similarity index 100%
rename from tools/binman/test/72_gbb_too_small.dts
rename to tools/binman/test/072_gbb_too_small.dts
diff --git a/tools/binman/test/73_gbb_no_size.dts b/tools/binman/test/073_gbb_no_size.dts
similarity index 100%
rename from tools/binman/test/73_gbb_no_size.dts
rename to tools/binman/test/073_gbb_no_size.dts
diff --git a/tools/binman/test/74_vblock.dts b/tools/binman/test/074_vblock.dts
similarity index 100%
rename from tools/binman/test/74_vblock.dts
rename to tools/binman/test/074_vblock.dts
diff --git a/tools/binman/test/75_vblock_no_content.dts b/tools/binman/test/075_vblock_no_content.dts
similarity index 100%
rename from tools/binman/test/75_vblock_no_content.dts
rename to tools/binman/test/075_vblock_no_content.dts
diff --git a/tools/binman/test/76_vblock_bad_phandle.dts b/tools/binman/test/076_vblock_bad_phandle.dts
similarity index 100%
rename from tools/binman/test/76_vblock_bad_phandle.dts
rename to tools/binman/test/076_vblock_bad_phandle.dts
diff --git a/tools/binman/test/77_vblock_bad_entry.dts b/tools/binman/test/077_vblock_bad_entry.dts
similarity index 100%
rename from tools/binman/test/77_vblock_bad_entry.dts
rename to tools/binman/test/077_vblock_bad_entry.dts
diff --git a/tools/binman/test/78_u_boot_tpl.dts b/tools/binman/test/078_u_boot_tpl.dts
similarity index 100%
rename from tools/binman/test/78_u_boot_tpl.dts
rename to tools/binman/test/078_u_boot_tpl.dts
diff --git a/tools/binman/test/79_uses_pos.dts b/tools/binman/test/079_uses_pos.dts
similarity index 100%
rename from tools/binman/test/79_uses_pos.dts
rename to tools/binman/test/079_uses_pos.dts
diff --git a/tools/binman/test/80_fill_empty.dts b/tools/binman/test/080_fill_empty.dts
similarity index 100%
rename from tools/binman/test/80_fill_empty.dts
rename to tools/binman/test/080_fill_empty.dts
diff --git a/tools/binman/test/81_x86-start16-tpl.dts b/tools/binman/test/081_x86-start16-tpl.dts
similarity index 100%
rename from tools/binman/test/81_x86-start16-tpl.dts
rename to tools/binman/test/081_x86-start16-tpl.dts
diff --git a/tools/binman/test/82_fdt_update_all.dts b/tools/binman/test/082_fdt_update_all.dts
similarity index 100%
rename from tools/binman/test/82_fdt_update_all.dts
rename to tools/binman/test/082_fdt_update_all.dts
diff --git a/tools/binman/test/83_compress.dts b/tools/binman/test/083_compress.dts
similarity index 100%
rename from tools/binman/test/83_compress.dts
rename to tools/binman/test/083_compress.dts
diff --git a/tools/binman/test/84_files.dts b/tools/binman/test/084_files.dts
similarity index 100%
rename from tools/binman/test/84_files.dts
rename to tools/binman/test/084_files.dts
diff --git a/tools/binman/test/85_files_compress.dts b/tools/binman/test/085_files_compress.dts
similarity index 100%
rename from tools/binman/test/85_files_compress.dts
rename to tools/binman/test/085_files_compress.dts
diff --git a/tools/binman/test/86_files_none.dts b/tools/binman/test/086_files_none.dts
similarity index 100%
rename from tools/binman/test/86_files_none.dts
rename to tools/binman/test/086_files_none.dts
diff --git a/tools/binman/test/87_files_no_pattern.dts b/tools/binman/test/087_files_no_pattern.dts
similarity index 100%
rename from tools/binman/test/87_files_no_pattern.dts
rename to tools/binman/test/087_files_no_pattern.dts
diff --git a/tools/binman/test/88_expand_size.dts b/tools/binman/test/088_expand_size.dts
similarity index 100%
rename from tools/binman/test/88_expand_size.dts
rename to tools/binman/test/088_expand_size.dts
diff --git a/tools/binman/test/89_expand_size_bad.dts b/tools/binman/test/089_expand_size_bad.dts
similarity index 100%
rename from tools/binman/test/89_expand_size_bad.dts
rename to tools/binman/test/089_expand_size_bad.dts
diff --git a/tools/binman/test/90_hash.dts b/tools/binman/test/090_hash.dts
similarity index 100%
rename from tools/binman/test/90_hash.dts
rename to tools/binman/test/090_hash.dts
diff --git a/tools/binman/test/91_hash_no_algo.dts b/tools/binman/test/091_hash_no_algo.dts
similarity index 100%
rename from tools/binman/test/91_hash_no_algo.dts
rename to tools/binman/test/091_hash_no_algo.dts
diff --git a/tools/binman/test/92_hash_bad_algo.dts b/tools/binman/test/092_hash_bad_algo.dts
similarity index 100%
rename from tools/binman/test/92_hash_bad_algo.dts
rename to tools/binman/test/092_hash_bad_algo.dts
diff --git a/tools/binman/test/93_x86_tpl_ucode.dts b/tools/binman/test/093_x86_tpl_ucode.dts
similarity index 100%
rename from tools/binman/test/93_x86_tpl_ucode.dts
rename to tools/binman/test/093_x86_tpl_ucode.dts
diff --git a/tools/binman/test/94_fmap_x86.dts b/tools/binman/test/094_fmap_x86.dts
similarity index 100%
rename from tools/binman/test/94_fmap_x86.dts
rename to tools/binman/test/094_fmap_x86.dts
diff --git a/tools/binman/test/95_fmap_x86_section.dts b/tools/binman/test/095_fmap_x86_section.dts
similarity index 100%
rename from tools/binman/test/95_fmap_x86_section.dts
rename to tools/binman/test/095_fmap_x86_section.dts
diff --git a/tools/binman/test/96_elf.dts b/tools/binman/test/096_elf.dts
similarity index 100%
rename from tools/binman/test/96_elf.dts
rename to tools/binman/test/096_elf.dts
diff --git a/tools/binman/test/97_elf_strip.dts b/tools/binman/test/097_elf_strip.dts
similarity index 100%
rename from tools/binman/test/97_elf_strip.dts
rename to tools/binman/test/097_elf_strip.dts
diff --git a/tools/binman/test/99_hash_section.dts b/tools/binman/test/099_hash_section.dts
similarity index 100%
rename from tools/binman/test/99_hash_section.dts
rename to tools/binman/test/099_hash_section.dts
-- 
2.19.0.605.g01d371f741-goog

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 27/45] binman: Add a test for Intel reference code
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (25 preceding siblings ...)
  2018-10-01 18:22 ` [U-Boot] [PATCH 26/45] binman: Move to three-digit test-file numbers Simon Glass
@ 2018-10-01 18:22 ` Simon Glass
  2018-10-22 20:54   ` [U-Boot] [U-Boot, " Tom Rini
  2018-10-01 18:22 ` [U-Boot] [PATCH 28/45] log: Add comments to the rest of the log categories Simon Glass
                   ` (57 subsequent siblings)
  84 siblings, 1 reply; 106+ messages in thread
From: Simon Glass @ 2018-10-01 18:22 UTC (permalink / raw)
  To: u-boot

Unfortunately the test was not included in the original implementation.
Add one.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 tools/binman/ftest.py                   |  7 +++++++
 tools/binman/test/100_intel_refcode.dts | 14 ++++++++++++++
 2 files changed, 21 insertions(+)
 create mode 100644 tools/binman/test/100_intel_refcode.dts

diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index 167f56dd060..e77fce5a26f 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -60,6 +60,7 @@ VBLOCK_DATA           = 'vblk'
 FILES_DATA            = ("sorry I'm late\nOh, don't bother apologising, I'm " +
                          "sorry you're alive\n")
 COMPRESS_DATA         = 'data to compress'
+REFCODE_DATA          = 'refcode'
 
 
 class TestFunctional(unittest.TestCase):
@@ -115,6 +116,7 @@ class TestFunctional(unittest.TestCase):
         TestFunctional._MakeInputFile('ecrw.bin', CROS_EC_RW_DATA)
         TestFunctional._MakeInputDir('devkeys')
         TestFunctional._MakeInputFile('bmpblk.bin', BMPBLK_DATA)
+        TestFunctional._MakeInputFile('refcode.bin', REFCODE_DATA)
 
         # ELF file with a '_dt_ucode_base_size' symbol
         with open(self.TestFile('u_boot_ucode_ptr')) as fd:
@@ -1764,6 +1766,11 @@ class TestFunctional(unittest.TestCase):
 <none>     00000003  00000004  u-boot-align
 ''', map_data)
 
+    def testPacRefCode(self):
+        """Test that an image with an Intel Reference code binary works"""
+        data = self._DoReadFile('100_intel_refcode.dts')
+        self.assertEqual(REFCODE_DATA, data[:len(REFCODE_DATA)])
+
 
 if __name__ == "__main__":
     unittest.main()
diff --git a/tools/binman/test/100_intel_refcode.dts b/tools/binman/test/100_intel_refcode.dts
new file mode 100644
index 00000000000..0a1a0270e5f
--- /dev/null
+++ b/tools/binman/test/100_intel_refcode.dts
@@ -0,0 +1,14 @@
+/dts-v1/;
+
+/ {
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	binman {
+		size = <16>;
+
+		intel-refcode {
+			filename = "refcode.bin";
+		};
+	};
+};
-- 
2.19.0.605.g01d371f741-goog

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 28/45] log: Add comments to the rest of the log categories
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (26 preceding siblings ...)
  2018-10-01 18:22 ` [U-Boot] [PATCH 27/45] binman: Add a test for Intel reference code Simon Glass
@ 2018-10-01 18:22 ` Simon Glass
  2018-10-01 18:22 ` [U-Boot] [PATCH 29/45] malloc_simple: Add logging of allocations Simon Glass
                   ` (56 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: Simon Glass @ 2018-10-01 18:22 UTC (permalink / raw)
  To: u-boot

At present some of the log categories are missing comments. Add them.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 include/log.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/include/log.h b/include/log.h
index 623f0fc32f7..0243bc08a4f 100644
--- a/include/log.h
+++ b/include/log.h
@@ -39,18 +39,18 @@ enum log_level_t {
 enum log_category_t {
 	LOGC_FIRST = 0,	/* First part mirrors UCLASS_... */
 
-	LOGC_NONE = UCLASS_COUNT,
-	LOGC_ARCH,
-	LOGC_BOARD,
-	LOGC_CORE,
+	LOGC_NONE = UCLASS_COUNT,	/* First number is after all uclasses */
+	LOGC_ARCH,	/* Related to arch-specific code */
+	LOGC_BOARD,	/* Related to board-specific code */
+	LOGC_CORE,	/* Related to core features (non-driver-model) */
 	LOGC_DM,	/* Core driver-model */
 	LOGC_DT,	/* Device-tree */
 	LOGC_EFI,	/* EFI implementation */
 	LOGC_BLOBLIST,	/* Bloblist */
 	LOGC_ALLOC,	/* Memory allocation */
 
-	LOGC_COUNT,
-	LOGC_END,
+	LOGC_COUNT,	/* Number of log categories */
+	LOGC_END,	/* Sentinel value for a list of log categories */
 };
 
 /* Helper to cast a uclass ID to a log category */
-- 
2.19.0.605.g01d371f741-goog

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 29/45] malloc_simple: Add logging of allocations
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (27 preceding siblings ...)
  2018-10-01 18:22 ` [U-Boot] [PATCH 28/45] log: Add comments to the rest of the log categories Simon Glass
@ 2018-10-01 18:22 ` Simon Glass
  2018-10-01 18:22 ` [U-Boot] [PATCH 30/45] Add a header file for strings Simon Glass
                   ` (55 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: Simon Glass @ 2018-10-01 18:22 UTC (permalink / raw)
  To: u-boot

It is sometimes useful to see what memory is being allocated early during
boot. Add logging to support this, using a new LOGC_ALLOC category.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 common/malloc_simple.c | 58 +++++++++++++++++++++++++++---------------
 include/malloc.h       |  1 +
 2 files changed, 38 insertions(+), 21 deletions(-)

diff --git a/common/malloc_simple.c b/common/malloc_simple.c
index 871b5444bd7..aae0b66680a 100644
--- a/common/malloc_simple.c
+++ b/common/malloc_simple.c
@@ -5,6 +5,8 @@
  * Copyright (c) 2014 Google, Inc
  */
 
+#define LOG_CATEGORY LOGC_ALLOC
+
 #include <common.h>
 #include <malloc.h>
 #include <mapmem.h>
@@ -12,40 +14,47 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-void *malloc_simple(size_t bytes)
+static void *alloc_simple(size_t bytes, int align)
 {
-	ulong new_ptr;
+	ulong addr, new_ptr;
 	void *ptr;
 
-	new_ptr = gd->malloc_ptr + bytes;
-	debug("%s: size=%zx, ptr=%lx, limit=%lx: ", __func__, bytes, new_ptr,
-	      gd->malloc_limit);
+	addr = ALIGN(gd->malloc_base + gd->malloc_ptr, align);
+	new_ptr = addr + bytes - gd->malloc_base;
+	log_debug("size=%zx, ptr=%lx, limit=%lx: ", bytes, new_ptr,
+	gd->malloc_limit);
 	if (new_ptr > gd->malloc_limit) {
-		debug("space exhausted\n");
+		log(LOGC_ALLOC, LOGL_ERR, "alloc space exhausted\n");
 		return NULL;
 	}
-	ptr = map_sysmem(gd->malloc_base + gd->malloc_ptr, bytes);
+
+	ptr = map_sysmem(addr, bytes);
 	gd->malloc_ptr = ALIGN(new_ptr, sizeof(new_ptr));
-	debug("%lx\n", (ulong)ptr);
 
 	return ptr;
 }
 
-void *memalign_simple(size_t align, size_t bytes)
+void *malloc_simple(size_t bytes)
 {
-	ulong addr, new_ptr;
 	void *ptr;
 
-	addr = ALIGN(gd->malloc_base + gd->malloc_ptr, align);
-	new_ptr = addr + bytes - gd->malloc_base;
-	if (new_ptr > gd->malloc_limit) {
-		debug("space exhausted\n");
-		return NULL;
-	}
+	ptr = alloc_simple(bytes, 1);
+	if (!ptr)
+		return ptr;
 
-	ptr = map_sysmem(addr, bytes);
-	gd->malloc_ptr = ALIGN(new_ptr, sizeof(new_ptr));
-	debug("%lx\n", (ulong)ptr);
+	log_debug("%lx\n", (ulong)ptr);
+
+	return ptr;
+}
+
+void *memalign_simple(size_t align, size_t bytes)
+{
+	void *ptr;
+
+	ptr = alloc_simple(bytes, align);
+	if (!ptr)
+		return ptr;
+	log_debug("aligned to %lx\n", (ulong)ptr);
 
 	return ptr;
 }
@@ -57,9 +66,16 @@ void *calloc(size_t nmemb, size_t elem_size)
 	void *ptr;
 
 	ptr = malloc(size);
-	if (ptr)
-		memset(ptr, '\0', size);
+	if (!ptr)
+		return ptr;
+	memset(ptr, '\0', size);
 
 	return ptr;
 }
 #endif
+
+void malloc_simple_info(void)
+{
+	log_info("malloc_simple: %lx bytes used, %lx remain\n", gd->malloc_ptr,
+		 CONFIG_VAL(SYS_MALLOC_F_LEN) - gd->malloc_ptr);
+}
diff --git a/include/malloc.h b/include/malloc.h
index 8175c75920c..b714fedf457 100644
--- a/include/malloc.h
+++ b/include/malloc.h
@@ -880,6 +880,7 @@ static inline void free(void *ptr) {}
 void *calloc(size_t nmemb, size_t size);
 void *memalign_simple(size_t alignment, size_t bytes);
 void *realloc_simple(void *ptr, size_t size);
+void malloc_simple_info(void);
 #else
 
 # ifdef USE_DL_PREFIX
-- 
2.19.0.605.g01d371f741-goog

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 30/45] Add a header file for strings
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (28 preceding siblings ...)
  2018-10-01 18:22 ` [U-Boot] [PATCH 29/45] malloc_simple: Add logging of allocations Simon Glass
@ 2018-10-01 18:22 ` Simon Glass
  2018-10-01 18:22 ` [U-Boot] [PATCH 31/45] Rename GPT_HEADER_SIGNATURE to avoid conflict Simon Glass
                   ` (54 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: Simon Glass @ 2018-10-01 18:22 UTC (permalink / raw)
  To: u-boot

Add a string.h header for libraries that expect this to be available, now
that U-Boot's version has moved to include/linux.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 include/string.h | 1 +
 1 file changed, 1 insertion(+)
 create mode 100644 include/string.h

diff --git a/include/string.h b/include/string.h
new file mode 100644
index 00000000000..38134dcf4c7
--- /dev/null
+++ b/include/string.h
@@ -0,0 +1 @@
+#include <linux/string.h>
-- 
2.19.0.605.g01d371f741-goog

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 31/45] Rename GPT_HEADER_SIGNATURE to avoid conflict
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (29 preceding siblings ...)
  2018-10-01 18:22 ` [U-Boot] [PATCH 30/45] Add a header file for strings Simon Glass
@ 2018-10-01 18:22 ` Simon Glass
  2018-10-01 18:22 ` [U-Boot] [PATCH 32/45] cros: Update ec_commands to latest version Simon Glass
                   ` (53 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: Simon Glass @ 2018-10-01 18:22 UTC (permalink / raw)
  To: u-boot

The current name conflicts with the Chrome OS verified boot library, which
prevents it being built. That library uses a string whereas U-Boot uses a
64-bit hex value. Rename this in U-Boot.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 disk/part_efi.c    | 6 +++---
 include/part_efi.h | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/disk/part_efi.c b/disk/part_efi.c
index 519a6376848..d6bb53e6b5d 100644
--- a/disk/part_efi.c
+++ b/disk/part_efi.c
@@ -82,11 +82,11 @@ static int validate_gpt_header(gpt_header *gpt_h, lbaint_t lba,
 	uint32_t calc_crc32;
 
 	/* Check the GPT header signature */
-	if (le64_to_cpu(gpt_h->signature) != GPT_HEADER_SIGNATURE) {
+	if (le64_to_cpu(gpt_h->signature) != GPT_HEADER_SIGNATURE_UBOOT) {
 		printf("%s signature is wrong: 0x%llX != 0x%llX\n",
 		       "GUID Partition Table Header",
 		       le64_to_cpu(gpt_h->signature),
-		       GPT_HEADER_SIGNATURE);
+		       GPT_HEADER_SIGNATURE_UBOOT);
 		return -1;
 	}
 
@@ -603,7 +603,7 @@ static uint32_t partition_entries_offset(struct blk_desc *dev_desc)
 int gpt_fill_header(struct blk_desc *dev_desc, gpt_header *gpt_h,
 		char *str_guid, int parts_count)
 {
-	gpt_h->signature = cpu_to_le64(GPT_HEADER_SIGNATURE);
+	gpt_h->signature = cpu_to_le64(GPT_HEADER_SIGNATURE_UBOOT);
 	gpt_h->revision = cpu_to_le32(GPT_HEADER_REVISION_V1);
 	gpt_h->header_size = cpu_to_le32(sizeof(gpt_header));
 	gpt_h->my_lba = cpu_to_le64(1);
diff --git a/include/part_efi.h b/include/part_efi.h
index 8525770445a..7170b61c955 100644
--- a/include/part_efi.h
+++ b/include/part_efi.h
@@ -24,7 +24,7 @@
 #define EFI_PMBR_OSTYPE_EFI 0xEF
 #define EFI_PMBR_OSTYPE_EFI_GPT 0xEE
 
-#define GPT_HEADER_SIGNATURE 0x5452415020494645ULL
+#define GPT_HEADER_SIGNATURE_UBOOT 0x5452415020494645ULL
 #define GPT_HEADER_REVISION_V1 0x00010000
 #define GPT_PRIMARY_PARTITION_TABLE_LBA 1ULL
 #define GPT_ENTRY_NUMBERS		CONFIG_EFI_PARTITION_ENTRIES_NUMBERS
-- 
2.19.0.605.g01d371f741-goog

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 32/45] cros: Update ec_commands to latest version
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (30 preceding siblings ...)
  2018-10-01 18:22 ` [U-Boot] [PATCH 31/45] Rename GPT_HEADER_SIGNATURE to avoid conflict Simon Glass
@ 2018-10-01 18:22 ` Simon Glass
  2018-10-01 18:22 ` [U-Boot] [PATCH 33/45] x86: Update mtrr functions to allow leaving cache alone Simon Glass
                   ` (52 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: Simon Glass @ 2018-10-01 18:22 UTC (permalink / raw)
  To: u-boot

This file has changed quite a bit in the last 5 years as the capabilities
of the ECs have grown. Sync it up with the copy in coreboot commit
b9141f2215.

The only change is the addition of EC_VBNV_BLOCK_SIZE_V2. This is needed
because U-Boot uses the new v2 vboot API and this is not currently fully
supported by Chromium OS firmware.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 cmd/cros_ec.c                  |    5 +-
 drivers/misc/cros_ec.c         |    7 +-
 drivers/misc/cros_ec_sandbox.c |    4 +-
 include/ec_commands.h          | 4324 ++++++++++++++++++++++++++------
 4 files changed, 3613 insertions(+), 727 deletions(-)

diff --git a/cmd/cros_ec.c b/cmd/cros_ec.c
index fb369a4e329..3ac4f3b235d 100644
--- a/cmd/cros_ec.c
+++ b/cmd/cros_ec.c
@@ -27,7 +27,7 @@ static int cros_ec_decode_region(int argc, char * const argv[])
 {
 	if (argc > 0) {
 		if (0 == strcmp(*argv, "rw"))
-			return EC_FLASH_REGION_RW;
+			return EC_FLASH_REGION_ACTIVE;
 		else if (0 == strcmp(*argv, "ro"))
 			return EC_FLASH_REGION_RO;
 
@@ -137,7 +137,6 @@ static int do_cros_ec(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 		}
 		printf("rows     = %u\n", info.rows);
 		printf("cols     = %u\n", info.cols);
-		printf("switches = %#x\n", info.switches);
 	} else if (0 == strcmp("curimage", cmd)) {
 		enum ec_current_image image;
 
@@ -177,7 +176,7 @@ static int do_cros_ec(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 			region = cros_ec_decode_region(argc - 2, argv + 2);
 			if (region == EC_FLASH_REGION_RO)
 				cmd = EC_REBOOT_JUMP_RO;
-			else if (region == EC_FLASH_REGION_RW)
+			else if (region == EC_FLASH_REGION_ACTIVE)
 				cmd = EC_REBOOT_JUMP_RW;
 			else
 				return CMD_RET_USAGE;
diff --git a/drivers/misc/cros_ec.c b/drivers/misc/cros_ec.c
index 5ccf8ad359b..2deed0e839f 100644
--- a/drivers/misc/cros_ec.c
+++ b/drivers/misc/cros_ec.c
@@ -473,7 +473,7 @@ int cros_ec_read_hash(struct udevice *dev, struct ec_response_vboot_hash *hash)
 	p.cmd = EC_VBOOT_HASH_START;
 	p.hash_type = EC_VBOOT_HASH_TYPE_SHA256;
 	p.nonce_size = 0;
-	p.offset = EC_VBOOT_HASH_OFFSET_RW;
+	p.offset = EC_VBOOT_HASH_OFFSET_ACTIVE;
 
 	if (ec_command(dev, EC_CMD_VBOOT_HASH, 0, &p, sizeof(p),
 		       hash, sizeof(*hash)) < 0)
@@ -894,7 +894,8 @@ int cros_ec_flash_update_rw(struct udevice *dev, const uint8_t *image,
 	uint32_t rw_offset, rw_size;
 	int ret;
 
-	if (cros_ec_flash_offset(dev, EC_FLASH_REGION_RW, &rw_offset, &rw_size))
+	if (cros_ec_flash_offset(dev, EC_FLASH_REGION_ACTIVE, &rw_offset,
+		&rw_size))
 		return -1;
 	if (image_size > (int)rw_size)
 		return -1;
@@ -1045,7 +1046,7 @@ int cros_ec_decode_ec_flash(struct udevice *dev, struct fdt_cros_ec *config)
 		if (0 == strcmp(name, "ro")) {
 			region = EC_FLASH_REGION_RO;
 		} else if (0 == strcmp(name, "rw")) {
-			region = EC_FLASH_REGION_RW;
+			region = EC_FLASH_REGION_ACTIVE;
 		} else if (0 == strcmp(name, "wp-ro")) {
 			region = EC_FLASH_REGION_WP_RO;
 		} else {
diff --git a/drivers/misc/cros_ec_sandbox.c b/drivers/misc/cros_ec_sandbox.c
index dedad9b8573..d741554d8a6 100644
--- a/drivers/misc/cros_ec_sandbox.c
+++ b/drivers/misc/cros_ec_sandbox.c
@@ -365,7 +365,7 @@ static int process_cmd(struct ec_state *ec,
 		struct fmap_entry *entry;
 		int ret, size;
 
-		entry = &ec->ec_config.region[EC_FLASH_REGION_RW];
+		entry = &ec->ec_config.region[EC_FLASH_REGION_ACTIVE];
 
 		switch (req->cmd) {
 		case EC_VBOOT_HASH_RECALC:
@@ -420,7 +420,7 @@ static int process_cmd(struct ec_state *ec,
 
 		switch (req->region) {
 		case EC_FLASH_REGION_RO:
-		case EC_FLASH_REGION_RW:
+		case EC_FLASH_REGION_ACTIVE:
 		case EC_FLASH_REGION_WP_RO:
 			entry = &ec->ec_config.region[req->region];
 			resp->offset = entry->offset;
diff --git a/include/ec_commands.h b/include/ec_commands.h
index 76050664372..392c1f1a43a 100644
--- a/include/ec_commands.h
+++ b/include/ec_commands.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
+/* Copyright (c) 2018 The Chromium OS Authors. All rights reserved.
  * Use of this source code is governed by a BSD-style license that can be
  * found in the LICENSE file.
  */
@@ -27,7 +27,13 @@
  * On I2C, all bytes are sent serially in the same message.
  */
 
-/* Current version of this protocol */
+/*
+ * Current version of this protocol
+ *
+ * TODO(crosbug.com/p/11223): This is effectively useless; protocol is
+ * determined in other ways.  Remove this once the kernel code no longer
+ * depends on it.
+ */
 #define EC_PROTO_VERSION          0x00000002
 
 /* Command version mask */
@@ -70,18 +76,22 @@
 #define EC_MEMMAP_TEXT_MAX     8   /* Size of a string in the memory map */
 
 /* The offset address of each type of data in mapped memory. */
-#define EC_MEMMAP_TEMP_SENSOR      0x00 /* Temp sensors */
-#define EC_MEMMAP_FAN              0x10 /* Fan speeds */
-#define EC_MEMMAP_TEMP_SENSOR_B    0x18 /* Temp sensors (second set) */
-#define EC_MEMMAP_ID               0x20 /* 'E' 'C' */
+#define EC_MEMMAP_TEMP_SENSOR      0x00 /* Temp sensors 0x00 - 0x0f */
+#define EC_MEMMAP_FAN              0x10 /* Fan speeds 0x10 - 0x17 */
+#define EC_MEMMAP_TEMP_SENSOR_B    0x18 /* More temp sensors 0x18 - 0x1f */
+#define EC_MEMMAP_ID               0x20 /* 0x20 == 'E', 0x21 == 'C' */
 #define EC_MEMMAP_ID_VERSION       0x22 /* Version of data in 0x20 - 0x2f */
 #define EC_MEMMAP_THERMAL_VERSION  0x23 /* Version of data in 0x00 - 0x1f */
 #define EC_MEMMAP_BATTERY_VERSION  0x24 /* Version of data in 0x40 - 0x7f */
 #define EC_MEMMAP_SWITCHES_VERSION 0x25 /* Version of data in 0x30 - 0x33 */
 #define EC_MEMMAP_EVENTS_VERSION   0x26 /* Version of data in 0x34 - 0x3f */
-#define EC_MEMMAP_HOST_CMD_FLAGS   0x27 /* Host command interface flags */
-#define EC_MEMMAP_SWITCHES         0x30
-#define EC_MEMMAP_HOST_EVENTS      0x34
+#define EC_MEMMAP_HOST_CMD_FLAGS   0x27 /* Host cmd interface flags (8 bits) */
+/* Unused 0x28 - 0x2f */
+#define EC_MEMMAP_SWITCHES         0x30	/* 8 bits */
+/* Unused 0x31 - 0x33 */
+#define EC_MEMMAP_HOST_EVENTS      0x34 /* 32 bits */
+/* Reserve 0x38 - 0x3f for additional host event-related stuff */
+/* Battery values are all 32 bits */
 #define EC_MEMMAP_BATT_VOLT        0x40 /* Battery Present Voltage */
 #define EC_MEMMAP_BATT_RATE        0x44 /* Battery Present Rate */
 #define EC_MEMMAP_BATT_CAP         0x48 /* Battery Remaining Capacity */
@@ -90,10 +100,33 @@
 #define EC_MEMMAP_BATT_DVLT        0x54 /* Battery Design Voltage */
 #define EC_MEMMAP_BATT_LFCC        0x58 /* Battery Last Full Charge Capacity */
 #define EC_MEMMAP_BATT_CCNT        0x5c /* Battery Cycle Count */
+/* Strings are all 8 bytes (EC_MEMMAP_TEXT_MAX) */
 #define EC_MEMMAP_BATT_MFGR        0x60 /* Battery Manufacturer String */
 #define EC_MEMMAP_BATT_MODEL       0x68 /* Battery Model Number String */
 #define EC_MEMMAP_BATT_SERIAL      0x70 /* Battery Serial Number String */
 #define EC_MEMMAP_BATT_TYPE        0x78 /* Battery Type String */
+#define EC_MEMMAP_ALS              0x80 /* ALS readings in lux (2 X 16 bits) */
+/* Unused 0x84 - 0x8f */
+#define EC_MEMMAP_ACC_STATUS       0x90 /* Accelerometer status (8 bits )*/
+/* Unused 0x91 */
+#define EC_MEMMAP_ACC_DATA         0x92 /* Accelerometers data 0x92 - 0x9f */
+/* 0x92: Lid Angle if available, LID_ANGLE_UNRELIABLE otherwise */
+/* 0x94 - 0x99: 1st Accelerometer */
+/* 0x9a - 0x9f: 2nd Accelerometer */
+#define EC_MEMMAP_GYRO_DATA        0xa0 /* Gyroscope data 0xa0 - 0xa5 */
+/* Unused 0xa6 - 0xdf */
+
+/*
+ * ACPI is unable to access memory mapped data at or above this offset due to
+ * limitations of the ACPI protocol. Do not place data in the range 0xe0 - 0xfe
+ * which might be needed by ACPI.
+ */
+#define EC_MEMMAP_NO_ACPI 0xe0
+
+/* Define the format of the accelerometer mapped memory status byte. */
+#define EC_MEMMAP_ACC_STATUS_SAMPLE_ID_MASK  0x0f
+#define EC_MEMMAP_ACC_STATUS_BUSY_BIT        (1 << 4)
+#define EC_MEMMAP_ACC_STATUS_PRESENCE_BIT    (1 << 7)
 
 /* Number of temp sensors@EC_MEMMAP_TEMP_SENSOR */
 #define EC_TEMP_SENSOR_ENTRIES     16
@@ -103,6 +136,8 @@
  * Valid only if EC_MEMMAP_THERMAL_VERSION returns >= 2.
  */
 #define EC_TEMP_SENSOR_B_ENTRIES      8
+
+/* Special values for mapped temperature sensors */
 #define EC_TEMP_SENSOR_NOT_PRESENT    0xff
 #define EC_TEMP_SENSOR_ERROR          0xfe
 #define EC_TEMP_SENSOR_NOT_POWERED    0xfd
@@ -113,6 +148,18 @@
  */
 #define EC_TEMP_SENSOR_OFFSET      200
 
+/*
+ * Number of ALS readings at EC_MEMMAP_ALS
+ */
+#define EC_ALS_ENTRIES             2
+
+/*
+ * The default value a temperature sensor will return when it is present but
+ * has not been read this boot.  This is a reasonable number to avoid
+ * triggering alarms on the host.
+ */
+#define EC_TEMP_SENSOR_DEFAULT     (296 - EC_TEMP_SENSOR_OFFSET)
+
 #define EC_FAN_SPEED_ENTRIES       4       /* Number of fans at EC_MEMMAP_FAN */
 #define EC_FAN_SPEED_NOT_PRESENT   0xffff  /* Entry not present */
 #define EC_FAN_SPEED_STALLED       0xfffe  /* Fan stalled */
@@ -142,9 +189,158 @@
 #define EC_HOST_CMD_FLAG_VERSION_3   0x02
 
 /* Wireless switch flags */
-#define EC_WIRELESS_SWITCH_WLAN      0x01
-#define EC_WIRELESS_SWITCH_BLUETOOTH 0x02
-#define EC_WIRELESS_SWITCH_WWAN      0x04
+#define EC_WIRELESS_SWITCH_ALL       ~0x00  /* All flags */
+#define EC_WIRELESS_SWITCH_WLAN       0x01  /* WLAN radio */
+#define EC_WIRELESS_SWITCH_BLUETOOTH  0x02  /* Bluetooth radio */
+#define EC_WIRELESS_SWITCH_WWAN       0x04  /* WWAN power */
+#define EC_WIRELESS_SWITCH_WLAN_POWER 0x08  /* WLAN power */
+
+/*****************************************************************************/
+/*
+ * ACPI commands
+ *
+ * These are valid ONLY on the ACPI command/data port.
+ */
+
+/*
+ * ACPI Read Embedded Controller
+ *
+ * This reads from ACPI memory space on the EC (EC_ACPI_MEM_*).
+ *
+ * Use the following sequence:
+ *
+ *    - Write EC_CMD_ACPI_READ to EC_LPC_ADDR_ACPI_CMD
+ *    - Wait for EC_LPC_CMDR_PENDING bit to clear
+ *    - Write address to EC_LPC_ADDR_ACPI_DATA
+ *    - Wait for EC_LPC_CMDR_DATA bit to set
+ *    - Read value from EC_LPC_ADDR_ACPI_DATA
+ */
+#define EC_CMD_ACPI_READ 0x0080
+
+/*
+ * ACPI Write Embedded Controller
+ *
+ * This reads from ACPI memory space on the EC (EC_ACPI_MEM_*).
+ *
+ * Use the following sequence:
+ *
+ *    - Write EC_CMD_ACPI_WRITE to EC_LPC_ADDR_ACPI_CMD
+ *    - Wait for EC_LPC_CMDR_PENDING bit to clear
+ *    - Write address to EC_LPC_ADDR_ACPI_DATA
+ *    - Wait for EC_LPC_CMDR_PENDING bit to clear
+ *    - Write value to EC_LPC_ADDR_ACPI_DATA
+ */
+#define EC_CMD_ACPI_WRITE 0x0081
+
+/*
+ * ACPI Burst Enable Embedded Controller
+ *
+ * This enables burst mode on the EC to allow the host to issue several
+ * commands back-to-back. While in this mode, writes to mapped multi-byte
+ * data are locked out to ensure data consistency.
+ */
+#define EC_CMD_ACPI_BURST_ENABLE 0x0082
+
+/*
+ * ACPI Burst Disable Embedded Controller
+ *
+ * This disables burst mode on the EC and stops preventing EC writes to mapped
+ * multi-byte data.
+ */
+#define EC_CMD_ACPI_BURST_DISABLE 0x0083
+
+/*
+ * ACPI Query Embedded Controller
+ *
+ * This clears the lowest-order bit in the currently pending host events, and
+ * sets the result code to the 1-based index of the bit (event 0x00000001 = 1,
+ * event 0x80000000 = 32), or 0 if no event was pending.
+ */
+#define EC_CMD_ACPI_QUERY_EVENT 0x0084
+
+/* Valid addresses in ACPI memory space, for read/write commands */
+
+/* Memory space version; set to EC_ACPI_MEM_VERSION_CURRENT */
+#define EC_ACPI_MEM_VERSION            0x00
+/*
+ * Test location; writing value here updates test compliment byte to (0xff -
+ * value).
+ */
+#define EC_ACPI_MEM_TEST               0x01
+/* Test compliment; writes here are ignored. */
+#define EC_ACPI_MEM_TEST_COMPLIMENT    0x02
+
+/* Keyboard backlight brightness percent (0 - 100) */
+#define EC_ACPI_MEM_KEYBOARD_BACKLIGHT 0x03
+/* DPTF Target Fan Duty (0-100, 0xff for auto/none) */
+#define EC_ACPI_MEM_FAN_DUTY           0x04
+
+/*
+ * DPTF temp thresholds. Any of the EC's temp sensors can have up to two
+ * independent thresholds attached to them. The current value of the ID
+ * register determines which sensor is affected by the THRESHOLD and COMMIT
+ * registers. The THRESHOLD register uses the same EC_TEMP_SENSOR_OFFSET scheme
+ * as the memory-mapped sensors. The COMMIT register applies those settings.
+ *
+ * The spec does not mandate any way to read back the threshold settings
+ * themselves, but when a threshold is crossed the AP needs a way to determine
+ * which sensor(s) are responsible. Each reading of the ID register clears and
+ * returns one sensor ID that has crossed one of its threshold (in either
+ * direction) since the last read. A value of 0xFF means "no new thresholds
+ * have tripped". Setting or enabling the thresholds for a sensor will clear
+ * the unread event count for that sensor.
+ */
+#define EC_ACPI_MEM_TEMP_ID            0x05
+#define EC_ACPI_MEM_TEMP_THRESHOLD     0x06
+#define EC_ACPI_MEM_TEMP_COMMIT        0x07
+/*
+ * Here are the bits for the COMMIT register:
+ *   bit 0 selects the threshold index for the chosen sensor (0/1)
+ *   bit 1 enables/disables the selected threshold (0 = off, 1 = on)
+ * Each write to the commit register affects one threshold.
+ */
+#define EC_ACPI_MEM_TEMP_COMMIT_SELECT_MASK (1 << 0)
+#define EC_ACPI_MEM_TEMP_COMMIT_ENABLE_MASK (1 << 1)
+/*
+ * Example:
+ *
+ * Set the thresholds for sensor 2 to 50 C and 60 C:
+ *   write 2 to [0x05]      --  select temp sensor 2
+ *   write 0x7b to [0x06]   --  C_TO_K(50) - EC_TEMP_SENSOR_OFFSET
+ *   write 0x2 to [0x07]    --  enable threshold 0 with this value
+ *   write 0x85 to [0x06]   --  C_TO_K(60) - EC_TEMP_SENSOR_OFFSET
+ *   write 0x3 to [0x07]    --  enable threshold 1 with this value
+ *
+ * Disable the 60 C threshold, leaving the 50 C threshold unchanged:
+ *   write 2 to [0x05]      --  select temp sensor 2
+ *   write 0x1 to [0x07]    --  disable threshold 1
+ */
+
+/* DPTF battery charging current limit */
+#define EC_ACPI_MEM_CHARGING_LIMIT     0x08
+
+/* Charging limit is specified in 64 mA steps */
+#define EC_ACPI_MEM_CHARGING_LIMIT_STEP_MA   64
+/* Value to disable DPTF battery charging limit */
+#define EC_ACPI_MEM_CHARGING_LIMIT_DISABLED  0xff
+
+/*
+ * Report device orientation
+ *   bit 0 device is tablet mode
+ */
+#define EC_ACPI_MEM_DEVICE_ORIENTATION 0x09
+#define EC_ACPI_MEM_DEVICE_TABLET_MODE 0x01
+
+/*
+ * ACPI addresses 0x20 - 0xff map to EC_MEMMAP offset 0x00 - 0xdf.  This data
+ * is read-only from the AP.  Added in EC_ACPI_MEM_VERSION 2.
+ */
+#define EC_ACPI_MEM_MAPPED_BEGIN   0x20
+#define EC_ACPI_MEM_MAPPED_SIZE    0xe0
+
+/* Current version of ACPI memory address space */
+#define EC_ACPI_MEM_VERSION_CURRENT 2
+
 
 /*
  * This header file is used in coreboot both in C and ACPI code.  The ACPI code
@@ -161,6 +357,92 @@
 #define __packed __attribute__((packed))
 #endif
 
+#ifndef __aligned
+#define __aligned(x) __attribute__((aligned(x)))
+#endif
+
+/*
+ * Attributes for EC request and response packets.  Just defining __packed
+ * results in inefficient assembly code on ARM, if the structure is actually
+ * 32-bit aligned, as it should be for all buffers.
+ *
+ * Be very careful when adding these to existing structures.  They will round
+ * up the structure size to the specified boundary.
+ *
+ * Also be very careful to make that if a structure is included in some other
+ * parent structure that the alignment will still be true given the packing of
+ * the parent structure.  This is particularly important if the sub-structure
+ * will be passed as a pointer to another function, since that function will
+ * not know about the misaligment caused by the parent structure's packing.
+ *
+ * Also be very careful using __packed - particularly when nesting non-packed
+ * structures inside packed ones.  In fact, DO NOT use __packed directly;
+ * always use one of these attributes.
+ *
+ * Once everything is annotated properly, the following search strings should
+ * not return ANY matches in this file other than right here:
+ *
+ * "__packed" - generates inefficient code; all sub-structs must also be packed
+ *
+ * "struct [^_]" - all structs should be annotated, except for structs that are
+ * members of other structs/unions (and their original declarations should be
+ * annotated).
+ */
+#ifdef CONFIG_HOSTCMD_ALIGNED
+
+/*
+ * Packed structures where offset and size are always aligned to 1, 2, or 4
+ * byte boundary.
+ */
+#define __ec_align1 __packed
+#define __ec_align2 __packed __aligned(2)
+#define __ec_align4 __packed __aligned(4)
+
+/*
+ * Packed structure which must be under-aligned, because its size is not a
+ * 4-byte multiple.  This is sub-optimal because it forces byte-wise access
+ * of all multi-byte fields in it, even though they are themselves aligned.
+ *
+ * In theory, we could duplicate the structure with __aligned(4) for accessing
+ * its members, but use the __packed version for sizeof().
+ */
+#define __ec_align_size1 __packed
+
+/*
+ * Packed structure which must be under-aligned, because its offset inside a
+ * parent structure is not a 4-byte multiple.
+ */
+#define __ec_align_offset1 __packed
+#define __ec_align_offset2 __packed __aligned(2)
+
+/*
+ * Structures which are complicated enough that I'm skipping them on the first
+ * pass.  They are effectively unchanged from their previous definitions.
+ *
+ * TODO(rspangler): Figure out what to do with these.  It's likely necessary
+ * to work out the size and offset of each member and add explicit padding to
+ * maintain those.
+ */
+#define __ec_todo_packed __packed
+#define __ec_todo_unpacked
+
+#else  /* !CONFIG_HOSTCMD_ALIGNED */
+
+/*
+ * Packed structures make no assumption about alignment, so they do inefficient
+ * byte-wise reads.
+ */
+#define __ec_align1 __packed
+#define __ec_align2 __packed
+#define __ec_align4 __packed
+#define __ec_align_size1 __packed
+#define __ec_align_offset1 __packed
+#define __ec_align_offset2 __packed
+#define __ec_todo_packed __packed
+#define __ec_todo_unpacked
+
+#endif  /* !CONFIG_HOSTCMD_ALIGNED */
+
 /* LPC command status byte masks */
 /* EC has written a byte in the data register and host hasn't read it yet */
 #define EC_LPC_STATUS_TO_HOST     0x01
@@ -170,7 +452,7 @@
 #define EC_LPC_STATUS_PROCESSING  0x04
 /* Last write to EC was a command, not data */
 #define EC_LPC_STATUS_LAST_CMD    0x08
-/* EC is in burst mode.  Unsupported by Chrome EC, so this bit is never set */
+/* EC is in burst mode */
 #define EC_LPC_STATUS_BURST_MODE  0x10
 /* SCI event is pending (requesting SCI query) */
 #define EC_LPC_STATUS_SCI_PENDING 0x20
@@ -186,7 +468,9 @@
 #define EC_LPC_STATUS_BUSY_MASK \
 	(EC_LPC_STATUS_FROM_HOST | EC_LPC_STATUS_PROCESSING)
 
-/* Host command response codes */
+/* Host command response codes (16-bit).  Note that response codes should be
+ * stored in a uint16_t rather than directly in a value of this type.
+ */
 enum ec_status {
 	EC_RES_SUCCESS = 0,
 	EC_RES_INVALID_COMMAND = 1,
@@ -202,7 +486,9 @@ enum ec_status {
 	EC_RES_OVERFLOW = 11,		/* Table / data overflow */
 	EC_RES_INVALID_HEADER = 12,     /* Header contains invalid data */
 	EC_RES_REQUEST_TRUNCATED = 13,  /* Didn't get the entire request */
-	EC_RES_RESPONSE_TOO_BIG = 14    /* Response was too big to handle */
+	EC_RES_RESPONSE_TOO_BIG = 14,   /* Response was too big to handle */
+	EC_RES_BUS_ERROR = 15,		/* Communications bus error */
+	EC_RES_BUSY = 16		/* Up but too busy.  Should retry */
 };
 
 /*
@@ -222,7 +508,8 @@ enum host_event_code {
 	EC_HOST_EVENT_BATTERY_CRITICAL = 7,
 	EC_HOST_EVENT_BATTERY = 8,
 	EC_HOST_EVENT_THERMAL_THRESHOLD = 9,
-	EC_HOST_EVENT_THERMAL_OVERLOAD = 10,
+	/* Event generated by a device attached to the EC */
+	EC_HOST_EVENT_DEVICE = 10,
 	EC_HOST_EVENT_THERMAL = 11,
 	EC_HOST_EVENT_USB_CHARGER = 12,
 	EC_HOST_EVENT_KEY_PRESSED = 13,
@@ -240,6 +527,49 @@ enum host_event_code {
 	/* Shutdown due to battery level too low */
 	EC_HOST_EVENT_BATTERY_SHUTDOWN = 17,
 
+	/* Suggest that the AP throttle itself */
+	EC_HOST_EVENT_THROTTLE_START = 18,
+	/* Suggest that the AP resume normal speed */
+	EC_HOST_EVENT_THROTTLE_STOP = 19,
+
+	/* Hang detect logic detected a hang and host event timeout expired */
+	EC_HOST_EVENT_HANG_DETECT = 20,
+	/* Hang detect logic detected a hang and warm rebooted the AP */
+	EC_HOST_EVENT_HANG_REBOOT = 21,
+
+	/* PD MCU triggering host event */
+	EC_HOST_EVENT_PD_MCU = 22,
+
+	/* Battery Status flags have changed */
+	EC_HOST_EVENT_BATTERY_STATUS = 23,
+
+	/* EC encountered a panic, triggering a reset */
+	EC_HOST_EVENT_PANIC = 24,
+
+	/* Keyboard fastboot combo has been pressed */
+	EC_HOST_EVENT_KEYBOARD_FASTBOOT = 25,
+
+	/* EC RTC event occurred */
+	EC_HOST_EVENT_RTC = 26,
+
+	/* Emulate MKBP event */
+	EC_HOST_EVENT_MKBP = 27,
+
+	/* EC desires to change state of host-controlled USB mux */
+	EC_HOST_EVENT_USB_MUX = 28,
+
+	/* TABLET/LAPTOP mode event*/
+	EC_HOST_EVENT_MODE_CHANGE = 29,
+
+	/* Keyboard recovery combo with hardware reinitialization */
+	EC_HOST_EVENT_KEYBOARD_RECOVERY_HW_REINIT = 30,
+
+	/*
+	 * Reserve this last bit to indicate that at least one bit in a
+	 * secondary host event word is set.  See crbug.com/633646.
+	 */
+	EC_HOST_EVENT_EXTENDED = 31,
+
 	/*
 	 * The high bit of the event mask is not used as a host event code.  If
 	 * it reads back as set, then the entire event mask should be
@@ -250,10 +580,10 @@ enum host_event_code {
 	EC_HOST_EVENT_INVALID = 32
 };
 /* Host event mask */
-#define EC_HOST_EVENT_MASK(event_code) (1UL << ((event_code) - 1))
+#define EC_HOST_EVENT_MASK(event_code) (1ULL << ((event_code) - 1))
 
 /* Arguments at EC_LPC_ADDR_HOST_ARGS */
-struct ec_lpc_host_args {
+struct __ec_align4 ec_lpc_host_args {
 	uint8_t flags;
 	uint8_t command_version;
 	uint8_t data_size;
@@ -262,7 +592,7 @@ struct ec_lpc_host_args {
 	 * all params/response data bytes.
 	 */
 	uint8_t checksum;
-} __packed;
+};
 
 /* Flags for ec_lpc_host_args.flags */
 /*
@@ -272,7 +602,7 @@ struct ec_lpc_host_args {
  * If EC gets a command and this flag is not set, this is an old-style command.
  * Command version is 0 and params from host are at EC_LPC_ADDR_OLD_PARAM with
  * unknown length.  EC must respond with an old-style response (that is,
- * withouth setting EC_HOST_ARGS_FLAG_TO_HOST).
+ * without setting EC_HOST_ARGS_FLAG_TO_HOST).
  */
 #define EC_HOST_ARGS_FLAG_FROM_HOST 0x01
 /*
@@ -284,6 +614,89 @@ struct ec_lpc_host_args {
  */
 #define EC_HOST_ARGS_FLAG_TO_HOST   0x02
 
+/*****************************************************************************/
+/*
+ * Byte codes returned by EC over SPI interface.
+ *
+ * These can be used by the AP to debug the EC interface, and to determine
+ * when the EC is not in a state where it will ever get around to responding
+ * to the AP.
+ *
+ * Example of sequence of bytes read from EC for a current good transfer:
+ *   1. -                  - AP asserts chip select (CS#)
+ *   2. EC_SPI_OLD_READY   - AP sends first byte(s) of request
+ *   3. -                  - EC starts handling CS# interrupt
+ *   4. EC_SPI_RECEIVING   - AP sends remaining byte(s) of request
+ *   5. EC_SPI_PROCESSING  - EC starts processing request; AP is clocking in
+ *                           bytes looking for EC_SPI_FRAME_START
+ *   6. -                  - EC finishes processing and sets up response
+ *   7. EC_SPI_FRAME_START - AP reads frame byte
+ *   8. (response packet)  - AP reads response packet
+ *   9. EC_SPI_PAST_END    - Any additional bytes read by AP
+ *   10 -                  - AP deasserts chip select
+ *   11 -                  - EC processes CS# interrupt and sets up DMA for
+ *                           next request
+ *
+ * If the AP is waiting for EC_SPI_FRAME_START and sees any value other than
+ * the following byte values:
+ *   EC_SPI_OLD_READY
+ *   EC_SPI_RX_READY
+ *   EC_SPI_RECEIVING
+ *   EC_SPI_PROCESSING
+ *
+ * Then the EC found an error in the request, or was not ready for the request
+ * and lost data.  The AP should give up waiting for EC_SPI_FRAME_START,
+ * because the EC is unable to tell when the AP is done sending its request.
+ */
+
+/*
+ * Framing byte which precedes a response packet from the EC.  After sending a
+ * request, the AP will clock in bytes until it sees the framing byte, then
+ * clock in the response packet.
+ */
+#define EC_SPI_FRAME_START    0xec
+
+/*
+ * Padding bytes which are clocked out after the end of a response packet.
+ */
+#define EC_SPI_PAST_END       0xed
+
+/*
+ * EC is ready to receive, and has ignored the byte sent by the AP.  EC expects
+ * that the AP will send a valid packet header (starting with
+ * EC_COMMAND_PROTOCOL_3) in the next 32 bytes.
+ */
+#define EC_SPI_RX_READY       0xf8
+
+/*
+ * EC has started receiving the request from the AP, but hasn't started
+ * processing it yet.
+ */
+#define EC_SPI_RECEIVING      0xf9
+
+/* EC has received the entire request from the AP and is processing it. */
+#define EC_SPI_PROCESSING     0xfa
+
+/*
+ * EC received bad data from the AP, such as a packet header with an invalid
+ * length.  EC will ignore all data until chip select deasserts.
+ */
+#define EC_SPI_RX_BAD_DATA    0xfb
+
+/*
+ * EC received data from the AP before it was ready.  That is, the AP asserted
+ * chip select and started clocking data before the EC was ready to receive it.
+ * EC will ignore all data until chip select deasserts.
+ */
+#define EC_SPI_NOT_READY      0xfc
+
+/*
+ * EC was ready to receive a request from the AP.  EC has treated the byte sent
+ * by the AP as part of a request packet, or (for old-style ECs) is processing
+ * a fully received packet but is not ready to respond yet.
+ */
+#define EC_SPI_OLD_READY      0xfd
+
 /*****************************************************************************/
 
 /*
@@ -332,8 +745,8 @@ struct ec_lpc_host_args {
 #define EC_HOST_REQUEST_VERSION 3
 
 /* Version 3 request from host */
-struct ec_host_request {
-	/* Struct version (=3)
+struct __ec_align4 ec_host_request {
+	/* Structure version (=3)
 	 *
 	 * EC will return EC_RES_INVALID_HEADER if it receives a header with a
 	 * version it doesn't know how to parse.
@@ -357,13 +770,13 @@ struct ec_host_request {
 
 	/* Length of data which follows this header */
 	uint16_t data_len;
-} __packed;
+};
 
 #define EC_HOST_RESPONSE_VERSION 3
 
 /* Version 3 response from EC */
-struct ec_host_response {
-	/* Struct version (=3) */
+struct __ec_align4 ec_host_response {
+	/* Structure version (=3) */
 	uint8_t struct_version;
 
 	/*
@@ -380,18 +793,21 @@ struct ec_host_response {
 
 	/* Unused bytes in current protocol version; set to 0 */
 	uint16_t reserved;
-} __packed;
+};
 
 /*****************************************************************************/
 /*
  * Notes on commands:
  *
- * Each command is an 8-byte command value.  Commands which take params or
- * return response data specify structs for that data.  If no struct is
+ * Each command is an 16-bit command value.  Commands which take params or
+ * return response data specify structures for that data.  If no structure is
  * specified, the command does not input or output data, respectively.
  * Parameter/response length is implicit in the structs.  Some underlying
  * communication protocols (I2C, SPI) may add length or checksum headers, but
  * those are implementation-dependent and not defined here.
+ *
+ * All commands MUST be #defined to be 4-digit UPPER CASE hex values
+ * (e.g., 0x00AB, not 0xab) for CONFIG_HOSTCMD_SECTION_SORTED to work.
  */
 
 /*****************************************************************************/
@@ -401,28 +817,28 @@ struct ec_host_response {
  * Get protocol version, used to deal with non-backward compatible protocol
  * changes.
  */
-#define EC_CMD_PROTO_VERSION 0x00
+#define EC_CMD_PROTO_VERSION 0x0000
 
-struct ec_response_proto_version {
+struct __ec_align4 ec_response_proto_version {
 	uint32_t version;
-} __packed;
+};
 
 /*
  * Hello.  This is a simple command to test the EC is responsive to
  * commands.
  */
-#define EC_CMD_HELLO 0x01
+#define EC_CMD_HELLO 0x0001
 
-struct ec_params_hello {
+struct __ec_align4 ec_params_hello {
 	uint32_t in_data;  /* Pass anything here */
-} __packed;
+};
 
-struct ec_response_hello {
+struct __ec_align4 ec_response_hello {
 	uint32_t out_data;  /* Output will be in_data + 0x01020304 */
-} __packed;
+};
 
 /* Get version number */
-#define EC_CMD_GET_VERSION 0x02
+#define EC_CMD_GET_VERSION 0x0002
 
 enum ec_current_image {
 	EC_IMAGE_UNKNOWN = 0,
@@ -430,49 +846,49 @@ enum ec_current_image {
 	EC_IMAGE_RW
 };
 
-struct ec_response_get_version {
+struct __ec_align4 ec_response_get_version {
 	/* Null-terminated version strings for RO, RW */
 	char version_string_ro[32];
 	char version_string_rw[32];
 	char reserved[32];       /* Was previously RW-B string */
 	uint32_t current_image;  /* One of ec_current_image */
-} __packed;
+};
 
 /* Read test */
-#define EC_CMD_READ_TEST 0x03
+#define EC_CMD_READ_TEST 0x0003
 
-struct ec_params_read_test {
+struct __ec_align4 ec_params_read_test {
 	uint32_t offset;   /* Starting value for read buffer */
 	uint32_t size;     /* Size to read in bytes */
-} __packed;
+};
 
-struct ec_response_read_test {
+struct __ec_align4 ec_response_read_test {
 	uint32_t data[32];
-} __packed;
+};
 
 /*
  * Get build information
  *
  * Response is null-terminated string.
  */
-#define EC_CMD_GET_BUILD_INFO 0x04
+#define EC_CMD_GET_BUILD_INFO 0x0004
 
 /* Get chip info */
-#define EC_CMD_GET_CHIP_INFO 0x05
+#define EC_CMD_GET_CHIP_INFO 0x0005
 
-struct ec_response_get_chip_info {
+struct __ec_align4 ec_response_get_chip_info {
 	/* Null-terminated strings */
 	char vendor[32];
 	char name[32];
 	char revision[32];  /* Mask version */
-} __packed;
+};
 
 /* Get board HW version */
-#define EC_CMD_GET_BOARD_VERSION 0x06
+#define EC_CMD_GET_BOARD_VERSION 0x0006
 
-struct ec_response_board_version {
+struct __ec_align2 ec_response_board_version {
 	uint16_t board_version;  /* A monotonously incrementing number. */
-} __packed;
+};
 
 /*
  * Read memory-mapped data.
@@ -482,72 +898,73 @@ struct ec_response_board_version {
  *
  * Response is params.size bytes of data.
  */
-#define EC_CMD_READ_MEMMAP 0x07
+#define EC_CMD_READ_MEMMAP 0x0007
 
-struct ec_params_read_memmap {
+struct __ec_align1 ec_params_read_memmap {
 	uint8_t offset;   /* Offset in memmap (EC_MEMMAP_*) */
 	uint8_t size;     /* Size to read in bytes */
-} __packed;
+};
 
 /* Read versions supported for a command */
-#define EC_CMD_GET_CMD_VERSIONS 0x08
+#define EC_CMD_GET_CMD_VERSIONS 0x0008
 
-struct ec_params_get_cmd_versions {
+struct __ec_align1 ec_params_get_cmd_versions {
 	uint8_t cmd;      /* Command to check */
-} __packed;
+};
+
+struct __ec_align2 ec_params_get_cmd_versions_v1 {
+	uint16_t cmd;     /* Command to check */
+};
 
-struct ec_response_get_cmd_versions {
+struct __ec_align4 ec_response_get_cmd_versions {
 	/*
 	 * Mask of supported versions; use EC_VER_MASK() to compare with a
 	 * desired version.
 	 */
 	uint32_t version_mask;
-} __packed;
+};
 
 /*
- * Check EC communcations status (busy). This is needed on i2c/spi but not
+ * Check EC communications status (busy). This is needed on i2c/spi but not
  * on lpc since it has its own out-of-band busy indicator.
  *
  * lpc must read the status from the command register. Attempting this on
  * lpc will overwrite the args/parameter space and corrupt its data.
  */
-#define EC_CMD_GET_COMMS_STATUS		0x09
+#define EC_CMD_GET_COMMS_STATUS		0x0009
 
 /* Avoid using ec_status which is for return values */
 enum ec_comms_status {
 	EC_COMMS_STATUS_PROCESSING	= 1 << 0,	/* Processing cmd */
 };
 
-struct ec_response_get_comms_status {
+struct __ec_align4 ec_response_get_comms_status {
 	uint32_t flags;		/* Mask of enum ec_comms_status */
-} __packed;
+};
 
-/*
- * Fake a variety of responses, purely for testing purposes.
- * FIXME: Would be nice to force checksum errors.
- */
-#define EC_CMD_TEST_PROTOCOL		0x0a
+/* Fake a variety of responses, purely for testing purposes. */
+#define EC_CMD_TEST_PROTOCOL		0x000A
 
 /* Tell the EC what to send back to us. */
-struct ec_params_test_protocol {
+struct __ec_align4 ec_params_test_protocol {
 	uint32_t ec_result;
 	uint32_t ret_len;
 	uint8_t buf[32];
-} __packed;
+};
 
 /* Here it comes... */
-struct ec_response_test_protocol {
+struct __ec_align4 ec_response_test_protocol {
 	uint8_t buf[32];
-} __packed;
+};
 
-/* Get prococol information */
-#define EC_CMD_GET_PROTOCOL_INFO	0x0b
+/* Get protocol information */
+#define EC_CMD_GET_PROTOCOL_INFO	0x000B
 
 /* Flags for ec_response_get_protocol_info.flags */
 /* EC_RES_IN_PROGRESS may be returned if a command is slow */
 #define EC_PROTOCOL_INFO_IN_PROGRESS_SUPPORTED (1 << 0)
 
-struct ec_response_get_protocol_info {
+struct __ec_align4 ec_response_get_protocol_info {
 	/* Fields which exist if@least protocol version 3 supported */
 
 	/* Bitmask of protocol versions supported (1 << n means version n)*/
@@ -561,15 +978,153 @@ struct ec_response_get_protocol_info {
 
 	/* Flags; see EC_PROTOCOL_INFO_* */
 	uint32_t flags;
-} __packed;
+};
+
+
+/*****************************************************************************/
+/* Get/Set miscellaneous values */
+
+/* The upper byte of .flags tells what to do (nothing means "get") */
+#define EC_GSV_SET        0x80000000
+
+/* The lower three bytes of .flags identifies the parameter, if that has
+   meaning for an individual command. */
+#define EC_GSV_PARAM_MASK 0x00ffffff
+
+struct __ec_align4 ec_params_get_set_value {
+	uint32_t flags;
+	uint32_t value;
+};
+
+struct __ec_align4 ec_response_get_set_value {
+	uint32_t flags;
+	uint32_t value;
+};
+
+/* More than one command can use these structs to get/set parameters. */
+#define EC_CMD_GSV_PAUSE_IN_S5	0x000C
+
+/*****************************************************************************/
+/* List the features supported by the firmware */
+#define EC_CMD_GET_FEATURES  0x000D
+
+/* Supported features */
+enum ec_feature_code {
+	/*
+	 * This image contains a limited set of features. Another image
+	 * in RW partition may support more features.
+	 */
+	EC_FEATURE_LIMITED = 0,
+	/*
+	 * Commands for probing/reading/writing/erasing the flash in the
+	 * EC are present.
+	 */
+	EC_FEATURE_FLASH = 1,
+	/*
+	 * Can control the fan speed directly.
+	 */
+	EC_FEATURE_PWM_FAN = 2,
+	/*
+	 * Can control the intensity of the keyboard backlight.
+	 */
+	EC_FEATURE_PWM_KEYB = 3,
+	/*
+	 * Support Google lightbar, introduced on Pixel.
+	 */
+	EC_FEATURE_LIGHTBAR = 4,
+	/* Control of LEDs  */
+	EC_FEATURE_LED = 5,
+	/* Exposes an interface to control gyro and sensors.
+	 * The host goes through the EC to access these sensors.
+	 * In addition, the EC may provide composite sensors, like lid angle.
+	 */
+	EC_FEATURE_MOTION_SENSE = 6,
+	/* The keyboard is controlled by the EC */
+	EC_FEATURE_KEYB = 7,
+	/* The AP can use part of the EC flash as persistent storage. */
+	EC_FEATURE_PSTORE = 8,
+	/* The EC monitors BIOS port 80h, and can return POST codes. */
+	EC_FEATURE_PORT80 = 9,
+	/*
+	 * Thermal management: include TMP specific commands.
+	 * Higher level than direct fan control.
+	 */
+	EC_FEATURE_THERMAL = 10,
+	/* Can switch the screen backlight on/off */
+	EC_FEATURE_BKLIGHT_SWITCH = 11,
+	/* Can switch the wifi module on/off */
+	EC_FEATURE_WIFI_SWITCH = 12,
+	/* Monitor host events, through for example SMI or SCI */
+	EC_FEATURE_HOST_EVENTS = 13,
+	/* The EC exposes GPIO commands to control/monitor connected devices. */
+	EC_FEATURE_GPIO = 14,
+	/* The EC can send i2c messages to downstream devices. */
+	EC_FEATURE_I2C = 15,
+	/* Command to control charger are included */
+	EC_FEATURE_CHARGER = 16,
+	/* Simple battery support. */
+	EC_FEATURE_BATTERY = 17,
+	/*
+	 * Support Smart battery protocol
+	 * (Common Smart Battery System Interface Specification)
+	 */
+	EC_FEATURE_SMART_BATTERY = 18,
+	/* EC can detect when the host hangs. */
+	EC_FEATURE_HANG_DETECT = 19,
+	/* Report power information, for pit only */
+	EC_FEATURE_PMU = 20,
+	/* Another Cros EC device is present downstream of this one */
+	EC_FEATURE_SUB_MCU = 21,
+	/* Support USB Power delivery (PD) commands */
+	EC_FEATURE_USB_PD = 22,
+	/* Control USB multiplexer, for audio through USB port for instance. */
+	EC_FEATURE_USB_MUX = 23,
+	/* Motion Sensor code has an internal software FIFO */
+	EC_FEATURE_MOTION_SENSE_FIFO = 24,
+	/* Support temporary secure vstore */
+	EC_FEATURE_VSTORE = 25,
+	/* EC decides on USB-C SS mux state, muxes configured by host */
+	EC_FEATURE_USBC_SS_MUX_VIRTUAL = 26,
+	/* EC has RTC feature that can be controlled by host commands */
+	EC_FEATURE_RTC = 27,
+	/* The MCU exposes a Fingerprint sensor */
+	EC_FEATURE_FINGERPRINT = 28,
+	/* The MCU exposes a Touchpad */
+	EC_FEATURE_TOUCHPAD = 29,
+	/* The MCU has RWSIG task enabled */
+	EC_FEATURE_RWSIG = 30,
+	/* EC has device events support */
+	EC_FEATURE_DEVICE_EVENT = 31,
+	/* EC supports the unified wake masks for LPC/eSPI systems */
+	EC_FEATURE_UNIFIED_WAKE_MASKS = 32,
+};
+
+#define EC_FEATURE_MASK_0(event_code) (1UL << (event_code % 32))
+#define EC_FEATURE_MASK_1(event_code) (1UL << (event_code - 32))
+struct __ec_align4 ec_response_get_features {
+	uint32_t flags[2];
+};
+
+/*****************************************************************************/
+/* Get the board's SKU ID from EC */
+#define EC_CMD_GET_SKU_ID 0x000E
+
+/* Set SKU ID from AP */
+#define EC_CMD_SET_SKU_ID 0x000F
+
+struct __ec_align4 ec_sku_id_info {
+	uint32_t sku_id;
+};
 
 /*****************************************************************************/
 /* Flash commands */
 
 /* Get flash info */
-#define EC_CMD_FLASH_INFO 0x10
+#define EC_CMD_FLASH_INFO 0x0010
+#define EC_VER_FLASH_INFO 2
 
-struct ec_response_flash_info {
+/* Version 0 returns these fields */
+struct __ec_align4 ec_response_flash_info {
 	/* Usable flash size, in bytes */
 	uint32_t flash_size;
 	/*
@@ -587,40 +1142,157 @@ struct ec_response_flash_info {
 	 * multiple of this.
 	 */
 	uint32_t protect_block_size;
-} __packed;
+};
+
+/* Flags for version 1+ flash info command */
+/* EC flash erases bits to 0 instead of 1 */
+#define EC_FLASH_INFO_ERASE_TO_0 (1 << 0)
+
+/* Flash must be selected for read/write/erase operations to succeed.  This may
+ * be necessary on a chip where write/erase can be corrupted by other board
+ * activity, or where the chip needs to enable some sort of programming voltage,
+ * or where the read/write/erase operations require cleanly suspending other
+ * chip functionality. */
+#define EC_FLASH_INFO_SELECT_REQUIRED (1 << 1)
 
 /*
- * Read flash
+ * Version 1 returns the same initial fields as version 0, with additional
+ * fields following.
  *
- * Response is params.size bytes of data.
+ * gcc anonymous structs don't seem to get along with the __packed directive;
+ * if they did we'd define the version 0 structure as a sub-structure of this
+ * one.
+ *
+ * Version 2 supports flash banks of different sizes:
+ * The caller specified the number of banks it has preallocated
+ * (num_banks_desc)
+ * The EC returns the number of banks describing the flash memory.
+ * It adds banks descriptions up to num_banks_desc.
  */
-#define EC_CMD_FLASH_READ 0x11
+struct __ec_align4 ec_response_flash_info_1 {
+	/* Version 0 fields; see above for description */
+	uint32_t flash_size;
+	uint32_t write_block_size;
+	uint32_t erase_block_size;
+	uint32_t protect_block_size;
 
-struct ec_params_flash_read {
-	uint32_t offset;   /* Byte offset to read */
-	uint32_t size;     /* Size to read in bytes */
-} __packed;
+	/* Version 1 adds these fields: */
+	/*
+	 * Ideal write size in bytes.  Writes will be fastest if size is
+	 * exactly this and offset is a multiple of this.  For example, an EC
+	 * may have a write buffer which can do half-page operations if data is
+	 * aligned, and a slower word-at-a-time write mode.
+	 */
+	uint32_t write_ideal_size;
 
-/* Write flash */
-#define EC_CMD_FLASH_WRITE 0x12
-#define EC_VER_FLASH_WRITE 1
+	/* Flags; see EC_FLASH_INFO_* */
+	uint32_t flags;
+};
 
-/* Version 0 of the flash command supported only 64 bytes of data */
+struct __ec_align4 ec_params_flash_info_2 {
+	/* Number of banks to describe */
+	uint16_t num_banks_desc;
+	/* Reserved; set 0; ignore on read */
+	uint8_t reserved[2];
+};
+
+struct ec_flash_bank {
+	/* Number of sector is in this bank. */
+	uint16_t count;
+	/* Size in power of 2 of each sector (8 --> 256 bytes) */
+	uint8_t size_exp;
+	/* Minimal write size for the sectors in this bank */
+	uint8_t write_size_exp;
+	/* Erase size for the sectors in this bank */
+	uint8_t erase_size_exp;
+	/* Size for write protection, usually identical to erase size. */
+	uint8_t protect_size_exp;
+	/* Reserved; set 0; ignore on read */
+	uint8_t reserved[2];
+};
+
+struct __ec_align4 ec_response_flash_info_2 {
+	/* Total flash in the EC. */
+	uint32_t flash_size;
+	/* Flags; see EC_FLASH_INFO_* */
+	uint32_t flags;
+	/* Maximum size to use to send data to write to the EC. */
+	uint32_t write_ideal_size;
+	/* Number of banks present in the EC. */
+	uint16_t num_banks_total;
+	/* Number of banks described in banks array. */
+	uint16_t num_banks_desc;
+	struct ec_flash_bank banks[0];
+};
+
+/*
+ * Read flash
+ *
+ * Response is params.size bytes of data.
+ */
+#define EC_CMD_FLASH_READ 0x0011
+
+struct __ec_align4 ec_params_flash_read {
+	uint32_t offset;   /* Byte offset to read */
+	uint32_t size;     /* Size to read in bytes */
+};
+
+/* Write flash */
+#define EC_CMD_FLASH_WRITE 0x0012
+#define EC_VER_FLASH_WRITE 1
+
+/* Version 0 of the flash command supported only 64 bytes of data */
 #define EC_FLASH_WRITE_VER0_SIZE 64
 
-struct ec_params_flash_write {
+struct __ec_align4 ec_params_flash_write {
 	uint32_t offset;   /* Byte offset to write */
 	uint32_t size;     /* Size to write in bytes */
 	/* Followed by data to write */
-} __packed;
+};
 
 /* Erase flash */
-#define EC_CMD_FLASH_ERASE 0x13
+#define EC_CMD_FLASH_ERASE 0x0013
 
-struct ec_params_flash_erase {
+/* v0 */
+struct __ec_align4 ec_params_flash_erase {
 	uint32_t offset;   /* Byte offset to erase */
 	uint32_t size;     /* Size to erase in bytes */
-} __packed;
+};
+
+
+#define EC_VER_FLASH_WRITE 1
+/* v1 add async erase:
+ * subcommands can returns:
+ * EC_RES_SUCCESS : erased (see ERASE_SECTOR_ASYNC case below).
+ * EC_RES_INVALID_PARAM : offset/size are not aligned on a erase boundary.
+ * EC_RES_ERROR : other errors.
+ * EC_RES_BUSY : an existing erase operation is in progress.
+ * EC_RES_ACCESS_DENIED: Trying to erase running image.
+ *
+ * When ERASE_SECTOR_ASYNC returns EC_RES_SUCCESS, the operation is just
+ * properly queued. The user must call ERASE_GET_RESULT subcommand to get
+ * the proper result.
+ * When ERASE_GET_RESULT returns EC_RES_BUSY, the caller must wait and send
+ * ERASE_GET_RESULT again to get the result of ERASE_SECTOR_ASYNC.
+ * ERASE_GET_RESULT command may timeout on EC where flash access is not
+ * permitted while erasing. (For instance, STM32F4).
+ */
+enum ec_flash_erase_cmd {
+	FLASH_ERASE_SECTOR,     /* Erase and wait for result */
+	FLASH_ERASE_SECTOR_ASYNC,  /* Erase and return immediately. */
+	FLASH_ERASE_GET_RESULT,  /* Ask for last erase result */
+};
+
+struct __ec_align4 ec_params_flash_erase_v1 {
+	/* One of ec_flash_erase_cmd. */
+	uint8_t  cmd;
+	/* Pad byte; currently always contains 0 */
+	uint8_t  reserved;
+	/* No flags defined yet; set to 0 */
+	uint16_t flag;
+	/* Same as v0 parameters. */
+	struct ec_params_flash_erase params;
+};
 
 /*
  * Get/set flash protection.
@@ -632,7 +1304,7 @@ struct ec_params_flash_erase {
  *
  * If mask=0, simply returns the current flags state.
  */
-#define EC_CMD_FLASH_PROTECT 0x15
+#define EC_CMD_FLASH_PROTECT 0x0015
 #define EC_VER_FLASH_PROTECT 1  /* Command version 1 */
 
 /* Flags for flash protection */
@@ -655,15 +1327,23 @@ struct ec_params_flash_erase {
  * re-requesting the desired flags, or by a hard reset if that fails.
  */
 #define EC_FLASH_PROTECT_ERROR_INCONSISTENT (1 << 5)
-/* Entile flash code protected when the EC boots */
+/* Entire flash code protected when the EC boots */
 #define EC_FLASH_PROTECT_ALL_AT_BOOT        (1 << 6)
-
-struct ec_params_flash_protect {
+/* RW flash code protected when the EC boots */
+#define EC_FLASH_PROTECT_RW_AT_BOOT         (1 << 7)
+/* RW flash code protected now. */
+#define EC_FLASH_PROTECT_RW_NOW             (1 << 8)
+/* Rollback information flash region protected when the EC boots */
+#define EC_FLASH_PROTECT_ROLLBACK_AT_BOOT   (1 << 9)
+/* Rollback information flash region protected now */
+#define EC_FLASH_PROTECT_ROLLBACK_NOW       (1 << 10)
+
+struct __ec_align4 ec_params_flash_protect {
 	uint32_t mask;   /* Bits in flags to apply */
 	uint32_t flags;  /* New flags to apply */
-} __packed;
+};
 
-struct ec_response_flash_protect {
+struct __ec_align4 ec_response_flash_protect {
 	/* Current value of flash protect flags */
 	uint32_t flags;
 	/*
@@ -674,7 +1354,7 @@ struct ec_response_flash_protect {
 	uint32_t valid_flags;
 	/* Flags which can be changed given the current protection state */
 	uint32_t writable_flags;
-} __packed;
+};
 
 /*
  * Note: commands 0x14 - 0x19 version 0 were old commands to get/set flash
@@ -682,89 +1362,166 @@ struct ec_response_flash_protect {
  */
 
 /* Get the region offset/size */
-#define EC_CMD_FLASH_REGION_INFO 0x16
+#define EC_CMD_FLASH_REGION_INFO 0x0016
 #define EC_VER_FLASH_REGION_INFO 1
 
 enum ec_flash_region {
 	/* Region which holds read-only EC image */
 	EC_FLASH_REGION_RO = 0,
-	/* Region which holds rewritable EC image */
-	EC_FLASH_REGION_RW,
+	/* Region which holds active rewritable EC image */
+	EC_FLASH_REGION_ACTIVE,
 	/*
 	 * Region which should be write-protected in the factory (a superset of
 	 * EC_FLASH_REGION_RO)
 	 */
 	EC_FLASH_REGION_WP_RO,
+	/* Region which holds updatable image */
+	EC_FLASH_REGION_UPDATE,
 	/* Number of regions */
 	EC_FLASH_REGION_COUNT,
 };
 
-struct ec_params_flash_region_info {
+struct __ec_align4 ec_params_flash_region_info {
 	uint32_t region;  /* enum ec_flash_region */
-} __packed;
+};
 
-struct ec_response_flash_region_info {
+struct __ec_align4 ec_response_flash_region_info {
 	uint32_t offset;
 	uint32_t size;
-} __packed;
+};
 
 /* Read/write VbNvContext */
-#define EC_CMD_VBNV_CONTEXT 0x17
+#define EC_CMD_VBNV_CONTEXT 0x0017
 #define EC_VER_VBNV_CONTEXT 1
 #define EC_VBNV_BLOCK_SIZE 16
+#define EC_VBNV_BLOCK_SIZE_V2 64
 
 enum ec_vbnvcontext_op {
 	EC_VBNV_CONTEXT_OP_READ,
 	EC_VBNV_CONTEXT_OP_WRITE,
 };
 
-struct ec_params_vbnvcontext {
+struct __ec_align4 ec_params_vbnvcontext {
 	uint32_t op;
-	uint8_t block[EC_VBNV_BLOCK_SIZE];
-} __packed;
+	uint8_t block[EC_VBNV_BLOCK_SIZE_V2];
+};
+
+struct __ec_align4 ec_response_vbnvcontext {
+	uint8_t block[EC_VBNV_BLOCK_SIZE_V2];
+};
+
+
+/* Get SPI flash information */
+#define EC_CMD_FLASH_SPI_INFO 0x0018
+
+struct __ec_align1 ec_response_flash_spi_info {
+	/* JEDEC info from command 0x9F (manufacturer, memory type, size) */
+	uint8_t jedec[3];
+
+	/* Pad byte; currently always contains 0 */
+	uint8_t reserved0;
+
+	/* Manufacturer / device ID from command 0x90 */
+	uint8_t mfr_dev_id[2];
+
+	/* Status registers from command 0x05 and 0x35 */
+	uint8_t sr1, sr2;
+};
+
 
-struct ec_response_vbnvcontext {
-	uint8_t block[EC_VBNV_BLOCK_SIZE];
-} __packed;
+/* Select flash during flash operations */
+#define EC_CMD_FLASH_SELECT 0x0019
+
+struct __ec_align4 ec_params_flash_select {
+	/* 1 to select flash, 0 to deselect flash */
+	uint8_t select;
+};
 
 /*****************************************************************************/
 /* PWM commands */
 
 /* Get fan target RPM */
-#define EC_CMD_PWM_GET_FAN_TARGET_RPM 0x20
+#define EC_CMD_PWM_GET_FAN_TARGET_RPM 0x0020
 
-struct ec_response_pwm_get_fan_rpm {
+struct __ec_align4 ec_response_pwm_get_fan_rpm {
 	uint32_t rpm;
-} __packed;
+};
 
 /* Set target fan RPM */
-#define EC_CMD_PWM_SET_FAN_TARGET_RPM 0x21
+#define EC_CMD_PWM_SET_FAN_TARGET_RPM 0x0021
+
+/* Version 0 of input params */
+struct __ec_align4 ec_params_pwm_set_fan_target_rpm_v0 {
+	uint32_t rpm;
+};
 
-struct ec_params_pwm_set_fan_target_rpm {
+/* Version 1 of input params */
+struct __ec_align_size1 ec_params_pwm_set_fan_target_rpm_v1 {
 	uint32_t rpm;
-} __packed;
+	uint8_t fan_idx;
+};
 
 /* Get keyboard backlight */
-#define EC_CMD_PWM_GET_KEYBOARD_BACKLIGHT 0x22
+/* OBSOLETE - Use EC_CMD_PWM_SET_DUTY */
+#define EC_CMD_PWM_GET_KEYBOARD_BACKLIGHT 0x0022
 
-struct ec_response_pwm_get_keyboard_backlight {
+struct __ec_align1 ec_response_pwm_get_keyboard_backlight {
 	uint8_t percent;
 	uint8_t enabled;
-} __packed;
+};
 
 /* Set keyboard backlight */
-#define EC_CMD_PWM_SET_KEYBOARD_BACKLIGHT 0x23
+/* OBSOLETE - Use EC_CMD_PWM_SET_DUTY */
+#define EC_CMD_PWM_SET_KEYBOARD_BACKLIGHT 0x0023
 
-struct ec_params_pwm_set_keyboard_backlight {
+struct __ec_align1 ec_params_pwm_set_keyboard_backlight {
 	uint8_t percent;
-} __packed;
+};
 
 /* Set target fan PWM duty cycle */
-#define EC_CMD_PWM_SET_FAN_DUTY 0x24
+#define EC_CMD_PWM_SET_FAN_DUTY 0x0024
+
+/* Version 0 of input params */
+struct __ec_align4 ec_params_pwm_set_fan_duty_v0 {
+	uint32_t percent;
+};
 
-struct ec_params_pwm_set_fan_duty {
+/* Version 1 of input params */
+struct __ec_align_size1 ec_params_pwm_set_fan_duty_v1 {
 	uint32_t percent;
-} __packed;
+	uint8_t fan_idx;
+};
+
+#define EC_CMD_PWM_SET_DUTY 0x0025
+/* 16 bit duty cycle, 0xffff = 100% */
+#define EC_PWM_MAX_DUTY 0xffff
+
+enum ec_pwm_type {
+	/* All types, indexed by board-specific enum pwm_channel */
+	EC_PWM_TYPE_GENERIC = 0,
+	/* Keyboard backlight */
+	EC_PWM_TYPE_KB_LIGHT,
+	/* Display backlight */
+	EC_PWM_TYPE_DISPLAY_LIGHT,
+	EC_PWM_TYPE_COUNT,
+};
+
+struct __ec_align4 ec_params_pwm_set_duty {
+	uint16_t duty;     /* Duty cycle, EC_PWM_MAX_DUTY = 100% */
+	uint8_t pwm_type;  /* ec_pwm_type */
+	uint8_t index;     /* Type-specific index, or 0 if unique */
+};
+
+#define EC_CMD_PWM_GET_DUTY 0x0026
+
+struct __ec_align1 ec_params_pwm_get_duty {
+	uint8_t pwm_type;  /* ec_pwm_type */
+	uint8_t index;     /* Type-specific index, or 0 if unique */
+};
+
+struct __ec_align2 ec_response_pwm_get_duty {
+	uint16_t duty;     /* Duty cycle, EC_PWM_MAX_DUTY = 100% */
+};
 
 /*****************************************************************************/
 /*
@@ -773,9 +1530,9 @@ struct ec_params_pwm_set_fan_duty {
  * into a subcommand. We'll make separate structs for subcommands with
  * different input args, so that we know how much to expect.
  */
-#define EC_CMD_LIGHTBAR_CMD 0x28
+#define EC_CMD_LIGHTBAR_CMD 0x0028
 
-struct rgb_s {
+struct __ec_todo_unpacked rgb_s {
 	uint8_t r, g, b;
 };
 
@@ -783,17 +1540,17 @@ struct rgb_s {
 /* List of tweakable parameters. NOTE: It's __packed so it can be sent in a
  * host command, but the alignment is the same regardless. Keep it that way.
  */
-struct lightbar_params {
+struct __ec_todo_packed lightbar_params_v0 {
 	/* Timing */
-	int google_ramp_up;
-	int google_ramp_down;
-	int s3s0_ramp_up;
-	int s0_tick_delay[2];			/* AC=0/1 */
-	int s0a_tick_delay[2];			/* AC=0/1 */
-	int s0s3_ramp_down;
-	int s3_sleep_for;
-	int s3_ramp_up;
-	int s3_ramp_down;
+	int32_t google_ramp_up;
+	int32_t google_ramp_down;
+	int32_t s3s0_ramp_up;
+	int32_t s0_tick_delay[2];		/* AC=0/1 */
+	int32_t s0a_tick_delay[2];		/* AC=0/1 */
+	int32_t s0s3_ramp_down;
+	int32_t s3_sleep_for;
+	int32_t s3_ramp_up;
+	int32_t s3_ramp_down;
 
 	/* Oscillation */
 	uint8_t new_s0;
@@ -815,52 +1572,221 @@ struct lightbar_params {
 
 	/* Color palette */
 	struct rgb_s color[8];			/* 0-3 are Google colors */
-} __packed;
+};
+
+struct __ec_todo_packed lightbar_params_v1 {
+	/* Timing */
+	int32_t google_ramp_up;
+	int32_t google_ramp_down;
+	int32_t s3s0_ramp_up;
+	int32_t s0_tick_delay[2];		/* AC=0/1 */
+	int32_t s0a_tick_delay[2];		/* AC=0/1 */
+	int32_t s0s3_ramp_down;
+	int32_t s3_sleep_for;
+	int32_t s3_ramp_up;
+	int32_t s3_ramp_down;
+	int32_t s5_ramp_up;
+	int32_t s5_ramp_down;
+	int32_t tap_tick_delay;
+	int32_t tap_gate_delay;
+	int32_t tap_display_time;
+
+	/* Tap-for-battery params */
+	uint8_t tap_pct_red;
+	uint8_t tap_pct_green;
+	uint8_t tap_seg_min_on;
+	uint8_t tap_seg_max_on;
+	uint8_t tap_seg_osc;
+	uint8_t tap_idx[3];
+
+	/* Oscillation */
+	uint8_t osc_min[2];			/* AC=0/1 */
+	uint8_t osc_max[2];			/* AC=0/1 */
+	uint8_t w_ofs[2];			/* AC=0/1 */
+
+	/* Brightness limits based on the backlight and AC. */
+	uint8_t bright_bl_off_fixed[2];		/* AC=0/1 */
+	uint8_t bright_bl_on_min[2];		/* AC=0/1 */
+	uint8_t bright_bl_on_max[2];		/* AC=0/1 */
+
+	/* Battery level thresholds */
+	uint8_t battery_threshold[LB_BATTERY_LEVELS - 1];
+
+	/* Map [AC][battery_level] to color index */
+	uint8_t s0_idx[2][LB_BATTERY_LEVELS];	/* AP is running */
+	uint8_t s3_idx[2][LB_BATTERY_LEVELS];	/* AP is sleeping */
+
+	/* s5: single color pulse on inhibited power-up */
+	uint8_t s5_idx;
+
+	/* Color palette */
+	struct rgb_s color[8];			/* 0-3 are Google colors */
+};
+
+/* Lightbar command params v2
+ * crbug.com/467716
+ *
+ * lightbar_parms_v1 was too big for i2c, therefore in v2, we split them up by
+ * logical groups to make it more manageable ( < 120 bytes).
+ *
+ * NOTE: Each of these groups must be less than 120 bytes.
+ */
+
+struct __ec_todo_packed lightbar_params_v2_timing {
+	/* Timing */
+	int32_t google_ramp_up;
+	int32_t google_ramp_down;
+	int32_t s3s0_ramp_up;
+	int32_t s0_tick_delay[2];		/* AC=0/1 */
+	int32_t s0a_tick_delay[2];		/* AC=0/1 */
+	int32_t s0s3_ramp_down;
+	int32_t s3_sleep_for;
+	int32_t s3_ramp_up;
+	int32_t s3_ramp_down;
+	int32_t s5_ramp_up;
+	int32_t s5_ramp_down;
+	int32_t tap_tick_delay;
+	int32_t tap_gate_delay;
+	int32_t tap_display_time;
+};
+
+struct __ec_todo_packed lightbar_params_v2_tap {
+	/* Tap-for-battery params */
+	uint8_t tap_pct_red;
+	uint8_t tap_pct_green;
+	uint8_t tap_seg_min_on;
+	uint8_t tap_seg_max_on;
+	uint8_t tap_seg_osc;
+	uint8_t tap_idx[3];
+};
+
+struct __ec_todo_packed lightbar_params_v2_oscillation {
+	/* Oscillation */
+	uint8_t osc_min[2];			/* AC=0/1 */
+	uint8_t osc_max[2];			/* AC=0/1 */
+	uint8_t w_ofs[2];			/* AC=0/1 */
+};
+
+struct __ec_todo_packed lightbar_params_v2_brightness {
+	/* Brightness limits based on the backlight and AC. */
+	uint8_t bright_bl_off_fixed[2];		/* AC=0/1 */
+	uint8_t bright_bl_on_min[2];		/* AC=0/1 */
+	uint8_t bright_bl_on_max[2];		/* AC=0/1 */
+};
+
+struct __ec_todo_packed lightbar_params_v2_thresholds {
+	/* Battery level thresholds */
+	uint8_t battery_threshold[LB_BATTERY_LEVELS - 1];
+};
+
+struct __ec_todo_packed lightbar_params_v2_colors {
+	/* Map [AC][battery_level] to color index */
+	uint8_t s0_idx[2][LB_BATTERY_LEVELS];	/* AP is running */
+	uint8_t s3_idx[2][LB_BATTERY_LEVELS];	/* AP is sleeping */
+
+	/* s5: single color pulse on inhibited power-up */
+	uint8_t s5_idx;
+
+	/* Color palette */
+	struct rgb_s color[8];			/* 0-3 are Google colors */
+};
+
+/* Lightbyte program. */
+#define EC_LB_PROG_LEN 192
+struct __ec_todo_unpacked lightbar_program {
+	uint8_t size;
+	uint8_t data[EC_LB_PROG_LEN];
+};
 
-struct ec_params_lightbar {
+struct __ec_todo_packed ec_params_lightbar {
 	uint8_t cmd;		      /* Command (see enum lightbar_command) */
 	union {
-		struct {
+		struct __ec_todo_unpacked {
 			/* no args */
-		} dump, off, on, init, get_seq, get_params;
+		} dump, off, on, init, get_seq, get_params_v0, get_params_v1,
+			version, get_brightness, get_demo, suspend, resume,
+			get_params_v2_timing, get_params_v2_tap,
+			get_params_v2_osc, get_params_v2_bright,
+			get_params_v2_thlds, get_params_v2_colors;
 
-		struct num {
+		struct __ec_todo_unpacked {
 			uint8_t num;
-		} brightness, seq, demo;
+		} set_brightness, seq, demo;
 
-		struct reg {
+		struct __ec_todo_unpacked {
 			uint8_t ctrl, reg, value;
 		} reg;
 
-		struct rgb {
+		struct __ec_todo_unpacked {
 			uint8_t led, red, green, blue;
-		} rgb;
+		} set_rgb;
+
+		struct __ec_todo_unpacked {
+			uint8_t led;
+		} get_rgb;
 
-		struct lightbar_params set_params;
+		struct __ec_todo_unpacked {
+			uint8_t enable;
+		} manual_suspend_ctrl;
+
+		struct lightbar_params_v0 set_params_v0;
+		struct lightbar_params_v1 set_params_v1;
+
+		struct lightbar_params_v2_timing set_v2par_timing;
+		struct lightbar_params_v2_tap set_v2par_tap;
+		struct lightbar_params_v2_oscillation set_v2par_osc;
+		struct lightbar_params_v2_brightness set_v2par_bright;
+		struct lightbar_params_v2_thresholds set_v2par_thlds;
+		struct lightbar_params_v2_colors set_v2par_colors;
+
+		struct lightbar_program set_program;
 	};
-} __packed;
+};
 
-struct ec_response_lightbar {
+struct __ec_todo_packed ec_response_lightbar {
 	union {
-		struct dump {
-			struct {
+		struct __ec_todo_unpacked {
+			struct __ec_todo_unpacked {
 				uint8_t reg;
 				uint8_t ic0;
 				uint8_t ic1;
 			} vals[23];
 		} dump;
 
-		struct get_seq {
+		struct __ec_todo_unpacked {
 			uint8_t num;
-		} get_seq;
+		} get_seq, get_brightness, get_demo;
 
-		struct lightbar_params get_params;
+		struct lightbar_params_v0 get_params_v0;
+		struct lightbar_params_v1 get_params_v1;
 
-		struct {
+
+		struct lightbar_params_v2_timing get_params_v2_timing;
+		struct lightbar_params_v2_tap get_params_v2_tap;
+		struct lightbar_params_v2_oscillation get_params_v2_osc;
+		struct lightbar_params_v2_brightness get_params_v2_bright;
+		struct lightbar_params_v2_thresholds get_params_v2_thlds;
+		struct lightbar_params_v2_colors get_params_v2_colors;
+
+		struct __ec_todo_unpacked {
+			uint32_t num;
+			uint32_t flags;
+		} version;
+
+		struct __ec_todo_unpacked {
+			uint8_t red, green, blue;
+		} get_rgb;
+
+		struct __ec_todo_unpacked {
 			/* no return params */
-		} off, on, init, brightness, seq, reg, rgb, demo, set_params;
+		} off, on, init, set_brightness, seq, reg, set_rgb,
+			demo, set_params_v0, set_params_v1,
+			set_program, manual_suspend_ctrl, suspend, resume,
+			set_v2par_timing, set_v2par_tap,
+			set_v2par_osc, set_v2par_bright, set_v2par_thlds,
+			set_v2par_colors;
 	};
-} __packed;
+};
 
 /* Lightbar commands */
 enum lightbar_command {
@@ -868,26 +1794,64 @@ enum lightbar_command {
 	LIGHTBAR_CMD_OFF = 1,
 	LIGHTBAR_CMD_ON = 2,
 	LIGHTBAR_CMD_INIT = 3,
-	LIGHTBAR_CMD_BRIGHTNESS = 4,
+	LIGHTBAR_CMD_SET_BRIGHTNESS = 4,
 	LIGHTBAR_CMD_SEQ = 5,
 	LIGHTBAR_CMD_REG = 6,
-	LIGHTBAR_CMD_RGB = 7,
+	LIGHTBAR_CMD_SET_RGB = 7,
 	LIGHTBAR_CMD_GET_SEQ = 8,
 	LIGHTBAR_CMD_DEMO = 9,
-	LIGHTBAR_CMD_GET_PARAMS = 10,
-	LIGHTBAR_CMD_SET_PARAMS = 11,
+	LIGHTBAR_CMD_GET_PARAMS_V0 = 10,
+	LIGHTBAR_CMD_SET_PARAMS_V0 = 11,
+	LIGHTBAR_CMD_VERSION = 12,
+	LIGHTBAR_CMD_GET_BRIGHTNESS = 13,
+	LIGHTBAR_CMD_GET_RGB = 14,
+	LIGHTBAR_CMD_GET_DEMO = 15,
+	LIGHTBAR_CMD_GET_PARAMS_V1 = 16,
+	LIGHTBAR_CMD_SET_PARAMS_V1 = 17,
+	LIGHTBAR_CMD_SET_PROGRAM = 18,
+	LIGHTBAR_CMD_MANUAL_SUSPEND_CTRL = 19,
+	LIGHTBAR_CMD_SUSPEND = 20,
+	LIGHTBAR_CMD_RESUME = 21,
+	LIGHTBAR_CMD_GET_PARAMS_V2_TIMING = 22,
+	LIGHTBAR_CMD_SET_PARAMS_V2_TIMING = 23,
+	LIGHTBAR_CMD_GET_PARAMS_V2_TAP = 24,
+	LIGHTBAR_CMD_SET_PARAMS_V2_TAP = 25,
+	LIGHTBAR_CMD_GET_PARAMS_V2_OSCILLATION = 26,
+	LIGHTBAR_CMD_SET_PARAMS_V2_OSCILLATION = 27,
+	LIGHTBAR_CMD_GET_PARAMS_V2_BRIGHTNESS = 28,
+	LIGHTBAR_CMD_SET_PARAMS_V2_BRIGHTNESS = 29,
+	LIGHTBAR_CMD_GET_PARAMS_V2_THRESHOLDS = 30,
+	LIGHTBAR_CMD_SET_PARAMS_V2_THRESHOLDS = 31,
+	LIGHTBAR_CMD_GET_PARAMS_V2_COLORS = 32,
+	LIGHTBAR_CMD_SET_PARAMS_V2_COLORS = 33,
 	LIGHTBAR_NUM_CMDS
 };
 
 /*****************************************************************************/
 /* LED control commands */
 
-#define EC_CMD_LED_CONTROL 0x29
+#define EC_CMD_LED_CONTROL 0x0029
 
 enum ec_led_id {
+	/* LED to indicate battery state of charge */
 	EC_LED_ID_BATTERY_LED = 0,
-	EC_LED_ID_POWER_BUTTON_LED,
+	/*
+	 * LED to indicate system power state (on or in suspend).
+	 * May be on power button or on C-panel.
+	 */
+	EC_LED_ID_POWER_LED,
+	/* LED on power adapter or its plug */
 	EC_LED_ID_ADAPTER_LED,
+	/* LED to indicate left side */
+	EC_LED_ID_LEFT_LED,
+	/* LED to indicate right side */
+	EC_LED_ID_RIGHT_LED,
+	/* LED to indicate recovery mode with HW_REINIT */
+	EC_LED_ID_RECOVERY_HW_REINIT_LED,
+	/* LED to indicate sysrq debug mode. */
+	EC_LED_ID_SYSRQ_DEBUG_LED,
+
+	EC_LED_ID_COUNT
 };
 
 /* LED control flags */
@@ -900,18 +1864,19 @@ enum ec_led_colors {
 	EC_LED_COLOR_BLUE,
 	EC_LED_COLOR_YELLOW,
 	EC_LED_COLOR_WHITE,
+	EC_LED_COLOR_AMBER,
 
 	EC_LED_COLOR_COUNT
 };
 
-struct ec_params_led_control {
+struct __ec_align1 ec_params_led_control {
 	uint8_t led_id;     /* Which LED to control */
 	uint8_t flags;      /* Control flags */
 
 	uint8_t brightness[EC_LED_COLOR_COUNT];
-} __packed;
+};
 
-struct ec_response_led_control {
+struct __ec_align1 ec_response_led_control {
 	/*
 	 * Available brightness value range.
 	 *
@@ -920,7 +1885,7 @@ struct ec_response_led_control {
 	 * Other values means the LED is control by PWM.
 	 */
 	uint8_t brightness_range[EC_LED_COLOR_COUNT];
-} __packed;
+};
 
 /*****************************************************************************/
 /* Verified boot commands */
@@ -931,9 +1896,9 @@ struct ec_response_led_control {
  */
 
 /* Verified boot hash command */
-#define EC_CMD_VBOOT_HASH 0x2A
+#define EC_CMD_VBOOT_HASH 0x002A
 
-struct ec_params_vboot_hash {
+struct __ec_align4 ec_params_vboot_hash {
 	uint8_t cmd;             /* enum ec_vboot_hash_cmd */
 	uint8_t hash_type;       /* enum ec_vboot_hash_type */
 	uint8_t nonce_size;      /* Nonce size; may be 0 */
@@ -941,9 +1906,9 @@ struct ec_params_vboot_hash {
 	uint32_t offset;         /* Offset in flash to hash */
 	uint32_t size;           /* Number of bytes to hash */
 	uint8_t nonce_data[64];  /* Nonce data; ignored if nonce_size=0 */
-} __packed;
+};
 
-struct ec_response_vboot_hash {
+struct __ec_align4 ec_response_vboot_hash {
 	uint8_t status;          /* enum ec_vboot_hash_status */
 	uint8_t hash_type;       /* enum ec_vboot_hash_type */
 	uint8_t digest_size;     /* Size of hash digest in bytes */
@@ -951,7 +1916,7 @@ struct ec_response_vboot_hash {
 	uint32_t offset;         /* Offset in flash which was hashed */
 	uint32_t size;           /* Number of bytes hashed */
 	uint8_t hash_digest[64]; /* Hash digest data */
-} __packed;
+};
 
 enum ec_vboot_hash_cmd {
 	EC_VBOOT_HASH_GET = 0,       /* Get current hash status */
@@ -975,741 +1940,2662 @@ enum ec_vboot_hash_status {
  * If one of these is specified, the EC will automatically update offset and
  * size to the correct values for the specified image (RO or RW).
  */
-#define EC_VBOOT_HASH_OFFSET_RO 0xfffffffe
-#define EC_VBOOT_HASH_OFFSET_RW 0xfffffffd
+#define EC_VBOOT_HASH_OFFSET_RO		0xfffffffe
+#define EC_VBOOT_HASH_OFFSET_ACTIVE	0xfffffffd
+#define EC_VBOOT_HASH_OFFSET_UPDATE	0xfffffffc
 
 /*****************************************************************************/
-/* USB charging control commands */
+/*
+ * Motion sense commands. We'll make separate structs for sub-commands with
+ * different input args, so that we know how much to expect.
+ */
+#define EC_CMD_MOTION_SENSE_CMD 0x002B
 
-/* Set USB port charging mode */
-#define EC_CMD_USB_CHARGE_SET_MODE 0x30
+/* Motion sense commands */
+enum motionsense_command {
+	/*
+	 * Dump command returns all motion sensor data including motion sense
+	 * module flags and individual sensor flags.
+	 */
+	MOTIONSENSE_CMD_DUMP = 0,
 
-struct ec_params_usb_charge_set_mode {
-	uint8_t usb_port_id;
-	uint8_t mode;
-} __packed;
+	/*
+	 * Info command returns data describing the details of a given sensor,
+	 * including enum motionsensor_type, enum motionsensor_location, and
+	 * enum motionsensor_chip.
+	 */
+	MOTIONSENSE_CMD_INFO = 1,
 
-/*****************************************************************************/
-/* Persistent storage for host */
+	/*
+	 * EC Rate command is a setter/getter command for the EC sampling rate
+	 * in milliseconds.
+	 * It is per sensor, the EC run sample task  at the minimum of all
+	 * sensors EC_RATE.
+	 * For sensors without hardware FIFO, EC_RATE should be equals to 1/ODR
+	 * to collect all the sensor samples.
+	 * For sensor with hardware FIFO, EC_RATE is used as the maximal delay
+	 * to process of all motion sensors in milliseconds.
+	 */
+	MOTIONSENSE_CMD_EC_RATE = 2,
 
-/* Maximum bytes that can be read/written in a single command */
-#define EC_PSTORE_SIZE_MAX 64
+	/*
+	 * Sensor ODR command is a setter/getter command for the output data
+	 * rate of a specific motion sensor in millihertz.
+	 */
+	MOTIONSENSE_CMD_SENSOR_ODR = 3,
 
-/* Get persistent storage info */
-#define EC_CMD_PSTORE_INFO 0x40
+	/*
+	 * Sensor range command is a setter/getter command for the range of
+	 * a specified motion sensor in +/-G's or +/- deg/s.
+	 */
+	MOTIONSENSE_CMD_SENSOR_RANGE = 4,
 
-struct ec_response_pstore_info {
-	/* Persistent storage size, in bytes */
-	uint32_t pstore_size;
-	/* Access size; read/write offset and size must be a multiple of this */
-	uint32_t access_size;
-} __packed;
+	/*
+	 * Setter/getter command for the keyboard wake angle. When the lid
+	 * angle is greater than this value, keyboard wake is disabled in S3,
+	 * and when the lid angle goes less than this value, keyboard wake is
+	 * enabled. Note, the lid angle measurement is an approximate,
+	 * un-calibrated value, hence the wake angle isn't exact.
+	 */
+	MOTIONSENSE_CMD_KB_WAKE_ANGLE = 5,
 
-/*
- * Read persistent storage
- *
- * Response is params.size bytes of data.
- */
-#define EC_CMD_PSTORE_READ 0x41
+	/*
+	 * Returns a single sensor data.
+	 */
+	MOTIONSENSE_CMD_DATA = 6,
 
-struct ec_params_pstore_read {
-	uint32_t offset;   /* Byte offset to read */
-	uint32_t size;     /* Size to read in bytes */
-} __packed;
+	/*
+	 * Return sensor fifo info.
+	 */
+	MOTIONSENSE_CMD_FIFO_INFO = 7,
 
-/* Write persistent storage */
-#define EC_CMD_PSTORE_WRITE 0x42
+	/*
+	 * Insert a flush element in the fifo and return sensor fifo info.
+	 * The host can use that element to synchronize its operation.
+	 */
+	MOTIONSENSE_CMD_FIFO_FLUSH = 8,
 
-struct ec_params_pstore_write {
-	uint32_t offset;   /* Byte offset to write */
-	uint32_t size;     /* Size to write in bytes */
-	uint8_t data[EC_PSTORE_SIZE_MAX];
-} __packed;
+	/*
+	 * Return a portion of the fifo.
+	 */
+	MOTIONSENSE_CMD_FIFO_READ = 9,
 
-/*****************************************************************************/
-/* Real-time clock */
+	/*
+	 * Perform low level calibration.
+	 * On sensors that support it, ask to do offset calibration.
+	 */
+	MOTIONSENSE_CMD_PERFORM_CALIB = 10,
 
-/* RTC params and response structures */
-struct ec_params_rtc {
-	uint32_t time;
-} __packed;
+	/*
+	 * Sensor Offset command is a setter/getter command for the offset
+	 * used for calibration.
+	 * The offsets can be calculated by the host, or via
+	 * PERFORM_CALIB command.
+	 */
+	MOTIONSENSE_CMD_SENSOR_OFFSET = 11,
 
-struct ec_response_rtc {
-	uint32_t time;
-} __packed;
+	/*
+	 * List available activities for a MOTION sensor.
+	 * Indicates if they are enabled or disabled.
+	 */
+	MOTIONSENSE_CMD_LIST_ACTIVITIES = 12,
 
-/* These use ec_response_rtc */
-#define EC_CMD_RTC_GET_VALUE 0x44
-#define EC_CMD_RTC_GET_ALARM 0x45
+	/*
+	 * Activity management
+	 * Enable/Disable activity recognition.
+	 */
+	MOTIONSENSE_CMD_SET_ACTIVITY = 13,
 
-/* These all use ec_params_rtc */
-#define EC_CMD_RTC_SET_VALUE 0x46
-#define EC_CMD_RTC_SET_ALARM 0x47
+	/*
+	 * Lid Angle
+	 */
+	MOTIONSENSE_CMD_LID_ANGLE = 14,
 
-/*****************************************************************************/
-/* Port80 log access */
+	/*
+	 * Allow the FIFO to trigger interrupt via MKBP events.
+	 * By default the FIFO does not send interrupt to process the FIFO
+	 * until the AP is ready or it is coming from a wakeup sensor.
+	 */
+	MOTIONSENSE_CMD_FIFO_INT_ENABLE = 15,
 
-/* Get last port80 code from previous boot */
-#define EC_CMD_PORT80_LAST_BOOT 0x48
+	/*
+	 * Spoof the readings of the sensors.  The spoofed readings can be set
+	 * to arbitrary values, or will lock to the last read actual values.
+	 */
+	MOTIONSENSE_CMD_SPOOF = 16,
 
-struct ec_response_port80_last_boot {
-	uint16_t code;
-} __packed;
+	/* Number of motionsense sub-commands. */
+	MOTIONSENSE_NUM_CMDS
+};
 
-/*****************************************************************************/
-/* Thermal engine commands */
+/* List of motion sensor types. */
+enum motionsensor_type {
+	MOTIONSENSE_TYPE_ACCEL = 0,
+	MOTIONSENSE_TYPE_GYRO = 1,
+	MOTIONSENSE_TYPE_MAG = 2,
+	MOTIONSENSE_TYPE_PROX = 3,
+	MOTIONSENSE_TYPE_LIGHT = 4,
+	MOTIONSENSE_TYPE_ACTIVITY = 5,
+	MOTIONSENSE_TYPE_BARO = 6,
+	MOTIONSENSE_TYPE_MAX,
+};
 
-/* Set thershold value */
-#define EC_CMD_THERMAL_SET_THRESHOLD 0x50
+/* List of motion sensor locations. */
+enum motionsensor_location {
+	MOTIONSENSE_LOC_BASE = 0,
+	MOTIONSENSE_LOC_LID = 1,
+	MOTIONSENSE_LOC_MAX,
+};
 
-struct ec_params_thermal_set_threshold {
-	uint8_t sensor_type;
-	uint8_t threshold_id;
-	uint16_t value;
-} __packed;
+/* List of motion sensor chips. */
+enum motionsensor_chip {
+	MOTIONSENSE_CHIP_KXCJ9 = 0,
+	MOTIONSENSE_CHIP_LSM6DS0 = 1,
+	MOTIONSENSE_CHIP_BMI160 = 2,
+	MOTIONSENSE_CHIP_SI1141 = 3,
+	MOTIONSENSE_CHIP_SI1142 = 4,
+	MOTIONSENSE_CHIP_SI1143 = 5,
+	MOTIONSENSE_CHIP_KX022 = 6,
+	MOTIONSENSE_CHIP_L3GD20H = 7,
+	MOTIONSENSE_CHIP_BMA255 = 8,
+	MOTIONSENSE_CHIP_BMP280 = 9,
+	MOTIONSENSE_CHIP_OPT3001 = 10,
+};
 
-/* Get threshold value */
-#define EC_CMD_THERMAL_GET_THRESHOLD 0x51
+struct __ec_todo_packed ec_response_motion_sensor_data {
+	/* Flags for each sensor. */
+	uint8_t flags;
+	/* sensor number the data comes from */
+	uint8_t sensor_num;
+	/* Each sensor is up to 3-axis. */
+	union {
+		int16_t             data[3];
+		struct __ec_todo_packed {
+			uint16_t    reserved;
+			uint32_t    timestamp;
+		};
+		struct __ec_todo_unpacked {
+			uint8_t     activity; /* motionsensor_activity */
+			uint8_t     state;
+			int16_t     add_info[2];
+		};
+	};
+};
 
-struct ec_params_thermal_get_threshold {
-	uint8_t sensor_type;
-	uint8_t threshold_id;
-} __packed;
+/* Note: used in ec_response_get_next_data */
+struct __ec_todo_packed ec_response_motion_sense_fifo_info {
+	/* Size of the fifo */
+	uint16_t size;
+	/* Amount of space used in the fifo */
+	uint16_t count;
+	/* Timestamp recorded in us */
+	uint32_t timestamp;
+	/* Total amount of vector lost */
+	uint16_t total_lost;
+	/* Lost events since the last fifo_info, per sensors */
+	uint16_t lost[0];
+};
 
-struct ec_response_thermal_get_threshold {
-	uint16_t value;
-} __packed;
+struct __ec_todo_packed ec_response_motion_sense_fifo_data {
+	uint32_t number_data;
+	struct ec_response_motion_sensor_data data[0];
+};
 
-/* Toggle automatic fan control */
-#define EC_CMD_THERMAL_AUTO_FAN_CTRL 0x52
+/* List supported activity recognition */
+enum motionsensor_activity {
+	MOTIONSENSE_ACTIVITY_RESERVED = 0,
+	MOTIONSENSE_ACTIVITY_SIG_MOTION = 1,
+	MOTIONSENSE_ACTIVITY_DOUBLE_TAP = 2,
+};
 
-/* Get TMP006 calibration data */
-#define EC_CMD_TMP006_GET_CALIBRATION 0x53
+struct __ec_todo_unpacked ec_motion_sense_activity {
+	uint8_t sensor_num;
+	uint8_t activity; /* one of enum motionsensor_activity */
+	uint8_t enable;   /* 1: enable, 0: disable */
+	uint8_t reserved;
+	uint16_t parameters[3]; /* activity dependent parameters */
+};
 
-struct ec_params_tmp006_get_calibration {
-	uint8_t index;
-} __packed;
+/* Module flag masks used for the dump sub-command. */
+#define MOTIONSENSE_MODULE_FLAG_ACTIVE (1<<0)
 
-struct ec_response_tmp006_get_calibration {
-	float s0;
-	float b0;
-	float b1;
-	float b2;
-} __packed;
+/* Sensor flag masks used for the dump sub-command. */
+#define MOTIONSENSE_SENSOR_FLAG_PRESENT (1<<0)
 
-/* Set TMP006 calibration data */
-#define EC_CMD_TMP006_SET_CALIBRATION 0x54
+/*
+ * Flush entry for synchronization.
+ * data contains time stamp
+ */
+#define MOTIONSENSE_SENSOR_FLAG_FLUSH (1<<0)
+#define MOTIONSENSE_SENSOR_FLAG_TIMESTAMP (1<<1)
+#define MOTIONSENSE_SENSOR_FLAG_WAKEUP (1<<2)
+#define MOTIONSENSE_SENSOR_FLAG_TABLET_MODE (1<<3)
 
-struct ec_params_tmp006_set_calibration {
-	uint8_t index;
-	uint8_t reserved[3];  /* Reserved; set 0 */
-	float s0;
-	float b0;
-	float b1;
-	float b2;
-} __packed;
+/*
+ * Send this value for the data element to only perform a read. If you
+ * send any other value, the EC will interpret it as data to set and will
+ * return the actual value set.
+ */
+#define EC_MOTION_SENSE_NO_VALUE -1
 
-/*****************************************************************************/
-/* MKBP - Matrix KeyBoard Protocol */
+#define EC_MOTION_SENSE_INVALID_CALIB_TEMP 0x8000
+
+/* MOTIONSENSE_CMD_SENSOR_OFFSET subcommand flag */
+/* Set Calibration information */
+#define MOTION_SENSE_SET_OFFSET 1
+
+#define LID_ANGLE_UNRELIABLE 500
+
+enum motionsense_spoof_mode {
+	/* Disable spoof mode. */
+	MOTIONSENSE_SPOOF_MODE_DISABLE = 0,
+
+	/* Enable spoof mode, but use provided component values. */
+	MOTIONSENSE_SPOOF_MODE_CUSTOM,
+
+	/* Enable spoof mode, but use the current sensor values. */
+	MOTIONSENSE_SPOOF_MODE_LOCK_CURRENT,
+
+	/* Query the current spoof mode status for the sensor. */
+	MOTIONSENSE_SPOOF_MODE_QUERY,
+};
+
+struct __ec_todo_packed ec_params_motion_sense {
+	uint8_t cmd;
+	union {
+		/* Used for MOTIONSENSE_CMD_DUMP */
+		struct __ec_todo_unpacked {
+			/*
+			 * Maximal number of sensor the host is expecting.
+			 * 0 means the host is only interested in the number
+			 * of sensors controlled by the EC.
+			 */
+			uint8_t max_sensor_count;
+		} dump;
+
+		/*
+		 * Used for MOTIONSENSE_CMD_KB_WAKE_ANGLE.
+		 */
+		struct __ec_todo_unpacked {
+			/* Data to set or EC_MOTION_SENSE_NO_VALUE to read.
+			 * kb_wake_angle: angle to wakup AP.
+			 */
+			int16_t data;
+		} kb_wake_angle;
+
+		/* Used for MOTIONSENSE_CMD_INFO, MOTIONSENSE_CMD_DATA
+		 * and MOTIONSENSE_CMD_PERFORM_CALIB. */
+		struct __ec_todo_unpacked {
+			uint8_t sensor_num;
+		} info, info_3, data, fifo_flush, perform_calib,
+				list_activities;
+
+		/*
+		 * Used for MOTIONSENSE_CMD_EC_RATE, MOTIONSENSE_CMD_SENSOR_ODR
+		 * and MOTIONSENSE_CMD_SENSOR_RANGE.
+		 */
+		struct __ec_todo_unpacked {
+			uint8_t sensor_num;
+
+			/* Rounding flag, true for round-up, false for down. */
+			uint8_t roundup;
+
+			uint16_t reserved;
+
+			/* Data to set or EC_MOTION_SENSE_NO_VALUE to read. */
+			int32_t data;
+		} ec_rate, sensor_odr, sensor_range;
+
+		/* Used for MOTIONSENSE_CMD_SENSOR_OFFSET */
+		struct __ec_todo_packed {
+			uint8_t sensor_num;
+
+			/*
+			 * bit 0: If set (MOTION_SENSE_SET_OFFSET), set
+			 * the calibration information in the EC.
+			 * If unset, just retrieve calibration information.
+			 */
+			uint16_t flags;
+
+			/*
+			 * Temperature at calibration, in units of 0.01 C
+			 * 0x8000: invalid / unknown.
+			 * 0x0: 0C
+			 * 0x7fff: +327.67C
+			 */
+			int16_t temp;
+
+			/*
+			 * Offset for calibration.
+			 * Unit:
+			 * Accelerometer: 1/1024 g
+			 * Gyro:          1/1024 deg/s
+			 * Compass:       1/16 uT
+			 */
+			int16_t offset[3];
+		} sensor_offset;
+
+		/* Used for MOTIONSENSE_CMD_FIFO_INFO */
+		struct __ec_todo_unpacked {
+		} fifo_info;
+
+		/* Used for MOTIONSENSE_CMD_FIFO_READ */
+		struct __ec_todo_unpacked {
+			/*
+			 * Number of expected vector to return.
+			 * EC may return less or 0 if none available.
+			 */
+			uint32_t max_data_vector;
+		} fifo_read;
+
+		struct ec_motion_sense_activity set_activity;
+
+		/* Used for MOTIONSENSE_CMD_LID_ANGLE */
+		struct __ec_todo_unpacked {
+		} lid_angle;
+
+		/* Used for MOTIONSENSE_CMD_FIFO_INT_ENABLE */
+		struct __ec_todo_unpacked {
+			/*
+			 * 1: enable, 0 disable fifo,
+			 * EC_MOTION_SENSE_NO_VALUE return value.
+			 */
+			int8_t enable;
+		} fifo_int_enable;
+
+		/* Used for MOTIONSENSE_CMD_SPOOF */
+		struct __ec_todo_packed {
+			uint8_t sensor_id;
+
+			/* See enum motionsense_spoof_mode. */
+			uint8_t spoof_enable;
+
+			/* Ignored, used for alignment. */
+			uint8_t reserved;
+
+			/* Individual component values to spoof. */
+			int16_t components[3];
+		} spoof;
+	};
+};
+
+struct __ec_todo_packed ec_response_motion_sense {
+	union {
+		/* Used for MOTIONSENSE_CMD_DUMP */
+		struct __ec_todo_unpacked {
+			/* Flags representing the motion sensor module. */
+			uint8_t module_flags;
+
+			/* Number of sensors managed directly by the EC */
+			uint8_t sensor_count;
+
+			/*
+			 * sensor data is truncated if response_max is too small
+			 * for holding all the data.
+			 */
+			struct ec_response_motion_sensor_data sensor[0];
+		} dump;
+
+		/* Used for MOTIONSENSE_CMD_INFO. */
+		struct __ec_todo_unpacked {
+			/* Should be element of enum motionsensor_type. */
+			uint8_t type;
+
+			/* Should be element of enum motionsensor_location. */
+			uint8_t location;
+
+			/* Should be element of enum motionsensor_chip. */
+			uint8_t chip;
+		} info;
+
+		/* Used for MOTIONSENSE_CMD_INFO version 3 */
+		struct __ec_todo_unpacked {
+			/* Should be element of enum motionsensor_type. */
+			uint8_t type;
+
+			/* Should be element of enum motionsensor_location. */
+			uint8_t location;
+
+			/* Should be element of enum motionsensor_chip. */
+			uint8_t chip;
+
+			/* Minimum sensor sampling frequency */
+			uint32_t min_frequency;
+
+			/* Maximum sensor sampling frequency */
+			uint32_t max_frequency;
+
+			/* Max number of sensor events that could be in fifo */
+			uint32_t fifo_max_event_count;
+		} info_3;
+
+		/* Used for MOTIONSENSE_CMD_DATA */
+		struct ec_response_motion_sensor_data data;
+
+		/*
+		 * Used for MOTIONSENSE_CMD_EC_RATE, MOTIONSENSE_CMD_SENSOR_ODR,
+		 * MOTIONSENSE_CMD_SENSOR_RANGE,
+		 * MOTIONSENSE_CMD_KB_WAKE_ANGLE,
+		 * MOTIONSENSE_CMD_FIFO_INT_ENABLE and
+		 * MOTIONSENSE_CMD_SPOOF.
+		 */
+		struct __ec_todo_unpacked {
+			/* Current value of the parameter queried. */
+			int32_t ret;
+		} ec_rate, sensor_odr, sensor_range, kb_wake_angle,
+		  fifo_int_enable, spoof;
+
+		/* Used for MOTIONSENSE_CMD_SENSOR_OFFSET */
+		struct __ec_todo_unpacked  {
+			int16_t temp;
+			int16_t offset[3];
+		} sensor_offset, perform_calib;
+
+		struct ec_response_motion_sense_fifo_info fifo_info, fifo_flush;
+
+		struct ec_response_motion_sense_fifo_data fifo_read;
+
+		struct __ec_todo_packed {
+			uint16_t reserved;
+			uint32_t enabled;
+			uint32_t disabled;
+		} list_activities;
+
+		struct __ec_todo_unpacked {
+		} set_activity;
+
+		/* Used for MOTIONSENSE_CMD_LID_ANGLE */
+		struct __ec_todo_unpacked {
+			/*
+			 * Angle between 0 and 360 degree if available,
+			 * LID_ANGLE_UNRELIABLE otherwise.
+			 */
+			uint16_t value;
+		} lid_angle;
+	};
+};
+
+/*****************************************************************************/
+/* Force lid open command */
+
+/* Make lid event always open */
+#define EC_CMD_FORCE_LID_OPEN 0x002C
+
+struct __ec_align1 ec_params_force_lid_open {
+	uint8_t enabled;
+};
+
+/*****************************************************************************/
+/* Configure the behavior of the power button */
+#define EC_CMD_CONFIG_POWER_BUTTON 0x002D
+
+enum ec_config_power_button_flags {
+	/* Enable/Disable power button pulses for x86 devices */
+	EC_POWER_BUTTON_ENABLE_PULSE = (1 << 0),
+};
+
+struct __ec_align1 ec_params_config_power_button {
+	/* See enum ec_config_power_button_flags */
+	uint8_t flags;
+};
+
+/*****************************************************************************/
+/* USB charging control commands */
+
+/* Set USB port charging mode */
+#define EC_CMD_USB_CHARGE_SET_MODE 0x0030
+
+struct __ec_align1 ec_params_usb_charge_set_mode {
+	uint8_t usb_port_id;
+	uint8_t mode;
+};
+
+/*****************************************************************************/
+/* Persistent storage for host */
+
+/* Maximum bytes that can be read/written in a single command */
+#define EC_PSTORE_SIZE_MAX 64
+
+/* Get persistent storage info */
+#define EC_CMD_PSTORE_INFO 0x0040
+
+struct __ec_align4 ec_response_pstore_info {
+	/* Persistent storage size, in bytes */
+	uint32_t pstore_size;
+	/* Access size; read/write offset and size must be a multiple of this */
+	uint32_t access_size;
+};
+
+/*
+ * Read persistent storage
+ *
+ * Response is params.size bytes of data.
+ */
+#define EC_CMD_PSTORE_READ 0x0041
+
+struct __ec_align4 ec_params_pstore_read {
+	uint32_t offset;   /* Byte offset to read */
+	uint32_t size;     /* Size to read in bytes */
+};
+
+/* Write persistent storage */
+#define EC_CMD_PSTORE_WRITE 0x0042
+
+struct __ec_align4 ec_params_pstore_write {
+	uint32_t offset;   /* Byte offset to write */
+	uint32_t size;     /* Size to write in bytes */
+	uint8_t data[EC_PSTORE_SIZE_MAX];
+};
+
+/*****************************************************************************/
+/* Real-time clock */
+
+/* RTC params and response structures */
+struct __ec_align4 ec_params_rtc {
+	uint32_t time;
+};
+
+struct __ec_align4 ec_response_rtc {
+	uint32_t time;
+};
+
+/* These use ec_response_rtc */
+#define EC_CMD_RTC_GET_VALUE 0x0044
+#define EC_CMD_RTC_GET_ALARM 0x0045
+
+/* These all use ec_params_rtc */
+#define EC_CMD_RTC_SET_VALUE 0x0046
+#define EC_CMD_RTC_SET_ALARM 0x0047
+
+/* Pass as time param to SET_ALARM to clear the current alarm */
+#define EC_RTC_ALARM_CLEAR 0
+
+/*****************************************************************************/
+/* Port80 log access */
+
+/* Maximum entries that can be read/written in a single command */
+#define EC_PORT80_SIZE_MAX 32
+
+/* Get last port80 code from previous boot */
+#define EC_CMD_PORT80_LAST_BOOT 0x0048
+#define EC_CMD_PORT80_READ 0x0048
+
+enum ec_port80_subcmd {
+	EC_PORT80_GET_INFO = 0,
+	EC_PORT80_READ_BUFFER,
+};
+
+struct __ec_todo_packed ec_params_port80_read {
+	uint16_t subcmd;
+	union {
+		struct __ec_todo_unpacked {
+			uint32_t offset;
+			uint32_t num_entries;
+		} read_buffer;
+	};
+};
+
+struct __ec_todo_packed ec_response_port80_read {
+	union {
+		struct __ec_todo_unpacked {
+			uint32_t writes;
+			uint32_t history_size;
+			uint32_t last_boot;
+		} get_info;
+		struct __ec_todo_unpacked {
+			uint16_t codes[EC_PORT80_SIZE_MAX];
+		} data;
+	};
+};
+
+struct __ec_align2 ec_response_port80_last_boot {
+	uint16_t code;
+};
+
+/*****************************************************************************/
+/* Temporary secure storage for host verified boot use */
+
+/* Number of bytes in a vstore slot */
+#define EC_VSTORE_SLOT_SIZE 64
+
+/* Maximum number of vstore slots */
+#define EC_VSTORE_SLOT_MAX 32
+
+/* Get persistent storage info */
+#define EC_CMD_VSTORE_INFO 0x0049
+struct __ec_align_size1 ec_response_vstore_info {
+	/* Indicates which slots are locked */
+	uint32_t slot_locked;
+	/* Total number of slots available */
+	uint8_t slot_count;
+};
+
+/*
+ * Read temporary secure storage
+ *
+ * Response is EC_VSTORE_SLOT_SIZE bytes of data.
+ */
+#define EC_CMD_VSTORE_READ 0x004A
+
+struct __ec_align1 ec_params_vstore_read {
+	uint8_t slot; /* Slot to read from */
+};
+
+struct __ec_align1 ec_response_vstore_read {
+	uint8_t data[EC_VSTORE_SLOT_SIZE];
+};
+
+/*
+ * Write temporary secure storage and lock it.
+ */
+#define EC_CMD_VSTORE_WRITE 0x004B
+
+struct __ec_align1 ec_params_vstore_write {
+	uint8_t slot; /* Slot to write to */
+	uint8_t data[EC_VSTORE_SLOT_SIZE];
+};
+
+/*****************************************************************************/
+/* Thermal engine commands. Note that there are two implementations. We'll
+ * reuse the command number, but the data and behavior is incompatible.
+ * Version 0 is what originally shipped on Link.
+ * Version 1 separates the CPU thermal limits from the fan control.
+ */
+
+#define EC_CMD_THERMAL_SET_THRESHOLD 0x0050
+#define EC_CMD_THERMAL_GET_THRESHOLD 0x0051
+
+/* The version 0 structs are opaque. You have to know what they are for
+ * the get/set commands to make any sense.
+ */
+
+/* Version 0 - set */
+struct __ec_align2 ec_params_thermal_set_threshold {
+	uint8_t sensor_type;
+	uint8_t threshold_id;
+	uint16_t value;
+};
+
+/* Version 0 - get */
+struct __ec_align1 ec_params_thermal_get_threshold {
+	uint8_t sensor_type;
+	uint8_t threshold_id;
+};
+
+struct __ec_align2 ec_response_thermal_get_threshold {
+	uint16_t value;
+};
+
+
+/* The version 1 structs are visible. */
+enum ec_temp_thresholds {
+	EC_TEMP_THRESH_WARN = 0,
+	EC_TEMP_THRESH_HIGH,
+	EC_TEMP_THRESH_HALT,
+
+	EC_TEMP_THRESH_COUNT
+};
+
+/*
+ * Thermal configuration for one temperature sensor. Temps are in degrees K.
+ * Zero values will be silently ignored by the thermal task.
+ *
+ * Note that this structure is a sub-structure of
+ * ec_params_thermal_set_threshold_v1, but maintains its alignment there.
+ */
+struct __ec_align4 ec_thermal_config {
+	uint32_t temp_host[EC_TEMP_THRESH_COUNT]; /* levels of hotness */
+	uint32_t temp_fan_off;		/* no active cooling needed */
+	uint32_t temp_fan_max;		/* max active cooling needed */
+};
+
+/* Version 1 - get config for one sensor. */
+struct __ec_align4 ec_params_thermal_get_threshold_v1 {
+	uint32_t sensor_num;
+};
+/* This returns a struct ec_thermal_config */
+
+/* Version 1 - set config for one sensor.
+ * Use read-modify-write for best results! */
+struct __ec_align4 ec_params_thermal_set_threshold_v1 {
+	uint32_t sensor_num;
+	struct ec_thermal_config cfg;
+};
+/* This returns no data */
+
+/****************************************************************************/
+
+/* Toggle automatic fan control */
+#define EC_CMD_THERMAL_AUTO_FAN_CTRL 0x0052
+
+/* Version 1 of input params */
+struct __ec_align1 ec_params_auto_fan_ctrl_v1 {
+	uint8_t fan_idx;
+};
+
+/* Get/Set TMP006 calibration data */
+#define EC_CMD_TMP006_GET_CALIBRATION 0x0053
+#define EC_CMD_TMP006_SET_CALIBRATION 0x0054
+
+/*
+ * The original TMP006 calibration only needed four params, but now we need
+ * more. Since the algorithm is nothing but magic numbers anyway, we'll leave
+ * the params opaque. The v1 "get" response will include the algorithm number
+ * and how many params it requires. That way we can change the EC code without
+ * needing to update this file. We can also use a different algorithm on each
+ * sensor.
+ */
+
+/* This is the same struct for both v0 and v1. */
+struct __ec_align1 ec_params_tmp006_get_calibration {
+	uint8_t index;
+};
+
+/* Version 0 */
+struct __ec_align4 ec_response_tmp006_get_calibration_v0 {
+	float s0;
+	float b0;
+	float b1;
+	float b2;
+};
+
+struct __ec_align4 ec_params_tmp006_set_calibration_v0 {
+	uint8_t index;
+	uint8_t reserved[3];
+	float s0;
+	float b0;
+	float b1;
+	float b2;
+};
+
+/* Version 1 */
+struct __ec_align4 ec_response_tmp006_get_calibration_v1 {
+	uint8_t algorithm;
+	uint8_t num_params;
+	uint8_t reserved[2];
+	float val[0];
+};
+
+struct __ec_align4 ec_params_tmp006_set_calibration_v1 {
+	uint8_t index;
+	uint8_t algorithm;
+	uint8_t num_params;
+	uint8_t reserved;
+	float val[0];
+};
+
+
+/* Read raw TMP006 data */
+#define EC_CMD_TMP006_GET_RAW 0x0055
+
+struct __ec_align1 ec_params_tmp006_get_raw {
+	uint8_t index;
+};
+
+struct __ec_align4 ec_response_tmp006_get_raw {
+	int32_t t;  /* In 1/100 K */
+	int32_t v;  /* In nV */
+};
+
+/*****************************************************************************/
+/* MKBP - Matrix KeyBoard Protocol */
 
 /*
  * Read key state
  *
  * Returns raw data for keyboard cols; see ec_response_mkbp_info.cols for
  * expected response size.
+ *
+ * NOTE: This has been superseded by EC_CMD_MKBP_GET_NEXT_EVENT.  If you wish
+ * to obtain the instantaneous state, use EC_CMD_MKBP_INFO with the type
+ * EC_MKBP_INFO_CURRENT and event EC_MKBP_EVENT_KEY_MATRIX.
  */
-#define EC_CMD_MKBP_STATE 0x60
+#define EC_CMD_MKBP_STATE 0x0060
+
+/*
+ * Provide information about various MKBP things.  See enum ec_mkbp_info_type.
+ */
+#define EC_CMD_MKBP_INFO 0x0061
+
+struct __ec_align_size1 ec_response_mkbp_info {
+	uint32_t rows;
+	uint32_t cols;
+	/* Formerly "switches", which was 0. */
+	uint8_t reserved;
+};
+
+struct __ec_align1 ec_params_mkbp_info {
+	uint8_t info_type;
+	uint8_t event_type;
+};
+
+enum ec_mkbp_info_type {
+	/*
+	 * Info about the keyboard matrix: number of rows and columns.
+	 *
+	 * Returns struct ec_response_mkbp_info.
+	 */
+	EC_MKBP_INFO_KBD = 0,
+
+	/*
+	 * For buttons and switches, info about which specifically are
+	 * supported.  event_type must be set to one of the values in enum
+	 * ec_mkbp_event.
+	 *
+	 * For EC_MKBP_EVENT_BUTTON and EC_MKBP_EVENT_SWITCH, returns a 4 byte
+	 * bitmask indicating which buttons or switches are present.  See the
+	 * bit inidices below.
+	 */
+	EC_MKBP_INFO_SUPPORTED = 1,
+
+	/*
+	 * Instantaneous state of buttons and switches.
+	 *
+	 * event_type must be set to one of the values in enum ec_mkbp_event.
+	 *
+	 * For EC_MKBP_EVENT_KEY_MATRIX, returns uint8_t key_matrix[13]
+	 * indicating the current state of the keyboard matrix.
+	 *
+	 * For EC_MKBP_EVENT_HOST_EVENT, return uint32_t host_event, the raw
+	 * event state.
+	 *
+	 * For EC_MKBP_EVENT_BUTTON, returns uint32_t buttons, indicating the
+	 * state of supported buttons.
+	 *
+	 * For EC_MKBP_EVENT_SWITCH, returns uint32_t switches, indicating the
+	 * state of supported switches.
+	 */
+	EC_MKBP_INFO_CURRENT = 2,
+};
+
+/* Simulate key press */
+#define EC_CMD_MKBP_SIMULATE_KEY 0x0062
+
+struct __ec_align1 ec_params_mkbp_simulate_key {
+	uint8_t col;
+	uint8_t row;
+	uint8_t pressed;
+};
+
+/* Configure keyboard scanning */
+#define EC_CMD_MKBP_SET_CONFIG 0x0064
+#define EC_CMD_MKBP_GET_CONFIG 0x0065
+
+/* flags */
+enum mkbp_config_flags {
+	EC_MKBP_FLAGS_ENABLE = 1,	/* Enable keyboard scanning */
+};
+
+enum mkbp_config_valid {
+	EC_MKBP_VALID_SCAN_PERIOD		= 1 << 0,
+	EC_MKBP_VALID_POLL_TIMEOUT		= 1 << 1,
+	EC_MKBP_VALID_MIN_POST_SCAN_DELAY	= 1 << 3,
+	EC_MKBP_VALID_OUTPUT_SETTLE		= 1 << 4,
+	EC_MKBP_VALID_DEBOUNCE_DOWN		= 1 << 5,
+	EC_MKBP_VALID_DEBOUNCE_UP		= 1 << 6,
+	EC_MKBP_VALID_FIFO_MAX_DEPTH		= 1 << 7,
+};
+
+/*
+ * Configuration for our key scanning algorithm.
+ *
+ * Note that this is used as a sub-structure of
+ * ec_{params/response}_mkbp_get_config.
+ */
+struct __ec_align_size1 ec_mkbp_config {
+	uint32_t valid_mask;		/* valid fields */
+	uint8_t flags;		/* some flags (enum mkbp_config_flags) */
+	uint8_t valid_flags;		/* which flags are valid */
+	uint16_t scan_period_us;	/* period between start of scans */
+	/* revert to interrupt mode after no activity for this long */
+	uint32_t poll_timeout_us;
+	/*
+	 * minimum post-scan relax time. Once we finish a scan we check
+	 * the time until we are due to start the next one. If this time is
+	 * shorter this field, we use this instead.
+	 */
+	uint16_t min_post_scan_delay_us;
+	/* delay between setting up output and waiting for it to settle */
+	uint16_t output_settle_us;
+	uint16_t debounce_down_us;	/* time for debounce on key down */
+	uint16_t debounce_up_us;	/* time for debounce on key up */
+	/* maximum depth to allow for fifo (0 = no keyscan output) */
+	uint8_t fifo_max_depth;
+};
+
+struct __ec_align_size1 ec_params_mkbp_set_config {
+	struct ec_mkbp_config config;
+};
+
+struct __ec_align_size1 ec_response_mkbp_get_config {
+	struct ec_mkbp_config config;
+};
+
+/* Run the key scan emulation */
+#define EC_CMD_KEYSCAN_SEQ_CTRL 0x0066
+
+enum ec_keyscan_seq_cmd {
+	EC_KEYSCAN_SEQ_STATUS = 0,	/* Get status information */
+	EC_KEYSCAN_SEQ_CLEAR = 1,	/* Clear sequence */
+	EC_KEYSCAN_SEQ_ADD = 2,		/* Add item to sequence */
+	EC_KEYSCAN_SEQ_START = 3,	/* Start running sequence */
+	EC_KEYSCAN_SEQ_COLLECT = 4,	/* Collect sequence summary data */
+};
+
+enum ec_collect_flags {
+	/*
+	 * Indicates this scan was processed by the EC. Due to timing, some
+	 * scans may be skipped.
+	 */
+	EC_KEYSCAN_SEQ_FLAG_DONE	= 1 << 0,
+};
+
+struct __ec_align1 ec_collect_item {
+	uint8_t flags;		/* some flags (enum ec_collect_flags) */
+};
+
+struct __ec_todo_packed ec_params_keyscan_seq_ctrl {
+	uint8_t cmd;	/* Command to send (enum ec_keyscan_seq_cmd) */
+	union {
+		struct __ec_align1 {
+			uint8_t active;		/* still active */
+			uint8_t num_items;	/* number of items */
+			/* Current item being presented */
+			uint8_t cur_item;
+		} status;
+		struct __ec_todo_unpacked {
+			/*
+			 * Absolute time for this scan, measured from the
+			 * start of the sequence.
+			 */
+			uint32_t time_us;
+			uint8_t scan[0];	/* keyscan data */
+		} add;
+		struct __ec_align1 {
+			uint8_t start_item;	/* First item to return */
+			uint8_t num_items;	/* Number of items to return */
+		} collect;
+	};
+};
+
+struct __ec_todo_packed ec_result_keyscan_seq_ctrl {
+	union {
+		struct __ec_todo_unpacked {
+			uint8_t num_items;	/* Number of items */
+			/* Data for each item */
+			struct ec_collect_item item[0];
+		} collect;
+	};
+};
+
+/*
+ * Get the next pending MKBP event.
+ *
+ * Returns EC_RES_UNAVAILABLE if there is no event pending.
+ */
+#define EC_CMD_GET_NEXT_EVENT 0x0067
+
+enum ec_mkbp_event {
+	/* Keyboard matrix changed. The event data is the new matrix state. */
+	EC_MKBP_EVENT_KEY_MATRIX = 0,
+
+	/* New host event. The event data is 4 bytes of host event flags. */
+	EC_MKBP_EVENT_HOST_EVENT = 1,
+
+	/* New Sensor FIFO data. The event data is fifo_info structure. */
+	EC_MKBP_EVENT_SENSOR_FIFO = 2,
+
+	/* The state of the non-matrixed buttons have changed. */
+	EC_MKBP_EVENT_BUTTON = 3,
+
+	/* The state of the switches have changed. */
+	EC_MKBP_EVENT_SWITCH = 4,
+
+	/* New Fingerprint sensor event, the event data is fp_events bitmap. */
+	EC_MKBP_EVENT_FINGERPRINT = 5,
+
+	/*
+	 * Sysrq event: send emulated sysrq. The event data is sysrq,
+	 * corresponding to the key to be pressed.
+	 */
+	EC_MKBP_EVENT_SYSRQ = 6,
+
+	/* Number of MKBP events */
+	EC_MKBP_EVENT_COUNT,
+};
+
+union __ec_align_offset1 ec_response_get_next_data {
+	uint8_t key_matrix[13];
+
+	/* Unaligned */
+	uint32_t host_event;
+
+	struct __ec_todo_unpacked {
+		/* For aligning the fifo_info */
+		uint8_t reserved[3];
+		struct ec_response_motion_sense_fifo_info info;
+	} sensor_fifo;
+
+	uint32_t buttons;
+
+	uint32_t switches;
+
+	uint32_t fp_events;
+
+	uint32_t sysrq;
+};
+
+struct __ec_align1 ec_response_get_next_event {
+	uint8_t event_type;
+	/* Followed by event data if any */
+	union ec_response_get_next_data data;
+};
+
+/* Bit indices for buttons and switches.*/
+/* Buttons */
+#define EC_MKBP_POWER_BUTTON	0
+#define EC_MKBP_VOL_UP		1
+#define EC_MKBP_VOL_DOWN	2
+#define EC_MKBP_RECOVERY	3
+
+/* Switches */
+#define EC_MKBP_LID_OPEN	0
+#define EC_MKBP_TABLET_MODE	1
+
+/* Run keyboard factory test scanning */
+#define EC_CMD_KEYBOARD_FACTORY_TEST 0x0068
+
+struct __ec_align2 ec_response_keyboard_factory_test {
+	uint16_t shorted;	/* Keyboard pins are shorted */
+};
+
+/* Fingerprint events in 'fp_events' for EC_MKBP_EVENT_FINGERPRINT */
+#define EC_MKBP_FP_RAW_EVENT(fp_events) ((fp_events) & 0x00FFFFFF)
+#define EC_MKBP_FP_FINGER_DOWN          (1 << 29)
+#define EC_MKBP_FP_FINGER_UP            (1 << 30)
+#define EC_MKBP_FP_IMAGE_READY          (1 << 31)
+
+/*****************************************************************************/
+/* Temperature sensor commands */
+
+/* Read temperature sensor info */
+#define EC_CMD_TEMP_SENSOR_GET_INFO 0x0070
+
+struct __ec_align1 ec_params_temp_sensor_get_info {
+	uint8_t id;
+};
+
+struct __ec_align1 ec_response_temp_sensor_get_info {
+	char sensor_name[32];
+	uint8_t sensor_type;
+};
+
+/*****************************************************************************/
+
+/*
+ * Note: host commands 0x80 - 0x87 are reserved to avoid conflict with ACPI
+ * commands accidentally sent to the wrong interface.  See the ACPI section
+ * below.
+ */
+
+/*****************************************************************************/
+/* Host event commands */
+
+
+/* Obsolete. New implementation should use EC_CMD_PROGRAM_HOST_EVENT instead */
+/*
+ * Host event mask params and response structures, shared by all of the host
+ * event commands below.
+ */
+struct __ec_align4 ec_params_host_event_mask {
+	uint32_t mask;
+};
+
+struct __ec_align4 ec_response_host_event_mask {
+	uint32_t mask;
+};
+
+/* These all use ec_response_host_event_mask */
+#define EC_CMD_HOST_EVENT_GET_B         0x0087
+#define EC_CMD_HOST_EVENT_GET_SMI_MASK  0x0088
+#define EC_CMD_HOST_EVENT_GET_SCI_MASK  0x0089
+#define EC_CMD_HOST_EVENT_GET_WAKE_MASK 0x008D
+
+/* These all use ec_params_host_event_mask */
+#define EC_CMD_HOST_EVENT_SET_SMI_MASK  0x008A
+#define EC_CMD_HOST_EVENT_SET_SCI_MASK  0x008B
+#define EC_CMD_HOST_EVENT_CLEAR         0x008C
+#define EC_CMD_HOST_EVENT_SET_WAKE_MASK 0x008E
+#define EC_CMD_HOST_EVENT_CLEAR_B       0x008F
+
+/*
+ * Unified host event programming interface - Should be used by newer versions
+ * of BIOS/OS to program host events and masks
+ */
+
+struct __ec_align4 ec_params_host_event {
+
+	/* Action requested by host - one of enum ec_host_event_action. */
+	uint8_t action;
+
+	/*
+	 * Mask type that the host requested the action on - one of
+	 * enum ec_host_event_mask_type.
+	 */
+	uint8_t mask_type;
+
+	/* Set to 0, ignore on read */
+	uint16_t reserved;
+
+	/* Value to be used in case of set operations. */
+	uint64_t value;
+};
+
+/*
+ * Response structure returned by EC_CMD_HOST_EVENT.
+ * Update the value on a GET request. Set to 0 on GET/CLEAR
+ */
+
+struct __ec_align4 ec_response_host_event {
+
+	/* Mask value in case of get operation */
+	uint64_t value;
+};
+
+enum ec_host_event_action {
+	/*
+	 * params.value is ignored. Value of mask_type populated
+	 * in response.value
+	 */
+	EC_HOST_EVENT_GET,
+
+	/* Bits in params.value are set */
+	EC_HOST_EVENT_SET,
+
+	/* Bits in params.value are cleared */
+	EC_HOST_EVENT_CLEAR,
+};
+
+enum ec_host_event_mask_type {
+
+	/* Main host event copy */
+	EC_HOST_EVENT_MAIN,
+
+	/* Copy B of host events */
+	EC_HOST_EVENT_B,
+
+	/* SCI Mask */
+	EC_HOST_EVENT_SCI_MASK,
+
+	/* SMI Mask */
+	EC_HOST_EVENT_SMI_MASK,
+
+	/* Mask of events that should be always reported in hostevents */
+	EC_HOST_EVENT_ALWAYS_REPORT_MASK,
+
+	/* Active wake mask */
+	EC_HOST_EVENT_ACTIVE_WAKE_MASK,
+
+	/* Lazy wake mask for S0ix */
+	EC_HOST_EVENT_LAZY_WAKE_MASK_S0IX,
+
+	/* Lazy wake mask for S3 */
+	EC_HOST_EVENT_LAZY_WAKE_MASK_S3,
+
+	/* Lazy wake mask for S5 */
+	EC_HOST_EVENT_LAZY_WAKE_MASK_S5,
+};
+
+#define EC_CMD_HOST_EVENT       0x00A4
+
+/*****************************************************************************/
+/* Switch commands */
+
+/* Enable/disable LCD backlight */
+#define EC_CMD_SWITCH_ENABLE_BKLIGHT 0x0090
+
+struct __ec_align1 ec_params_switch_enable_backlight {
+	uint8_t enabled;
+};
+
+/* Enable/disable WLAN/Bluetooth */
+#define EC_CMD_SWITCH_ENABLE_WIRELESS 0x0091
+#define EC_VER_SWITCH_ENABLE_WIRELESS 1
+
+/* Version 0 params; no response */
+struct __ec_align1 ec_params_switch_enable_wireless_v0 {
+	uint8_t enabled;
+};
+
+/* Version 1 params */
+struct __ec_align1 ec_params_switch_enable_wireless_v1 {
+	/* Flags to enable now */
+	uint8_t now_flags;
+
+	/* Which flags to copy from now_flags */
+	uint8_t now_mask;
+
+	/*
+	 * Flags to leave enabled in S3, if they're on@the S0->S3
+	 * transition.  (Other flags will be disabled by the S0->S3
+	 * transition.)
+	 */
+	uint8_t suspend_flags;
+
+	/* Which flags to copy from suspend_flags */
+	uint8_t suspend_mask;
+};
+
+/* Version 1 response */
+struct __ec_align1 ec_response_switch_enable_wireless_v1 {
+	/* Flags to enable now */
+	uint8_t now_flags;
+
+	/* Flags to leave enabled in S3 */
+	uint8_t suspend_flags;
+};
+
+/*****************************************************************************/
+/* GPIO commands. Only available on EC if write protect has been disabled. */
+
+/* Set GPIO output value */
+#define EC_CMD_GPIO_SET 0x0092
+
+struct __ec_align1 ec_params_gpio_set {
+	char name[32];
+	uint8_t val;
+};
+
+/* Get GPIO value */
+#define EC_CMD_GPIO_GET 0x0093
+
+/* Version 0 of input params and response */
+struct __ec_align1 ec_params_gpio_get {
+	char name[32];
+};
+
+struct __ec_align1 ec_response_gpio_get {
+	uint8_t val;
+};
+
+/* Version 1 of input params and response */
+struct __ec_align1 ec_params_gpio_get_v1 {
+	uint8_t subcmd;
+	union {
+		struct __ec_align1 {
+			char name[32];
+		} get_value_by_name;
+		struct __ec_align1 {
+			uint8_t index;
+		} get_info;
+	};
+};
+
+struct __ec_todo_packed ec_response_gpio_get_v1 {
+	union {
+		struct __ec_align1 {
+			uint8_t val;
+		} get_value_by_name, get_count;
+		struct __ec_todo_unpacked {
+			uint8_t val;
+			char name[32];
+			uint32_t flags;
+		} get_info;
+	};
+};
+
+enum gpio_get_subcmd {
+	EC_GPIO_GET_BY_NAME = 0,
+	EC_GPIO_GET_COUNT = 1,
+	EC_GPIO_GET_INFO = 2,
+};
+
+/*****************************************************************************/
+/* I2C commands. Only available when flash write protect is unlocked. */
+
+/*
+ * CAUTION: These commands are deprecated, and are not supported anymore in EC
+ * builds >= 8398.0.0 (see crosbug.com/p/23570).
+ *
+ * Use EC_CMD_I2C_PASSTHRU instead.
+ */
+
+/* Read I2C bus */
+#define EC_CMD_I2C_READ 0x0094
+
+struct __ec_align_size1 ec_params_i2c_read {
+	uint16_t addr; /* 8-bit address (7-bit shifted << 1) */
+	uint8_t read_size; /* Either 8 or 16. */
+	uint8_t port;
+	uint8_t offset;
+};
+
+struct __ec_align2 ec_response_i2c_read {
+	uint16_t data;
+};
+
+/* Write I2C bus */
+#define EC_CMD_I2C_WRITE 0x0095
+
+struct __ec_align_size1 ec_params_i2c_write {
+	uint16_t data;
+	uint16_t addr; /* 8-bit address (7-bit shifted << 1) */
+	uint8_t write_size; /* Either 8 or 16. */
+	uint8_t port;
+	uint8_t offset;
+};
+
+/*****************************************************************************/
+/* Charge state commands. Only available when flash write protect unlocked. */
+
+/* Force charge state machine to stop charging the battery or force it to
+ * discharge the battery.
+ */
+#define EC_CMD_CHARGE_CONTROL 0x0096
+#define EC_VER_CHARGE_CONTROL 1
+
+enum ec_charge_control_mode {
+	CHARGE_CONTROL_NORMAL = 0,
+	CHARGE_CONTROL_IDLE,
+	CHARGE_CONTROL_DISCHARGE,
+};
+
+struct __ec_align4 ec_params_charge_control {
+	uint32_t mode;  /* enum charge_control_mode */
+};
+
+/*****************************************************************************/
+/* Console commands. Only available when flash write protect is unlocked. */
+
+/* Snapshot console output buffer for use by EC_CMD_CONSOLE_READ. */
+#define EC_CMD_CONSOLE_SNAPSHOT 0x0097
+
+/*
+ * Read data from the saved snapshot. If the subcmd parameter is
+ * CONSOLE_READ_NEXT, this will return data starting from the beginning of
+ * the latest snapshot. If it is CONSOLE_READ_RECENT, it will start from the
+ * end of the previous snapshot.
+ *
+ * The params are only looked@in version >= 1 of this command. Prior
+ * versions will just default to CONSOLE_READ_NEXT behavior.
+ *
+ * Response is null-terminated string.  Empty string, if there is no more
+ * remaining output.
+ */
+#define EC_CMD_CONSOLE_READ 0x0098
+
+enum ec_console_read_subcmd {
+	CONSOLE_READ_NEXT = 0,
+	CONSOLE_READ_RECENT
+};
+
+struct __ec_align1 ec_params_console_read_v1 {
+	uint8_t subcmd; /* enum ec_console_read_subcmd */
+};
+
+/*****************************************************************************/
+
+/*
+ * Cut off battery power immediately or after the host has shut down.
+ *
+ * return EC_RES_INVALID_COMMAND if unsupported by a board/battery.
+ *	  EC_RES_SUCCESS if the command was successful.
+ *	  EC_RES_ERROR if the cut off command failed.
+ */
+#define EC_CMD_BATTERY_CUT_OFF 0x0099
+
+#define EC_BATTERY_CUTOFF_FLAG_AT_SHUTDOWN	(1 << 0)
+
+struct __ec_align1 ec_params_battery_cutoff {
+	uint8_t flags;
+};
+
+/*****************************************************************************/
+/* USB port mux control. */
+
+/*
+ * Switch USB mux or return to automatic switching.
+ */
+#define EC_CMD_USB_MUX 0x009A
+
+struct __ec_align1 ec_params_usb_mux {
+	uint8_t mux;
+};
+
+/*****************************************************************************/
+/* LDOs / FETs control. */
+
+enum ec_ldo_state {
+	EC_LDO_STATE_OFF = 0,	/* the LDO / FET is shut down */
+	EC_LDO_STATE_ON = 1,	/* the LDO / FET is ON / providing power */
+};
+
+/*
+ * Switch on/off a LDO.
+ */
+#define EC_CMD_LDO_SET 0x009B
+
+struct __ec_align1 ec_params_ldo_set {
+	uint8_t index;
+	uint8_t state;
+};
+
+/*
+ * Get LDO state.
+ */
+#define EC_CMD_LDO_GET 0x009C
+
+struct __ec_align1 ec_params_ldo_get {
+	uint8_t index;
+};
+
+struct __ec_align1 ec_response_ldo_get {
+	uint8_t state;
+};
+
+/*****************************************************************************/
+/* Power info. */
+
+/*
+ * Get power info.
+ */
+#define EC_CMD_POWER_INFO 0x009D
+
+struct __ec_align4 ec_response_power_info {
+	uint32_t usb_dev_type;
+	uint16_t voltage_ac;
+	uint16_t voltage_system;
+	uint16_t current_system;
+	uint16_t usb_current_limit;
+};
+
+/*****************************************************************************/
+/* I2C passthru command */
+
+#define EC_CMD_I2C_PASSTHRU 0x009E
+
+/* Read data; if not present, message is a write */
+#define EC_I2C_FLAG_READ	(1 << 15)
+
+/* Mask for address */
+#define EC_I2C_ADDR_MASK	0x3ff
+
+#define EC_I2C_STATUS_NAK	(1 << 0) /* Transfer was not acknowledged */
+#define EC_I2C_STATUS_TIMEOUT	(1 << 1) /* Timeout during transfer */
+
+/* Any error */
+#define EC_I2C_STATUS_ERROR	(EC_I2C_STATUS_NAK | EC_I2C_STATUS_TIMEOUT)
+
+struct __ec_align2 ec_params_i2c_passthru_msg {
+	uint16_t addr_flags;	/* I2C slave address (7 or 10 bits) and flags */
+	uint16_t len;		/* Number of bytes to read or write */
+};
+
+struct __ec_align2 ec_params_i2c_passthru {
+	uint8_t port;		/* I2C port number */
+	uint8_t num_msgs;	/* Number of messages */
+	struct ec_params_i2c_passthru_msg msg[];
+	/* Data to write for all messages is concatenated here */
+};
+
+struct __ec_align1 ec_response_i2c_passthru {
+	uint8_t i2c_status;	/* Status flags (EC_I2C_STATUS_...) */
+	uint8_t num_msgs;	/* Number of messages processed */
+	uint8_t data[];		/* Data read by messages concatenated here */
+};
+
+/*****************************************************************************/
+/* Power button hang detect */
+
+#define EC_CMD_HANG_DETECT 0x009F
+
+/* Reasons to start hang detection timer */
+/* Power button pressed */
+#define EC_HANG_START_ON_POWER_PRESS  (1 << 0)
+
+/* Lid closed */
+#define EC_HANG_START_ON_LID_CLOSE    (1 << 1)
+
+ /* Lid opened */
+#define EC_HANG_START_ON_LID_OPEN     (1 << 2)
+
+/* Start of AP S3->S0 transition (booting or resuming from suspend) */
+#define EC_HANG_START_ON_RESUME       (1 << 3)
+
+/* Reasons to cancel hang detection */
+
+/* Power button released */
+#define EC_HANG_STOP_ON_POWER_RELEASE (1 << 8)
+
+/* Any host command from AP received */
+#define EC_HANG_STOP_ON_HOST_COMMAND  (1 << 9)
+
+/* Stop on end of AP S0->S3 transition (suspending or shutting down) */
+#define EC_HANG_STOP_ON_SUSPEND       (1 << 10)
+
+/*
+ * If this flag is set, all the other fields are ignored, and the hang detect
+ * timer is started.  This provides the AP a way to start the hang timer
+ * without reconfiguring any of the other hang detect settings.  Note that
+ * you must previously have configured the timeouts.
+ */
+#define EC_HANG_START_NOW             (1 << 30)
+
+/*
+ * If this flag is set, all the other fields are ignored (including
+ * EC_HANG_START_NOW).  This provides the AP a way to stop the hang timer
+ * without reconfiguring any of the other hang detect settings.
+ */
+#define EC_HANG_STOP_NOW              (1 << 31)
+
+struct __ec_align4 ec_params_hang_detect {
+	/* Flags; see EC_HANG_* */
+	uint32_t flags;
+
+	/* Timeout in msec before generating host event, if enabled */
+	uint16_t host_event_timeout_msec;
+
+	/* Timeout in msec before generating warm reboot, if enabled */
+	uint16_t warm_reboot_timeout_msec;
+};
+
+/*****************************************************************************/
+/* Commands for battery charging */
+
+/*
+ * This is the single catch-all host command to exchange data regarding the
+ * charge state machine (v2 and up).
+ */
+#define EC_CMD_CHARGE_STATE 0x00A0
+
+/* Subcommands for this host command */
+enum charge_state_command {
+	CHARGE_STATE_CMD_GET_STATE,
+	CHARGE_STATE_CMD_GET_PARAM,
+	CHARGE_STATE_CMD_SET_PARAM,
+	CHARGE_STATE_NUM_CMDS
+};
+
+/*
+ * Known param numbers are defined here. Ranges are reserved for board-specific
+ * params, which are handled by the particular implementations.
+ */
+enum charge_state_params {
+	CS_PARAM_CHG_VOLTAGE,	      /* charger voltage limit */
+	CS_PARAM_CHG_CURRENT,	      /* charger current limit */
+	CS_PARAM_CHG_INPUT_CURRENT,   /* charger input current limit */
+	CS_PARAM_CHG_STATUS,	      /* charger-specific status */
+	CS_PARAM_CHG_OPTION,	      /* charger-specific options */
+	CS_PARAM_LIMIT_POWER,	      /*
+				       * Check if power is limited due to
+				       * low battery and / or a weak external
+				       * charger. READ ONLY.
+				       */
+	/* How many so far? */
+	CS_NUM_BASE_PARAMS,
+
+	/* Range for CONFIG_CHARGER_PROFILE_OVERRIDE params */
+	CS_PARAM_CUSTOM_PROFILE_MIN = 0x10000,
+	CS_PARAM_CUSTOM_PROFILE_MAX = 0x1ffff,
+
+	/* Other custom param ranges go here... */
+};
+
+struct __ec_todo_packed ec_params_charge_state {
+	uint8_t cmd;				/* enum charge_state_command */
+	union {
+		struct __ec_align1 {
+			/* no args */
+		} get_state;
+
+		struct __ec_todo_unpacked {
+			uint32_t param;		/* enum charge_state_param */
+		} get_param;
+
+		struct __ec_todo_unpacked {
+			uint32_t param;		/* param to set */
+			uint32_t value;		/* value to set */
+		} set_param;
+	};
+};
+
+struct __ec_align4 ec_response_charge_state {
+	union {
+		struct __ec_align4 {
+			int ac;
+			int chg_voltage;
+			int chg_current;
+			int chg_input_current;
+			int batt_state_of_charge;
+		} get_state;
+
+		struct __ec_align4 {
+			uint32_t value;
+		} get_param;
+		struct __ec_align4 {
+			/* no return values */
+		} set_param;
+	};
+};
+
+
+/*
+ * Set maximum battery charging current.
+ */
+#define EC_CMD_CHARGE_CURRENT_LIMIT 0x00A1
+
+struct __ec_align4 ec_params_current_limit {
+	uint32_t limit; /* in mA */
+};
+
+/*
+ * Set maximum external voltage / current.
+ */
+#define EC_CMD_EXTERNAL_POWER_LIMIT 0x00A2
+
+/* Command v0 is used only on Spring and is obsolete + unsupported */
+struct __ec_align2 ec_params_external_power_limit_v1 {
+	uint16_t current_lim; /* in mA, or EC_POWER_LIMIT_NONE to clear limit */
+	uint16_t voltage_lim; /* in mV, or EC_POWER_LIMIT_NONE to clear limit */
+};
+
+#define EC_POWER_LIMIT_NONE 0xffff
+
+/*
+ * Set maximum voltage & current of a dedicated charge port
+ */
+#define EC_CMD_OVERRIDE_DEDICATED_CHARGER_LIMIT 0x00A3
+
+struct __ec_align2 ec_params_dedicated_charger_limit {
+	uint16_t current_lim; /* in mA */
+	uint16_t voltage_lim; /* in mV */
+};
+
+/*****************************************************************************/
+/* Hibernate/Deep Sleep Commands */
+
+/* Set the delay before going into hibernation. */
+#define EC_CMD_HIBERNATION_DELAY 0x00A8
+
+struct __ec_align4 ec_params_hibernation_delay {
+	/*
+	 * Seconds to wait in G3 before hibernate.  Pass in 0 to read the
+	 * current settings without changing them.
+	 */
+	uint32_t seconds;
+};
+
+struct __ec_align4 ec_response_hibernation_delay {
+	/*
+	 * The current time in seconds in which the system has been in the G3
+	 * state.  This value is reset if the EC transitions out of G3.
+	 */
+	uint32_t time_g3;
+
+	/*
+	 * The current time remaining in seconds until the EC should hibernate.
+	 * This value is also reset if the EC transitions out of G3.
+	 */
+	uint32_t time_remaining;
+
+	/*
+	 * The current time in seconds that the EC should wait in G3 before
+	 * hibernating.
+	 */
+	uint32_t hibernate_delay;
+};
+
+/* Inform the EC when entering a sleep state */
+#define EC_CMD_HOST_SLEEP_EVENT 0x00A9
+
+enum host_sleep_event {
+	HOST_SLEEP_EVENT_S3_SUSPEND   = 1,
+	HOST_SLEEP_EVENT_S3_RESUME    = 2,
+	HOST_SLEEP_EVENT_S0IX_SUSPEND = 3,
+	HOST_SLEEP_EVENT_S0IX_RESUME  = 4
+};
+
+struct __ec_align1 ec_params_host_sleep_event {
+	uint8_t sleep_event;
+};
+
+/*****************************************************************************/
+/* Device events */
+#define EC_CMD_DEVICE_EVENT 0x00AA
+
+enum ec_device_event {
+	EC_DEVICE_EVENT_TRACKPAD,
+	EC_DEVICE_EVENT_DSP,
+	EC_DEVICE_EVENT_WIFI,
+};
+
+enum ec_device_event_param {
+	/* Get and clear pending device events */
+	EC_DEVICE_EVENT_PARAM_GET_CURRENT_EVENTS,
+	/* Get device event mask */
+	EC_DEVICE_EVENT_PARAM_GET_ENABLED_EVENTS,
+	/* Set device event mask */
+	EC_DEVICE_EVENT_PARAM_SET_ENABLED_EVENTS,
+};
+
+#define EC_DEVICE_EVENT_MASK(event_code) (1UL << (event_code % 32))
 
-/* Provide information about the matrix : number of rows and columns */
-#define EC_CMD_MKBP_INFO 0x61
+struct __ec_align_size1 ec_params_device_event {
+	uint32_t event_mask;
+	uint8_t param;
+};
 
-struct ec_response_mkbp_info {
-	uint32_t rows;
-	uint32_t cols;
-	uint8_t switches;
-} __packed;
+struct __ec_align4 ec_response_device_event {
+	uint32_t event_mask;
+};
 
-/* Simulate key press */
-#define EC_CMD_MKBP_SIMULATE_KEY 0x62
+/*****************************************************************************/
+/* Smart battery pass-through */
 
-struct ec_params_mkbp_simulate_key {
-	uint8_t col;
-	uint8_t row;
-	uint8_t pressed;
-} __packed;
+/* Get / Set 16-bit smart battery registers */
+#define EC_CMD_SB_READ_WORD   0x00B0
+#define EC_CMD_SB_WRITE_WORD  0x00B1
 
-/* Configure keyboard scanning */
-#define EC_CMD_MKBP_SET_CONFIG 0x64
-#define EC_CMD_MKBP_GET_CONFIG 0x65
+/* Get / Set string smart battery parameters
+ * formatted as SMBUS "block".
+ */
+#define EC_CMD_SB_READ_BLOCK  0x00B2
+#define EC_CMD_SB_WRITE_BLOCK 0x00B3
 
-/* flags */
-enum mkbp_config_flags {
-	EC_MKBP_FLAGS_ENABLE = 1,	/* Enable keyboard scanning */
+struct __ec_align1 ec_params_sb_rd {
+	uint8_t reg;
 };
 
-enum mkbp_config_valid {
-	EC_MKBP_VALID_SCAN_PERIOD		= 1 << 0,
-	EC_MKBP_VALID_POLL_TIMEOUT		= 1 << 1,
-	EC_MKBP_VALID_MIN_POST_SCAN_DELAY	= 1 << 3,
-	EC_MKBP_VALID_OUTPUT_SETTLE		= 1 << 4,
-	EC_MKBP_VALID_DEBOUNCE_DOWN		= 1 << 5,
-	EC_MKBP_VALID_DEBOUNCE_UP		= 1 << 6,
-	EC_MKBP_VALID_FIFO_MAX_DEPTH		= 1 << 7,
+struct __ec_align2 ec_response_sb_rd_word {
+	uint16_t value;
 };
 
-/* Configuration for our key scanning algorithm */
-struct ec_mkbp_config {
-	uint32_t valid_mask;		/* valid fields */
-	uint8_t flags;		/* some flags (enum mkbp_config_flags) */
-	uint8_t valid_flags;		/* which flags are valid */
-	uint16_t scan_period_us;	/* period between start of scans */
-	/* revert to interrupt mode after no activity for this long */
-	uint32_t poll_timeout_us;
-	/*
-	 * minimum post-scan relax time. Once we finish a scan we check
-	 * the time until we are due to start the next one. If this time is
-	 * shorter this field, we use this instead.
-	 */
-	uint16_t min_post_scan_delay_us;
-	/* delay between setting up output and waiting for it to settle */
-	uint16_t output_settle_us;
-	uint16_t debounce_down_us;	/* time for debounce on key down */
-	uint16_t debounce_up_us;	/* time for debounce on key up */
-	/* maximum depth to allow for fifo (0 = no keyscan output) */
-	uint8_t fifo_max_depth;
-} __packed;
+struct __ec_align1 ec_params_sb_wr_word {
+	uint8_t reg;
+	uint16_t value;
+};
 
-struct ec_params_mkbp_set_config {
-	struct ec_mkbp_config config;
-} __packed;
+struct __ec_align1 ec_response_sb_rd_block {
+	uint8_t data[32];
+};
 
-struct ec_response_mkbp_get_config {
-	struct ec_mkbp_config config;
-} __packed;
+struct __ec_align1 ec_params_sb_wr_block {
+	uint8_t reg;
+	uint16_t data[32];
+};
 
-/* Run the key scan emulation */
-#define EC_CMD_KEYSCAN_SEQ_CTRL 0x66
+/*****************************************************************************/
+/* Battery vendor parameters
+ *
+ * Get or set vendor-specific parameters in the battery. Implementations may
+ * differ between boards or batteries. On a set operation, the response
+ * contains the actual value set, which may be rounded or clipped from the
+ * requested value.
+ */
 
-enum ec_keyscan_seq_cmd {
-	EC_KEYSCAN_SEQ_STATUS = 0,	/* Get status information */
-	EC_KEYSCAN_SEQ_CLEAR = 1,	/* Clear sequence */
-	EC_KEYSCAN_SEQ_ADD = 2,		/* Add item to sequence */
-	EC_KEYSCAN_SEQ_START = 3,	/* Start running sequence */
-	EC_KEYSCAN_SEQ_COLLECT = 4,	/* Collect sequence summary data */
+#define EC_CMD_BATTERY_VENDOR_PARAM 0x00B4
+
+enum ec_battery_vendor_param_mode {
+	BATTERY_VENDOR_PARAM_MODE_GET = 0,
+	BATTERY_VENDOR_PARAM_MODE_SET,
 };
 
-enum ec_collect_flags {
-	/*
-	 * Indicates this scan was processed by the EC. Due to timing, some
-	 * scans may be skipped.
-	 */
-	EC_KEYSCAN_SEQ_FLAG_DONE	= 1 << 0,
+struct __ec_align_size1 ec_params_battery_vendor_param {
+	uint32_t param;
+	uint32_t value;
+	uint8_t mode;
 };
 
-struct ec_collect_item {
-	uint8_t flags;		/* some flags (enum ec_collect_flags) */
+struct __ec_align4 ec_response_battery_vendor_param {
+	uint32_t value;
 };
 
-struct ec_params_keyscan_seq_ctrl {
-	uint8_t cmd;	/* Command to send (enum ec_keyscan_seq_cmd) */
+/*****************************************************************************/
+/*
+ * Smart Battery Firmware Update Commands
+ */
+#define EC_CMD_SB_FW_UPDATE 0x00B5
+
+enum ec_sb_fw_update_subcmd {
+	EC_SB_FW_UPDATE_PREPARE  = 0x0,
+	EC_SB_FW_UPDATE_INFO     = 0x1, /*query sb info */
+	EC_SB_FW_UPDATE_BEGIN    = 0x2, /*check if protected */
+	EC_SB_FW_UPDATE_WRITE    = 0x3, /*check if protected */
+	EC_SB_FW_UPDATE_END      = 0x4,
+	EC_SB_FW_UPDATE_STATUS   = 0x5,
+	EC_SB_FW_UPDATE_PROTECT  = 0x6,
+	EC_SB_FW_UPDATE_MAX      = 0x7,
+};
+
+#define SB_FW_UPDATE_CMD_WRITE_BLOCK_SIZE 32
+#define SB_FW_UPDATE_CMD_STATUS_SIZE 2
+#define SB_FW_UPDATE_CMD_INFO_SIZE 8
+
+struct __ec_align4 ec_sb_fw_update_header {
+	uint16_t subcmd;  /* enum ec_sb_fw_update_subcmd */
+	uint16_t fw_id;   /* firmware id */
+};
+
+struct __ec_align4 ec_params_sb_fw_update {
+	struct ec_sb_fw_update_header hdr;
 	union {
-		struct {
-			uint8_t active;		/* still active */
-			uint8_t num_items;	/* number of items */
-			/* Current item being presented */
-			uint8_t cur_item;
-		} status;
-		struct {
-			/*
-			 * Absolute time for this scan, measured from the
-			 * start of the sequence.
-			 */
-			uint32_t time_us;
-			uint8_t scan[0];	/* keyscan data */
-		} add;
-		struct {
-			uint8_t start_item;	/* First item to return */
-			uint8_t num_items;	/* Number of items to return */
-		} collect;
+		/* EC_SB_FW_UPDATE_PREPARE  = 0x0 */
+		/* EC_SB_FW_UPDATE_INFO     = 0x1 */
+		/* EC_SB_FW_UPDATE_BEGIN    = 0x2 */
+		/* EC_SB_FW_UPDATE_END      = 0x4 */
+		/* EC_SB_FW_UPDATE_STATUS   = 0x5 */
+		/* EC_SB_FW_UPDATE_PROTECT  = 0x6 */
+		struct __ec_align4 {
+			/* no args */
+		} dummy;
+
+		/* EC_SB_FW_UPDATE_WRITE    = 0x3 */
+		struct __ec_align4 {
+			uint8_t  data[SB_FW_UPDATE_CMD_WRITE_BLOCK_SIZE];
+		} write;
 	};
-} __packed;
+};
 
-struct ec_result_keyscan_seq_ctrl {
+struct __ec_align1 ec_response_sb_fw_update {
 	union {
-		struct {
-			uint8_t num_items;	/* Number of items */
-			/* Data for each item */
-			struct ec_collect_item item[0];
-		} collect;
+		/* EC_SB_FW_UPDATE_INFO     = 0x1 */
+		struct __ec_align1 {
+			uint8_t data[SB_FW_UPDATE_CMD_INFO_SIZE];
+		} info;
+
+		/* EC_SB_FW_UPDATE_STATUS   = 0x5 */
+		struct __ec_align1 {
+			uint8_t data[SB_FW_UPDATE_CMD_STATUS_SIZE];
+		} status;
 	};
-} __packed;
+};
+
+/*
+ * Entering Verified Boot Mode Command
+ * Default mode is VBOOT_MODE_NORMAL if EC did not receive this command.
+ * Valid Modes are: normal, developer, and recovery.
+ */
+#define EC_CMD_ENTERING_MODE 0x00B6
+
+struct __ec_align4 ec_params_entering_mode {
+	int vboot_mode;
+};
+
+#define VBOOT_MODE_NORMAL    0
+#define VBOOT_MODE_DEVELOPER 1
+#define VBOOT_MODE_RECOVERY  2
 
 /*****************************************************************************/
-/* Temperature sensor commands */
+/*
+ * I2C passthru protection command: Protects I2C tunnels against access on
+ * certain addresses (board-specific).
+ */
+#define EC_CMD_I2C_PASSTHRU_PROTECT 0x00B7
 
-/* Read temperature sensor info */
-#define EC_CMD_TEMP_SENSOR_GET_INFO 0x70
+enum ec_i2c_passthru_protect_subcmd {
+	EC_CMD_I2C_PASSTHRU_PROTECT_STATUS = 0x0,
+	EC_CMD_I2C_PASSTHRU_PROTECT_ENABLE = 0x1,
+};
 
-struct ec_params_temp_sensor_get_info {
-	uint8_t id;
-} __packed;
+struct __ec_align1 ec_params_i2c_passthru_protect {
+	uint8_t subcmd;
+	uint8_t port;		/* I2C port number */
+};
 
-struct ec_response_temp_sensor_get_info {
-	char sensor_name[32];
-	uint8_t sensor_type;
-} __packed;
+struct __ec_align1 ec_response_i2c_passthru_protect {
+	uint8_t status;		/* Status flags (0: unlocked, 1: locked) */
+};
 
 /*****************************************************************************/
+/* System commands */
 
 /*
- * Note: host commands 0x80 - 0x87 are reserved to avoid conflict with ACPI
- * commands accidentally sent to the wrong interface.  See the ACPI section
- * below.
+ * TODO(crosbug.com/p/23747): This is a confusing name, since it doesn't
+ * necessarily reboot the EC.  Rename to "image" or something similar?
  */
+#define EC_CMD_REBOOT_EC 0x00D2
 
-/*****************************************************************************/
-/* Host event commands */
+/* Command */
+enum ec_reboot_cmd {
+	EC_REBOOT_CANCEL = 0,        /* Cancel a pending reboot */
+	EC_REBOOT_JUMP_RO = 1,       /* Jump to RO without rebooting */
+	EC_REBOOT_JUMP_RW = 2,       /* Jump to RW without rebooting */
+	/* (command 3 was jump to RW-B) */
+	EC_REBOOT_COLD = 4,          /* Cold-reboot */
+	EC_REBOOT_DISABLE_JUMP = 5,  /* Disable jump until next reboot */
+	EC_REBOOT_HIBERNATE = 6,     /* Hibernate EC */
+	EC_REBOOT_HIBERNATE_CLEAR_AP_OFF = 7, /* and clears AP_OFF flag */
+};
+
+/* Flags for ec_params_reboot_ec.reboot_flags */
+#define EC_REBOOT_FLAG_RESERVED0      (1 << 0)  /* Was recovery request */
+#define EC_REBOOT_FLAG_ON_AP_SHUTDOWN (1 << 1)  /* Reboot after AP shutdown */
+#define EC_REBOOT_FLAG_SWITCH_RW_SLOT (1 << 2)  /* Switch RW slot */
+
+struct __ec_align1 ec_params_reboot_ec {
+	uint8_t cmd;           /* enum ec_reboot_cmd */
+	uint8_t flags;         /* See EC_REBOOT_FLAG_* */
+};
 
 /*
- * Host event mask params and response structures, shared by all of the host
- * event commands below.
+ * Get information on last EC panic.
+ *
+ * Returns variable-length platform-dependent panic information.  See panic.h
+ * for details.
  */
-struct ec_params_host_event_mask {
-	uint32_t mask;
-} __packed;
+#define EC_CMD_GET_PANIC_INFO 0x00D3
 
-struct ec_response_host_event_mask {
-	uint32_t mask;
-} __packed;
+/*****************************************************************************/
+/*
+ * Special commands
+ *
+ * These do not follow the normal rules for commands.  See each command for
+ * details.
+ */
 
-/* These all use ec_response_host_event_mask */
-#define EC_CMD_HOST_EVENT_GET_B         0x87
-#define EC_CMD_HOST_EVENT_GET_SMI_MASK  0x88
-#define EC_CMD_HOST_EVENT_GET_SCI_MASK  0x89
-#define EC_CMD_HOST_EVENT_GET_WAKE_MASK 0x8d
+/*
+ * Reboot NOW
+ *
+ * This command will work even when the EC LPC interface is busy, because the
+ * reboot command is processed at interrupt level.  Note that when the EC
+ * reboots, the host will reboot too, so there is no response to this command.
+ *
+ * Use EC_CMD_REBOOT_EC to reboot the EC more politely.
+ */
+#define EC_CMD_REBOOT 0x00D1  /* Think "die" */
 
-/* These all use ec_params_host_event_mask */
-#define EC_CMD_HOST_EVENT_SET_SMI_MASK  0x8a
-#define EC_CMD_HOST_EVENT_SET_SCI_MASK  0x8b
-#define EC_CMD_HOST_EVENT_CLEAR         0x8c
-#define EC_CMD_HOST_EVENT_SET_WAKE_MASK 0x8e
-#define EC_CMD_HOST_EVENT_CLEAR_B       0x8f
+/*
+ * Resend last response (not supported on LPC).
+ *
+ * Returns EC_RES_UNAVAILABLE if there is no response available - for example,
+ * there was no previous command, or the previous command's response was too
+ * big to save.
+ */
+#define EC_CMD_RESEND_RESPONSE 0x00DB
+
+/*
+ * This header byte on a command indicate version 0. Any header byte less
+ * than this means that we are talking to an old EC which doesn't support
+ * versioning. In that case, we assume version 0.
+ *
+ * Header bytes greater than this indicate a later version. For example,
+ * EC_CMD_VERSION0 + 1 means we are using version 1.
+ *
+ * The old EC interface must not use commands 0xdc or higher.
+ */
+#define EC_CMD_VERSION0 0x00DC
 
 /*****************************************************************************/
-/* Switch commands */
+/*
+ * PD commands
+ *
+ * These commands are for PD MCU communication.
+ */
 
-/* Enable/disable LCD backlight */
-#define EC_CMD_SWITCH_ENABLE_BKLIGHT 0x90
+/* EC to PD MCU exchange status command */
+#define EC_CMD_PD_EXCHANGE_STATUS 0x0100
+#define EC_VER_PD_EXCHANGE_STATUS 2
 
-struct ec_params_switch_enable_backlight {
-	uint8_t enabled;
-} __packed;
+enum pd_charge_state {
+	PD_CHARGE_NO_CHANGE = 0, /* Don't change charge state */
+	PD_CHARGE_NONE,          /* No charging allowed */
+	PD_CHARGE_5V,            /* 5V charging only */
+	PD_CHARGE_MAX            /* Charge@max voltage */
+};
 
-/* Enable/disable WLAN/Bluetooth */
-#define EC_CMD_SWITCH_ENABLE_WIRELESS 0x91
+/* Status of EC being sent to PD */
+#define EC_STATUS_HIBERNATING	(1 << 0)
+
+struct __ec_align1 ec_params_pd_status {
+	uint8_t status;       /* EC status */
+	int8_t batt_soc;      /* battery state of charge */
+	uint8_t charge_state; /* charging state (from enum pd_charge_state) */
+};
+
+/* Status of PD being sent back to EC */
+#define PD_STATUS_HOST_EVENT      (1 << 0) /* Forward host event to AP */
+#define PD_STATUS_IN_RW           (1 << 1) /* Running RW image */
+#define PD_STATUS_JUMPED_TO_IMAGE (1 << 2) /* Current image was jumped to */
+#define PD_STATUS_TCPC_ALERT_0    (1 << 3) /* Alert active in port 0 TCPC */
+#define PD_STATUS_TCPC_ALERT_1    (1 << 4) /* Alert active in port 1 TCPC */
+#define PD_STATUS_TCPC_ALERT_2    (1 << 5) /* Alert active in port 2 TCPC */
+#define PD_STATUS_TCPC_ALERT_3    (1 << 6) /* Alert active in port 3 TCPC */
+#define PD_STATUS_EC_INT_ACTIVE  (PD_STATUS_TCPC_ALERT_0 | \
+				      PD_STATUS_TCPC_ALERT_1 | \
+				      PD_STATUS_HOST_EVENT)
+struct __ec_align_size1 ec_response_pd_status {
+	uint32_t curr_lim_ma;       /* input current limit */
+	uint16_t status;            /* PD MCU status */
+	int8_t active_charge_port;  /* active charging port */
+};
+
+/* AP to PD MCU host event status command, cleared on read */
+#define EC_CMD_PD_HOST_EVENT_STATUS 0x0104
+
+/* PD MCU host event status bits */
+#define PD_EVENT_UPDATE_DEVICE     (1 << 0)
+#define PD_EVENT_POWER_CHANGE      (1 << 1)
+#define PD_EVENT_IDENTITY_RECEIVED (1 << 2)
+#define PD_EVENT_DATA_SWAP         (1 << 3)
+struct __ec_align4 ec_response_host_event_status {
+	uint32_t status;      /* PD MCU host event status */
+};
+
+/* Set USB type-C port role and muxes */
+#define EC_CMD_USB_PD_CONTROL 0x0101
+
+enum usb_pd_control_role {
+	USB_PD_CTRL_ROLE_NO_CHANGE = 0,
+	USB_PD_CTRL_ROLE_TOGGLE_ON = 1, /* == AUTO */
+	USB_PD_CTRL_ROLE_TOGGLE_OFF = 2,
+	USB_PD_CTRL_ROLE_FORCE_SINK = 3,
+	USB_PD_CTRL_ROLE_FORCE_SOURCE = 4,
+	USB_PD_CTRL_ROLE_COUNT
+};
+
+enum usb_pd_control_mux {
+	USB_PD_CTRL_MUX_NO_CHANGE = 0,
+	USB_PD_CTRL_MUX_NONE = 1,
+	USB_PD_CTRL_MUX_USB = 2,
+	USB_PD_CTRL_MUX_DP = 3,
+	USB_PD_CTRL_MUX_DOCK = 4,
+	USB_PD_CTRL_MUX_AUTO = 5,
+	USB_PD_CTRL_MUX_COUNT
+};
+
+enum usb_pd_control_swap {
+	USB_PD_CTRL_SWAP_NONE = 0,
+	USB_PD_CTRL_SWAP_DATA = 1,
+	USB_PD_CTRL_SWAP_POWER = 2,
+	USB_PD_CTRL_SWAP_VCONN = 3,
+	USB_PD_CTRL_SWAP_COUNT
+};
+
+struct __ec_align1 ec_params_usb_pd_control {
+	uint8_t port;
+	uint8_t role;
+	uint8_t mux;
+	uint8_t swap;
+};
 
-struct ec_params_switch_enable_wireless {
+#define PD_CTRL_RESP_ENABLED_COMMS      (1 << 0) /* Communication enabled */
+#define PD_CTRL_RESP_ENABLED_CONNECTED  (1 << 1) /* Device connected */
+#define PD_CTRL_RESP_ENABLED_PD_CAPABLE (1 << 2) /* Partner is PD capable */
+
+#define PD_CTRL_RESP_ROLE_POWER         (1 << 0) /* 0=SNK/1=SRC */
+#define PD_CTRL_RESP_ROLE_DATA          (1 << 1) /* 0=UFP/1=DFP */
+#define PD_CTRL_RESP_ROLE_VCONN         (1 << 2) /* Vconn status */
+#define PD_CTRL_RESP_ROLE_DR_POWER      (1 << 3) /* Partner is dualrole power */
+#define PD_CTRL_RESP_ROLE_DR_DATA       (1 << 4) /* Partner is dualrole data */
+#define PD_CTRL_RESP_ROLE_USB_COMM      (1 << 5) /* Partner USB comm capable */
+#define PD_CTRL_RESP_ROLE_EXT_POWERED   (1 << 6) /* Partner externally powerd */
+
+struct __ec_align1 ec_response_usb_pd_control {
 	uint8_t enabled;
-} __packed;
+	uint8_t role;
+	uint8_t polarity;
+	uint8_t state;
+};
 
-/*****************************************************************************/
-/* GPIO commands. Only available on EC if write protect has been disabled. */
+struct __ec_align1 ec_response_usb_pd_control_v1 {
+	uint8_t enabled;
+	uint8_t role;
+	uint8_t polarity;
+	char state[32];
+};
 
-/* Set GPIO output value */
-#define EC_CMD_GPIO_SET 0x92
+#define EC_CMD_USB_PD_PORTS 0x0102
 
-struct ec_params_gpio_set {
-	char name[32];
-	uint8_t val;
-} __packed;
+/* Maximum number of PD ports on a device, num_ports will be <= this */
+#define EC_USB_PD_MAX_PORTS 8
 
-/* Get GPIO value */
-#define EC_CMD_GPIO_GET 0x93
+struct __ec_align1 ec_response_usb_pd_ports {
+	uint8_t num_ports;
+};
 
-struct ec_params_gpio_get {
-	char name[32];
-} __packed;
-struct ec_response_gpio_get {
-	uint8_t val;
-} __packed;
+#define EC_CMD_USB_PD_POWER_INFO 0x0103
+
+#define PD_POWER_CHARGING_PORT 0xff
+struct __ec_align1 ec_params_usb_pd_power_info {
+	uint8_t port;
+};
+
+enum usb_chg_type {
+	USB_CHG_TYPE_NONE,
+	USB_CHG_TYPE_PD,
+	USB_CHG_TYPE_C,
+	USB_CHG_TYPE_PROPRIETARY,
+	USB_CHG_TYPE_BC12_DCP,
+	USB_CHG_TYPE_BC12_CDP,
+	USB_CHG_TYPE_BC12_SDP,
+	USB_CHG_TYPE_OTHER,
+	USB_CHG_TYPE_VBUS,
+	USB_CHG_TYPE_UNKNOWN,
+};
+enum usb_power_roles {
+	USB_PD_PORT_POWER_DISCONNECTED,
+	USB_PD_PORT_POWER_SOURCE,
+	USB_PD_PORT_POWER_SINK,
+	USB_PD_PORT_POWER_SINK_NOT_CHARGING,
+};
+
+struct __ec_align2 usb_chg_measures {
+	uint16_t voltage_max;
+	uint16_t voltage_now;
+	uint16_t current_max;
+	uint16_t current_lim;
+};
+
+struct __ec_align4 ec_response_usb_pd_power_info {
+	uint8_t role;
+	uint8_t type;
+	uint8_t dualrole;
+	uint8_t reserved1;
+	struct usb_chg_measures meas;
+	uint32_t max_power;
+};
+
+/* Write USB-PD device FW */
+#define EC_CMD_USB_PD_FW_UPDATE 0x0110
+
+enum usb_pd_fw_update_cmds {
+	USB_PD_FW_REBOOT,
+	USB_PD_FW_FLASH_ERASE,
+	USB_PD_FW_FLASH_WRITE,
+	USB_PD_FW_ERASE_SIG,
+};
+
+struct __ec_align4 ec_params_usb_pd_fw_update {
+	uint16_t dev_id;
+	uint8_t cmd;
+	uint8_t port;
+	uint32_t size;     /* Size to write in bytes */
+	/* Followed by data to write */
+};
 
-/*****************************************************************************/
-/* I2C commands. Only available when flash write protect is unlocked. */
+/* Write USB-PD Accessory RW_HASH table entry */
+#define EC_CMD_USB_PD_RW_HASH_ENTRY 0x0111
+/* RW hash is first 20 bytes of SHA-256 of RW section */
+#define PD_RW_HASH_SIZE 20
+struct __ec_align1 ec_params_usb_pd_rw_hash_entry {
+	uint16_t dev_id;
+	uint8_t dev_rw_hash[PD_RW_HASH_SIZE];
+	uint8_t reserved;        /* For alignment of current_image
+				  * TODO(rspangler) but it's not aligned!
+				  * Should have been reserved[2]. */
+	uint32_t current_image;  /* One of ec_current_image */
+};
 
-/* Read I2C bus */
-#define EC_CMD_I2C_READ 0x94
+/* Read USB-PD Accessory info */
+#define EC_CMD_USB_PD_DEV_INFO 0x0112
 
-struct ec_params_i2c_read {
-	uint16_t addr; /* 8-bit address (7-bit shifted << 1) */
-	uint8_t read_size; /* Either 8 or 16. */
+struct __ec_align1 ec_params_usb_pd_info_request {
 	uint8_t port;
-	uint8_t offset;
-} __packed;
-struct ec_response_i2c_read {
-	uint16_t data;
-} __packed;
+};
 
-/* Write I2C bus */
-#define EC_CMD_I2C_WRITE 0x95
+/* Read USB-PD Device discovery info */
+#define EC_CMD_USB_PD_DISCOVERY 0x0113
+struct __ec_align_size1 ec_params_usb_pd_discovery_entry {
+	uint16_t vid;  /* USB-IF VID */
+	uint16_t pid;  /* USB-IF PID */
+	uint8_t ptype; /* product type (hub,periph,cable,ama) */
+};
 
-struct ec_params_i2c_write {
-	uint16_t data;
-	uint16_t addr; /* 8-bit address (7-bit shifted << 1) */
-	uint8_t write_size; /* Either 8 or 16. */
-	uint8_t port;
-	uint8_t offset;
-} __packed;
+/* Override default charge behavior */
+#define EC_CMD_PD_CHARGE_PORT_OVERRIDE 0x0114
 
-/*****************************************************************************/
-/* Charge state commands. Only available when flash write protect unlocked. */
+/* Negative port parameters have special meaning */
+enum usb_pd_override_ports {
+	OVERRIDE_DONT_CHARGE = -2,
+	OVERRIDE_OFF = -1,
+	/* [0, CONFIG_USB_PD_PORT_COUNT): Port# */
+};
 
-/* Force charge state machine to stop in idle mode */
-#define EC_CMD_CHARGE_FORCE_IDLE 0x96
+struct __ec_align2 ec_params_charge_port_override {
+	int16_t override_port; /* Override port# */
+};
 
-struct ec_params_force_idle {
-	uint8_t enabled;
-} __packed;
+/* Read (and delete) one entry of PD event log */
+#define EC_CMD_PD_GET_LOG_ENTRY 0x0115
 
-/*****************************************************************************/
-/* Console commands. Only available when flash write protect is unlocked. */
+struct __ec_align4 ec_response_pd_log {
+	uint32_t timestamp; /* relative timestamp in milliseconds */
+	uint8_t type;       /* event type : see PD_EVENT_xx below */
+	uint8_t size_port;  /* [7:5] port number [4:0] payload size in bytes */
+	uint16_t data;      /* type-defined data payload */
+	uint8_t payload[0]; /* optional additional data payload: 0..16 bytes */
+};
 
-/* Snapshot console output buffer for use by EC_CMD_CONSOLE_READ. */
-#define EC_CMD_CONSOLE_SNAPSHOT 0x97
+
+/* The timestamp is the microsecond counter shifted to get about a ms. */
+#define PD_LOG_TIMESTAMP_SHIFT 10 /* 1 LSB = 1024us */
+
+#define PD_LOG_SIZE_MASK  0x1f
+#define PD_LOG_PORT_MASK  0xe0
+#define PD_LOG_PORT_SHIFT    5
+#define PD_LOG_PORT_SIZE(port, size) (((port) << PD_LOG_PORT_SHIFT) | \
+				      ((size) & PD_LOG_SIZE_MASK))
+#define PD_LOG_PORT(size_port) ((size_port) >> PD_LOG_PORT_SHIFT)
+#define PD_LOG_SIZE(size_port) ((size_port) & PD_LOG_SIZE_MASK)
+
+/* PD event log : entry types */
+/* PD MCU events */
+#define PD_EVENT_MCU_BASE       0x00
+#define PD_EVENT_MCU_CHARGE             (PD_EVENT_MCU_BASE+0)
+#define PD_EVENT_MCU_CONNECT            (PD_EVENT_MCU_BASE+1)
+/* Reserved for custom board event */
+#define PD_EVENT_MCU_BOARD_CUSTOM       (PD_EVENT_MCU_BASE+2)
+/* PD generic accessory events */
+#define PD_EVENT_ACC_BASE       0x20
+#define PD_EVENT_ACC_RW_FAIL   (PD_EVENT_ACC_BASE+0)
+#define PD_EVENT_ACC_RW_ERASE  (PD_EVENT_ACC_BASE+1)
+/* PD power supply events */
+#define PD_EVENT_PS_BASE        0x40
+#define PD_EVENT_PS_FAULT      (PD_EVENT_PS_BASE+0)
+/* PD video dongles events */
+#define PD_EVENT_VIDEO_BASE     0x60
+#define PD_EVENT_VIDEO_DP_MODE (PD_EVENT_VIDEO_BASE+0)
+#define PD_EVENT_VIDEO_CODEC   (PD_EVENT_VIDEO_BASE+1)
+/* Returned in the "type" field, when there is no entry available */
+#define PD_EVENT_NO_ENTRY       0xff
 
 /*
- * Read next chunk of data from saved snapshot.
- *
- * Response is null-terminated string.  Empty string, if there is no more
- * remaining output.
+ * PD_EVENT_MCU_CHARGE event definition :
+ * the payload is "struct usb_chg_measures"
+ * the data field contains the port state flags as defined below :
  */
-#define EC_CMD_CONSOLE_READ 0x98
-
-/*****************************************************************************/
+/* Port partner is a dual role device */
+#define CHARGE_FLAGS_DUAL_ROLE         (1 << 15)
+/* Port is the pending override port */
+#define CHARGE_FLAGS_DELAYED_OVERRIDE  (1 << 14)
+/* Port is the override port */
+#define CHARGE_FLAGS_OVERRIDE          (1 << 13)
+/* Charger type */
+#define CHARGE_FLAGS_TYPE_SHIFT               3
+#define CHARGE_FLAGS_TYPE_MASK       (0xf << CHARGE_FLAGS_TYPE_SHIFT)
+/* Power delivery role */
+#define CHARGE_FLAGS_ROLE_MASK         (7 <<  0)
 
 /*
- * Cut off battery power output if the battery supports.
- *
- * For unsupported battery, just don't implement this command and lets EC
- * return EC_RES_INVALID_COMMAND.
+ * PD_EVENT_PS_FAULT data field flags definition :
  */
-#define EC_CMD_BATTERY_CUT_OFF 0x99
-
-/*****************************************************************************/
-/* USB port mux control. */
+#define PS_FAULT_OCP                          1
+#define PS_FAULT_FAST_OCP                     2
+#define PS_FAULT_OVP                          3
+#define PS_FAULT_DISCH                        4
 
 /*
- * Switch USB mux or return to automatic switching.
+ * PD_EVENT_VIDEO_CODEC payload is "struct mcdp_info".
  */
-#define EC_CMD_USB_MUX 0x9a
+struct __ec_align4 mcdp_version {
+	uint8_t major;
+	uint8_t minor;
+	uint16_t build;
+};
 
-struct ec_params_usb_mux {
-	uint8_t mux;
-} __packed;
+struct __ec_align4 mcdp_info {
+	uint8_t family[2];
+	uint8_t chipid[2];
+	struct mcdp_version irom;
+	struct mcdp_version fw;
+};
 
-/*****************************************************************************/
-/* LDOs / FETs control. */
+/* struct mcdp_info field decoding */
+#define MCDP_CHIPID(chipid) ((chipid[0] << 8) | chipid[1])
+#define MCDP_FAMILY(family) ((family[0] << 8) | family[1])
 
-enum ec_ldo_state {
-	EC_LDO_STATE_OFF = 0,	/* the LDO / FET is shut down */
-	EC_LDO_STATE_ON = 1,	/* the LDO / FET is ON / providing power */
+/* Get/Set USB-PD Alternate mode info */
+#define EC_CMD_USB_PD_GET_AMODE 0x0116
+struct __ec_align_size1 ec_params_usb_pd_get_mode_request {
+	uint16_t svid_idx; /* SVID index to get */
+	uint8_t port;      /* port */
 };
 
-/*
- * Switch on/off a LDO.
- */
-#define EC_CMD_LDO_SET 0x9b
+struct __ec_align4 ec_params_usb_pd_get_mode_response {
+	uint16_t svid;   /* SVID */
+	uint16_t opos;    /* Object Position */
+	uint32_t vdo[6]; /* Mode VDOs */
+};
 
-struct ec_params_ldo_set {
-	uint8_t index;
-	uint8_t state;
-} __packed;
+#define EC_CMD_USB_PD_SET_AMODE 0x0117
 
-/*
- * Get LDO state.
- */
-#define EC_CMD_LDO_GET 0x9c
+enum pd_mode_cmd {
+	PD_EXIT_MODE = 0,
+	PD_ENTER_MODE = 1,
+	/* Not a command.  Do NOT remove. */
+	PD_MODE_CMD_COUNT,
+};
 
-struct ec_params_ldo_get {
-	uint8_t index;
-} __packed;
+struct __ec_align4 ec_params_usb_pd_set_mode_request {
+	uint32_t cmd;  /* enum pd_mode_cmd */
+	uint16_t svid; /* SVID to set */
+	uint8_t opos;  /* Object Position */
+	uint8_t port;  /* port */
+};
 
-struct ec_response_ldo_get {
-	uint8_t state;
-} __packed;
+/* Ask the PD MCU to record a log of a requested type */
+#define EC_CMD_PD_WRITE_LOG_ENTRY 0x0118
 
-/*****************************************************************************/
-/* Power info. */
+struct __ec_align1 ec_params_pd_write_log_entry {
+	uint8_t type; /* event type : see PD_EVENT_xx above */
+	uint8_t port; /* port#, or 0 for events unrelated to a given port */
+};
 
-/*
- * Get power info.
- */
-#define EC_CMD_POWER_INFO 0x9d
 
-struct ec_response_power_info {
-	uint32_t usb_dev_type;
-	uint16_t voltage_ac;
-	uint16_t voltage_system;
-	uint16_t current_system;
-	uint16_t usb_current_limit;
-} __packed;
+/* Control USB-PD chip */
+#define EC_CMD_PD_CONTROL 0x0119
 
-/*****************************************************************************/
-/* I2C passthru command */
+enum ec_pd_control_cmd {
+	PD_SUSPEND = 0,      /* Suspend the PD chip (EC: stop talking to PD) */
+	PD_RESUME,           /* Resume the PD chip (EC: start talking to PD) */
+	PD_RESET,            /* Force reset the PD chip */
+	PD_CONTROL_DISABLE   /* Disable further calls to this command */
+};
 
-#define EC_CMD_I2C_PASSTHRU 0x9e
+struct __ec_align1 ec_params_pd_control {
+	uint8_t chip;         /* chip id (should be 0) */
+	uint8_t subcmd;
+};
 
-/* Slave address is 10 (not 7) bit */
-#define EC_I2C_FLAG_10BIT	(1 << 16)
+/* Get info about USB-C SS muxes */
+#define EC_CMD_USB_PD_MUX_INFO 0x011A
 
-/* Read data; if not present, message is a write */
-#define EC_I2C_FLAG_READ	(1 << 15)
+struct __ec_align1 ec_params_usb_pd_mux_info {
+	uint8_t port; /* USB-C port number */
+};
 
-/* Mask for address */
-#define EC_I2C_ADDR_MASK	0x3ff
+/* Flags representing mux state */
+#define USB_PD_MUX_USB_ENABLED       (1 << 0)
+#define USB_PD_MUX_DP_ENABLED        (1 << 1)
+#define USB_PD_MUX_POLARITY_INVERTED (1 << 2)
+#define USB_PD_MUX_HPD_IRQ           (1 << 3)
 
-#define EC_I2C_STATUS_NAK	(1 << 0) /* Transfer was not acknowledged */
-#define EC_I2C_STATUS_TIMEOUT	(1 << 1) /* Timeout during transfer */
+struct __ec_align1 ec_response_usb_pd_mux_info {
+	uint8_t flags; /* USB_PD_MUX_*-encoded USB mux state */
+};
 
-/* Any error */
-#define EC_I2C_STATUS_ERROR	(EC_I2C_STATUS_NAK | EC_I2C_STATUS_TIMEOUT)
+#define EC_CMD_PD_CHIP_INFO		0x011B
 
-struct ec_params_i2c_passthru_msg {
-	uint16_t addr_flags;	/* I2C slave address (7 or 10 bits) and flags */
-	uint16_t len;		/* Number of bytes to read or write */
-} __packed;
+struct __ec_align1 ec_params_pd_chip_info {
+	uint8_t port;	/* USB-C port number */
+	uint8_t renew;	/* Force renewal */
+};
 
-struct ec_params_i2c_passthru {
-	uint8_t port;		/* I2C port number */
-	uint8_t num_msgs;	/* Number of messages */
-	struct ec_params_i2c_passthru_msg msg[];
-	/* Data to write for all messages is concatenated here */
-} __packed;
+struct __ec_align2 ec_response_pd_chip_info {
+	uint16_t vendor_id;
+	uint16_t product_id;
+	uint16_t device_id;
+	union {
+		uint8_t fw_version_string[8];
+		uint64_t fw_version_number;
+	};
+};
 
-struct ec_response_i2c_passthru {
-	uint8_t i2c_status;	/* Status flags (EC_I2C_STATUS_...) */
-	uint8_t num_msgs;	/* Number of messages processed */
-	uint8_t data[];		/* Data read by messages concatenated here */
-} __packed;
+/* Run RW signature verification and get status */
+#define EC_CMD_RWSIG_CHECK_STATUS	0x011C
+
+struct __ec_align4 ec_response_rwsig_check_status {
+	uint32_t status;
+};
 
+/* For controlling RWSIG task */
+#define EC_CMD_RWSIG_ACTION	0x011D
 
-/*****************************************************************************/
-/* Temporary debug commands. TODO: remove this crosbug.com/p/13849 */
+enum rwsig_action {
+	RWSIG_ACTION_ABORT = 0,		/* Abort RWSIG and prevent jumping */
+	RWSIG_ACTION_CONTINUE = 1,	/* Jump to RW immediately */
+};
+
+struct __ec_align4 ec_params_rwsig_action {
+	uint32_t action;
+};
+
+/* Run verification on a slot */
+#define EC_CMD_EFS_VERIFY	0x011E
+
+struct __ec_align1 ec_params_efs_verify {
+	uint8_t region;		/* enum ec_flash_region */
+};
 
 /*
- * Dump charge state machine context.
- *
- * Response is a binary dump of charge state machine context.
+ * Retrieve info from Cros Board Info store. Response is based on the data
+ * type. Integers return a uint32. Strings return a string, using the response
+ * size to determine how big it is.
+ */
+#define EC_CMD_GET_CROS_BOARD_INFO	0x011F
+/*
+ * Write info into Cros Board Info on EEPROM. Write fails if the board has
+ * hardware write-protect enabled.
  */
-#define EC_CMD_CHARGE_DUMP 0xa0
+#define EC_CMD_SET_CROS_BOARD_INFO	0x0120
+
+enum cbi_data_tag {
+	CBI_TAG_BOARD_VERSION = 0, /* uint16_t or uint8_t[] = {minor,major} */
+	CBI_TAG_OEM_ID = 1,        /* uint8_t */
+	CBI_TAG_SKU_ID = 2,        /* uint8_t */
+	CBI_TAG_COUNT,
+};
 
 /*
- * Set maximum battery charging current.
+ * Flags to control read operation
+ *
+ * RELOAD:  Invalidate cache and read data from EEPROM. Useful to verify
+ *          write was successful without reboot.
  */
-#define EC_CMD_CHARGE_CURRENT_LIMIT 0xa1
+#define CBI_GET_RELOAD		(1 << 0)
 
-struct ec_params_current_limit {
-	uint32_t limit; /* in mA */
-} __packed;
+struct __ec_align4 ec_params_get_cbi {
+	uint32_t type;		/* enum cbi_data_tag */
+	uint32_t flag;		/* CBI_GET_* */
+};
 
 /*
- * Set maximum external power current.
+ * Flags to control write behavior.
+ *
+ * NO_SYNC: Makes EC update data in RAM but skip writing to EEPROM. It's
+ *          useful when writing multiple fields in a row.
+ * INIT:    Needs to be set when creating a new CBI from scratch. All fields
+ *          will be initialized to zero first.
  */
-#define EC_CMD_EXT_POWER_CURRENT_LIMIT 0xa2
+#define CBI_SET_NO_SYNC		(1 << 0)
+#define CBI_SET_INIT		(1 << 1)
+
+struct __ec_align1 ec_params_set_cbi {
+	uint32_t tag;		/* enum cbi_data_tag */
+	uint32_t flag;		/* CBI_SET_* */
+	uint32_t size;		/* Data size */
+	uint8_t data[];		/* For string and raw data */
+};
 
-struct ec_params_ext_power_current_limit {
-	uint32_t limit; /* in mA */
-} __packed;
+/*****************************************************************************/
+/* The command range 0x200-0x2FF is reserved for Rotor. */
 
 /*****************************************************************************/
-/* Smart battery pass-through */
+/*
+ * Reserve a range of host commands for the CR51 firmware.
+ */
+#define EC_CMD_CR51_BASE 0x0300
+#define EC_CMD_CR51_LAST 0x03FF
 
-/* Get / Set 16-bit smart battery registers */
-#define EC_CMD_SB_READ_WORD   0xb0
-#define EC_CMD_SB_WRITE_WORD  0xb1
+/*****************************************************************************/
+/* Fingerprint MCU commands: range 0x0400-0x040x */
 
-/* Get / Set string smart battery parameters
- * formatted as SMBUS "block".
- */
-#define EC_CMD_SB_READ_BLOCK  0xb2
-#define EC_CMD_SB_WRITE_BLOCK 0xb3
+/* Fingerprint SPI sensor passthru command: prototyping ONLY */
+#define EC_CMD_FP_PASSTHRU 0x0400
 
-struct ec_params_sb_rd {
-	uint8_t reg;
-} __packed;
+#define EC_FP_FLAG_NOT_COMPLETE 0x1
 
-struct ec_response_sb_rd_word {
-	uint16_t value;
-} __packed;
+struct __ec_align2 ec_params_fp_passthru {
+	uint16_t len;		/* Number of bytes to write then read */
+	uint16_t flags;		/* EC_FP_FLAG_xxx */
+	uint8_t data[];		/* Data to send */
+};
 
-struct ec_params_sb_wr_word {
-	uint8_t reg;
-	uint16_t value;
-} __packed;
+/* Fingerprint sensor configuration command: prototyping ONLY */
+#define EC_CMD_FP_SENSOR_CONFIG 0x0401
 
-struct ec_response_sb_rd_block {
-	uint8_t data[32];
-} __packed;
+#define EC_FP_SENSOR_CONFIG_MAX_REGS 16
 
-struct ec_params_sb_wr_block {
-	uint8_t reg;
-	uint16_t data[32];
-} __packed;
+struct __ec_align2 ec_params_fp_sensor_config {
+	uint8_t count;		/* Number of setup registers */
+	/*
+	 * the value to send to each of the 'count' setup registers
+	 * is stored in the 'data' array for 'len' bytes just after
+	 * the previous one.
+	 */
+	uint8_t len[EC_FP_SENSOR_CONFIG_MAX_REGS];
+	uint8_t data[];
+};
 
-/*
- * Entering Verified Boot Mode Command
- * Default mode is VBOOT_MODE_NORMAL if EC did not receive this command.
- * Valid Modes are: normal, developer, and recovery.
- */
-#define EC_CMD_ENTERING_MODE 0xb6
+/* Configure the Fingerprint MCU behavior */
+#define EC_CMD_FP_MODE 0x0402
+
+/* Put the sensor in its lowest power mode */
+#define FP_MODE_DEEPSLEEP     (1<<0)
+/* Wait to see a finger on the sensor */
+#define FP_MODE_FINGER_DOWN   (1<<1)
+/* Poll until the finger has left the sensor */
+#define FP_MODE_FINGER_UP     (1<<2)
+/* Capture the current finger image */
+#define FP_MODE_CAPTURE       (1<<3)
+/* special value: don't change anything just read back current mode */
+#define FP_MODE_DONT_CHANGE   (1<<31)
+
+struct __ec_align4 ec_params_fp_mode {
+	uint32_t mode; /* as defined by FP_MODE_ constants */
+	/* TBD */
+};
 
-struct ec_params_entering_mode {
-	int vboot_mode;
-} __packed;
+struct __ec_align4 ec_response_fp_mode {
+	uint32_t mode; /* as defined by FP_MODE_ constants */
+	/* TBD */
+};
 
-#define VBOOT_MODE_NORMAL    0
-#define VBOOT_MODE_DEVELOPER 1
-#define VBOOT_MODE_RECOVERY  2
+/* Retrieve Fingerprint sensor information */
+#define EC_CMD_FP_INFO 0x0403
+
+struct __ec_align2 ec_response_fp_info {
+	/* Sensor identification */
+	uint32_t vendor_id;
+	uint32_t product_id;
+	uint32_t model_id;
+	uint32_t version;
+	/* Image frame characteristics */
+	uint32_t frame_size;
+	uint32_t pixel_format; /* using V4L2_PIX_FMT_ */
+	uint16_t width;
+	uint16_t height;
+	uint16_t bpp;
+};
+
+/* Get the last captured finger frame: TODO: will be AES-encrypted */
+#define EC_CMD_FP_FRAME 0x0404
+
+struct __ec_align4 ec_params_fp_frame {
+	uint32_t offset;
+	uint32_t size;
+};
 
 /*****************************************************************************/
-/* System commands */
+/* Touchpad MCU commands: range 0x0500-0x05FF */
 
-/*
- * TODO: this is a confusing name, since it doesn't necessarily reboot the EC.
- * Rename to "set image" or something similar.
- */
-#define EC_CMD_REBOOT_EC 0xd2
+/* Perform touchpad self test */
+#define EC_CMD_TP_SELF_TEST 0x0500
 
-/* Command */
-enum ec_reboot_cmd {
-	EC_REBOOT_CANCEL = 0,        /* Cancel a pending reboot */
-	EC_REBOOT_JUMP_RO = 1,       /* Jump to RO without rebooting */
-	EC_REBOOT_JUMP_RW = 2,       /* Jump to RW without rebooting */
-	/* (command 3 was jump to RW-B) */
-	EC_REBOOT_COLD = 4,          /* Cold-reboot */
-	EC_REBOOT_DISABLE_JUMP = 5,  /* Disable jump until next reboot */
-	EC_REBOOT_HIBERNATE = 6      /* Hibernate EC */
+/* Get number of frame types, and the size of each type */
+#define EC_CMD_TP_FRAME_INFO 0x0501
+
+struct __ec_align4 ec_response_tp_frame_info {
+	uint32_t n_frames;
+	uint32_t frame_sizes[0];
 };
 
-/* Flags for ec_params_reboot_ec.reboot_flags */
-#define EC_REBOOT_FLAG_RESERVED0      (1 << 0)  /* Was recovery request */
-#define EC_REBOOT_FLAG_ON_AP_SHUTDOWN (1 << 1)  /* Reboot after AP shutdown */
+/* Create a snapshot of current frame readings */
+#define EC_CMD_TP_FRAME_SNAPSHOT 0x0502
 
-struct ec_params_reboot_ec {
-	uint8_t cmd;           /* enum ec_reboot_cmd */
-	uint8_t flags;         /* See EC_REBOOT_FLAG_* */
-} __packed;
+/* Read the frame */
+#define EC_CMD_TP_FRAME_GET 0x0503
 
-/*
- * Get information on last EC panic.
- *
- * Returns variable-length platform-dependent panic information.  See panic.h
- * for details.
- */
-#define EC_CMD_GET_PANIC_INFO 0xd3
+struct __ec_align4 ec_params_tp_frame_get {
+	uint32_t frame_index;
+	uint32_t offset;
+	uint32_t size;
+};
 
 /*****************************************************************************/
 /*
- * ACPI commands
- *
- * These are valid ONLY on the ACPI command/data port.
- */
-
-/*
- * ACPI Read Embedded Controller
+ * Reserve a range of host commands for board-specific, experimental, or
+ * special purpose features. These can be (re)used without updating this file.
  *
- * This reads from ACPI memory space on the EC (EC_ACPI_MEM_*).
+ * CAUTION: Don't go nuts with this. Shipping products should document ALL
+ * their EC commands for easier development, testing, debugging, and support.
  *
- * Use the following sequence:
+ * All commands MUST be #defined to be 4-digit UPPER CASE hex values
+ * (e.g., 0x00AB, not 0xab) for CONFIG_HOSTCMD_SECTION_SORTED to work.
  *
- *    - Write EC_CMD_ACPI_READ to EC_LPC_ADDR_ACPI_CMD
- *    - Wait for EC_LPC_CMDR_PENDING bit to clear
- *    - Write address to EC_LPC_ADDR_ACPI_DATA
- *    - Wait for EC_LPC_CMDR_DATA bit to set
- *    - Read value from EC_LPC_ADDR_ACPI_DATA
- */
-#define EC_CMD_ACPI_READ 0x80
-
-/*
- * ACPI Write Embedded Controller
+ * In your experimental code, you may want to do something like this:
  *
- * This reads from ACPI memory space on the EC (EC_ACPI_MEM_*).
+ *   #define EC_CMD_MAGIC_FOO 0x0000
+ *   #define EC_CMD_MAGIC_BAR 0x0001
+ *   #define EC_CMD_MAGIC_HEY 0x0002
  *
- * Use the following sequence:
+ *   DECLARE_PRIVATE_HOST_COMMAND(EC_CMD_MAGIC_FOO, magic_foo_handler,
+ *      EC_VER_MASK(0);
  *
- *    - Write EC_CMD_ACPI_WRITE to EC_LPC_ADDR_ACPI_CMD
- *    - Wait for EC_LPC_CMDR_PENDING bit to clear
- *    - Write address to EC_LPC_ADDR_ACPI_DATA
- *    - Wait for EC_LPC_CMDR_PENDING bit to clear
- *    - Write value to EC_LPC_ADDR_ACPI_DATA
- */
-#define EC_CMD_ACPI_WRITE 0x81
-
-/*
- * ACPI Query Embedded Controller
+ *   DECLARE_PRIVATE_HOST_COMMAND(EC_CMD_MAGIC_BAR, magic_bar_handler,
+ *      EC_VER_MASK(0);
  *
- * This clears the lowest-order bit in the currently pending host events, and
- * sets the result code to the 1-based index of the bit (event 0x00000001 = 1,
- * event 0x80000000 = 32), or 0 if no event was pending.
+ *   DECLARE_PRIVATE_HOST_COMMAND(EC_CMD_MAGIC_HEY, magic_hey_handler,
+ *      EC_VER_MASK(0);
  */
-#define EC_CMD_ACPI_QUERY_EVENT 0x84
+#define EC_CMD_BOARD_SPECIFIC_BASE 0x3E00
+#define EC_CMD_BOARD_SPECIFIC_LAST 0x3FFF
 
-/* Valid addresses in ACPI memory space, for read/write commands */
-/* Memory space version; set to EC_ACPI_MEM_VERSION_CURRENT */
-#define EC_ACPI_MEM_VERSION            0x00
 /*
- * Test location; writing value here updates test compliment byte to (0xff -
- * value).
+ * Given the private host command offset, calculate the true private host
+ * command value.
  */
-#define EC_ACPI_MEM_TEST               0x01
-/* Test compliment; writes here are ignored. */
-#define EC_ACPI_MEM_TEST_COMPLIMENT    0x02
-/* Keyboard backlight brightness percent (0 - 100) */
-#define EC_ACPI_MEM_KEYBOARD_BACKLIGHT 0x03
-
-/* Current version of ACPI memory address space */
-#define EC_ACPI_MEM_VERSION_CURRENT 1
-
+#define EC_PRIVATE_HOST_COMMAND_VALUE(command) \
+	(EC_CMD_BOARD_SPECIFIC_BASE + (command))
 
 /*****************************************************************************/
 /*
- * Special commands
+ * Passthru commands
  *
- * These do not follow the normal rules for commands.  See each command for
- * details.
- */
-
-/*
- * Reboot NOW
+ * Some platforms have sub-processors chained to each other.  For example.
  *
- * This command will work even when the EC LPC interface is busy, because the
- * reboot command is processed@interrupt level.  Note that when the EC
- * reboots, the host will reboot too, so there is no response to this command.
+ *     AP <--> EC <--> PD MCU
  *
- * Use EC_CMD_REBOOT_EC to reboot the EC more politely.
- */
-#define EC_CMD_REBOOT 0xd1  /* Think "die" */
-
-/*
- * Resend last response (not supported on LPC).
+ * The top 2 bits of the command number are used to indicate which device the
+ * command is intended for.  Device 0 is always the device receiving the
+ * command; other device mapping is board-specific.
  *
- * Returns EC_RES_UNAVAILABLE if there is no response available - for example,
- * there was no previous command, or the previous command's response was too
- * big to save.
+ * When a device receives a command to be passed to a sub-processor, it passes
+ * it on with the device number set back to 0.  This allows the sub-processor
+ * to remain blissfully unaware of whether the command originated on the next
+ * device up the chain, or was passed through from the AP.
+ *
+ * In the above example, if the AP wants to send command 0x0002 to the PD MCU,
+ *     AP sends command 0x4002 to the EC
+ *     EC sends command 0x0002 to the PD MCU
+ *     EC forwards PD MCU response back to the AP
  */
-#define EC_CMD_RESEND_RESPONSE 0xdb
 
+/* Offset and max command number for sub-device n */
+#define EC_CMD_PASSTHRU_OFFSET(n) (0x4000 * (n))
+#define EC_CMD_PASSTHRU_MAX(n) (EC_CMD_PASSTHRU_OFFSET(n) + 0x3fff)
+
+/*****************************************************************************/
 /*
- * This header byte on a command indicate version 0. Any header byte less
- * than this means that we are talking to an old EC which doesn't support
- * versioning. In that case, we assume version 0.
- *
- * Header bytes greater than this indicate a later version. For example,
- * EC_CMD_VERSION0 + 1 means we are using version 1.
- *
- * The old EC interface must not use commands 0dc or higher.
+ * Deprecated constants. These constants have been renamed for clarity. The
+ * meaning and size has not changed. Programs that use the old names should
+ * switch to the new names soon, as the old names may not be carried forward
+ * forever.
  */
-#define EC_CMD_VERSION0 0xdc
+#define EC_HOST_PARAM_SIZE      EC_PROTO2_MAX_PARAM_SIZE
+#define EC_LPC_ADDR_OLD_PARAM   EC_HOST_CMD_REGION1
+#define EC_OLD_PARAM_SIZE       EC_HOST_CMD_REGION_SIZE
 
-#endif  /* !__ACPI__ */
+#endif  /* !__ACPI__ && !__KERNEL__ */
 
 #endif  /* __CROS_EC_COMMANDS_H */
-- 
2.19.0.605.g01d371f741-goog

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 33/45] x86: Update mtrr functions to allow leaving cache alone
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (31 preceding siblings ...)
  2018-10-01 18:22 ` [U-Boot] [PATCH 32/45] cros: Update ec_commands to latest version Simon Glass
@ 2018-10-01 18:22 ` Simon Glass
  2018-10-02 13:41   ` Bin Meng
  2018-10-09 23:54   ` sjg at google.com
  2018-10-01 18:22 ` [U-Boot] [PATCH 34/45] cros_ec: Update cros_ec_read_hash() to specify the image Simon Glass
                   ` (51 subsequent siblings)
  84 siblings, 2 replies; 106+ messages in thread
From: Simon Glass @ 2018-10-01 18:22 UTC (permalink / raw)
  To: u-boot

At present the mtrr functions disable the cache before making changes and
enable it again afterwards. This is fine in U-Boot, but does not work if
running in CAR (such as we are in SPL).

Update the functions so that the caller can request that caches be left
alone.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 arch/x86/cpu/mtrr.c         | 31 +++++++++++++++++++++++--------
 arch/x86/include/asm/mtrr.h |  6 ++++--
 cmd/x86/mtrr.c              |  8 ++++----
 3 files changed, 31 insertions(+), 14 deletions(-)

diff --git a/arch/x86/cpu/mtrr.c b/arch/x86/cpu/mtrr.c
index 30940065621..0939736164d 100644
--- a/arch/x86/cpu/mtrr.c
+++ b/arch/x86/cpu/mtrr.c
@@ -11,6 +11,11 @@
  * System Programming
  */
 
+/*
+ * Note that any console output (e.g. debug()) in this file will likely fail
+ * since the MTRR registers are sometimes in flux.
+ */
+
 #include <common.h>
 #include <asm/io.h>
 #include <asm/msr.h>
@@ -19,27 +24,29 @@
 DECLARE_GLOBAL_DATA_PTR;
 
 /* Prepare to adjust MTRRs */
-void mtrr_open(struct mtrr_state *state)
+void mtrr_open(struct mtrr_state *state, bool do_caches)
 {
 	if (!gd->arch.has_mtrr)
 		return;
 
-	state->enable_cache = dcache_status();
+	if (do_caches) {
+		state->enable_cache = dcache_status();
 
-	if (state->enable_cache)
-		disable_caches();
+		if (state->enable_cache)
+			disable_caches();
+	}
 	state->deftype = native_read_msr(MTRR_DEF_TYPE_MSR);
 	wrmsrl(MTRR_DEF_TYPE_MSR, state->deftype & ~MTRR_DEF_TYPE_EN);
 }
 
 /* Clean up after adjusting MTRRs, and enable them */
-void mtrr_close(struct mtrr_state *state)
+void mtrr_close(struct mtrr_state *state, bool do_caches)
 {
 	if (!gd->arch.has_mtrr)
 		return;
 
 	wrmsrl(MTRR_DEF_TYPE_MSR, state->deftype | MTRR_DEF_TYPE_EN);
-	if (state->enable_cache)
+	if (do_caches && state->enable_cache)
 		enable_caches();
 }
 
@@ -50,10 +57,14 @@ int mtrr_commit(bool do_caches)
 	uint64_t mask;
 	int i;
 
+	debug("%s: enabled=%d, count=%d\n", __func__, gd->arch.has_mtrr,
+	      gd->arch.mtrr_req_count);
 	if (!gd->arch.has_mtrr)
 		return -ENOSYS;
 
-	mtrr_open(&state);
+	debug("open\n");
+	mtrr_open(&state, do_caches);
+	debug("open done\n");
 	for (i = 0; i < gd->arch.mtrr_req_count; i++, req++) {
 		mask = ~(req->size - 1);
 		mask &= (1ULL << CONFIG_CPU_ADDR_BITS) - 1;
@@ -62,9 +73,12 @@ int mtrr_commit(bool do_caches)
 	}
 
 	/* Clear the ones that are unused */
+	debug("clear\n");
 	for (; i < MTRR_COUNT; i++)
 		wrmsrl(MTRR_PHYS_MASK_MSR(i), 0);
-	mtrr_close(&state);
+	debug("close\n");
+	mtrr_close(&state, do_caches);
+	debug("mtrr done\n");
 
 	return 0;
 }
@@ -74,6 +88,7 @@ int mtrr_add_request(int type, uint64_t start, uint64_t size)
 	struct mtrr_request *req;
 	uint64_t mask;
 
+	debug("%s: count=%d\n", __func__, gd->arch.mtrr_req_count);
 	if (!gd->arch.has_mtrr)
 		return -ENOSYS;
 
diff --git a/arch/x86/include/asm/mtrr.h b/arch/x86/include/asm/mtrr.h
index 05cd7b7f17b..2d897f82ef7 100644
--- a/arch/x86/include/asm/mtrr.h
+++ b/arch/x86/include/asm/mtrr.h
@@ -77,8 +77,9 @@ struct mtrr_state {
  * possibly the cache.
  *
  * @state:	Empty structure to pass in to hold settings
+ * @do_caches:	true to disable caches before opening
  */
-void mtrr_open(struct mtrr_state *state);
+void mtrr_open(struct mtrr_state *state, bool do_caches);
 
 /**
  * mtrr_open() - Clean up after adjusting MTRRs, and enable them
@@ -86,8 +87,9 @@ void mtrr_open(struct mtrr_state *state);
  * This uses the structure containing information returned from mtrr_open().
  *
  * @state:	Structure from mtrr_open()
+ * @state:	true to restore cache state to that before mtrr_open()
  */
-void mtrr_close(struct mtrr_state *state);
+void mtrr_close(struct mtrr_state *state, bool do_caches);
 
 /**
  * mtrr_add_request() - Add a new MTRR request
diff --git a/cmd/x86/mtrr.c b/cmd/x86/mtrr.c
index 70f373a72a5..d3fd959235f 100644
--- a/cmd/x86/mtrr.c
+++ b/cmd/x86/mtrr.c
@@ -73,10 +73,10 @@ static int do_mtrr_set(uint reg, int argc, char * const argv[])
 		mask |= MTRR_PHYS_MASK_VALID;
 
 	printf("base=%llx, mask=%llx\n", base, mask);
-	mtrr_open(&state);
+	mtrr_open(&state, true);
 	wrmsrl(MTRR_PHYS_BASE_MSR(reg), base);
 	wrmsrl(MTRR_PHYS_MASK_MSR(reg), mask);
-	mtrr_close(&state);
+	mtrr_close(&state, true);
 
 	return 0;
 }
@@ -86,14 +86,14 @@ static int mtrr_set_valid(int reg, bool valid)
 	struct mtrr_state state;
 	uint64_t mask;
 
-	mtrr_open(&state);
+	mtrr_open(&state, true);
 	mask = native_read_msr(MTRR_PHYS_MASK_MSR(reg));
 	if (valid)
 		mask |= MTRR_PHYS_MASK_VALID;
 	else
 		mask &= ~MTRR_PHYS_MASK_VALID;
 	wrmsrl(MTRR_PHYS_MASK_MSR(reg), mask);
-	mtrr_close(&state);
+	mtrr_close(&state, true);
 
 	return 0;
 }
-- 
2.19.0.605.g01d371f741-goog

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 34/45] cros_ec: Update cros_ec_read_hash() to specify the image
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (32 preceding siblings ...)
  2018-10-01 18:22 ` [U-Boot] [PATCH 33/45] x86: Update mtrr functions to allow leaving cache alone Simon Glass
@ 2018-10-01 18:22 ` Simon Glass
  2018-10-01 18:22 ` [U-Boot] [PATCH 35/45] cros_ec: Add support for v3 messages on LPC Simon Glass
                   ` (50 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: Simon Glass @ 2018-10-01 18:22 UTC (permalink / raw)
  To: u-boot

Allow selection of which EC image to hash.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 cmd/cros_ec.c          | 2 +-
 drivers/misc/cros_ec.c | 7 ++++---
 include/cros_ec.h      | 4 +++-
 3 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/cmd/cros_ec.c b/cmd/cros_ec.c
index 3ac4f3b235d..9e2f1b06f3c 100644
--- a/cmd/cros_ec.c
+++ b/cmd/cros_ec.c
@@ -149,7 +149,7 @@ static int do_cros_ec(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 		struct ec_response_vboot_hash hash;
 		int i;
 
-		if (cros_ec_read_hash(dev, &hash)) {
+		if (cros_ec_read_hash(dev, EC_VBOOT_HASH_OFFSET_ACTIVE, &hash)) {
 			debug("%s: Could not read KBC hash\n", __func__);
 			return 1;
 		}
diff --git a/drivers/misc/cros_ec.c b/drivers/misc/cros_ec.c
index 2deed0e839f..d2543f8ddc0 100644
--- a/drivers/misc/cros_ec.c
+++ b/drivers/misc/cros_ec.c
@@ -444,13 +444,14 @@ static int cros_ec_wait_on_hash_done(struct udevice *dev,
 	return 0;
 }
 
-
-int cros_ec_read_hash(struct udevice *dev, struct ec_response_vboot_hash *hash)
+int cros_ec_read_hash(struct udevice *dev, uint hash_offset,
+		      struct ec_response_vboot_hash *hash)
 {
 	struct ec_params_vboot_hash p;
 	int rv;
 
 	p.cmd = EC_VBOOT_HASH_GET;
+	p.offset = hash_offset;
 	if (ec_command(dev, EC_CMD_VBOOT_HASH, 0, &p, sizeof(p),
 		       hash, sizeof(*hash)) < 0)
 		return -1;
@@ -473,7 +474,7 @@ int cros_ec_read_hash(struct udevice *dev, struct ec_response_vboot_hash *hash)
 	p.cmd = EC_VBOOT_HASH_START;
 	p.hash_type = EC_VBOOT_HASH_TYPE_SHA256;
 	p.nonce_size = 0;
-	p.offset = EC_VBOOT_HASH_OFFSET_ACTIVE;
+	p.offset = hash_offset;
 
 	if (ec_command(dev, EC_CMD_VBOOT_HASH, 0, &p, sizeof(p),
 		       hash, sizeof(*hash)) < 0)
diff --git a/include/cros_ec.h b/include/cros_ec.h
index 5576bcf32ee..4771e6b7d1c 100644
--- a/include/cros_ec.h
+++ b/include/cros_ec.h
@@ -96,10 +96,12 @@ int cros_ec_read_current_image(struct udevice *dev,
  * Read the hash of the CROS-EC device firmware.
  *
  * @param dev		CROS-EC device
+ * @param hash_offset	Offset in flash to read from
  * @param hash		Destination for hash information
  * @return 0 if ok, <0 on error
  */
-int cros_ec_read_hash(struct udevice *dev, struct ec_response_vboot_hash *hash);
+int cros_ec_read_hash(struct udevice *dev, uint hash_offset,
+		      struct ec_response_vboot_hash *hash);
 
 /**
  * Send a reboot command to the CROS-EC device.
-- 
2.19.0.605.g01d371f741-goog

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 35/45] cros_ec: Add support for v3 messages on LPC
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (33 preceding siblings ...)
  2018-10-01 18:22 ` [U-Boot] [PATCH 34/45] cros_ec: Update cros_ec_read_hash() to specify the image Simon Glass
@ 2018-10-01 18:22 ` Simon Glass
  2018-10-01 18:22 ` [U-Boot] [PATCH 36/45] test: panel: Add a test for the panel uclass Simon Glass
                   ` (49 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: Simon Glass @ 2018-10-01 18:22 UTC (permalink / raw)
  To: u-boot

At present version 3 messages are only supported on SPI. Add support for
using LPC as well, as used on samus.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/misc/cros_ec_lpc.c | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/drivers/misc/cros_ec_lpc.c b/drivers/misc/cros_ec_lpc.c
index be17adcc5ac..71d03bfba2b 100644
--- a/drivers/misc/cros_ec_lpc.c
+++ b/drivers/misc/cros_ec_lpc.c
@@ -40,6 +40,38 @@ static int wait_for_sync(struct cros_ec_dev *dev)
 	return 0;
 }
 
+int cros_ec_lpc_packet(struct udevice *udev, int out_bytes, int in_bytes)
+{
+	struct cros_ec_dev *dev = dev_get_uclass_priv(udev);
+	uint8_t *d;
+	int i;
+
+	if (out_bytes > EC_LPC_HOST_PACKET_SIZE)
+		return log_msg_ret("Cannot send that many bytes\n", -E2BIG);
+
+	if (in_bytes > EC_LPC_HOST_PACKET_SIZE)
+		return log_msg_ret("Cannot receive that many bytes\n", -E2BIG);
+
+	if (wait_for_sync(dev))
+		return log_msg_ret("Timeout waiting ready\n", -ETIMEDOUT);
+
+	/* Write data */
+	for (i = 0, d = (uint8_t *)dev->dout; i < out_bytes; i++, d++)
+		outb(*d, EC_LPC_ADDR_HOST_PACKET + i);
+
+	/* Start the command */
+	outb(EC_COMMAND_PROTOCOL_3, EC_LPC_ADDR_HOST_CMD);
+
+	if (wait_for_sync(dev))
+		return log_msg_ret("Timeout waiting ready\n", -ETIMEDOUT);
+
+	/* Read back args */
+	for (i = 0, d = dev->din; i < in_bytes; i++, d++)
+		*d = inb(EC_LPC_ADDR_HOST_PACKET + i);
+
+	return in_bytes;
+}
+
 int cros_ec_lpc_command(struct udevice *udev, uint8_t cmd, int cmd_version,
 		     const uint8_t *dout, int dout_len,
 		     uint8_t **dinp, int din_len)
@@ -200,6 +232,7 @@ static int cros_ec_probe(struct udevice *dev)
 }
 
 static struct dm_cros_ec_ops cros_ec_ops = {
+	.packet = cros_ec_lpc_packet,
 	.command = cros_ec_lpc_command,
 	.check_version = cros_ec_lpc_check_version,
 };
-- 
2.19.0.605.g01d371f741-goog

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 36/45] test: panel: Add a test for the panel uclass
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (34 preceding siblings ...)
  2018-10-01 18:22 ` [U-Boot] [PATCH 35/45] cros_ec: Add support for v3 messages on LPC Simon Glass
@ 2018-10-01 18:22 ` Simon Glass
  2018-10-01 18:22 ` [U-Boot] [PATCH 37/45] panel: Expand the backlight support Simon Glass
                   ` (48 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: Simon Glass @ 2018-10-01 18:22 UTC (permalink / raw)
  To: u-boot

At present this uclass has no tests. Add a simple one which checks the PWM
configuration, regulator and GPIO.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 arch/sandbox/dts/sandbox_pmic.dtsi |  2 +-
 arch/sandbox/dts/test.dts          | 20 +++++++++++-
 arch/sandbox/include/asm/test.h    | 15 +++++++++
 drivers/pwm/sandbox_pwm.c          | 25 +++++++++++++++
 test/dm/Makefile                   |  1 +
 test/dm/panel.c                    | 50 ++++++++++++++++++++++++++++++
 6 files changed, 111 insertions(+), 2 deletions(-)
 create mode 100644 test/dm/panel.c

diff --git a/arch/sandbox/dts/sandbox_pmic.dtsi b/arch/sandbox/dts/sandbox_pmic.dtsi
index 403656f25e5..5ecafaab364 100644
--- a/arch/sandbox/dts/sandbox_pmic.dtsi
+++ b/arch/sandbox/dts/sandbox_pmic.dtsi
@@ -60,7 +60,7 @@
 		regulator-max-microvolt = <3300000>;
 	};
 
-	ldo1 {
+	ldo_1: ldo1 {
 		regulator-name = "VDD_EMMC_1.8V";
 		regulator-min-microvolt = <1800000>;
 		regulator-max-microvolt = <1800000>;
diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index 491f889f3b9..43f79509f75 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -11,6 +11,8 @@
 		eth0 = "/eth at 10002000";
 		eth3 = &eth_3;
 		eth5 = &eth_5;
+		gpio1 = &gpio_a;
+		gpio2 = &gpio_b;
 		i2c0 = "/i2c at 0";
 		mmc0 = "/mmc0";
 		mmc1 = "/mmc1";
@@ -62,6 +64,15 @@
 		reg = <2 1>;
 	};
 
+	backlight: backlight {
+		compatible = "pwm-backlight";
+		enable-gpios = <&gpio_a 1>;
+		power-supply = <&ldo_1>;
+		pwms = <&pwm 0 1000>;
+		default-brightness-level = <5>;
+		brightness-levels = <0 16 32 64 128 170 202 234 255>;
+	};
+
 	bind-test {
 		bind-test-child1 {
 			compatible = "sandbox,phy";
@@ -412,12 +423,14 @@
 		power-domains = <&pwrdom 2>;
 	};
 
-	pwm {
+	pwm: pwm {
 		compatible = "sandbox,pwm";
+		#pwm-cells = <2>;
 	};
 
 	pwm2 {
 		compatible = "sandbox,pwm";
+		#pwm-cells = <2>;
 	};
 
 	ram {
@@ -454,6 +467,11 @@
 		remoteproc-name = "remoteproc-test-dev2";
 	};
 
+	panel {
+		compatible = "simple-panel";
+		backlight = <&backlight 0 100>;
+	};
+
 	smem at 0 {
 		compatible = "sandbox,smem";
 	};
diff --git a/arch/sandbox/include/asm/test.h b/arch/sandbox/include/asm/test.h
index 89f3d90c734..8e60f80ae7f 100644
--- a/arch/sandbox/include/asm/test.h
+++ b/arch/sandbox/include/asm/test.h
@@ -98,4 +98,19 @@ int sandbox_usb_keyb_add_string(struct udevice *dev, const char *str);
  * @buflen:	length of buffer in bytes
  */
 int sandbox_osd_get_mem(struct udevice *dev, u8 *buf, size_t buflen);
+
+/**
+ * sandbox_pwm_get_config() - get the PWM config for a channel
+ *
+ * @dev: Device to check
+ * @channel: Channel number to check
+ * @period_ns: Period of the PWM in nanoseconds
+ * @duty_ns: Current duty cycle of the PWM in nanoseconds
+ * @enable: true if the PWM is enabled
+ * @polarity: true if the PWM polarity is active high
+ * @return 0 if OK, -ENOSPC if the PWM number is invalid
+ */
+int sandbox_pwm_get_config(struct udevice *dev, uint channel, uint *period_nsp,
+			   uint *duty_nsp, bool *enablep, bool *polarityp);
+
 #endif
diff --git a/drivers/pwm/sandbox_pwm.c b/drivers/pwm/sandbox_pwm.c
index 4b50b19c618..28988187e03 100644
--- a/drivers/pwm/sandbox_pwm.c
+++ b/drivers/pwm/sandbox_pwm.c
@@ -14,6 +14,14 @@ enum {
 	NUM_CHANNELS	= 3,
 };
 
+/**
+ * struct sandbox_pwm_chan - a sandbox PWM channel
+ *
+ * @period_ns: Period of the PWM in nanoseconds
+ * @duty_ns: Current duty cycle of the PWM in nanoseconds
+ * @enable: true if the PWM is enabled
+ * @polarity: true if the PWM polarity is active high
+ */
 struct sandbox_pwm_chan {
 	uint period_ns;
 	uint duty_ns;
@@ -25,6 +33,23 @@ struct sandbox_pwm_priv {
 	struct sandbox_pwm_chan chan[NUM_CHANNELS];
 };
 
+int sandbox_pwm_get_config(struct udevice *dev, uint channel, uint *period_nsp,
+			   uint *duty_nsp, bool *enablep, bool *polarityp)
+{
+	struct sandbox_pwm_priv *priv = dev_get_priv(dev);
+	struct sandbox_pwm_chan *chan;
+
+	if (channel >= NUM_CHANNELS)
+		return -ENOSPC;
+	chan = &priv->chan[channel];
+	*period_nsp = chan->period_ns;
+	*duty_nsp = chan->duty_ns;
+	*enablep = chan->enable;
+	*polarityp = chan->polarity;
+
+	return 0;
+}
+
 static int sandbox_pwm_set_config(struct udevice *dev, uint channel,
 				  uint period_ns, uint duty_ns)
 {
diff --git a/test/dm/Makefile b/test/dm/Makefile
index 264f12633ff..2da762ddc8e 100644
--- a/test/dm/Makefile
+++ b/test/dm/Makefile
@@ -25,6 +25,7 @@ obj-$(CONFIG_DM_MAILBOX) += mailbox.o
 obj-$(CONFIG_DM_MMC) += mmc.o
 obj-y += ofnode.o
 obj-$(CONFIG_OSD) += osd.o
+obj-$(CONFIG_DM_VIDEO) += panel.o
 obj-$(CONFIG_DM_PCI) += pci.o
 obj-$(CONFIG_PHY) += phy.o
 obj-$(CONFIG_POWER_DOMAIN) += power-domain.o
diff --git a/test/dm/panel.c b/test/dm/panel.c
new file mode 100644
index 00000000000..ca032409f8c
--- /dev/null
+++ b/test/dm/panel.c
@@ -0,0 +1,50 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Test for panel uclass
+ *
+ * Copyright (c) 2018 Google, Inc
+ * Written by Simon Glass <sjg@chromium.org>
+ */
+
+#include <common.h>
+#include <backlight.h>
+#include <dm.h>
+#include <panel.h>
+#include <video.h>
+#include <asm/gpio.h>
+#include <asm/test.h>
+#include <dm/test.h>
+#include <test/ut.h>
+#include <power/regulator.h>
+
+/* Basic test of the panel uclass */
+static int dm_test_panel(struct unit_test_state *uts)
+{
+	struct udevice *dev, *pwm, *gpio, *reg;
+	uint period_ns;
+	uint duty_ns;
+	bool enable;
+	bool polarity;
+
+	ut_assertok(uclass_first_device_err(UCLASS_PANEL, &dev));
+	ut_assertok(uclass_first_device_err(UCLASS_PWM, &pwm));
+	ut_assertok(uclass_get_device(UCLASS_GPIO, 1, &gpio));
+	ut_assertok(regulator_get_by_platname("VDD_EMMC_1.8V", &reg));
+	ut_assertok(sandbox_pwm_get_config(pwm, 0, &period_ns, &duty_ns,
+					   &enable, &polarity));
+	ut_asserteq(false, enable);
+	ut_asserteq(false, regulator_get_enable(reg));
+
+	ut_assertok(panel_enable_backlight(dev));
+	ut_assertok(sandbox_pwm_get_config(pwm, 0, &period_ns, &duty_ns,
+					   &enable, &polarity));
+	ut_asserteq(1000, period_ns);
+	ut_asserteq(170 * 1000 / 256, duty_ns);
+	ut_asserteq(true, enable);
+	ut_asserteq(false, polarity);
+	ut_asserteq(1, sandbox_gpio_get_value(gpio, 1));
+	ut_asserteq(true, regulator_get_enable(reg));
+
+	return 0;
+}
+DM_TEST(dm_test_panel, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
-- 
2.19.0.605.g01d371f741-goog

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 37/45] panel: Expand the backlight support
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (35 preceding siblings ...)
  2018-10-01 18:22 ` [U-Boot] [PATCH 36/45] test: panel: Add a test for the panel uclass Simon Glass
@ 2018-10-01 18:22 ` Simon Glass
  2018-10-01 18:22 ` [U-Boot] [PATCH 38/45] ctags: Minor changes to fix ctags output Simon Glass
                   ` (47 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: Simon Glass @ 2018-10-01 18:22 UTC (permalink / raw)
  To: u-boot

At present the panel can be turned on but not off, and the brightness
cannot be controlled at run-time. Add a new API function to both the panel
and backlight uclasses to handle this. Enhance the PWM backlight driver
to deal with custom levels properly and allow the backlight to be turned
on and off.

Update the test to cover thes new features.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/video/backlight-uclass.c |  10 ++
 drivers/video/panel-uclass.c     |  18 +++
 drivers/video/pwm_backlight.c    | 186 +++++++++++++++++++++++++------
 drivers/video/simple_panel.c     |  20 +++-
 include/backlight.h              |  25 +++++
 include/panel.h                  |  22 +++-
 test/dm/panel.c                  |  29 +++++
 7 files changed, 273 insertions(+), 37 deletions(-)

diff --git a/drivers/video/backlight-uclass.c b/drivers/video/backlight-uclass.c
index 92715e2f130..0aadf8a1f97 100644
--- a/drivers/video/backlight-uclass.c
+++ b/drivers/video/backlight-uclass.c
@@ -18,6 +18,16 @@ int backlight_enable(struct udevice *dev)
 	return ops->enable(dev);
 }
 
+int backlight_set_brightness(struct udevice *dev, int percent)
+{
+	const struct backlight_ops *ops = backlight_get_ops(dev);
+
+	if (!ops->set_brightness)
+		return -ENOSYS;
+
+	return ops->set_brightness(dev, percent);
+}
+
 UCLASS_DRIVER(backlight) = {
 	.id		= UCLASS_PANEL_BACKLIGHT,
 	.name		= "backlight",
diff --git a/drivers/video/panel-uclass.c b/drivers/video/panel-uclass.c
index aec44a8bf7a..246d1b2836d 100644
--- a/drivers/video/panel-uclass.c
+++ b/drivers/video/panel-uclass.c
@@ -18,6 +18,24 @@ int panel_enable_backlight(struct udevice *dev)
 	return ops->enable_backlight(dev);
 }
 
+/**
+ * panel_set_backlight - Set brightness for the panel backlight
+ *
+ * @dev:	Panel device containing the backlight to update
+ * @percent:	Brightness value (0=off, 1=min brightness,
+ *		100=full brightness)
+ * @return 0 if OK, -ve on error
+ */
+int panel_set_backlight(struct udevice *dev, int percent)
+{
+	struct panel_ops *ops = panel_get_ops(dev);
+
+	if (!ops->set_backlight)
+		return -ENOSYS;
+
+	return ops->set_backlight(dev, percent);
+}
+
 int panel_get_display_timing(struct udevice *dev,
 			     struct display_timing *timings)
 {
diff --git a/drivers/video/pwm_backlight.c b/drivers/video/pwm_backlight.c
index 53953179bfb..33308ccbe63 100644
--- a/drivers/video/pwm_backlight.c
+++ b/drivers/video/pwm_backlight.c
@@ -4,6 +4,8 @@
  * Written by Simon Glass <sjg@chromium.org>
  */
 
+#define LOG_CATEGORY UCLASS_PANEL_BACKLIGHT
+
 #include <common.h>
 #include <dm.h>
 #include <backlight.h>
@@ -11,48 +13,155 @@
 #include <asm/gpio.h>
 #include <power/regulator.h>
 
+/**
+ * Private information for the PWM backlight
+ *
+ * If @num_levels is 0 then the levels are simple values with the backlight
+ * value going between the minimum (default 0) and the maximum (default 255).
+ * Otherwise the levels are an index into @levels (0..n-1).
+ *
+ * @reg: Regulator to enable to turn the backlight on (NULL if none)
+ * @enable, GPIO to set to enable the backlight (can be missing)
+ * @pwm: PWM to use to change the backlight brightness
+ * @channel: PWM channel to use
+ * @period_ns: Period of the backlight in nanoseconds
+ * @levels: Levels for the backlight, or NULL if not using indexed levels
+ * @num_levels: Number of levels
+ * @cur_level: Current level for the backlight (index or value)
+ * @default_level: Default level for the backlight (index or value)
+ * @min_level: Minimum level of the backlight (full off)
+ * @min_level: Maximum level of the backlight (full on)
+ * @enabled: true if backlight is enabled
+ */
 struct pwm_backlight_priv {
 	struct udevice *reg;
 	struct gpio_desc enable;
 	struct udevice *pwm;
 	uint channel;
 	uint period_ns;
+	u32 *levels;
+	int num_levels;
 	uint default_level;
+	int cur_level;
 	uint min_level;
 	uint max_level;
+	bool enabled;
 };
 
-static int pwm_backlight_enable(struct udevice *dev)
+static int set_pwm(struct pwm_backlight_priv *priv)
 {
-	struct pwm_backlight_priv *priv = dev_get_priv(dev);
-	struct dm_regulator_uclass_platdata *plat;
 	uint duty_cycle;
 	int ret;
 
-	if (priv->reg) {
-		plat = dev_get_uclass_platdata(priv->reg);
-		debug("%s: Enable '%s', regulator '%s'/'%s'\n", __func__,
-		      dev->name, priv->reg->name, plat->name);
-		ret = regulator_set_enable(priv->reg, true);
-		if (ret) {
-			debug("%s: Cannot enable regulator for PWM '%s'\n",
-			      __func__, dev->name);
-			return ret;
-		}
-		mdelay(120);
-	}
-
-	duty_cycle = priv->period_ns * (priv->default_level - priv->min_level) /
+	duty_cycle = priv->period_ns * (priv->cur_level - priv->min_level) /
 		(priv->max_level - priv->min_level + 1);
 	ret = pwm_set_config(priv->pwm, priv->channel, priv->period_ns,
 			     duty_cycle);
+
+	return log_ret(ret);
+}
+
+static int enable_sequence(struct udevice *dev, int seq)
+{
+	struct pwm_backlight_priv *priv = dev_get_priv(dev);
+	int ret;
+
+	switch (seq) {
+	case 0:
+		if (priv->reg) {
+			struct dm_regulator_uclass_platdata *plat;
+
+			plat = dev_get_uclass_platdata(priv->reg);
+			log_debug("Enable '%s', regulator '%s'/'%s'\n",
+				  dev->name, priv->reg->name, plat->name);
+			ret = regulator_set_enable(priv->reg, true);
+			if (ret) {
+				log_debug("Cannot enable regulator for PWM '%s'\n",
+					  __func__, dev->name);
+				return log_ret(ret);
+			}
+			mdelay(120);
+		}
+		break;
+	case 1:
+		mdelay(10);
+		dm_gpio_set_value(&priv->enable, 1);
+		break;
+	}
+
+	return 0;
+}
+
+static int pwm_backlight_enable(struct udevice *dev)
+{
+	struct pwm_backlight_priv *priv = dev_get_priv(dev);
+	int ret;
+
+	ret = enable_sequence(dev, 0);
+	if (ret)
+		return log_ret(ret);
+	ret = set_pwm(priv);
 	if (ret)
-		return ret;
+		return log_ret(ret);
 	ret = pwm_set_enable(priv->pwm, priv->channel, true);
 	if (ret)
-		return ret;
-	mdelay(10);
-	dm_gpio_set_value(&priv->enable, 1);
+		return log_ret(ret);
+	ret = enable_sequence(dev, 1);
+	if (ret)
+		return log_ret(ret);
+	priv->enabled = true;
+
+	return 0;
+}
+
+static int pwm_backlight_set_brightness(struct udevice *dev, int percent)
+{
+	struct pwm_backlight_priv *priv = dev_get_priv(dev);
+	bool disable = false;
+	int level;
+	int ret;
+
+	if (!priv->enabled) {
+		ret = enable_sequence(dev, 0);
+		if (ret)
+			return log_ret(ret);
+	}
+	if (percent == BACKLIGHT_OFF) {
+		disable = true;
+		percent = 0;
+	}
+	if (percent == BACKLIGHT_DEFAULT) {
+		level = priv->default_level;
+	} else {
+		if (priv->levels) {
+			level = priv->levels[percent * (priv->num_levels - 1)
+				/ 100];
+		} else {
+			level = priv->min_level +
+				(priv->max_level - priv->min_level) *
+				percent / 100;
+		}
+	}
+	priv->cur_level = level;
+
+	ret = set_pwm(priv);
+	if (ret)
+		return log_ret(ret);
+	if (!priv->enabled) {
+		ret = enable_sequence(dev, 1);
+		if (ret)
+			return log_ret(ret);
+		priv->enabled = true;
+	}
+	if (disable) {
+		dm_gpio_set_value(&priv->enable, 0);
+		if (priv->reg) {
+			ret = regulator_set_enable(priv->reg, false);
+			if (ret)
+				return log_ret(ret);
+		}
+		priv->enabled = false;
+	}
 
 	return 0;
 }
@@ -64,31 +173,32 @@ static int pwm_backlight_ofdata_to_platdata(struct udevice *dev)
 	int index, ret, count, len;
 	const u32 *cell;
 
-	debug("%s: start\n", __func__);
+	log_debug("start\n");
 	ret = uclass_get_device_by_phandle(UCLASS_REGULATOR, dev,
 					   "power-supply", &priv->reg);
 	if (ret)
-		debug("%s: Cannot get power supply: ret=%d\n", __func__, ret);
+		log_debug("Cannot get power supply: ret=%d\n", ret);
 	ret = gpio_request_by_name(dev, "enable-gpios", 0, &priv->enable,
 				   GPIOD_IS_OUT);
 	if (ret) {
-		debug("%s: Warning: cannot get enable GPIO: ret=%d\n",
-		      __func__, ret);
+		log_debug("Warning: cannot get enable GPIO: ret=%d\n", ret);
 		if (ret != -ENOENT)
-			return ret;
+			return log_ret(ret);
 	}
 	ret = dev_read_phandle_with_args(dev, "pwms", "#pwm-cells", 0, 0,
 					 &args);
 	if (ret) {
-		debug("%s: Cannot get PWM phandle: ret=%d\n", __func__, ret);
-		return ret;
+		log_debug("Cannot get PWM phandle: ret=%d\n", ret);
+		return log_ret(ret);
 	}
 
 	ret = uclass_get_device_by_ofnode(UCLASS_PWM, args.node, &priv->pwm);
 	if (ret) {
-		debug("%s: Cannot get PWM: ret=%d\n", __func__, ret);
-		return ret;
+		log_debug("Cannot get PWM: ret=%d\n", ret);
+		return log_ret(ret);
 	}
+	if (args.args_count < 2)
+		return log_msg_ret("Not enough arguments to pwm\n", -EINVAL);
 	priv->channel = args.args[0];
 	priv->period_ns = args.args[1];
 
@@ -96,13 +206,20 @@ static int pwm_backlight_ofdata_to_platdata(struct udevice *dev)
 	cell = dev_read_prop(dev, "brightness-levels", &len);
 	count = len / sizeof(u32);
 	if (cell && count > index) {
-		priv->default_level = fdt32_to_cpu(cell[index]);
-		priv->max_level = fdt32_to_cpu(cell[count - 1]);
+		priv->levels = malloc(len);
+		if (!priv->levels)
+			return log_ret(-ENOMEM);
+		dev_read_u32_array(dev, "brightness-levels", priv->levels,
+				   count);
+		priv->num_levels = count;
+		priv->default_level = priv->levels[index];
+		priv->max_level = priv->levels[count - 1];
 	} else {
 		priv->default_level = index;
 		priv->max_level = 255;
 	}
-	debug("%s: done\n", __func__);
+	priv->cur_level = priv->default_level;
+	log_debug("done\n");
 
 
 	return 0;
@@ -114,7 +231,8 @@ static int pwm_backlight_probe(struct udevice *dev)
 }
 
 static const struct backlight_ops pwm_backlight_ops = {
-	.enable	= pwm_backlight_enable,
+	.enable		= pwm_backlight_enable,
+	.set_brightness	= pwm_backlight_set_brightness,
 };
 
 static const struct udevice_id pwm_backlight_ids[] = {
diff --git a/drivers/video/simple_panel.c b/drivers/video/simple_panel.c
index 6c604f9bedb..7a968e740c5 100644
--- a/drivers/video/simple_panel.c
+++ b/drivers/video/simple_panel.c
@@ -32,6 +32,21 @@ static int simple_panel_enable_backlight(struct udevice *dev)
 	return 0;
 }
 
+static int simple_panel_set_backlight(struct udevice *dev, int percent)
+{
+	struct simple_panel_priv *priv = dev_get_priv(dev);
+	int ret;
+
+	debug("%s: start, backlight = '%s'\n", __func__, priv->backlight->name);
+	dm_gpio_set_value(&priv->enable, 1);
+	ret = backlight_set_brightness(priv->backlight, percent);
+	debug("%s: done, ret = %d\n", __func__, ret);
+	if (ret)
+		return ret;
+
+	return 0;
+}
+
 static int simple_panel_ofdata_to_platdata(struct udevice *dev)
 {
 	struct simple_panel_priv *priv = dev_get_priv(dev);
@@ -51,7 +66,7 @@ static int simple_panel_ofdata_to_platdata(struct udevice *dev)
 					   "backlight", &priv->backlight);
 	if (ret) {
 		debug("%s: Cannot get backlight: ret=%d\n", __func__, ret);
-		return ret;
+		return log_ret(ret);
 	}
 	ret = gpio_request_by_name(dev, "enable-gpios", 0, &priv->enable,
 				   GPIOD_IS_OUT);
@@ -59,7 +74,7 @@ static int simple_panel_ofdata_to_platdata(struct udevice *dev)
 		debug("%s: Warning: cannot get enable GPIO: ret=%d\n",
 		      __func__, ret);
 		if (ret != -ENOENT)
-			return ret;
+			return log_ret(ret);
 	}
 
 	return 0;
@@ -82,6 +97,7 @@ static int simple_panel_probe(struct udevice *dev)
 
 static const struct panel_ops simple_panel_ops = {
 	.enable_backlight	= simple_panel_enable_backlight,
+	.set_backlight		= simple_panel_set_backlight,
 };
 
 static const struct udevice_id simple_panel_ids[] = {
diff --git a/include/backlight.h b/include/backlight.h
index a304c36e019..ac59eb293b4 100644
--- a/include/backlight.h
+++ b/include/backlight.h
@@ -7,6 +7,13 @@
 #ifndef _BACKLIGHT_H
 #define _BACKLIGHT_H
 
+enum {
+	BACKLIGHT_MAX		= 100,
+	BACKLIGHT_MIN		= 0,
+	BACKLIGHT_OFF		= -1,
+	BACKLIGHT_DEFAULT	= -2,
+};
+
 struct backlight_ops {
 	/**
 	 * enable() - Enable a backlight
@@ -15,6 +22,15 @@ struct backlight_ops {
 	 * @return 0 if OK, -ve on error
 	 */
 	int (*enable)(struct udevice *dev);
+
+	/**
+	 * set_brightness - Set brightness
+	 *
+	 * @dev:	Backlight device to update
+	 * @percent:	Brightness value (0 to 100, or BACKLIGHT_... value)
+	 * @return 0 if OK, -ve on error
+	 */
+	int (*set_brightness)(struct udevice *dev, int percent);
 };
 
 #define backlight_get_ops(dev)	((struct backlight_ops *)(dev)->driver->ops)
@@ -27,4 +43,13 @@ struct backlight_ops {
  */
 int backlight_enable(struct udevice *dev);
 
+/**
+ * backlight_set_brightness - Set brightness
+ *
+ * @dev:	Backlight device to update
+ * @percent:	Brightness value (0 to 100, or BACKLIGHT_... value)
+ * @return 0 if OK, -ve on error
+ */
+int backlight_set_brightness(struct udevice *dev, int percent);
+
 #endif
diff --git a/include/panel.h b/include/panel.h
index 6237d32657d..cd596d48c02 100644
--- a/include/panel.h
+++ b/include/panel.h
@@ -15,6 +15,16 @@ struct panel_ops {
 	 * @return 0 if OK, -ve on error
 	 */
 	int (*enable_backlight)(struct udevice *dev);
+
+	/**
+	 * set_backlight - Set panel backlight brightness
+	 *
+	 * @dev:	Panel device containing the backlight to update
+	 * @percent:	Brightness value (0 to 100, or BACKLIGHT_... value)
+	 * @return 0 if OK, -ve on error
+	 */
+	int (*set_backlight)(struct udevice *dev, int percent);
+
 	/**
 	 * get_timings() - Get display timings from panel.
 	 *
@@ -29,13 +39,23 @@ struct panel_ops {
 #define panel_get_ops(dev)	((struct panel_ops *)(dev)->driver->ops)
 
 /**
- * panel_enable_backlight() - Enable the panel backlight
+ * panel_enable_backlight() - Enable/disable the panel backlight
  *
  * @dev:	Panel device containing the backlight to enable
+ * @enable:	true to enable the backlight, false to dis
  * @return 0 if OK, -ve on error
  */
 int panel_enable_backlight(struct udevice *dev);
 
+/**
+ * panel_set_backlight - Set brightness for the panel backlight
+ *
+ * @dev:	Panel device containing the backlight to update
+ * @percent:	Brightness value (0 to 100, or BACKLIGHT_... value)
+ * @return 0 if OK, -ve on error
+ */
+int panel_set_backlight(struct udevice *dev, int percent);
+
 /**
  * panel_get_display_timing() - Get display timings from panel.
  *
diff --git a/test/dm/panel.c b/test/dm/panel.c
index ca032409f8c..7e4ebd6d81e 100644
--- a/test/dm/panel.c
+++ b/test/dm/panel.c
@@ -45,6 +45,35 @@ static int dm_test_panel(struct unit_test_state *uts)
 	ut_asserteq(1, sandbox_gpio_get_value(gpio, 1));
 	ut_asserteq(true, regulator_get_enable(reg));
 
+	ut_assertok(panel_set_backlight(dev, 40));
+	ut_assertok(sandbox_pwm_get_config(pwm, 0, &period_ns, &duty_ns,
+					   &enable, &polarity));
+	ut_asserteq(64 * 1000 / 256, duty_ns);
+
+	ut_assertok(panel_set_backlight(dev, BACKLIGHT_MAX));
+	ut_assertok(sandbox_pwm_get_config(pwm, 0, &period_ns, &duty_ns,
+					   &enable, &polarity));
+	ut_asserteq(255 * 1000 / 256, duty_ns);
+
+	ut_assertok(panel_set_backlight(dev, BACKLIGHT_MIN));
+	ut_assertok(sandbox_pwm_get_config(pwm, 0, &period_ns, &duty_ns,
+					   &enable, &polarity));
+	ut_asserteq(0 * 1000 / 256, duty_ns);
+	ut_asserteq(1, sandbox_gpio_get_value(gpio, 1));
+
+	ut_assertok(panel_set_backlight(dev, BACKLIGHT_DEFAULT));
+	ut_assertok(sandbox_pwm_get_config(pwm, 0, &period_ns, &duty_ns,
+					   &enable, &polarity));
+	ut_asserteq(true, enable);
+	ut_asserteq(170 * 1000 / 256, duty_ns);
+
+	ut_assertok(panel_set_backlight(dev, BACKLIGHT_OFF));
+	ut_assertok(sandbox_pwm_get_config(pwm, 0, &period_ns, &duty_ns,
+					   &enable, &polarity));
+	ut_asserteq(0 * 1000 / 256, duty_ns);
+	ut_asserteq(0, sandbox_gpio_get_value(gpio, 1));
+	ut_asserteq(false, regulator_get_enable(reg));
+
 	return 0;
 }
 DM_TEST(dm_test_panel, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
-- 
2.19.0.605.g01d371f741-goog

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 38/45] ctags: Minor changes to fix ctags output
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (36 preceding siblings ...)
  2018-10-01 18:22 ` [U-Boot] [PATCH 37/45] panel: Expand the backlight support Simon Glass
@ 2018-10-01 18:22 ` Simon Glass
  2018-10-01 18:22 ` [U-Boot] [PATCH 39/45] fdt: Allow C++ comments in link scripts and DT files Simon Glass
                   ` (46 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: Simon Glass @ 2018-10-01 18:22 UTC (permalink / raw)
  To: u-boot

At present ctags emits lines with unmatched quotes which means that the
output file is invalid. This is with exuberant-ctags version 5.9~svn201103
but I also see it with plain ctags. I am not sure that it is a bug though.

Make a few minor changes in the source code to fix this problem.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/video/tegra124/sor.c | 3 ++-
 include/linux/compiler-gcc.h | 6 ++++--
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/video/tegra124/sor.c b/drivers/video/tegra124/sor.c
index 91e61b58527..172bb14d6c8 100644
--- a/drivers/video/tegra124/sor.c
+++ b/drivers/video/tegra124/sor.c
@@ -533,7 +533,8 @@ static int tegra_dc_sor_power_up(struct udevice *dev, int is_lvds)
 #if DEBUG_SOR
 static void dump_sor_reg(struct tegra_dc_sor_data *sor)
 {
-#define DUMP_REG(a) printk(BIOS_INFO, "%-32s  %03x  %08x\n",		\
+#define DUMP_REG(a) printk(BIOS_INFO, \
+		"%-32s  %03x  %08x\n",		\
 		#a, a, tegra_sor_readl(sor, a));
 
 	DUMP_REG(SUPER_STATE0);
diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
index 22ab246feed..8d9e0794351 100644
--- a/include/linux/compiler-gcc.h
+++ b/include/linux/compiler-gcc.h
@@ -12,7 +12,8 @@
 /* Optimization barrier */
 
 /* The "volatile" is due to gcc bugs */
-#define barrier() __asm__ __volatile__("": : :"memory")
+#define barrier() \
+	__asm__ __volatile__("": : :"memory")
 /*
  * This version is i.e. to prevent dead stores elimination on @ptr
  * where gcc and llvm may behave differently when otherwise using
@@ -26,7 +27,8 @@
  * the compiler that the inline asm absolutely may see the contents
  * of @ptr. See also: https://llvm.org/bugs/show_bug.cgi?id=15495
  */
-#define barrier_data(ptr) __asm__ __volatile__("": :"r"(ptr) :"memory")
+#define barrier_data(ptr) \
+	__asm__ __volatile__("": :"r"(ptr) :"memory")
 
 /*
  * This macro obfuscates arithmetic on a variable address so that gcc
-- 
2.19.0.605.g01d371f741-goog

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 39/45] fdt: Allow C++ comments in link scripts and DT files
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (37 preceding siblings ...)
  2018-10-01 18:22 ` [U-Boot] [PATCH 38/45] ctags: Minor changes to fix ctags output Simon Glass
@ 2018-10-01 18:22 ` Simon Glass
  2018-10-01 18:22 ` [U-Boot] [PATCH 40/45] pci: Add a little more debugging to pci_rom Simon Glass
                   ` (45 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: Simon Glass @ 2018-10-01 18:22 UTC (permalink / raw)
  To: u-boot

At present // in a device-tree file or link script causes a warning. But
this is used in the standard license header. Update the compiler flags to
use C99, which permits this.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 Makefile             | 2 +-
 scripts/Makefile.spl | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index f578cce3663..5d4533b4243 100644
--- a/Makefile
+++ b/Makefile
@@ -1521,7 +1521,7 @@ $(defaultenv_h): $(CONFIG_DEFAULT_ENV_FILE:"%"=%) FORCE
 # ---------------------------------------------------------------------------
 quiet_cmd_cpp_lds = LDS     $@
 cmd_cpp_lds = $(CPP) -Wp,-MD,$(depfile) $(cpp_flags) $(LDPPFLAGS) \
-		-D__ASSEMBLY__ -x assembler-with-cpp -P -o $@ $<
+		-D__ASSEMBLY__ -x assembler-with-cpp -std=c99 -P -o $@ $<
 
 u-boot.lds: $(LDSCRIPT) prepare FORCE
 	$(call if_changed_dep,cpp_lds)
diff --git a/scripts/Makefile.spl b/scripts/Makefile.spl
index c71497ff008..7416abec62e 100644
--- a/scripts/Makefile.spl
+++ b/scripts/Makefile.spl
@@ -371,7 +371,7 @@ $(u-boot-spl-dirs): $(u-boot-spl-platdata)
 
 quiet_cmd_cpp_lds = LDS     $@
 cmd_cpp_lds = $(CPP) -Wp,-MD,$(depfile) $(cpp_flags) $(LDPPFLAGS) -ansi \
-		-D__ASSEMBLY__ -x assembler-with-cpp -P -o $@ $<
+		-D__ASSEMBLY__ -x assembler-with-cpp -std=c99 -P -o $@ $<
 
 $(obj)/u-boot-spl.lds: $(LDSCRIPT) FORCE
 	$(call if_changed_dep,cpp_lds)
-- 
2.19.0.605.g01d371f741-goog

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 40/45] pci: Add a little more debugging to pci_rom
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (38 preceding siblings ...)
  2018-10-01 18:22 ` [U-Boot] [PATCH 39/45] fdt: Allow C++ comments in link scripts and DT files Simon Glass
@ 2018-10-01 18:22 ` Simon Glass
  2018-10-02 13:37   ` Bin Meng
  2018-10-09 23:54   ` sjg at google.com
  2018-10-01 18:22 ` [U-Boot] [PATCH 41/45] sysreset: Tidy up a few comments and logging Simon Glass
                   ` (44 subsequent siblings)
  84 siblings, 2 replies; 106+ messages in thread
From: Simon Glass @ 2018-10-01 18:22 UTC (permalink / raw)
  To: u-boot

Add some logging on failure.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/pci/pci_rom.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/pci_rom.c b/drivers/pci/pci_rom.c
index 29113f79586..eaacd4066e8 100644
--- a/drivers/pci/pci_rom.c
+++ b/drivers/pci/pci_rom.c
@@ -247,7 +247,7 @@ int dm_pci_run_vga_bios(struct udevice *dev, int (*int15_handler)(void),
 	}
 
 	if (!board_should_load_oprom(dev))
-		return -ENXIO;
+		return log_msg_ret("Should not load OPROM", -ENXIO);
 
 	ret = pci_rom_probe(dev, &rom);
 	if (ret)
@@ -328,7 +328,7 @@ int vbe_setup_video_priv(struct vesa_mode_info *vesa,
 			 struct video_uc_platdata *plat)
 {
 	if (!vesa->x_resolution)
-		return -ENXIO;
+		return log_msg_ret("No x resolution", -ENXIO);
 	uc_priv->xsize = vesa->x_resolution;
 	uc_priv->ysize = vesa->y_resolution;
 	switch (vesa->bits_per_pixel) {
-- 
2.19.0.605.g01d371f741-goog

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 41/45] sysreset: Tidy up a few comments and logging
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (39 preceding siblings ...)
  2018-10-01 18:22 ` [U-Boot] [PATCH 40/45] pci: Add a little more debugging to pci_rom Simon Glass
@ 2018-10-01 18:22 ` Simon Glass
  2018-10-01 18:22 ` [U-Boot] [PATCH 42/45] sysreset: Add a way to find the last reset Simon Glass
                   ` (43 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: Simon Glass @ 2018-10-01 18:22 UTC (permalink / raw)
  To: u-boot

Some comments are incorrect or missing pieces. Fix these and use logging
to print the error.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/sysreset/sysreset-uclass.c | 4 +++-
 include/sysreset.h                 | 4 +++-
 test/dm/sysreset.c                 | 1 -
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/sysreset/sysreset-uclass.c b/drivers/sysreset/sysreset-uclass.c
index 06ef0ed96c7..e38814b3ed1 100644
--- a/drivers/sysreset/sysreset-uclass.c
+++ b/drivers/sysreset/sysreset-uclass.c
@@ -4,6 +4,8 @@
  * Written by Simon Glass <sjg@chromium.org>
  */
 
+#define LOG_CATEGORY UCLASS_SYSRESET
+
 #include <common.h>
 #include <sysreset.h>
 #include <dm.h>
@@ -64,7 +66,7 @@ void sysreset_walk_halt(enum sysreset_t type)
 		mdelay(100);
 
 	/* Still no reset? Give up */
-	debug("System reset not supported on this platform\n");
+	log_err("System reset not supported on this platform\n");
 	hang();
 }
 
diff --git a/include/sysreset.h b/include/sysreset.h
index a5c0b74a473..343e46f1aa5 100644
--- a/include/sysreset.h
+++ b/include/sysreset.h
@@ -31,6 +31,7 @@ struct sysreset_ops {
 	/**
 	 * get_status() - get printable reset status information
 	 *
+	 * @dev:	Device to check
 	 * @buf:	Buffer to receive the textual reset information
 	 * @size:	Size of the passed buffer
 	 * @return 0 if OK, -ve on error
@@ -49,8 +50,9 @@ struct sysreset_ops {
 int sysreset_request(struct udevice *dev, enum sysreset_t type);
 
 /**
- * get_status() - get printable reset status information
+ * sysreset_get_status() - get printable reset status information
  *
+ * @dev:	Device to check
  * @buf:	Buffer to receive the textual reset information
  * @size:	Size of the passed buffer
  * @return 0 if OK, -ve on error
diff --git a/test/dm/sysreset.c b/test/dm/sysreset.c
index 04d4621d9e1..218cc239cc6 100644
--- a/test/dm/sysreset.c
+++ b/test/dm/sysreset.c
@@ -62,7 +62,6 @@ static int dm_test_sysreset_get_status(struct unit_test_state *uts)
 
 	return 0;
 }
-
 DM_TEST(dm_test_sysreset_get_status, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
 
 /* Test that we can walk through the sysreset devices */
-- 
2.19.0.605.g01d371f741-goog

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 42/45] sysreset: Add a way to find the last reset
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (40 preceding siblings ...)
  2018-10-01 18:22 ` [U-Boot] [PATCH 41/45] sysreset: Tidy up a few comments and logging Simon Glass
@ 2018-10-01 18:22 ` Simon Glass
  2018-10-01 18:22 ` [U-Boot] [PATCH 43/45] video: at91: Adjust vidconsole_position_cursor() to use char pos Simon Glass
                   ` (42 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: Simon Glass @ 2018-10-01 18:22 UTC (permalink / raw)
  To: u-boot

We have a method to return the last reset as a string for humans, but not
a method that allows it to be used programmatically. Add a new method that
returns the last reset as an enum.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/sysreset/sysreset-uclass.c  | 30 +++++++++++++++++++++++++++++
 drivers/sysreset/sysreset_sandbox.c | 12 ++++++++++++
 include/sysreset.h                  | 30 +++++++++++++++++++++++++++++
 test/dm/sysreset.c                  | 19 ++++++++++++++++++
 4 files changed, 91 insertions(+)

diff --git a/drivers/sysreset/sysreset-uclass.c b/drivers/sysreset/sysreset-uclass.c
index e38814b3ed1..ad831c703a9 100644
--- a/drivers/sysreset/sysreset-uclass.c
+++ b/drivers/sysreset/sysreset-uclass.c
@@ -36,6 +36,16 @@ int sysreset_get_status(struct udevice *dev, char *buf, int size)
 	return ops->get_status(dev, buf, size);
 }
 
+int sysreset_get_last(struct udevice *dev)
+{
+	struct sysreset_ops *ops = sysreset_get_ops(dev);
+
+	if (!ops->get_last)
+		return -ENOSYS;
+
+	return ops->get_last(dev);
+}
+
 int sysreset_walk(enum sysreset_t type)
 {
 	struct udevice *dev;
@@ -55,6 +65,26 @@ int sysreset_walk(enum sysreset_t type)
 	return ret;
 }
 
+int sysreset_get_last_walk(void)
+{
+	struct udevice *dev;
+	int value = -ENOENT;
+
+	for (uclass_first_device(UCLASS_SYSRESET, &dev);
+	     dev;
+	     uclass_next_device(&dev)) {
+		int ret;
+
+		ret = sysreset_get_last(dev);
+		if (ret >= 0) {
+			value = ret;
+			break;
+		}
+	}
+
+	return value;
+}
+
 void sysreset_walk_halt(enum sysreset_t type)
 {
 	int ret;
diff --git a/drivers/sysreset/sysreset_sandbox.c b/drivers/sysreset/sysreset_sandbox.c
index 75004d9f774..51252f7f71b 100644
--- a/drivers/sysreset/sysreset_sandbox.c
+++ b/drivers/sysreset/sysreset_sandbox.c
@@ -36,6 +36,11 @@ int sandbox_warm_sysreset_get_status(struct udevice *dev, char *buf, int size)
 	return 0;
 }
 
+int sandbox_warm_sysreset_get_last(struct udevice *dev)
+{
+	return SYSRESET_WARM;
+}
+
 static int sandbox_sysreset_request(struct udevice *dev, enum sysreset_t type)
 {
 	struct sandbox_state *state = state_get_current();
@@ -74,9 +79,15 @@ int sandbox_sysreset_get_status(struct udevice *dev, char *buf, int size)
 	return 0;
 }
 
+int sandbox_sysreset_get_last(struct udevice *dev)
+{
+	return SYSRESET_COLD;
+}
+
 static struct sysreset_ops sandbox_sysreset_ops = {
 	.request	= sandbox_sysreset_request,
 	.get_status	= sandbox_sysreset_get_status,
+	.get_last	= sandbox_sysreset_get_last,
 };
 
 static const struct udevice_id sandbox_sysreset_ids[] = {
@@ -94,6 +105,7 @@ U_BOOT_DRIVER(sysreset_sandbox) = {
 static struct sysreset_ops sandbox_warm_sysreset_ops = {
 	.request	= sandbox_warm_sysreset_request,
 	.get_status	= sandbox_warm_sysreset_get_status,
+	.get_last	= sandbox_warm_sysreset_get_last,
 };
 
 static const struct udevice_id sandbox_warm_sysreset_ids[] = {
diff --git a/include/sysreset.h b/include/sysreset.h
index 343e46f1aa5..61295e3fcbb 100644
--- a/include/sysreset.h
+++ b/include/sysreset.h
@@ -11,6 +11,7 @@ enum sysreset_t {
 	SYSRESET_WARM,	/* Reset CPU, keep GPIOs active */
 	SYSRESET_COLD,	/* Reset CPU and GPIOs */
 	SYSRESET_POWER,	/* Reset PMIC (remove and restore power) */
+	SYSRESET_POWER_OFF,	/* Turn off power */
 
 	SYSRESET_COUNT,
 };
@@ -37,6 +38,14 @@ struct sysreset_ops {
 	 * @return 0 if OK, -ve on error
 	 */
 	int (*get_status)(struct udevice *dev, char *buf, int size);
+
+	/**
+	 * get_last() - get information on the last reset
+	 *
+	 * @dev:	Device to check
+	 * @return last reset state (enum sysreset_t) or -ve error
+	 */
+	int (*get_last)(struct udevice *dev);
 };
 
 #define sysreset_get_ops(dev)        ((struct sysreset_ops *)(dev)->driver->ops)
@@ -59,6 +68,14 @@ int sysreset_request(struct udevice *dev, enum sysreset_t type);
  */
 int sysreset_get_status(struct udevice *dev, char *buf, int size);
 
+/**
+ * sysreset_get_last() - get information on the last reset
+ *
+ * @dev:	Device to check
+ * @return last reset state (enum sysreset_t) or -ve error
+ */
+int sysreset_get_last(struct udevice *dev);
+
 /**
  * sysreset_walk() - cause a system reset
  *
@@ -73,6 +90,19 @@ int sysreset_get_status(struct udevice *dev, char *buf, int size);
  */
 int sysreset_walk(enum sysreset_t type);
 
+/**
+ * sysreset_get_last_walk() - get information on the last reset
+ *
+ * This works through the available sysreset devices until it finds one that can
+ * perform a reset. If the provided sysreset type is not available, the next one
+ * will be tried.
+ *
+ * If no device prives the information, this function returns -ENOENT
+ *
+ * @return last reset state (enum sysreset_t) or -ve error
+ */
+int sysreset_get_last_walk(void);
+
 /**
  * sysreset_walk_halt() - try to reset, otherwise halt
  *
diff --git a/test/dm/sysreset.c b/test/dm/sysreset.c
index 218cc239cc6..a4607fa857e 100644
--- a/test/dm/sysreset.c
+++ b/test/dm/sysreset.c
@@ -90,3 +90,22 @@ static int dm_test_sysreset_walk(struct unit_test_state *uts)
 	return 0;
 }
 DM_TEST(dm_test_sysreset_walk, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
+static int dm_test_sysreset_get_last(struct unit_test_state *uts)
+{
+	struct udevice *dev;
+
+	/* Device 1 is the warm sysreset device */
+	ut_assertok(uclass_get_device(UCLASS_SYSRESET, 1, &dev));
+	ut_asserteq(SYSRESET_WARM, sysreset_get_last(dev));
+
+	/* Device 2 is the cold sysreset device */
+	ut_assertok(uclass_get_device(UCLASS_SYSRESET, 2, &dev));
+	ut_asserteq(SYSRESET_COLD, sysreset_get_last(dev));
+
+	/* This is device 0, the non-DT one */
+	ut_asserteq(SYSRESET_COLD, sysreset_get_last_walk());
+
+	return 0;
+}
+DM_TEST(dm_test_sysreset_get_last, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
-- 
2.19.0.605.g01d371f741-goog

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 43/45] video: at91: Adjust vidconsole_position_cursor() to use char pos
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (41 preceding siblings ...)
  2018-10-01 18:22 ` [U-Boot] [PATCH 42/45] sysreset: Add a way to find the last reset Simon Glass
@ 2018-10-01 18:22 ` Simon Glass
  2018-10-01 20:22   ` Anatolij Gustschin
  2018-10-01 18:22 ` [U-Boot] [PATCH 44/45] video: Tidy up a few comments in video.o Simon Glass
                   ` (41 subsequent siblings)
  84 siblings, 1 reply; 106+ messages in thread
From: Simon Glass @ 2018-10-01 18:22 UTC (permalink / raw)
  To: u-boot

At present this function uses pixels but it seems more useful for it to
position in terms of characters on the screen. This also matches the
comment to the function. Update this.

Unfortunately there is one user of this function (at91). Have a crack at
fixing this, since I cannot test it.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 board/atmel/common/video_display.c | 5 ++++-
 drivers/video/vidconsole-uclass.c  | 2 ++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/board/atmel/common/video_display.c b/board/atmel/common/video_display.c
index 7dd7b85556e..e02cb00f866 100644
--- a/board/atmel/common/video_display.c
+++ b/board/atmel/common/video_display.c
@@ -18,6 +18,7 @@ DECLARE_GLOBAL_DATA_PTR;
 
 int at91_video_show_board_info(void)
 {
+	struct vidconsole_priv *priv;
 	ulong dram_size, nand_size;
 	int i;
 	u32 len = 0;
@@ -63,7 +64,9 @@ int at91_video_show_board_info(void)
 	if (ret)
 		return ret;
 
-	vidconsole_position_cursor(con, 0, logo_info.logo_height);
+	priv = dev_get_uclass_priv(con);
+	vidconsole_position_cursor(con, 0, (logo_info.logo_height +
+				   con->y_charsize - 1) / con->y_charsize);
 	for (s = buf, i = 0; i < len; s++, i++)
 		vidconsole_put_char(con, *s);
 
diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c
index 89ac8b3cc8f..1874887f2f3 100644
--- a/drivers/video/vidconsole-uclass.c
+++ b/drivers/video/vidconsole-uclass.c
@@ -511,6 +511,8 @@ void vidconsole_position_cursor(struct udevice *dev, unsigned col, unsigned row)
 	struct udevice *vid_dev = dev->parent;
 	struct video_priv *vid_priv = dev_get_uclass_priv(vid_dev);
 
+	col *= priv->x_charsize;
+	row *= priv->y_charsize;
 	priv->xcur_frac = VID_TO_POS(min_t(short, col, vid_priv->xsize - 1));
 	priv->ycur = min_t(short, row, vid_priv->ysize - 1);
 }
-- 
2.19.0.605.g01d371f741-goog

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 44/45] video: Tidy up a few comments in video.o
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (42 preceding siblings ...)
  2018-10-01 18:22 ` [U-Boot] [PATCH 43/45] video: at91: Adjust vidconsole_position_cursor() to use char pos Simon Glass
@ 2018-10-01 18:22 ` Simon Glass
  2018-10-01 19:25   ` Anatolij Gustschin
  2018-10-09 23:54   ` sjg at google.com
  2018-10-01 18:22 ` [U-Boot] [PATCH 45/45] dtoc: Fix the value of SetInt() Simon Glass
                   ` (40 subsequent siblings)
  84 siblings, 2 replies; 106+ messages in thread
From: Simon Glass @ 2018-10-01 18:22 UTC (permalink / raw)
  To: u-boot

Add a little more information to one comment and update the guard comment
to be more accurate.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 include/video.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/video.h b/include/video.h
index ab416c1cfac..75200f0e452 100644
--- a/include/video.h
+++ b/include/video.h
@@ -55,7 +55,7 @@ enum video_log2_bpp {
  * @xsize:	Number of pixel columns (e.g. 1366)
  * @ysize:	Number of pixels rows (e.g.. 768)
  * @rot:	Display rotation (0=none, 1=90 degrees clockwise, etc.)
- * @bpix:	Encoded bits per pixel
+ * @bpix:	Encoded bits per pixel (enum video_log2_bpp)
  * @vidconsole_drv_name:	Driver to use for the text console, NULL to
  *		select automatically
  * @font_size:	Font size in pixels (0 to use a default value)
@@ -269,6 +269,6 @@ int lg4573_spi_startup(unsigned int bus, unsigned int cs,
  */
 void video_get_info_str(int line_number, char *info);
 
-#endif /* CONFIG_DM_VIDEO */
+#endif /* !CONFIG_DM_VIDEO */
 
 #endif
-- 
2.19.0.605.g01d371f741-goog

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 45/45] dtoc: Fix the value of SetInt()
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (43 preceding siblings ...)
  2018-10-01 18:22 ` [U-Boot] [PATCH 44/45] video: Tidy up a few comments in video.o Simon Glass
@ 2018-10-01 18:22 ` Simon Glass
  2018-10-09 23:54 ` sjg at google.com
                   ` (39 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: Simon Glass @ 2018-10-01 18:22 UTC (permalink / raw)
  To: u-boot

This does not set the correct value at present. Fix it.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 tools/dtoc/fdt.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/dtoc/fdt.py b/tools/dtoc/fdt.py
index 2df2d4b0cc7..9ad72f89ec7 100644
--- a/tools/dtoc/fdt.py
+++ b/tools/dtoc/fdt.py
@@ -171,7 +171,7 @@ class Prop:
             val: Integer value (32-bit, single cell)
         """
         self.bytes = struct.pack('>I', val);
-        self.value = val
+        self.value = self.bytes
         self.type = TYPE_INT
         self.dirty = True
 
-- 
2.19.0.605.g01d371f741-goog

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 22/45] video: Adjust video_clear() to return an error
  2018-10-01 18:22 ` [U-Boot] [PATCH 22/45] video: Adjust video_clear() to return an error Simon Glass
@ 2018-10-01 19:23   ` Anatolij Gustschin
  2018-10-09 23:55   ` sjg at google.com
  1 sibling, 0 replies; 106+ messages in thread
From: Anatolij Gustschin @ 2018-10-01 19:23 UTC (permalink / raw)
  To: u-boot

On Mon,  1 Oct 2018 12:22:26 -0600
Simon Glass sjg at chromium.org wrote:

> All driver-model operation should return an error code. Adjust this
> function to do so also.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>

Reviewed-by: Anatolij Gustschin <agust@denx.de>

--
Anatolij

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 44/45] video: Tidy up a few comments in video.o
  2018-10-01 18:22 ` [U-Boot] [PATCH 44/45] video: Tidy up a few comments in video.o Simon Glass
@ 2018-10-01 19:25   ` Anatolij Gustschin
  2018-10-09 23:54   ` sjg at google.com
  1 sibling, 0 replies; 106+ messages in thread
From: Anatolij Gustschin @ 2018-10-01 19:25 UTC (permalink / raw)
  To: u-boot

On Mon,  1 Oct 2018 12:22:48 -0600
Simon Glass sjg at chromium.org wrote:

> Add a little more information to one comment and update the guard comment
> to be more accurate.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>

Reviewed-by: Anatolij Gustschin <agust@denx.de>

--
Anatolij

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 43/45] video: at91: Adjust vidconsole_position_cursor() to use char pos
  2018-10-01 18:22 ` [U-Boot] [PATCH 43/45] video: at91: Adjust vidconsole_position_cursor() to use char pos Simon Glass
@ 2018-10-01 20:22   ` Anatolij Gustschin
  2018-10-02  7:37     ` Eugen Hristev
  2018-10-09  3:41     ` Simon Glass
  0 siblings, 2 replies; 106+ messages in thread
From: Anatolij Gustschin @ 2018-10-01 20:22 UTC (permalink / raw)
  To: u-boot

Hi Simon,

On Mon,  1 Oct 2018 12:22:47 -0600
Simon Glass sjg at chromium.org wrote:

> At present this function uses pixels but it seems more useful for it to
> position in terms of characters on the screen. This also matches the
> comment to the function. Update this.
> 
> Unfortunately there is one user of this function (at91). Have a crack at
> fixing this, since I cannot test it.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>

Reviewed-by: Anatolij Gustschin <agust@denx.de>

> ---
> 
>  board/atmel/common/video_display.c | 5 ++++-
>  drivers/video/vidconsole-uclass.c  | 2 ++
>  2 files changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/board/atmel/common/video_display.c b/board/atmel/common/video_display.c
> index 7dd7b85556e..e02cb00f866 100644
> --- a/board/atmel/common/video_display.c
> +++ b/board/atmel/common/video_display.c
> @@ -18,6 +18,7 @@ DECLARE_GLOBAL_DATA_PTR;
>  
>  int at91_video_show_board_info(void)
>  {
> +	struct vidconsole_priv *priv;
>  	ulong dram_size, nand_size;
>  	int i;
>  	u32 len = 0;
> @@ -63,7 +64,9 @@ int at91_video_show_board_info(void)
>  	if (ret)
>  		return ret;
>  
> -	vidconsole_position_cursor(con, 0, logo_info.logo_height);
> +	priv = dev_get_uclass_priv(con);
> +	vidconsole_position_cursor(con, 0, (logo_info.logo_height +
> +				   con->y_charsize - 1) / con->y_charsize);

Shouldn't it be priv->y_charsize? 'con' is struct udevice * and doesn't
have y_charsize.


--
Anatolij

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 43/45] video: at91: Adjust vidconsole_position_cursor() to use char pos
  2018-10-01 20:22   ` Anatolij Gustschin
@ 2018-10-02  7:37     ` Eugen Hristev
  2018-10-09  3:40       ` Simon Glass
  2018-10-09  3:41     ` Simon Glass
  1 sibling, 1 reply; 106+ messages in thread
From: Eugen Hristev @ 2018-10-02  7:37 UTC (permalink / raw)
  To: u-boot



On 01.10.2018 23:22, Anatolij Gustschin wrote:
> Hi Simon,
> 
> On Mon,  1 Oct 2018 12:22:47 -0600
> Simon Glass sjg at chromium.org wrote:
> 
>> At present this function uses pixels but it seems more useful for it to
>> position in terms of characters on the screen. This also matches the
>> comment to the function. Update this.
>>
>> Unfortunately there is one user of this function (at91). Have a crack at
>> fixing this, since I cannot test it.

Hello Simon,

I will gladly test this for you on at91 board,
but I am having some issues applying your patch series:

Applying: binman: Move to three-digit test-file numbers
error: patch failed: tools/binman/entry_test.py:25
error: tools/binman/entry_test.py: patch does not apply
error: patch failed: tools/binman/ftest.py:712
error: tools/binman/ftest.py: patch does not apply
Patch failed at 0026 binman: Move to three-digit test-file numbers

Do you have them in some public tree I can pull from ?

Also, any specific tests you would like except just checking the video 
console ?

Eugen


>>
>> Signed-off-by: Simon Glass <sjg@chromium.org>
> 
> Reviewed-by: Anatolij Gustschin <agust@denx.de>
> 
>> ---
>>
>>   board/atmel/common/video_display.c | 5 ++++-
>>   drivers/video/vidconsole-uclass.c  | 2 ++
>>   2 files changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/board/atmel/common/video_display.c b/board/atmel/common/video_display.c
>> index 7dd7b85556e..e02cb00f866 100644
>> --- a/board/atmel/common/video_display.c
>> +++ b/board/atmel/common/video_display.c
>> @@ -18,6 +18,7 @@ DECLARE_GLOBAL_DATA_PTR;
>>   
>>   int at91_video_show_board_info(void)
>>   {
>> +	struct vidconsole_priv *priv;
>>   	ulong dram_size, nand_size;
>>   	int i;
>>   	u32 len = 0;
>> @@ -63,7 +64,9 @@ int at91_video_show_board_info(void)
>>   	if (ret)
>>   		return ret;
>>   
>> -	vidconsole_position_cursor(con, 0, logo_info.logo_height);
>> +	priv = dev_get_uclass_priv(con);
>> +	vidconsole_position_cursor(con, 0, (logo_info.logo_height +
>> +				   con->y_charsize - 1) / con->y_charsize);
> 
> Shouldn't it be priv->y_charsize? 'con' is struct udevice * and doesn't
> have y_charsize.
> 
> 
> --
> Anatolij
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> https://lists.denx.de/listinfo/u-boot
> 

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 40/45] pci: Add a little more debugging to pci_rom
  2018-10-01 18:22 ` [U-Boot] [PATCH 40/45] pci: Add a little more debugging to pci_rom Simon Glass
@ 2018-10-02 13:37   ` Bin Meng
  2018-10-09 23:54   ` sjg at google.com
  1 sibling, 0 replies; 106+ messages in thread
From: Bin Meng @ 2018-10-02 13:37 UTC (permalink / raw)
  To: u-boot

On Tue, Oct 2, 2018 at 2:48 AM Simon Glass <sjg@chromium.org> wrote:
>
> Add some logging on failure.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>  drivers/pci/pci_rom.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 33/45] x86: Update mtrr functions to allow leaving cache alone
  2018-10-01 18:22 ` [U-Boot] [PATCH 33/45] x86: Update mtrr functions to allow leaving cache alone Simon Glass
@ 2018-10-02 13:41   ` Bin Meng
  2018-10-09 23:54   ` sjg at google.com
  1 sibling, 0 replies; 106+ messages in thread
From: Bin Meng @ 2018-10-02 13:41 UTC (permalink / raw)
  To: u-boot

On Tue, Oct 2, 2018 at 2:24 AM Simon Glass <sjg@chromium.org> wrote:
>
> At present the mtrr functions disable the cache before making changes and
> enable it again afterwards. This is fine in U-Boot, but does not work if
> running in CAR (such as we are in SPL).
>
> Update the functions so that the caller can request that caches be left
> alone.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>  arch/x86/cpu/mtrr.c         | 31 +++++++++++++++++++++++--------
>  arch/x86/include/asm/mtrr.h |  6 ++++--
>  cmd/x86/mtrr.c              |  8 ++++----
>  3 files changed, 31 insertions(+), 14 deletions(-)
>

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 43/45] video: at91: Adjust vidconsole_position_cursor() to use char pos
  2018-10-02  7:37     ` Eugen Hristev
@ 2018-10-09  3:40       ` Simon Glass
  2018-10-09 10:44         ` Eugen.Hristev at microchip.com
  2018-10-09 23:54         ` sjg at google.com
  0 siblings, 2 replies; 106+ messages in thread
From: Simon Glass @ 2018-10-09  3:40 UTC (permalink / raw)
  To: u-boot

Hi Eugen,

On 2 October 2018 at 01:37, Eugen Hristev <eugen.hristev@microchip.com> wrote:
>
>
>
> On 01.10.2018 23:22, Anatolij Gustschin wrote:
>>
>> Hi Simon,
>>
>> On Mon,  1 Oct 2018 12:22:47 -0600
>> Simon Glass sjg at chromium.org wrote:
>>
>>> At present this function uses pixels but it seems more useful for it to
>>> position in terms of characters on the screen. This also matches the
>>> comment to the function. Update this.
>>>
>>> Unfortunately there is one user of this function (at91). Have a crack at
>>> fixing this, since I cannot test it.
>
>
> Hello Simon,
>
> I will gladly test this for you on at91 board,
> but I am having some issues applying your patch series:
>
> Applying: binman: Move to three-digit test-file numbers
> error: patch failed: tools/binman/entry_test.py:25
> error: tools/binman/entry_test.py: patch does not apply
> error: patch failed: tools/binman/ftest.py:712
> error: tools/binman/ftest.py: patch does not apply
> Patch failed at 0026 binman: Move to three-digit test-file numbers
>
> Do you have them in some public tree I can pull from ?

Yes you can try u-boot-dm/testing

>
> Also, any specific tests you would like except just checking the video console ?

It looks like this code runs when the board boots up, so just starting
it should be enough.

Thanks,
Simon


>
> Eugen
>
>
>>>
>>> Signed-off-by: Simon Glass <sjg@chromium.org>
>>
>>
>> Reviewed-by: Anatolij Gustschin <agust@denx.de>
>>
>>> ---
>>>
>>>   board/atmel/common/video_display.c | 5 ++++-
>>>   drivers/video/vidconsole-uclass.c  | 2 ++
>>>   2 files changed, 6 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/board/atmel/common/video_display.c b/board/atmel/common/video_display.c
>>> index 7dd7b85556e..e02cb00f866 100644
>>> --- a/board/atmel/common/video_display.c
>>> +++ b/board/atmel/common/video_display.c
>>> @@ -18,6 +18,7 @@ DECLARE_GLOBAL_DATA_PTR;
>>>     int at91_video_show_board_info(void)
>>>   {
>>> +       struct vidconsole_priv *priv;
>>>         ulong dram_size, nand_size;
>>>         int i;
>>>         u32 len = 0;
>>> @@ -63,7 +64,9 @@ int at91_video_show_board_info(void)
>>>         if (ret)
>>>                 return ret;
>>>   -     vidconsole_position_cursor(con, 0, logo_info.logo_height);
>>> +       priv = dev_get_uclass_priv(con);
>>> +       vidconsole_position_cursor(con, 0, (logo_info.logo_height +
>>> +                                  con->y_charsize - 1) / con->y_charsize);
>>
>>
>> Shouldn't it be priv->y_charsize? 'con' is struct udevice * and doesn't
>> have y_charsize.
>>
>>
>> --
>> Anatolij
>> _______________________________________________
>> U-Boot mailing list
>> U-Boot at lists.denx.de
>> https://lists.denx.de/listinfo/u-boot
>>

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 43/45] video: at91: Adjust vidconsole_position_cursor() to use char pos
  2018-10-01 20:22   ` Anatolij Gustschin
  2018-10-02  7:37     ` Eugen Hristev
@ 2018-10-09  3:41     ` Simon Glass
  1 sibling, 0 replies; 106+ messages in thread
From: Simon Glass @ 2018-10-09  3:41 UTC (permalink / raw)
  To: u-boot

Hi Anatolij,

On 1 October 2018 at 14:22, Anatolij Gustschin <agust@denx.de> wrote:
> Hi Simon,
>
> On Mon,  1 Oct 2018 12:22:47 -0600
> Simon Glass sjg at chromium.org wrote:
>
>> At present this function uses pixels but it seems more useful for it to
>> position in terms of characters on the screen. This also matches the
>> comment to the function. Update this.
>>
>> Unfortunately there is one user of this function (at91). Have a crack at
>> fixing this, since I cannot test it.
>>
>> Signed-off-by: Simon Glass <sjg@chromium.org>
>
> Reviewed-by: Anatolij Gustschin <agust@denx.de>
>
>> ---
>>
>>  board/atmel/common/video_display.c | 5 ++++-
>>  drivers/video/vidconsole-uclass.c  | 2 ++
>>  2 files changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/board/atmel/common/video_display.c b/board/atmel/common/video_display.c
>> index 7dd7b85556e..e02cb00f866 100644
>> --- a/board/atmel/common/video_display.c
>> +++ b/board/atmel/common/video_display.c
>> @@ -18,6 +18,7 @@ DECLARE_GLOBAL_DATA_PTR;
>>
>>  int at91_video_show_board_info(void)
>>  {
>> +     struct vidconsole_priv *priv;
>>       ulong dram_size, nand_size;
>>       int i;
>>       u32 len = 0;
>> @@ -63,7 +64,9 @@ int at91_video_show_board_info(void)
>>       if (ret)
>>               return ret;
>>
>> -     vidconsole_position_cursor(con, 0, logo_info.logo_height);
>> +     priv = dev_get_uclass_priv(con);
>> +     vidconsole_position_cursor(con, 0, (logo_info.logo_height +
>> +                                con->y_charsize - 1) / con->y_charsize);
>
> Shouldn't it be priv->y_charsize? 'con' is struct udevice * and doesn't
> have y_charsize.

Yes thanks, I will fix that when I apply this.

Regards,
Simon

>
>
> --
> Anatolij

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 43/45] video: at91: Adjust vidconsole_position_cursor() to use char pos
  2018-10-09  3:40       ` Simon Glass
@ 2018-10-09 10:44         ` Eugen.Hristev at microchip.com
  2018-10-09 23:54         ` sjg at google.com
  1 sibling, 0 replies; 106+ messages in thread
From: Eugen.Hristev at microchip.com @ 2018-10-09 10:44 UTC (permalink / raw)
  To: u-boot



On 09.10.2018 06:40, Simon Glass wrote:
> Hi Eugen,
> 
> On 2 October 2018 at 01:37, Eugen Hristev <eugen.hristev@microchip.com> wrote:
>>
>>
>>
>> On 01.10.2018 23:22, Anatolij Gustschin wrote:
>>>
>>> Hi Simon,
>>>
>>> On Mon,  1 Oct 2018 12:22:47 -0600
>>> Simon Glass sjg at chromium.org wrote:
>>>
>>>> At present this function uses pixels but it seems more useful for it to
>>>> position in terms of characters on the screen. This also matches the
>>>> comment to the function. Update this.
>>>>
>>>> Unfortunately there is one user of this function (at91). Have a crack at
>>>> fixing this, since I cannot test it.
>>
>>
>> Hello Simon,
>>
>> I will gladly test this for you on at91 board,
>> but I am having some issues applying your patch series:
>>
>> Applying: binman: Move to three-digit test-file numbers
>> error: patch failed: tools/binman/entry_test.py:25
>> error: tools/binman/entry_test.py: patch does not apply
>> error: patch failed: tools/binman/ftest.py:712
>> error: tools/binman/ftest.py: patch does not apply
>> Patch failed at 0026 binman: Move to three-digit test-file numbers
>>
>> Do you have them in some public tree I can pull from ?
> 
> Yes you can try u-boot-dm/testing
> 
>>
>> Also, any specific tests you would like except just checking the video console ?
> 
> It looks like this code runs when the board boots up, so just starting
> it should be enough.

I made a build on your branch and tested it on at91 sama5d2_xplained 
board, and the logo and text appears on the display.

Tested-by: Eugen Hristev <eugen.hristev@microchip.com>

Let me know if you want me to do more tests.

Eugen
> 
> Thanks,
> Simon
> 
> 
>>
>> Eugen
>>
>>
>>>>
>>>> Signed-off-by: Simon Glass <sjg@chromium.org>
>>>
>>>
>>> Reviewed-by: Anatolij Gustschin <agust@denx.de>
>>>
>>>> ---
>>>>
>>>>    board/atmel/common/video_display.c | 5 ++++-
>>>>    drivers/video/vidconsole-uclass.c  | 2 ++
>>>>    2 files changed, 6 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/board/atmel/common/video_display.c b/board/atmel/common/video_display.c
>>>> index 7dd7b85556e..e02cb00f866 100644
>>>> --- a/board/atmel/common/video_display.c
>>>> +++ b/board/atmel/common/video_display.c
>>>> @@ -18,6 +18,7 @@ DECLARE_GLOBAL_DATA_PTR;
>>>>      int at91_video_show_board_info(void)
>>>>    {
>>>> +       struct vidconsole_priv *priv;
>>>>          ulong dram_size, nand_size;
>>>>          int i;
>>>>          u32 len = 0;
>>>> @@ -63,7 +64,9 @@ int at91_video_show_board_info(void)
>>>>          if (ret)
>>>>                  return ret;
>>>>    -     vidconsole_position_cursor(con, 0, logo_info.logo_height);
>>>> +       priv = dev_get_uclass_priv(con);
>>>> +       vidconsole_position_cursor(con, 0, (logo_info.logo_height +
>>>> +                                  con->y_charsize - 1) / con->y_charsize);
>>>
>>>
>>> Shouldn't it be priv->y_charsize? 'con' is struct udevice * and doesn't
>>> have y_charsize.
>>>
>>>
>>> --
>>> Anatolij
>>> _______________________________________________
>>> U-Boot mailing list
>>> U-Boot at lists.denx.de
>>> https://lists.denx.de/listinfo/u-boot
>>>

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 45/45] dtoc: Fix the value of SetInt()
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (44 preceding siblings ...)
  2018-10-01 18:22 ` [U-Boot] [PATCH 45/45] dtoc: Fix the value of SetInt() Simon Glass
@ 2018-10-09 23:54 ` sjg at google.com
  2018-10-09 23:54 ` [U-Boot] [PATCH 42/45] sysreset: Add a way to find the last reset sjg at google.com
                   ` (38 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: sjg at google.com @ 2018-10-09 23:54 UTC (permalink / raw)
  To: u-boot

This does not set the correct value at present. Fix it.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 tools/dtoc/fdt.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied to u-boot-dm

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 44/45] video: Tidy up a few comments in video.o
  2018-10-01 18:22 ` [U-Boot] [PATCH 44/45] video: Tidy up a few comments in video.o Simon Glass
  2018-10-01 19:25   ` Anatolij Gustschin
@ 2018-10-09 23:54   ` sjg at google.com
  1 sibling, 0 replies; 106+ messages in thread
From: sjg at google.com @ 2018-10-09 23:54 UTC (permalink / raw)
  To: u-boot

On Mon,  1 Oct 2018 12:22:48 -0600
Simon Glass sjg at chromium.org wrote:

> Add a little more information to one comment and update the guard comment
> to be more accurate.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>

Reviewed-by: Anatolij Gustschin <agust@denx.de>

--
Anatolij

Applied to u-boot-dm

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 43/45] video: at91: Adjust vidconsole_position_cursor() to use char pos
  2018-10-09  3:40       ` Simon Glass
  2018-10-09 10:44         ` Eugen.Hristev at microchip.com
@ 2018-10-09 23:54         ` sjg at google.com
  1 sibling, 0 replies; 106+ messages in thread
From: sjg at google.com @ 2018-10-09 23:54 UTC (permalink / raw)
  To: u-boot

On 09.10.2018 06:40, Simon Glass wrote:
> Hi Eugen,
>
> On 2 October 2018 at 01:37, Eugen Hristev <eugen.hristev@microchip.com> wrote:
>>
>>
>>
>> On 01.10.2018 23:22, Anatolij Gustschin wrote:
>>>
>>> Hi Simon,
>>>
>>> On Mon,  1 Oct 2018 12:22:47 -0600
>>> Simon Glass sjg at chromium.org wrote:
>>>
>>>> At present this function uses pixels but it seems more useful for it to
>>>> position in terms of characters on the screen. This also matches the
>>>> comment to the function. Update this.
>>>>
>>>> Unfortunately there is one user of this function (at91). Have a crack at
>>>> fixing this, since I cannot test it.
>>
>>
>> Hello Simon,
>>
>> I will gladly test this for you on at91 board,
>> but I am having some issues applying your patch series:
>>
>> Applying: binman: Move to three-digit test-file numbers
>> error: patch failed: tools/binman/entry_test.py:25
>> error: tools/binman/entry_test.py: patch does not apply
>> error: patch failed: tools/binman/ftest.py:712
>> error: tools/binman/ftest.py: patch does not apply
>> Patch failed at 0026 binman: Move to three-digit test-file numbers
>>
>> Do you have them in some public tree I can pull from ?
>
> Yes you can try u-boot-dm/testing
>
>>
>> Also, any specific tests you would like except just checking the video console ?
>
> It looks like this code runs when the board boots up, so just starting
> it should be enough.

I made a build on your branch and tested it on at91 sama5d2_xplained
board, and the logo and text appears on the display.

Tested-by: Eugen Hristev <eugen.hristev@microchip.com>

Let me know if you want me to do more tests.

Eugen
>
> Thanks,
> Simon
>
>
>>
>> Eugen
>>
>>
>>>>
>>>> Signed-off-by: Simon Glass <sjg@chromium.org>
>>>
>>>
>>> Reviewed-by: Anatolij Gustschin <agust@denx.de>
>>>
>>>> ---
>>>>
>>>>    board/atmel/common/video_display.c | 5 ++++-
>>>>    drivers/video/vidconsole-uclass.c  | 2 ++
>>>>    2 files changed, 6 insertions(+), 1 deletion(-)
>>>>
Applied to u-boot-dm

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 42/45] sysreset: Add a way to find the last reset
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (45 preceding siblings ...)
  2018-10-09 23:54 ` sjg at google.com
@ 2018-10-09 23:54 ` sjg at google.com
  2018-10-09 23:54 ` [U-Boot] [PATCH 41/45] sysreset: Tidy up a few comments and logging sjg at google.com
                   ` (37 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: sjg at google.com @ 2018-10-09 23:54 UTC (permalink / raw)
  To: u-boot

We have a method to return the last reset as a string for humans, but not
a method that allows it to be used programmatically. Add a new method that
returns the last reset as an enum.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/sysreset/sysreset-uclass.c  | 30 +++++++++++++++++++++++++++++
 drivers/sysreset/sysreset_sandbox.c | 12 ++++++++++++
 include/sysreset.h                  | 30 +++++++++++++++++++++++++++++
 test/dm/sysreset.c                  | 19 ++++++++++++++++++
 4 files changed, 91 insertions(+)

Applied to u-boot-dm

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 41/45] sysreset: Tidy up a few comments and logging
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (46 preceding siblings ...)
  2018-10-09 23:54 ` [U-Boot] [PATCH 42/45] sysreset: Add a way to find the last reset sjg at google.com
@ 2018-10-09 23:54 ` sjg at google.com
  2018-10-09 23:54 ` [U-Boot] [PATCH 38/45] ctags: Minor changes to fix ctags output sjg at google.com
                   ` (36 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: sjg at google.com @ 2018-10-09 23:54 UTC (permalink / raw)
  To: u-boot

Some comments are incorrect or missing pieces. Fix these and use logging
to print the error.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/sysreset/sysreset-uclass.c | 4 +++-
 include/sysreset.h                 | 4 +++-
 test/dm/sysreset.c                 | 1 -
 3 files changed, 6 insertions(+), 3 deletions(-)

Applied to u-boot-dm

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 40/45] pci: Add a little more debugging to pci_rom
  2018-10-01 18:22 ` [U-Boot] [PATCH 40/45] pci: Add a little more debugging to pci_rom Simon Glass
  2018-10-02 13:37   ` Bin Meng
@ 2018-10-09 23:54   ` sjg at google.com
  1 sibling, 0 replies; 106+ messages in thread
From: sjg at google.com @ 2018-10-09 23:54 UTC (permalink / raw)
  To: u-boot

On Tue, Oct 2, 2018 at 2:48 AM Simon Glass <sjg@chromium.org> wrote:
>
> Add some logging on failure.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>  drivers/pci/pci_rom.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

Applied to u-boot-dm

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 38/45] ctags: Minor changes to fix ctags output
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (47 preceding siblings ...)
  2018-10-09 23:54 ` [U-Boot] [PATCH 41/45] sysreset: Tidy up a few comments and logging sjg at google.com
@ 2018-10-09 23:54 ` sjg at google.com
  2018-10-09 23:54 ` [U-Boot] [PATCH 39/45] fdt: Allow C++ comments in link scripts and DT files sjg at google.com
                   ` (35 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: sjg at google.com @ 2018-10-09 23:54 UTC (permalink / raw)
  To: u-boot

At present ctags emits lines with unmatched quotes which means that the
output file is invalid. This is with exuberant-ctags version 5.9~svn201103
but I also see it with plain ctags. I am not sure that it is a bug though.

Make a few minor changes in the source code to fix this problem.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/video/tegra124/sor.c | 3 ++-
 include/linux/compiler-gcc.h | 6 ++++--
 2 files changed, 6 insertions(+), 3 deletions(-)

Applied to u-boot-dm

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 39/45] fdt: Allow C++ comments in link scripts and DT files
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (48 preceding siblings ...)
  2018-10-09 23:54 ` [U-Boot] [PATCH 38/45] ctags: Minor changes to fix ctags output sjg at google.com
@ 2018-10-09 23:54 ` sjg at google.com
  2018-10-09 23:54 ` [U-Boot] [PATCH 37/45] panel: Expand the backlight support sjg at google.com
                   ` (34 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: sjg at google.com @ 2018-10-09 23:54 UTC (permalink / raw)
  To: u-boot

At present // in a device-tree file or link script causes a warning. But
this is used in the standard license header. Update the compiler flags to
use C99, which permits this.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 Makefile             | 2 +-
 scripts/Makefile.spl | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Applied to u-boot-dm

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 37/45] panel: Expand the backlight support
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (49 preceding siblings ...)
  2018-10-09 23:54 ` [U-Boot] [PATCH 39/45] fdt: Allow C++ comments in link scripts and DT files sjg at google.com
@ 2018-10-09 23:54 ` sjg at google.com
  2018-10-09 23:54 ` [U-Boot] [PATCH 36/45] test: panel: Add a test for the panel uclass sjg at google.com
                   ` (33 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: sjg at google.com @ 2018-10-09 23:54 UTC (permalink / raw)
  To: u-boot

At present the panel can be turned on but not off, and the brightness
cannot be controlled at run-time. Add a new API function to both the panel
and backlight uclasses to handle this. Enhance the PWM backlight driver
to deal with custom levels properly and allow the backlight to be turned
on and off.

Update the test to cover thes new features.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/video/backlight-uclass.c |  10 ++
 drivers/video/panel-uclass.c     |  18 +++
 drivers/video/pwm_backlight.c    | 186 +++++++++++++++++++++++++------
 drivers/video/simple_panel.c     |  20 +++-
 include/backlight.h              |  25 +++++
 include/panel.h                  |  22 +++-
 test/dm/panel.c                  |  29 +++++
 7 files changed, 273 insertions(+), 37 deletions(-)

Applied to u-boot-dm

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 36/45] test: panel: Add a test for the panel uclass
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (50 preceding siblings ...)
  2018-10-09 23:54 ` [U-Boot] [PATCH 37/45] panel: Expand the backlight support sjg at google.com
@ 2018-10-09 23:54 ` sjg at google.com
  2018-10-09 23:54 ` [U-Boot] [PATCH 35/45] cros_ec: Add support for v3 messages on LPC sjg at google.com
                   ` (32 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: sjg at google.com @ 2018-10-09 23:54 UTC (permalink / raw)
  To: u-boot

At present this uclass has no tests. Add a simple one which checks the PWM
configuration, regulator and GPIO.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 arch/sandbox/dts/sandbox_pmic.dtsi |  2 +-
 arch/sandbox/dts/test.dts          | 20 +++++++++++-
 arch/sandbox/include/asm/test.h    | 15 +++++++++
 drivers/pwm/sandbox_pwm.c          | 25 +++++++++++++++
 test/dm/Makefile                   |  1 +
 test/dm/panel.c                    | 50 ++++++++++++++++++++++++++++++
 6 files changed, 111 insertions(+), 2 deletions(-)
 create mode 100644 test/dm/panel.c

Applied to u-boot-dm

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 35/45] cros_ec: Add support for v3 messages on LPC
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (51 preceding siblings ...)
  2018-10-09 23:54 ` [U-Boot] [PATCH 36/45] test: panel: Add a test for the panel uclass sjg at google.com
@ 2018-10-09 23:54 ` sjg at google.com
  2018-10-09 23:54 ` [U-Boot] [PATCH 34/45] cros_ec: Update cros_ec_read_hash() to specify the image sjg at google.com
                   ` (31 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: sjg at google.com @ 2018-10-09 23:54 UTC (permalink / raw)
  To: u-boot

At present version 3 messages are only supported on SPI. Add support for
using LPC as well, as used on samus.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/misc/cros_ec_lpc.c | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

Applied to u-boot-dm

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 34/45] cros_ec: Update cros_ec_read_hash() to specify the image
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (52 preceding siblings ...)
  2018-10-09 23:54 ` [U-Boot] [PATCH 35/45] cros_ec: Add support for v3 messages on LPC sjg at google.com
@ 2018-10-09 23:54 ` sjg at google.com
  2018-10-09 23:55 ` [U-Boot] [PATCH 32/45] cros: Update ec_commands to latest version sjg at google.com
                   ` (30 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: sjg at google.com @ 2018-10-09 23:54 UTC (permalink / raw)
  To: u-boot

Allow selection of which EC image to hash.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 cmd/cros_ec.c          | 2 +-
 drivers/misc/cros_ec.c | 7 ++++---
 include/cros_ec.h      | 4 +++-
 3 files changed, 8 insertions(+), 5 deletions(-)

Applied to u-boot-dm

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 33/45] x86: Update mtrr functions to allow leaving cache alone
  2018-10-01 18:22 ` [U-Boot] [PATCH 33/45] x86: Update mtrr functions to allow leaving cache alone Simon Glass
  2018-10-02 13:41   ` Bin Meng
@ 2018-10-09 23:54   ` sjg at google.com
  1 sibling, 0 replies; 106+ messages in thread
From: sjg at google.com @ 2018-10-09 23:54 UTC (permalink / raw)
  To: u-boot

On Tue, Oct 2, 2018 at 2:24 AM Simon Glass <sjg@chromium.org> wrote:
>
> At present the mtrr functions disable the cache before making changes and
> enable it again afterwards. This is fine in U-Boot, but does not work if
> running in CAR (such as we are in SPL).
>
> Update the functions so that the caller can request that caches be left
> alone.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>  arch/x86/cpu/mtrr.c         | 31 +++++++++++++++++++++++--------
>  arch/x86/include/asm/mtrr.h |  6 ++++--
>  cmd/x86/mtrr.c              |  8 ++++----
>  3 files changed, 31 insertions(+), 14 deletions(-)
>

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

Applied to u-boot-dm

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 31/45] Rename GPT_HEADER_SIGNATURE to avoid conflict
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (54 preceding siblings ...)
  2018-10-09 23:55 ` [U-Boot] [PATCH 32/45] cros: Update ec_commands to latest version sjg at google.com
@ 2018-10-09 23:55 ` sjg at google.com
  2018-10-09 23:55 ` [U-Boot] [PATCH 30/45] Add a header file for strings sjg at google.com
                   ` (28 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: sjg at google.com @ 2018-10-09 23:55 UTC (permalink / raw)
  To: u-boot

The current name conflicts with the Chrome OS verified boot library, which
prevents it being built. That library uses a string whereas U-Boot uses a
64-bit hex value. Rename this in U-Boot.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 disk/part_efi.c    | 6 +++---
 include/part_efi.h | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

Applied to u-boot-dm

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 32/45] cros: Update ec_commands to latest version
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (53 preceding siblings ...)
  2018-10-09 23:54 ` [U-Boot] [PATCH 34/45] cros_ec: Update cros_ec_read_hash() to specify the image sjg at google.com
@ 2018-10-09 23:55 ` sjg at google.com
  2018-10-09 23:55 ` [U-Boot] [PATCH 31/45] Rename GPT_HEADER_SIGNATURE to avoid conflict sjg at google.com
                   ` (29 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: sjg at google.com @ 2018-10-09 23:55 UTC (permalink / raw)
  To: u-boot

This file has changed quite a bit in the last 5 years as the capabilities
of the ECs have grown. Sync it up with the copy in coreboot commit
b9141f2215.

The only change is the addition of EC_VBNV_BLOCK_SIZE_V2. This is needed
because U-Boot uses the new v2 vboot API and this is not currently fully
supported by Chromium OS firmware.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 cmd/cros_ec.c                  |    5 +-
 drivers/misc/cros_ec.c         |    7 +-
 drivers/misc/cros_ec_sandbox.c |    4 +-
 include/ec_commands.h          | 4324 ++++++++++++++++++++++++++------
 4 files changed, 3613 insertions(+), 727 deletions(-)

Applied to u-boot-dm

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 30/45] Add a header file for strings
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (55 preceding siblings ...)
  2018-10-09 23:55 ` [U-Boot] [PATCH 31/45] Rename GPT_HEADER_SIGNATURE to avoid conflict sjg at google.com
@ 2018-10-09 23:55 ` sjg at google.com
  2018-10-09 23:55 ` [U-Boot] [PATCH 29/45] malloc_simple: Add logging of allocations sjg at google.com
                   ` (27 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: sjg at google.com @ 2018-10-09 23:55 UTC (permalink / raw)
  To: u-boot

Add a string.h header for libraries that expect this to be available, now
that U-Boot's version has moved to include/linux.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 include/string.h | 1 +
 1 file changed, 1 insertion(+)
 create mode 100644 include/string.h

Applied to u-boot-dm

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 29/45] malloc_simple: Add logging of allocations
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (56 preceding siblings ...)
  2018-10-09 23:55 ` [U-Boot] [PATCH 30/45] Add a header file for strings sjg at google.com
@ 2018-10-09 23:55 ` sjg at google.com
  2018-10-09 23:55 ` [U-Boot] [PATCH 28/45] log: Add comments to the rest of the log categories sjg at google.com
                   ` (26 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: sjg at google.com @ 2018-10-09 23:55 UTC (permalink / raw)
  To: u-boot

It is sometimes useful to see what memory is being allocated early during
boot. Add logging to support this, using a new LOGC_ALLOC category.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 common/malloc_simple.c | 58 +++++++++++++++++++++++++++---------------
 include/malloc.h       |  1 +
 2 files changed, 38 insertions(+), 21 deletions(-)

Applied to u-boot-dm

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 28/45] log: Add comments to the rest of the log categories
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (57 preceding siblings ...)
  2018-10-09 23:55 ` [U-Boot] [PATCH 29/45] malloc_simple: Add logging of allocations sjg at google.com
@ 2018-10-09 23:55 ` sjg at google.com
  2018-10-09 23:55 ` [U-Boot] [PATCH 27/45] binman: Add a test for Intel reference code sjg at google.com
                   ` (25 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: sjg at google.com @ 2018-10-09 23:55 UTC (permalink / raw)
  To: u-boot

At present some of the log categories are missing comments. Add them.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 include/log.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Applied to u-boot-dm

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 27/45] binman: Add a test for Intel reference code
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (58 preceding siblings ...)
  2018-10-09 23:55 ` [U-Boot] [PATCH 28/45] log: Add comments to the rest of the log categories sjg at google.com
@ 2018-10-09 23:55 ` sjg at google.com
  2018-10-09 23:55 ` [U-Boot] [PATCH 26/45] binman: Move to three-digit test-file numbers sjg at google.com
                   ` (24 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: sjg at google.com @ 2018-10-09 23:55 UTC (permalink / raw)
  To: u-boot

Unfortunately the test was not included in the original implementation.
Add one.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 tools/binman/ftest.py                   |  7 +++++++
 tools/binman/test/100_intel_refcode.dts | 14 ++++++++++++++
 2 files changed, 21 insertions(+)
 create mode 100644 tools/binman/test/100_intel_refcode.dts

Applied to u-boot-dm

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 26/45] binman: Move to three-digit test-file numbers
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (59 preceding siblings ...)
  2018-10-09 23:55 ` [U-Boot] [PATCH 27/45] binman: Add a test for Intel reference code sjg at google.com
@ 2018-10-09 23:55 ` sjg at google.com
  2018-10-09 23:55 ` [U-Boot] [PATCH 25/45] tpm: Add a few new commands for v1 sjg at google.com
                   ` (23 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: sjg at google.com @ 2018-10-09 23:55 UTC (permalink / raw)
  To: u-boot

We now have 99 tests. Before adding any more, rename everything to three
digits. This helps to preserve the ordering of tests and makes it easier
to find things.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 tools/binman/entry_test.py                    |   2 +-
 tools/binman/fdt_test.py                      |   4 +-
 tools/binman/ftest.py                         | 224 +++++++++---------
 .../test/{01_invalid.dts => 001_invalid.dts}  |   0
 ..._missing_node.dts => 002_missing_node.dts} |   0
 .../test/{03_empty.dts => 003_empty.dts}      |   0
 ...nvalid_entry.dts => 004_invalid_entry.dts} |   0
 .../test/{05_simple.dts => 005_simple.dts}    |   0
 .../{06_dual_image.dts => 006_dual_image.dts} |   0
 .../{07_bad_align.dts => 007_bad_align.dts}   |   0
 .../binman/test/{08_pack.dts => 008_pack.dts} |   0
 .../{09_pack_extra.dts => 009_pack_extra.dts} |   0
 ...n_power2.dts => 010_pack_align_power2.dts} |   0
 ...er2.dts => 011_pack_align_size_power2.dts} |   0
 ...k_inv_align.dts => 012_pack_inv_align.dts} |   0
 ..._align.dts => 013_pack_inv_size_align.dts} |   0
 ..._pack_overlap.dts => 014_pack_overlap.dts} |   0
 ...ack_overflow.dts => 015_pack_overflow.dts} |   0
 ...erflow.dts => 016_pack_image_overflow.dts} |   0
 ...image_size.dts => 017_pack_image_size.dts} |   0
 ...age_align.dts => 018_pack_image_align.dts} |   0
 ...align.dts => 019_pack_inv_image_align.dts} |   0
 ...ts => 020_pack_inv_image_align_power2.dts} |   0
 .../{21_image_pad.dts => 021_image_pad.dts}   |   0
 .../{22_image_name.dts => 022_image_name.dts} |   0
 .../binman/test/{23_blob.dts => 023_blob.dts} |   0
 .../test/{24_sorted.dts => 024_sorted.dts}    |   0
 ...k_zero_size.dts => 025_pack_zero_size.dts} |   0
 ...u_boot_dtb.dts => 026_pack_u_boot_dtb.dts} |   0
 ...b_no_size.dts => 027_pack_4gb_no_size.dts} |   0
 ...b_outside.dts => 028_pack_4gb_outside.dts} |   0
 .../test/{29_x86-rom.dts => 029_x86-rom.dts}  |   0
 ...no-desc.dts => 030_x86-rom-me-no-desc.dts} |   0
 .../{31_x86-rom-me.dts => 031_x86-rom-me.dts} |   0
 .../{32_intel-vga.dts => 032_intel-vga.dts}   |   0
 ...33_x86-start16.dts => 033_x86-start16.dts} |   0
 .../{34_x86_ucode.dts => 034_x86_ucode.dts}   |   0
 ...gle_ucode.dts => 035_x86_single_ucode.dts} |   0
 .../{36_u_boot_img.dts => 036_u_boot_img.dts} |   0
 ..._x86_no_ucode.dts => 037_x86_no_ucode.dts} |   0
 ...ode.dts => 038_x86_ucode_missing_node.dts} |   0
 ...e2.dts => 039_x86_ucode_missing_node2.dts} |   0
 ...age.dts => 040_x86_ucode_not_in_image.dts} |   0
 ..._pos_size.dts => 041_unknown_pos_size.dts} |   0
 .../{42_intel-fsp.dts => 042_intel-fsp.dts}   |   0
 .../{43_intel-cmc.dts => 043_intel-cmc.dts}   |   0
 ...l_ucode.dts => 044_x86_optional_ucode.dts} |   0
 .../{45_prop_test.dts => 045_prop_test.dts}   |   0
 .../{46_intel-vbt.dts => 046_intel-vbt.dts}   |   0
 ...47_spl_bss_pad.dts => 047_spl_bss_pad.dts} |   0
 ...tart16-spl.dts => 048_x86-start16-spl.dts} |   0
 ...86_ucode_spl.dts => 049_x86_ucode_spl.dts} |   0
 .../{50_intel_mrc.dts => 050_intel_mrc.dts}   |   0
 ...oot_spl_dtb.dts => 051_u_boot_spl_dtb.dts} |   0
 ...spl_nodtb.dts => 052_u_boot_spl_nodtb.dts} |   0
 .../test/{53_symbols.dts => 053_symbols.dts}  |   0
 ..._unit_address.dts => 054_unit_address.dts} |   0
 .../{55_sections.dts => 055_sections.dts}     |   0
 ...56_name_prefix.dts => 056_name_prefix.dts} |   0
 ..._contents.dts => 057_unknown_contents.dts} |   0
 ....dts => 058_x86_ucode_spl_needs_retry.dts} |   0
 ...59_change_size.dts => 059_change_size.dts} |   0
 .../{60_fdt_update.dts => 060_fdt_update.dts} |   0
 ..._update_bad.dts => 061_fdt_update_bad.dts} |   0
 .../{62_entry_args.dts => 062_entry_args.dts} |   0
 ...missing.dts => 063_entry_args_missing.dts} |   0
 ...quired.dts => 064_entry_args_required.dts} |   0
 ...ts => 065_entry_args_unknown_datatype.dts} |   0
 .../binman/test/{66_text.dts => 066_text.dts} |   0
 .../binman/test/{67_fmap.dts => 067_fmap.dts} |   0
 ...d_by_arg.dts => 068_blob_named_by_arg.dts} |   0
 .../binman/test/{69_fill.dts => 069_fill.dts} |   0
 ..._fill_no_size.dts => 070_fill_no_size.dts} |   0
 tools/binman/test/{71_gbb.dts => 071_gbb.dts} |   0
 ...bb_too_small.dts => 072_gbb_too_small.dts} |   0
 ...73_gbb_no_size.dts => 073_gbb_no_size.dts} |   0
 .../test/{74_vblock.dts => 074_vblock.dts}    |   0
 ..._content.dts => 075_vblock_no_content.dts} |   0
 ...phandle.dts => 076_vblock_bad_phandle.dts} |   0
 ...bad_entry.dts => 077_vblock_bad_entry.dts} |   0
 .../{78_u_boot_tpl.dts => 078_u_boot_tpl.dts} |   0
 .../{79_uses_pos.dts => 079_uses_pos.dts}     |   0
 .../{80_fill_empty.dts => 080_fill_empty.dts} |   0
 ...tart16-tpl.dts => 081_x86-start16-tpl.dts} |   0
 ..._update_all.dts => 082_fdt_update_all.dts} |   0
 .../{83_compress.dts => 083_compress.dts}     |   0
 .../test/{84_files.dts => 084_files.dts}      |   0
 ...es_compress.dts => 085_files_compress.dts} |   0
 .../{86_files_none.dts => 086_files_none.dts} |   0
 ...o_pattern.dts => 087_files_no_pattern.dts} |   0
 ...88_expand_size.dts => 088_expand_size.dts} |   0
 ...d_size_bad.dts => 089_expand_size_bad.dts} |   0
 .../binman/test/{90_hash.dts => 090_hash.dts} |   0
 ..._hash_no_algo.dts => 091_hash_no_algo.dts} |   0
 ...ash_bad_algo.dts => 092_hash_bad_algo.dts} |   0
 ...86_tpl_ucode.dts => 093_x86_tpl_ucode.dts} |   0
 .../{94_fmap_x86.dts => 094_fmap_x86.dts}     |   0
 ...6_section.dts => 095_fmap_x86_section.dts} |   0
 tools/binman/test/{96_elf.dts => 096_elf.dts} |   0
 .../{97_elf_strip.dts => 097_elf_strip.dts}   |   0
 ..._hash_section.dts => 099_hash_section.dts} |   0
 101 files changed, 115 insertions(+), 115 deletions(-)
 rename tools/binman/test/{01_invalid.dts => 001_invalid.dts} (100%)
 rename tools/binman/test/{02_missing_node.dts => 002_missing_node.dts} (100%)
 rename tools/binman/test/{03_empty.dts => 003_empty.dts} (100%)
 rename tools/binman/test/{04_invalid_entry.dts => 004_invalid_entry.dts} (100%)
 rename tools/binman/test/{05_simple.dts => 005_simple.dts} (100%)
 rename tools/binman/test/{06_dual_image.dts => 006_dual_image.dts} (100%)
 rename tools/binman/test/{07_bad_align.dts => 007_bad_align.dts} (100%)
 rename tools/binman/test/{08_pack.dts => 008_pack.dts} (100%)
 rename tools/binman/test/{09_pack_extra.dts => 009_pack_extra.dts} (100%)
 rename tools/binman/test/{10_pack_align_power2.dts =>
010_pack_align_power2.dts} (100%)
 rename tools/binman/test/{11_pack_align_size_power2.dts =>
011_pack_align_size_power2.dts} (100%)
 rename tools/binman/test/{12_pack_inv_align.dts =>
012_pack_inv_align.dts} (100%)
 rename tools/binman/test/{13_pack_inv_size_align.dts =>
013_pack_inv_size_align.dts} (100%)
 rename tools/binman/test/{14_pack_overlap.dts => 014_pack_overlap.dts} (100%)
 rename tools/binman/test/{15_pack_overflow.dts => 015_pack_overflow.dts} (100%)
 rename tools/binman/test/{16_pack_image_overflow.dts =>
016_pack_image_overflow.dts} (100%)
 rename tools/binman/test/{17_pack_image_size.dts =>
017_pack_image_size.dts} (100%)
 rename tools/binman/test/{18_pack_image_align.dts =>
018_pack_image_align.dts} (100%)
 rename tools/binman/test/{19_pack_inv_image_align.dts =>
019_pack_inv_image_align.dts} (100%)
 rename tools/binman/test/{20_pack_inv_image_align_power2.dts =>
020_pack_inv_image_align_power2.dts} (100%)
 rename tools/binman/test/{21_image_pad.dts => 021_image_pad.dts} (100%)
 rename tools/binman/test/{22_image_name.dts => 022_image_name.dts} (100%)
 rename tools/binman/test/{23_blob.dts => 023_blob.dts} (100%)
 rename tools/binman/test/{24_sorted.dts => 024_sorted.dts} (100%)
 rename tools/binman/test/{25_pack_zero_size.dts =>
025_pack_zero_size.dts} (100%)
 rename tools/binman/test/{26_pack_u_boot_dtb.dts =>
026_pack_u_boot_dtb.dts} (100%)
 rename tools/binman/test/{27_pack_4gb_no_size.dts =>
027_pack_4gb_no_size.dts} (100%)
 rename tools/binman/test/{28_pack_4gb_outside.dts =>
028_pack_4gb_outside.dts} (100%)
 rename tools/binman/test/{29_x86-rom.dts => 029_x86-rom.dts} (100%)
 rename tools/binman/test/{30_x86-rom-me-no-desc.dts =>
030_x86-rom-me-no-desc.dts} (100%)
 rename tools/binman/test/{31_x86-rom-me.dts => 031_x86-rom-me.dts} (100%)
 rename tools/binman/test/{32_intel-vga.dts => 032_intel-vga.dts} (100%)
 rename tools/binman/test/{33_x86-start16.dts => 033_x86-start16.dts} (100%)
 rename tools/binman/test/{34_x86_ucode.dts => 034_x86_ucode.dts} (100%)
 rename tools/binman/test/{35_x86_single_ucode.dts =>
035_x86_single_ucode.dts} (100%)
 rename tools/binman/test/{36_u_boot_img.dts => 036_u_boot_img.dts} (100%)
 rename tools/binman/test/{37_x86_no_ucode.dts => 037_x86_no_ucode.dts} (100%)
 rename tools/binman/test/{38_x86_ucode_missing_node.dts =>
038_x86_ucode_missing_node.dts} (100%)
 rename tools/binman/test/{39_x86_ucode_missing_node2.dts =>
039_x86_ucode_missing_node2.dts} (100%)
 rename tools/binman/test/{40_x86_ucode_not_in_image.dts =>
040_x86_ucode_not_in_image.dts} (100%)
 rename tools/binman/test/{41_unknown_pos_size.dts =>
041_unknown_pos_size.dts} (100%)
 rename tools/binman/test/{42_intel-fsp.dts => 042_intel-fsp.dts} (100%)
 rename tools/binman/test/{43_intel-cmc.dts => 043_intel-cmc.dts} (100%)
 rename tools/binman/test/{44_x86_optional_ucode.dts =>
044_x86_optional_ucode.dts} (100%)
 rename tools/binman/test/{45_prop_test.dts => 045_prop_test.dts} (100%)
 rename tools/binman/test/{46_intel-vbt.dts => 046_intel-vbt.dts} (100%)
 rename tools/binman/test/{47_spl_bss_pad.dts => 047_spl_bss_pad.dts} (100%)
 rename tools/binman/test/{48_x86-start16-spl.dts =>
048_x86-start16-spl.dts} (100%)
 rename tools/binman/test/{49_x86_ucode_spl.dts => 049_x86_ucode_spl.dts} (100%)
 rename tools/binman/test/{50_intel_mrc.dts => 050_intel_mrc.dts} (100%)
 rename tools/binman/test/{51_u_boot_spl_dtb.dts =>
051_u_boot_spl_dtb.dts} (100%)
 rename tools/binman/test/{52_u_boot_spl_nodtb.dts =>
052_u_boot_spl_nodtb.dts} (100%)
 rename tools/binman/test/{53_symbols.dts => 053_symbols.dts} (100%)
 rename tools/binman/test/{54_unit_address.dts => 054_unit_address.dts} (100%)
 rename tools/binman/test/{55_sections.dts => 055_sections.dts} (100%)
 rename tools/binman/test/{56_name_prefix.dts => 056_name_prefix.dts} (100%)
 rename tools/binman/test/{57_unknown_contents.dts =>
057_unknown_contents.dts} (100%)
 rename tools/binman/test/{58_x86_ucode_spl_needs_retry.dts =>
058_x86_ucode_spl_needs_retry.dts} (100%)
 rename tools/binman/test/{59_change_size.dts => 059_change_size.dts} (100%)
 rename tools/binman/test/{60_fdt_update.dts => 060_fdt_update.dts} (100%)
 rename tools/binman/test/{61_fdt_update_bad.dts =>
061_fdt_update_bad.dts} (100%)
 rename tools/binman/test/{62_entry_args.dts => 062_entry_args.dts} (100%)
 rename tools/binman/test/{63_entry_args_missing.dts =>
063_entry_args_missing.dts} (100%)
 rename tools/binman/test/{64_entry_args_required.dts =>
064_entry_args_required.dts} (100%)
 rename tools/binman/test/{65_entry_args_unknown_datatype.dts =>
065_entry_args_unknown_datatype.dts} (100%)
 rename tools/binman/test/{66_text.dts => 066_text.dts} (100%)
 rename tools/binman/test/{67_fmap.dts => 067_fmap.dts} (100%)
 rename tools/binman/test/{68_blob_named_by_arg.dts =>
068_blob_named_by_arg.dts} (100%)
 rename tools/binman/test/{69_fill.dts => 069_fill.dts} (100%)
 rename tools/binman/test/{70_fill_no_size.dts => 070_fill_no_size.dts} (100%)
 rename tools/binman/test/{71_gbb.dts => 071_gbb.dts} (100%)
 rename tools/binman/test/{72_gbb_too_small.dts => 072_gbb_too_small.dts} (100%)
 rename tools/binman/test/{73_gbb_no_size.dts => 073_gbb_no_size.dts} (100%)
 rename tools/binman/test/{74_vblock.dts => 074_vblock.dts} (100%)
 rename tools/binman/test/{75_vblock_no_content.dts =>
075_vblock_no_content.dts} (100%)
 rename tools/binman/test/{76_vblock_bad_phandle.dts =>
076_vblock_bad_phandle.dts} (100%)
 rename tools/binman/test/{77_vblock_bad_entry.dts =>
077_vblock_bad_entry.dts} (100%)
 rename tools/binman/test/{78_u_boot_tpl.dts => 078_u_boot_tpl.dts} (100%)
 rename tools/binman/test/{79_uses_pos.dts => 079_uses_pos.dts} (100%)
 rename tools/binman/test/{80_fill_empty.dts => 080_fill_empty.dts} (100%)
 rename tools/binman/test/{81_x86-start16-tpl.dts =>
081_x86-start16-tpl.dts} (100%)
 rename tools/binman/test/{82_fdt_update_all.dts =>
082_fdt_update_all.dts} (100%)
 rename tools/binman/test/{83_compress.dts => 083_compress.dts} (100%)
 rename tools/binman/test/{84_files.dts => 084_files.dts} (100%)
 rename tools/binman/test/{85_files_compress.dts =>
085_files_compress.dts} (100%)
 rename tools/binman/test/{86_files_none.dts => 086_files_none.dts} (100%)
 rename tools/binman/test/{87_files_no_pattern.dts =>
087_files_no_pattern.dts} (100%)
 rename tools/binman/test/{88_expand_size.dts => 088_expand_size.dts} (100%)
 rename tools/binman/test/{89_expand_size_bad.dts =>
089_expand_size_bad.dts} (100%)
 rename tools/binman/test/{90_hash.dts => 090_hash.dts} (100%)
 rename tools/binman/test/{91_hash_no_algo.dts => 091_hash_no_algo.dts} (100%)
 rename tools/binman/test/{92_hash_bad_algo.dts => 092_hash_bad_algo.dts} (100%)
 rename tools/binman/test/{93_x86_tpl_ucode.dts => 093_x86_tpl_ucode.dts} (100%)
 rename tools/binman/test/{94_fmap_x86.dts => 094_fmap_x86.dts} (100%)
 rename tools/binman/test/{95_fmap_x86_section.dts =>
095_fmap_x86_section.dts} (100%)
 rename tools/binman/test/{96_elf.dts => 096_elf.dts} (100%)
 rename tools/binman/test/{97_elf_strip.dts => 097_elf_strip.dts} (100%)
 rename tools/binman/test/{99_hash_section.dts => 099_hash_section.dts} (100%)

Applied to u-boot-dm

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 25/45] tpm: Add a few new commands for v1
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (60 preceding siblings ...)
  2018-10-09 23:55 ` [U-Boot] [PATCH 26/45] binman: Move to three-digit test-file numbers sjg at google.com
@ 2018-10-09 23:55 ` sjg at google.com
  2018-10-09 23:55 ` [U-Boot] [PATCH 24/45] tpm: Tidy up logging in tpm-common.c sjg at google.com
                   ` (22 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: sjg at google.com @ 2018-10-09 23:55 UTC (permalink / raw)
  To: u-boot

These are needed for the 2018 version of Chromium OS vboot. Add an
implementation for TPM v1, with v2 to come later.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 cmd/tpm_test.c   | 15 -----------
 include/tpm-v1.h | 28 ++++++++++++++++++++
 lib/tpm-v1.c     | 68 +++++++++++++++++++++++++++++++++++++++++++++---
 3 files changed, 93 insertions(+), 18 deletions(-)

Applied to u-boot-dm

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 24/45] tpm: Tidy up logging in tpm-common.c
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (61 preceding siblings ...)
  2018-10-09 23:55 ` [U-Boot] [PATCH 25/45] tpm: Add a few new commands for v1 sjg at google.com
@ 2018-10-09 23:55 ` sjg at google.com
  2018-10-09 23:55 ` [U-Boot] [PATCH 23/45] tpm: Use livetree and allow children sjg at google.com
                   ` (21 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: sjg at google.com @ 2018-10-09 23:55 UTC (permalink / raw)
  To: u-boot

At present this file uses logging but it should use the new macros. Update
it and add a log message for an error.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 lib/tpm-common.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

Applied to u-boot-dm

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 23/45] tpm: Use livetree and allow children
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (62 preceding siblings ...)
  2018-10-09 23:55 ` [U-Boot] [PATCH 24/45] tpm: Tidy up logging in tpm-common.c sjg at google.com
@ 2018-10-09 23:55 ` sjg at google.com
  2018-10-09 23:55 ` [U-Boot] [PATCH 21/45] fdt: Remove fdtdec_decode_region() function sjg at google.com
                   ` (20 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: sjg at google.com @ 2018-10-09 23:55 UTC (permalink / raw)
  To: u-boot

Adjust the TPM drivers to use livetree (only one does not). Also,
sometimes TPMs can have child devices if they provide a service to the
system (such as storing secure data), so permit that.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/misc/cros_ec.c    | 6 +++---
 drivers/tpm/tpm-uclass.c  | 1 +
 drivers/tpm/tpm_tis_lpc.c | 2 +-
 3 files changed, 5 insertions(+), 4 deletions(-)

Applied to u-boot-dm

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 22/45] video: Adjust video_clear() to return an error
  2018-10-01 18:22 ` [U-Boot] [PATCH 22/45] video: Adjust video_clear() to return an error Simon Glass
  2018-10-01 19:23   ` Anatolij Gustschin
@ 2018-10-09 23:55   ` sjg at google.com
  1 sibling, 0 replies; 106+ messages in thread
From: sjg at google.com @ 2018-10-09 23:55 UTC (permalink / raw)
  To: u-boot

On Mon,  1 Oct 2018 12:22:26 -0600
Simon Glass sjg at chromium.org wrote:

> All driver-model operation should return an error code. Adjust this
> function to do so also.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>

Reviewed-by: Anatolij Gustschin <agust@denx.de>

--
Anatolij

Applied to u-boot-dm

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 21/45] fdt: Remove fdtdec_decode_region() function
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (63 preceding siblings ...)
  2018-10-09 23:55 ` [U-Boot] [PATCH 23/45] tpm: Use livetree and allow children sjg at google.com
@ 2018-10-09 23:55 ` sjg at google.com
  2018-10-09 23:55 ` [U-Boot] [PATCH 20/45] dm: spi: Add logging of some return values sjg at google.com
                   ` (19 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: sjg at google.com @ 2018-10-09 23:55 UTC (permalink / raw)
  To: u-boot

This function is not used in U-Boot now. Remove it along with its 'memory'
version.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 include/fdtdec.h | 45 --------------------------
 lib/fdtdec.c     | 83 ------------------------------------------------
 2 files changed, 128 deletions(-)

Applied to u-boot-dm

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 20/45] dm: spi: Add logging of some return values
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (64 preceding siblings ...)
  2018-10-09 23:55 ` [U-Boot] [PATCH 21/45] fdt: Remove fdtdec_decode_region() function sjg at google.com
@ 2018-10-09 23:55 ` sjg at google.com
  2018-10-09 23:55 ` [U-Boot] [PATCH 19/45] cros: Adjust board_get_cros_ec_dev() to return a udevice sjg at google.com
                   ` (18 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: sjg at google.com @ 2018-10-09 23:55 UTC (permalink / raw)
  To: u-boot

When SPI flash operations fail it is helpful to be able to see the error
codes and where they are generated. Add logging to capture this
information for read operations.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/mtd/spi/sf-uclass.c | 6 +++---
 drivers/mtd/spi/sf_probe.c  | 2 +-
 drivers/mtd/spi/spi_flash.c | 8 ++++----
 drivers/spi/spi-uclass.c    | 6 +++---
 4 files changed, 11 insertions(+), 11 deletions(-)

Applied to u-boot-dm

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 19/45] cros: Adjust board_get_cros_ec_dev() to return a udevice
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (65 preceding siblings ...)
  2018-10-09 23:55 ` [U-Boot] [PATCH 20/45] dm: spi: Add logging of some return values sjg at google.com
@ 2018-10-09 23:55 ` sjg at google.com
  2018-10-09 23:55 ` [U-Boot] [PATCH 18/45] cros: Update cros_ec code to use struct udevice sjg at google.com
                   ` (17 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: sjg at google.com @ 2018-10-09 23:55 UTC (permalink / raw)
  To: u-boot

Rather than returning what is effectively an internal data structure,
return the cros EC device itself.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 common/cros_ec.c  | 4 ++--
 include/cros_ec.h | 4 +---
 2 files changed, 3 insertions(+), 5 deletions(-)

Applied to u-boot-dm

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 18/45] cros: Update cros_ec code to use struct udevice
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (66 preceding siblings ...)
  2018-10-09 23:55 ` [U-Boot] [PATCH 19/45] cros: Adjust board_get_cros_ec_dev() to return a udevice sjg at google.com
@ 2018-10-09 23:55 ` sjg at google.com
  2018-10-09 23:55 ` [U-Boot] [PATCH 17/45] fdt: Allow libfdt in TPL sjg at google.com
                   ` (16 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: sjg at google.com @ 2018-10-09 23:55 UTC (permalink / raw)
  To: u-boot

At present we pass around a private pointer to specify the cros_ec device.
With driver model it makes more sense to pass the device. Update the code
to do this.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 cmd/cros_ec.c                  |  24 +++---
 drivers/misc/cros_ec.c         | 147 +++++++++++++++++----------------
 drivers/misc/cros_ec_sandbox.c |   4 +-
 drivers/tpm/tpm-uclass.c       |   6 +-
 include/cros_ec.h              |  66 +++++++--------
 5 files changed, 122 insertions(+), 125 deletions(-)

Applied to u-boot-dm

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 17/45] fdt: Allow libfdt in TPL
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (67 preceding siblings ...)
  2018-10-09 23:55 ` [U-Boot] [PATCH 18/45] cros: Update cros_ec code to use struct udevice sjg at google.com
@ 2018-10-09 23:55 ` sjg at google.com
  2018-10-09 23:55 ` [U-Boot] [PATCH 16/45] serial: Allow serial to be absent " sjg at google.com
                   ` (15 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: sjg at google.com @ 2018-10-09 23:55 UTC (permalink / raw)
  To: u-boot

In some cases (e.g. sandbox with verified boot) it is useful to support
libfdt in TPL. Update the Kconfig to handle this.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 lib/Kconfig | 10 ++++++++++
 1 file changed, 10 insertions(+)

Applied to u-boot-dm

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 16/45] serial: Allow serial to be absent in TPL
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (68 preceding siblings ...)
  2018-10-09 23:55 ` [U-Boot] [PATCH 17/45] fdt: Allow libfdt in TPL sjg at google.com
@ 2018-10-09 23:55 ` sjg at google.com
  2018-10-09 23:55 ` [U-Boot] [PATCH 15/45] tpm: Add support for SPL and TPL sjg at google.com
                   ` (14 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: sjg at google.com @ 2018-10-09 23:55 UTC (permalink / raw)
  To: u-boot

At present this option applies to SPL, but it should be available in TPL
also, and separately. Change to using CONFIG_IS_ENABLED(), add a new
Kconfig option and fix up hang().

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/serial/Kconfig         | 10 ++++++++++
 drivers/serial/serial-uclass.c |  4 ++++
 lib/hang.c                     |  5 +++--
 3 files changed, 17 insertions(+), 2 deletions(-)

Applied to u-boot-dm

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 15/45] tpm: Add support for SPL and TPL
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (69 preceding siblings ...)
  2018-10-09 23:55 ` [U-Boot] [PATCH 16/45] serial: Allow serial to be absent " sjg at google.com
@ 2018-10-09 23:55 ` sjg at google.com
  2018-10-09 23:55 ` [U-Boot] [PATCH 14/45] fdt: Allow indicating a node is for U-Boot proper only sjg at google.com
                   ` (13 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: sjg at google.com @ 2018-10-09 23:55 UTC (permalink / raw)
  To: u-boot

At present the tpm can only be used in U-Boot proper. Updated it to work
in SPL and TPL also.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/tpm/Makefile |  2 +-
 lib/Kconfig          | 22 ++++++++++++++++++++++
 lib/Makefile         | 10 +++++++---
 3 files changed, 30 insertions(+), 4 deletions(-)

Applied to u-boot-dm

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 14/45] fdt: Allow indicating a node is for U-Boot proper only
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (70 preceding siblings ...)
  2018-10-09 23:55 ` [U-Boot] [PATCH 15/45] tpm: Add support for SPL and TPL sjg at google.com
@ 2018-10-09 23:55 ` sjg at google.com
  2018-10-09 23:55 ` [U-Boot] [PATCH 13/45] doc: Update docs for device tree in SPL, TPL sjg at google.com
                   ` (12 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: sjg at google.com @ 2018-10-09 23:55 UTC (permalink / raw)
  To: u-boot

At present it is not possible to specify that a node should be used before
relocation (in U-Boot proper) without it also ending up in SPL and TPL
device trees. Add a new "u-boot,dm-pre-proper" boolean property for this.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 doc/driver-model/README.txt | 4 +++-
 drivers/core/ofnode.c       | 2 ++
 2 files changed, 5 insertions(+), 1 deletion(-)

Applied to u-boot-dm

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 13/45] doc: Update docs for device tree in SPL, TPL
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (71 preceding siblings ...)
  2018-10-09 23:55 ` [U-Boot] [PATCH 14/45] fdt: Allow indicating a node is for U-Boot proper only sjg at google.com
@ 2018-10-09 23:55 ` sjg at google.com
  2018-10-09 23:55 ` [U-Boot] [PATCH 12/45] fdt: Document the fact that dtc is now built sjg at google.com
                   ` (11 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: sjg at google.com @ 2018-10-09 23:55 UTC (permalink / raw)
  To: u-boot

Make a few small updates to indicate that device tree can be used in SPL
and TPL.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 doc/README.fdt-control      | 10 ++++++++++
 doc/driver-model/README.txt |  3 ++-
 2 files changed, 12 insertions(+), 1 deletion(-)

Applied to u-boot-dm

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 12/45] fdt: Document the fact that dtc is now built
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (72 preceding siblings ...)
  2018-10-09 23:55 ` [U-Boot] [PATCH 13/45] doc: Update docs for device tree in SPL, TPL sjg at google.com
@ 2018-10-09 23:55 ` sjg at google.com
  2018-10-09 23:55 ` [U-Boot] [PATCH 11/45] rtc: Allow use of RTC in SPL and TPL sjg at google.com
                   ` (10 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: sjg at google.com @ 2018-10-09 23:55 UTC (permalink / raw)
  To: u-boot

This documentation is out of date now that U-Boot builds dtc
automatically. Update it.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 doc/README.fdt-control | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Applied to u-boot-dm

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 11/45] rtc: Allow use of RTC in SPL and TPL
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (73 preceding siblings ...)
  2018-10-09 23:55 ` [U-Boot] [PATCH 12/45] fdt: Document the fact that dtc is now built sjg at google.com
@ 2018-10-09 23:55 ` sjg at google.com
  2018-10-09 23:55 ` [U-Boot] [PATCH 10/45] Kconfig: Convert CONFIG_RTC_MC146818 to Kconfig sjg at google.com
                   ` (9 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: sjg at google.com @ 2018-10-09 23:55 UTC (permalink / raw)
  To: u-boot

Add Kconfig options so that the RTC can be used in SPL and TPL. This is
helpful for accessing the contents of CMOS RAM, for example.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/rtc/Kconfig      | 18 ++++++++++++++++++
 drivers/rtc/Makefile     |  2 +-
 drivers/rtc/rtc-uclass.c |  1 +
 3 files changed, 20 insertions(+), 1 deletion(-)

Applied to u-boot-dm

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 10/45] Kconfig: Convert CONFIG_RTC_MC146818 to Kconfig
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (74 preceding siblings ...)
  2018-10-09 23:55 ` [U-Boot] [PATCH 11/45] rtc: Allow use of RTC in SPL and TPL sjg at google.com
@ 2018-10-09 23:55 ` sjg at google.com
  2018-10-09 23:55 ` [U-Boot] [PATCH 09/45] blk: Support block drivers in TPL sjg at google.com
                   ` (8 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: sjg at google.com @ 2018-10-09 23:55 UTC (permalink / raw)
  To: u-boot

Move this option to Kconfig and tidy up the two boards which use it.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 configs/edison_defconfig     | 1 +
 configs/malta_defconfig      | 1 +
 drivers/rtc/Kconfig          | 8 ++++++++
 include/configs/edison.h     | 1 -
 include/configs/malta.h      | 1 -
 scripts/config_whitelist.txt | 1 -
 6 files changed, 10 insertions(+), 3 deletions(-)

Applied to u-boot-dm

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 09/45] blk: Support block drivers in TPL
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (75 preceding siblings ...)
  2018-10-09 23:55 ` [U-Boot] [PATCH 10/45] Kconfig: Convert CONFIG_RTC_MC146818 to Kconfig sjg at google.com
@ 2018-10-09 23:55 ` sjg at google.com
  2018-10-09 23:55 ` [U-Boot] [PATCH 08/45] spl: misc: Allow misc drivers in SPL and TPL sjg at google.com
                   ` (7 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: sjg at google.com @ 2018-10-09 23:55 UTC (permalink / raw)
  To: u-boot

At present it is not possible to enable/disable block drivers in TPL. This
is needed to provide sandbox support. Add a Kconfig option and adjust the
Makefile.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/block/Kconfig  | 12 ++++++++++++
 drivers/block/Makefile |  2 +-
 2 files changed, 13 insertions(+), 1 deletion(-)

Applied to u-boot-dm

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 08/45] spl: misc: Allow misc drivers in SPL and TPL
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (76 preceding siblings ...)
  2018-10-09 23:55 ` [U-Boot] [PATCH 09/45] blk: Support block drivers in TPL sjg at google.com
@ 2018-10-09 23:55 ` sjg at google.com
  2018-10-09 23:55 ` [U-Boot] [PATCH 07/45] Makefile: Add a warning if SPL/TPL cannot be built sjg at google.com
                   ` (6 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: sjg at google.com @ 2018-10-09 23:55 UTC (permalink / raw)
  To: u-boot

In some cases it is necessary to read the keyboard in early phases of
U-Boot. The cros_ec keyboard is kept in the misc directory. Update the
config to allow this.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/misc/Kconfig  | 72 +++++++++++++++++++++++++++++++++++++++++++
 drivers/misc/Makefile |  9 +++---
 2 files changed, 77 insertions(+), 4 deletions(-)

Applied to u-boot-dm

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 07/45] Makefile: Add a warning if SPL/TPL cannot be built
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (77 preceding siblings ...)
  2018-10-09 23:55 ` [U-Boot] [PATCH 08/45] spl: misc: Allow misc drivers in SPL and TPL sjg at google.com
@ 2018-10-09 23:55 ` sjg at google.com
  2018-10-09 23:55 ` [U-Boot] [PATCH 06/45] spl: input: Allow input in SPL and TPL sjg at google.com
                   ` (5 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: sjg at google.com @ 2018-10-09 23:55 UTC (permalink / raw)
  To: u-boot

At present the build fails in strange ways if CONFIG_SPL is defined by
CONFIG_SUPPORT_SPL is not. Add a warning for this case as it can be very
confusing to debug.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 scripts/Makefile.spl | 7 +++++++
 1 file changed, 7 insertions(+)

Applied to u-boot-dm

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 05/45] sf: Avoid allocating memory on every read operation
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (79 preceding siblings ...)
  2018-10-09 23:55 ` [U-Boot] [PATCH 06/45] spl: input: Allow input in SPL and TPL sjg at google.com
@ 2018-10-09 23:55 ` sjg at google.com
  2018-10-09 23:55 ` [U-Boot] [PATCH 04/45] dm: core: Update ofnode to read binman-style flash entry sjg at google.com
                   ` (3 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: sjg at google.com @ 2018-10-09 23:55 UTC (permalink / raw)
  To: u-boot

At present spi_flash_cmd_read_ops() allocates and frees a few bytes of
memory every time it is called. It is faster to use the stack for this
and this is now supported by the minimum GCC version required by U-Boot.

Remove the allocation and use a variable-sized array instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/mtd/spi/spi_flash.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

Applied to u-boot-dm

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 06/45] spl: input: Allow input in SPL and TPL
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (78 preceding siblings ...)
  2018-10-09 23:55 ` [U-Boot] [PATCH 07/45] Makefile: Add a warning if SPL/TPL cannot be built sjg at google.com
@ 2018-10-09 23:55 ` sjg at google.com
  2018-10-09 23:55 ` [U-Boot] [PATCH 05/45] sf: Avoid allocating memory on every read operation sjg at google.com
                   ` (4 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: sjg at google.com @ 2018-10-09 23:55 UTC (permalink / raw)
  To: u-boot

In some cases it is necessary to read the keyboard in early phases of
U-Boot. Update the config to allow this.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/input/Kconfig  | 48 ++++++++++++++++++++++++++++++++++++++++++
 drivers/input/Makefile | 11 ++++++----
 drivers/input/input.c  |  5 ++++-
 3 files changed, 59 insertions(+), 5 deletions(-)

Applied to u-boot-dm

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 04/45] dm: core: Update ofnode to read binman-style flash entry
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (80 preceding siblings ...)
  2018-10-09 23:55 ` [U-Boot] [PATCH 05/45] sf: Avoid allocating memory on every read operation sjg at google.com
@ 2018-10-09 23:55 ` sjg at google.com
  2018-10-09 23:55 ` [U-Boot] [PATCH 03/45] dm: core: Add a function to find the first inactive child sjg at google.com
                   ` (2 subsequent siblings)
  84 siblings, 0 replies; 106+ messages in thread
From: sjg at google.com @ 2018-10-09 23:55 UTC (permalink / raw)
  To: u-boot

At present ofnode_read_fmap_entry() reads a flash map entry in a format
which is not supported by binman. To allow use to use binman-format
descriptions, update this function.

Also add a simple test.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 arch/sandbox/dts/sandbox.dts   | 20 ++++++++++----------
 arch/sandbox/dts/sandbox64.dts | 20 ++++++++++----------
 drivers/core/of_extra.c        | 27 +++++++++++++++++++--------
 drivers/misc/cros_ec.c         | 33 +++++++++++++++++----------------
 include/dm/of_extra.h          |  3 ++-
 test/dm/ofnode.c               | 16 ++++++++++++++++
 6 files changed, 74 insertions(+), 45 deletions(-)

Applied to u-boot-dm

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 03/45] dm: core: Add a function to find the first inactive child
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (81 preceding siblings ...)
  2018-10-09 23:55 ` [U-Boot] [PATCH 04/45] dm: core: Update ofnode to read binman-style flash entry sjg at google.com
@ 2018-10-09 23:55 ` sjg at google.com
  2018-10-09 23:55 ` [U-Boot] [PATCH 02/45] dm: core: Update some functions to use const sjg at google.com
  2018-10-09 23:55 ` [U-Boot] [PATCH 01/45] dm: core: Alloc uclass-private data to be cache-aligned sjg at google.com
  84 siblings, 0 replies; 106+ messages in thread
From: sjg at google.com @ 2018-10-09 23:55 UTC (permalink / raw)
  To: u-boot

Some devices have children and want to press an existing inactive child
into service when needed. Add a function to help with this.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/core/device.c | 18 ++++++++++++++++++
 include/dm/device.h   | 15 +++++++++++++++
 test/dm/core.c        | 31 +++++++++++++++++++++++++++++++
 3 files changed, 64 insertions(+)

Applied to u-boot-dm

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 02/45] dm: core: Update some functions to use const
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (82 preceding siblings ...)
  2018-10-09 23:55 ` [U-Boot] [PATCH 03/45] dm: core: Add a function to find the first inactive child sjg at google.com
@ 2018-10-09 23:55 ` sjg at google.com
  2018-10-09 23:55 ` [U-Boot] [PATCH 01/45] dm: core: Alloc uclass-private data to be cache-aligned sjg at google.com
  84 siblings, 0 replies; 106+ messages in thread
From: sjg at google.com @ 2018-10-09 23:55 UTC (permalink / raw)
  To: u-boot

Quite a few functions do not actually modify the device that is passed in.
Update the function signatures to reflect that.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/core/device.c | 24 ++++++++++++------------
 include/dm/device.h   | 24 ++++++++++++------------
 2 files changed, 24 insertions(+), 24 deletions(-)

Applied to u-boot-dm

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [U-Boot] [PATCH 01/45] dm: core: Alloc uclass-private data to be cache-aligned
  2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
                   ` (83 preceding siblings ...)
  2018-10-09 23:55 ` [U-Boot] [PATCH 02/45] dm: core: Update some functions to use const sjg at google.com
@ 2018-10-09 23:55 ` sjg at google.com
  84 siblings, 0 replies; 106+ messages in thread
From: sjg at google.com @ 2018-10-09 23:55 UTC (permalink / raw)
  To: u-boot

There is no reason why this feature should not be supported for uclass-
private data. Update the code accordingly.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/core/device.c | 3 ++-
 include/dm/uclass.h   | 3 +++
 2 files changed, 5 insertions(+), 1 deletion(-)

Applied to u-boot-dm

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [U-Boot] [U-Boot,11/45] rtc: Allow use of RTC in SPL and TPL
  2018-10-01 18:22 ` [U-Boot] [PATCH 11/45] rtc: Allow use of RTC in SPL and TPL Simon Glass
@ 2018-10-11 19:21   ` Heinrich Schuchardt
  2018-10-11 19:56     ` Heinrich Schuchardt
  0 siblings, 1 reply; 106+ messages in thread
From: Heinrich Schuchardt @ 2018-10-11 19:21 UTC (permalink / raw)
  To: u-boot


On 10/01/2018 08:22 PM, Simon Glass wrote:
> Add Kconfig options so that the RTC can be used in SPL and TPL. This is
> helpful for accessing the contents of CMOS RAM, for example.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---

Hello Simon,

with this patch x86_64 does not boot anymore:
$ qemu-system-x86_64 -bios u-boot.rom -nographic --enable-kvm --cpu host
### ERROR ### Please RESET the board ###

I am currently testing Bin's patch series:
https://patchwork.ozlabs.org/project/uboot/list/?series=70127
[U-Boot,1/4] x86: Specify -march=core2 to build 64-bit U-Boot proper

> 
>  drivers/rtc/Kconfig      | 18 ++++++++++++++++++
>  drivers/rtc/Makefile     |  2 +-
>  drivers/rtc/rtc-uclass.c |  1 +
>  3 files changed, 20 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
> index 97cf7d84dfa..bcc01b135e5 100644
> --- a/drivers/rtc/Kconfig
> +++ b/drivers/rtc/Kconfig
> @@ -13,6 +13,24 @@ config DM_RTC
>  	  drivers to perform the actual functions. See rtc.h for a
>  	  description of the API.
>  
> +config SPL_DM_RTC
> +	bool "Enable Driver Model for RTC drivers in SPL"
> +	depends on SPL_DM
> +	help
> +	  Enable drver model for real-time-clock drivers. The RTC uclass
> +	  then provides the rtc_get()/rtc_set() interface, delegating to
> +	  drivers to perform the actual functions. See rtc.h for a
> +	  description of the API.
> +
> +config TPL_DM_RTC
> +	bool "Enable Driver Model for RTC drivers in TPL"
> +	depends on TPL_DM
> +	help
> +	  Enable drver model for real-time-clock drivers. The RTC uclass
> +	  then provides the rtc_get()/rtc_set() interface, delegating to
> +	  drivers to perform the actual functions. See rtc.h for a
> +	  description of the API.
> +
>  config RTC_PCF2127
>  	bool "Enable PCF2127 driver"
>  	depends on DM_RTC
> diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
> index 513e3ffc079..1724602f1cb 100644
> --- a/drivers/rtc/Makefile
> +++ b/drivers/rtc/Makefile
> @@ -4,7 +4,7 @@
>  # Wolfgang Denk, DENX Software Engineering, wd at denx.de.
>  #ccflags-y += -DDEBUG
>  
> -obj-$(CONFIG_DM_RTC) += rtc-uclass.o
> +obj-$(CONFIG_$(SPL_TPL_)DM_RTC) += rtc-uclass.o

This is the line to be reverted.

Best regards

Heinrich

>  
>  obj-$(CONFIG_RTC_AT91SAM9_RTT) += at91sam9_rtt.o
>  obj-y += date.o
> diff --git a/drivers/rtc/rtc-uclass.c b/drivers/rtc/rtc-uclass.c
> index c676f0ff359..a0a238aedda 100644
> --- a/drivers/rtc/rtc-uclass.c
> +++ b/drivers/rtc/rtc-uclass.c
> @@ -122,4 +122,5 @@ int rtc_write32(struct udevice *dev, unsigned int reg, u32 value)
>  UCLASS_DRIVER(rtc) = {
>  	.name		= "rtc",
>  	.id		= UCLASS_RTC,
> +	.post_bind	= dm_scan_fdt_dev,
>  };
> 

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [U-Boot] [U-Boot,11/45] rtc: Allow use of RTC in SPL and TPL
  2018-10-11 19:21   ` [U-Boot] [U-Boot,11/45] " Heinrich Schuchardt
@ 2018-10-11 19:56     ` Heinrich Schuchardt
  2018-10-13  2:46       ` Bin Meng
  0 siblings, 1 reply; 106+ messages in thread
From: Heinrich Schuchardt @ 2018-10-11 19:56 UTC (permalink / raw)
  To: u-boot

On 10/11/2018 09:21 PM, Heinrich Schuchardt wrote:
> 
> On 10/01/2018 08:22 PM, Simon Glass wrote:
>> Add Kconfig options so that the RTC can be used in SPL and TPL. This is
>> helpful for accessing the contents of CMOS RAM, for example.
>>
>> Signed-off-by: Simon Glass <sjg@chromium.org>
>> Signed-off-by: Simon Glass <sjg@chromium.org>
>> ---
> 
> Hello Simon,
> 
> with this patch x86_64 does not boot anymore:
> $ qemu-system-x86_64 -bios u-boot.rom -nographic --enable-kvm --cpu host
> ### ERROR ### Please RESET the board ###
> 
> I am currently testing Bin's patch series:
> https://patchwork.ozlabs.org/project/uboot/list/?series=70127
> [U-Boot,1/4] x86: Specify -march=core2 to build 64-bit U-Boot proper
> 

As a workaround for qemu-x86_defconfig I have sent a patch changing that
single configuration file. But your patch may have broken more boards.

https://lists.denx.de/pipermail/u-boot/2018-October/344137.html
x86: qemu: enable CONFIG_SPL_DM_RTC

Regards

Heinrich

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [U-Boot] [U-Boot,11/45] rtc: Allow use of RTC in SPL and TPL
  2018-10-11 19:56     ` Heinrich Schuchardt
@ 2018-10-13  2:46       ` Bin Meng
  2018-10-19  3:25         ` Simon Glass
  0 siblings, 1 reply; 106+ messages in thread
From: Bin Meng @ 2018-10-13  2:46 UTC (permalink / raw)
  To: u-boot

Hi Heinrich,

On Fri, Oct 12, 2018 at 3:56 AM Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>
> On 10/11/2018 09:21 PM, Heinrich Schuchardt wrote:
> >
> > On 10/01/2018 08:22 PM, Simon Glass wrote:
> >> Add Kconfig options so that the RTC can be used in SPL and TPL. This is
> >> helpful for accessing the contents of CMOS RAM, for example.
> >>
> >> Signed-off-by: Simon Glass <sjg@chromium.org>
> >> Signed-off-by: Simon Glass <sjg@chromium.org>
> >> ---
> >
> > Hello Simon,
> >
> > with this patch x86_64 does not boot anymore:
> > $ qemu-system-x86_64 -bios u-boot.rom -nographic --enable-kvm --cpu host
> > ### ERROR ### Please RESET the board ###
> >
> > I am currently testing Bin's patch series:
> > https://patchwork.ozlabs.org/project/uboot/list/?series=70127
> > [U-Boot,1/4] x86: Specify -march=core2 to build 64-bit U-Boot proper
> >
>
> As a workaround for qemu-x86_defconfig I have sent a patch changing that
> single configuration file. But your patch may have broken more boards.
>

Thanks for checking.

> https://lists.denx.de/pipermail/u-boot/2018-October/344137.html
> x86: qemu: enable CONFIG_SPL_DM_RTC

Simon, can you take a look at this? Whether I should take Heinrich's
patch directly, or you will re-work the original RTC patch?

Regards,
Bin

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [U-Boot] [U-Boot,11/45] rtc: Allow use of RTC in SPL and TPL
  2018-10-13  2:46       ` Bin Meng
@ 2018-10-19  3:25         ` Simon Glass
  2018-10-19  4:20           ` Bin Meng
  0 siblings, 1 reply; 106+ messages in thread
From: Simon Glass @ 2018-10-19  3:25 UTC (permalink / raw)
  To: u-boot

Hi Bin,

On 12 October 2018 at 20:46, Bin Meng <bmeng.cn@gmail.com> wrote:
> Hi Heinrich,
>
> On Fri, Oct 12, 2018 at 3:56 AM Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>>
>> On 10/11/2018 09:21 PM, Heinrich Schuchardt wrote:
>> >
>> > On 10/01/2018 08:22 PM, Simon Glass wrote:
>> >> Add Kconfig options so that the RTC can be used in SPL and TPL. This is
>> >> helpful for accessing the contents of CMOS RAM, for example.
>> >>
>> >> Signed-off-by: Simon Glass <sjg@chromium.org>
>> >> Signed-off-by: Simon Glass <sjg@chromium.org>
>> >> ---
>> >
>> > Hello Simon,
>> >
>> > with this patch x86_64 does not boot anymore:
>> > $ qemu-system-x86_64 -bios u-boot.rom -nographic --enable-kvm --cpu host
>> > ### ERROR ### Please RESET the board ###
>> >
>> > I am currently testing Bin's patch series:
>> > https://patchwork.ozlabs.org/project/uboot/list/?series=70127
>> > [U-Boot,1/4] x86: Specify -march=core2 to build 64-bit U-Boot proper
>> >
>>
>> As a workaround for qemu-x86_defconfig I have sent a patch changing that
>> single configuration file. But your patch may have broken more boards.
>>
>
> Thanks for checking.
>
>> https://lists.denx.de/pipermail/u-boot/2018-October/344137.html
>> x86: qemu: enable CONFIG_SPL_DM_RTC
>
> Simon, can you take a look at this? Whether I should take Heinrich's
> patch directly, or you will re-work the original RTC patch?

I think Heinrich's patch is good.

I don't believe any boards that use DM_RTC are using it in SPL. My
reasoning is that this line would likely cause a build error for such
boards, since they probably don't use DT:

+       .post_bind      = dm_scan_fdt_dev,

Regards,
Simon

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [U-Boot] [U-Boot,11/45] rtc: Allow use of RTC in SPL and TPL
  2018-10-19  3:25         ` Simon Glass
@ 2018-10-19  4:20           ` Bin Meng
  0 siblings, 0 replies; 106+ messages in thread
From: Bin Meng @ 2018-10-19  4:20 UTC (permalink / raw)
  To: u-boot

Hi Simon,

On Fri, Oct 19, 2018 at 11:25 AM Simon Glass <sjg@chromium.org> wrote:
>
> Hi Bin,
>
> On 12 October 2018 at 20:46, Bin Meng <bmeng.cn@gmail.com> wrote:
> > Hi Heinrich,
> >
> > On Fri, Oct 12, 2018 at 3:56 AM Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
> >>
> >> On 10/11/2018 09:21 PM, Heinrich Schuchardt wrote:
> >> >
> >> > On 10/01/2018 08:22 PM, Simon Glass wrote:
> >> >> Add Kconfig options so that the RTC can be used in SPL and TPL. This is
> >> >> helpful for accessing the contents of CMOS RAM, for example.
> >> >>
> >> >> Signed-off-by: Simon Glass <sjg@chromium.org>
> >> >> Signed-off-by: Simon Glass <sjg@chromium.org>
> >> >> ---
> >> >
> >> > Hello Simon,
> >> >
> >> > with this patch x86_64 does not boot anymore:
> >> > $ qemu-system-x86_64 -bios u-boot.rom -nographic --enable-kvm --cpu host
> >> > ### ERROR ### Please RESET the board ###
> >> >
> >> > I am currently testing Bin's patch series:
> >> > https://patchwork.ozlabs.org/project/uboot/list/?series=70127
> >> > [U-Boot,1/4] x86: Specify -march=core2 to build 64-bit U-Boot proper
> >> >
> >>
> >> As a workaround for qemu-x86_defconfig I have sent a patch changing that
> >> single configuration file. But your patch may have broken more boards.
> >>
> >
> > Thanks for checking.
> >
> >> https://lists.denx.de/pipermail/u-boot/2018-October/344137.html
> >> x86: qemu: enable CONFIG_SPL_DM_RTC
> >
> > Simon, can you take a look at this? Whether I should take Heinrich's
> > patch directly, or you will re-work the original RTC patch?
>
> I think Heinrich's patch is good.
>

Thanks for the confirmation. I will take Heinrich's patch then.

> I don't believe any boards that use DM_RTC are using it in SPL. My
> reasoning is that this line would likely cause a build error for such
> boards, since they probably don't use DT:
>
> +       .post_bind      = dm_scan_fdt_dev,
>

Regards,
Bin

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [U-Boot] [U-Boot, 27/45] binman: Add a test for Intel reference code
  2018-10-01 18:22 ` [U-Boot] [PATCH 27/45] binman: Add a test for Intel reference code Simon Glass
@ 2018-10-22 20:54   ` Tom Rini
  0 siblings, 0 replies; 106+ messages in thread
From: Tom Rini @ 2018-10-22 20:54 UTC (permalink / raw)
  To: u-boot

On Mon, Oct 01, 2018 at 12:22:31PM -0600, Simon Glass wrote:

> Unfortunately the test was not included in the original implementation.
> Add one.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>
> Signed-off-by: Simon Glass <sjg@chromium.org>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181022/d371d750/attachment.sig>

^ permalink raw reply	[flat|nested] 106+ messages in thread

end of thread, other threads:[~2018-10-22 20:54 UTC | newest]

Thread overview: 106+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-01 18:22 [U-Boot] [PATCH 00/45] Various fixes and improvements Simon Glass
2018-10-01 18:22 ` [U-Boot] [PATCH 01/45] dm: core: Alloc uclass-private data to be cache-aligned Simon Glass
2018-10-01 18:22 ` [U-Boot] [PATCH 02/45] dm: core: Update some functions to use const Simon Glass
2018-10-01 18:22 ` [U-Boot] [PATCH 03/45] dm: core: Add a function to find the first inactive child Simon Glass
2018-10-01 18:22 ` [U-Boot] [PATCH 04/45] dm: core: Update ofnode to read binman-style flash entry Simon Glass
2018-10-01 18:22 ` [U-Boot] [PATCH 05/45] sf: Avoid allocating memory on every read operation Simon Glass
2018-10-01 18:22 ` [U-Boot] [PATCH 06/45] spl: input: Allow input in SPL and TPL Simon Glass
2018-10-01 18:22 ` [U-Boot] [PATCH 07/45] Makefile: Add a warning if SPL/TPL cannot be built Simon Glass
2018-10-01 18:22 ` [U-Boot] [PATCH 08/45] spl: misc: Allow misc drivers in SPL and TPL Simon Glass
2018-10-01 18:22 ` [U-Boot] [PATCH 09/45] blk: Support block drivers in TPL Simon Glass
2018-10-01 18:22 ` [U-Boot] [PATCH 10/45] Kconfig: Convert CONFIG_RTC_MC146818 to Kconfig Simon Glass
2018-10-01 18:22 ` [U-Boot] [PATCH 11/45] rtc: Allow use of RTC in SPL and TPL Simon Glass
2018-10-11 19:21   ` [U-Boot] [U-Boot,11/45] " Heinrich Schuchardt
2018-10-11 19:56     ` Heinrich Schuchardt
2018-10-13  2:46       ` Bin Meng
2018-10-19  3:25         ` Simon Glass
2018-10-19  4:20           ` Bin Meng
2018-10-01 18:22 ` [U-Boot] [PATCH 12/45] fdt: Document the fact that dtc is now built Simon Glass
2018-10-01 18:22 ` [U-Boot] [PATCH 13/45] doc: Update docs for device tree in SPL, TPL Simon Glass
2018-10-01 18:22 ` [U-Boot] [PATCH 14/45] fdt: Allow indicating a node is for U-Boot proper only Simon Glass
2018-10-01 18:22 ` [U-Boot] [PATCH 15/45] tpm: Add support for SPL and TPL Simon Glass
2018-10-01 18:22 ` [U-Boot] [PATCH 16/45] serial: Allow serial to be absent in TPL Simon Glass
2018-10-01 18:22 ` [U-Boot] [PATCH 17/45] fdt: Allow libfdt " Simon Glass
2018-10-01 18:22 ` [U-Boot] [PATCH 18/45] cros: Update cros_ec code to use struct udevice Simon Glass
2018-10-01 18:22 ` [U-Boot] [PATCH 19/45] cros: Adjust board_get_cros_ec_dev() to return a udevice Simon Glass
2018-10-01 18:22 ` [U-Boot] [PATCH 20/45] dm: spi: Add logging of some return values Simon Glass
2018-10-01 18:22 ` [U-Boot] [PATCH 21/45] fdt: Remove fdtdec_decode_region() function Simon Glass
2018-10-01 18:22 ` [U-Boot] [PATCH 22/45] video: Adjust video_clear() to return an error Simon Glass
2018-10-01 19:23   ` Anatolij Gustschin
2018-10-09 23:55   ` sjg at google.com
2018-10-01 18:22 ` [U-Boot] [PATCH 23/45] tpm: Use livetree and allow children Simon Glass
2018-10-01 18:22 ` [U-Boot] [PATCH 24/45] tpm: Tidy up logging in tpm-common.c Simon Glass
2018-10-01 18:22 ` [U-Boot] [PATCH 25/45] tpm: Add a few new commands for v1 Simon Glass
2018-10-01 18:22 ` [U-Boot] [PATCH 26/45] binman: Move to three-digit test-file numbers Simon Glass
2018-10-01 18:22 ` [U-Boot] [PATCH 27/45] binman: Add a test for Intel reference code Simon Glass
2018-10-22 20:54   ` [U-Boot] [U-Boot, " Tom Rini
2018-10-01 18:22 ` [U-Boot] [PATCH 28/45] log: Add comments to the rest of the log categories Simon Glass
2018-10-01 18:22 ` [U-Boot] [PATCH 29/45] malloc_simple: Add logging of allocations Simon Glass
2018-10-01 18:22 ` [U-Boot] [PATCH 30/45] Add a header file for strings Simon Glass
2018-10-01 18:22 ` [U-Boot] [PATCH 31/45] Rename GPT_HEADER_SIGNATURE to avoid conflict Simon Glass
2018-10-01 18:22 ` [U-Boot] [PATCH 32/45] cros: Update ec_commands to latest version Simon Glass
2018-10-01 18:22 ` [U-Boot] [PATCH 33/45] x86: Update mtrr functions to allow leaving cache alone Simon Glass
2018-10-02 13:41   ` Bin Meng
2018-10-09 23:54   ` sjg at google.com
2018-10-01 18:22 ` [U-Boot] [PATCH 34/45] cros_ec: Update cros_ec_read_hash() to specify the image Simon Glass
2018-10-01 18:22 ` [U-Boot] [PATCH 35/45] cros_ec: Add support for v3 messages on LPC Simon Glass
2018-10-01 18:22 ` [U-Boot] [PATCH 36/45] test: panel: Add a test for the panel uclass Simon Glass
2018-10-01 18:22 ` [U-Boot] [PATCH 37/45] panel: Expand the backlight support Simon Glass
2018-10-01 18:22 ` [U-Boot] [PATCH 38/45] ctags: Minor changes to fix ctags output Simon Glass
2018-10-01 18:22 ` [U-Boot] [PATCH 39/45] fdt: Allow C++ comments in link scripts and DT files Simon Glass
2018-10-01 18:22 ` [U-Boot] [PATCH 40/45] pci: Add a little more debugging to pci_rom Simon Glass
2018-10-02 13:37   ` Bin Meng
2018-10-09 23:54   ` sjg at google.com
2018-10-01 18:22 ` [U-Boot] [PATCH 41/45] sysreset: Tidy up a few comments and logging Simon Glass
2018-10-01 18:22 ` [U-Boot] [PATCH 42/45] sysreset: Add a way to find the last reset Simon Glass
2018-10-01 18:22 ` [U-Boot] [PATCH 43/45] video: at91: Adjust vidconsole_position_cursor() to use char pos Simon Glass
2018-10-01 20:22   ` Anatolij Gustschin
2018-10-02  7:37     ` Eugen Hristev
2018-10-09  3:40       ` Simon Glass
2018-10-09 10:44         ` Eugen.Hristev at microchip.com
2018-10-09 23:54         ` sjg at google.com
2018-10-09  3:41     ` Simon Glass
2018-10-01 18:22 ` [U-Boot] [PATCH 44/45] video: Tidy up a few comments in video.o Simon Glass
2018-10-01 19:25   ` Anatolij Gustschin
2018-10-09 23:54   ` sjg at google.com
2018-10-01 18:22 ` [U-Boot] [PATCH 45/45] dtoc: Fix the value of SetInt() Simon Glass
2018-10-09 23:54 ` sjg at google.com
2018-10-09 23:54 ` [U-Boot] [PATCH 42/45] sysreset: Add a way to find the last reset sjg at google.com
2018-10-09 23:54 ` [U-Boot] [PATCH 41/45] sysreset: Tidy up a few comments and logging sjg at google.com
2018-10-09 23:54 ` [U-Boot] [PATCH 38/45] ctags: Minor changes to fix ctags output sjg at google.com
2018-10-09 23:54 ` [U-Boot] [PATCH 39/45] fdt: Allow C++ comments in link scripts and DT files sjg at google.com
2018-10-09 23:54 ` [U-Boot] [PATCH 37/45] panel: Expand the backlight support sjg at google.com
2018-10-09 23:54 ` [U-Boot] [PATCH 36/45] test: panel: Add a test for the panel uclass sjg at google.com
2018-10-09 23:54 ` [U-Boot] [PATCH 35/45] cros_ec: Add support for v3 messages on LPC sjg at google.com
2018-10-09 23:54 ` [U-Boot] [PATCH 34/45] cros_ec: Update cros_ec_read_hash() to specify the image sjg at google.com
2018-10-09 23:55 ` [U-Boot] [PATCH 32/45] cros: Update ec_commands to latest version sjg at google.com
2018-10-09 23:55 ` [U-Boot] [PATCH 31/45] Rename GPT_HEADER_SIGNATURE to avoid conflict sjg at google.com
2018-10-09 23:55 ` [U-Boot] [PATCH 30/45] Add a header file for strings sjg at google.com
2018-10-09 23:55 ` [U-Boot] [PATCH 29/45] malloc_simple: Add logging of allocations sjg at google.com
2018-10-09 23:55 ` [U-Boot] [PATCH 28/45] log: Add comments to the rest of the log categories sjg at google.com
2018-10-09 23:55 ` [U-Boot] [PATCH 27/45] binman: Add a test for Intel reference code sjg at google.com
2018-10-09 23:55 ` [U-Boot] [PATCH 26/45] binman: Move to three-digit test-file numbers sjg at google.com
2018-10-09 23:55 ` [U-Boot] [PATCH 25/45] tpm: Add a few new commands for v1 sjg at google.com
2018-10-09 23:55 ` [U-Boot] [PATCH 24/45] tpm: Tidy up logging in tpm-common.c sjg at google.com
2018-10-09 23:55 ` [U-Boot] [PATCH 23/45] tpm: Use livetree and allow children sjg at google.com
2018-10-09 23:55 ` [U-Boot] [PATCH 21/45] fdt: Remove fdtdec_decode_region() function sjg at google.com
2018-10-09 23:55 ` [U-Boot] [PATCH 20/45] dm: spi: Add logging of some return values sjg at google.com
2018-10-09 23:55 ` [U-Boot] [PATCH 19/45] cros: Adjust board_get_cros_ec_dev() to return a udevice sjg at google.com
2018-10-09 23:55 ` [U-Boot] [PATCH 18/45] cros: Update cros_ec code to use struct udevice sjg at google.com
2018-10-09 23:55 ` [U-Boot] [PATCH 17/45] fdt: Allow libfdt in TPL sjg at google.com
2018-10-09 23:55 ` [U-Boot] [PATCH 16/45] serial: Allow serial to be absent " sjg at google.com
2018-10-09 23:55 ` [U-Boot] [PATCH 15/45] tpm: Add support for SPL and TPL sjg at google.com
2018-10-09 23:55 ` [U-Boot] [PATCH 14/45] fdt: Allow indicating a node is for U-Boot proper only sjg at google.com
2018-10-09 23:55 ` [U-Boot] [PATCH 13/45] doc: Update docs for device tree in SPL, TPL sjg at google.com
2018-10-09 23:55 ` [U-Boot] [PATCH 12/45] fdt: Document the fact that dtc is now built sjg at google.com
2018-10-09 23:55 ` [U-Boot] [PATCH 11/45] rtc: Allow use of RTC in SPL and TPL sjg at google.com
2018-10-09 23:55 ` [U-Boot] [PATCH 10/45] Kconfig: Convert CONFIG_RTC_MC146818 to Kconfig sjg at google.com
2018-10-09 23:55 ` [U-Boot] [PATCH 09/45] blk: Support block drivers in TPL sjg at google.com
2018-10-09 23:55 ` [U-Boot] [PATCH 08/45] spl: misc: Allow misc drivers in SPL and TPL sjg at google.com
2018-10-09 23:55 ` [U-Boot] [PATCH 07/45] Makefile: Add a warning if SPL/TPL cannot be built sjg at google.com
2018-10-09 23:55 ` [U-Boot] [PATCH 06/45] spl: input: Allow input in SPL and TPL sjg at google.com
2018-10-09 23:55 ` [U-Boot] [PATCH 05/45] sf: Avoid allocating memory on every read operation sjg at google.com
2018-10-09 23:55 ` [U-Boot] [PATCH 04/45] dm: core: Update ofnode to read binman-style flash entry sjg at google.com
2018-10-09 23:55 ` [U-Boot] [PATCH 03/45] dm: core: Add a function to find the first inactive child sjg at google.com
2018-10-09 23:55 ` [U-Boot] [PATCH 02/45] dm: core: Update some functions to use const sjg at google.com
2018-10-09 23:55 ` [U-Boot] [PATCH 01/45] dm: core: Alloc uclass-private data to be cache-aligned sjg at google.com

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.