Merge branch '2019-07-17-master-imports'
authorTom Rini <trini@konsulko.com>
Thu, 18 Jul 2019 15:31:37 +0000 (11:31 -0400)
committerTom Rini <trini@konsulko.com>
Thu, 18 Jul 2019 15:31:37 +0000 (11:31 -0400)
- Various FS/disk related fixes with security implications.
- Proper fix for the pci_ep test.
- Assorted bugfixes
- Some MediaTek updates.
- 'env erase' support.

45 files changed:
.travis.yml
arch/arm/Kconfig
arch/arm/cpu/armv8/fsl-layerscape/Kconfig
arch/arm/dts/mt7629-rfb.dts
arch/arm/dts/mt7629.dtsi
arch/arm/include/asm/proc-armv/ptrace.h
arch/arm/mach-mediatek/mt7629/lowlevel_init.S
board/emulation/qemu-riscv/Kconfig
cmd/Kconfig
cmd/mem.c
cmd/nvedit.c
common/command.c
configs/UCP1020_SPIFLASH_defconfig [deleted file]
configs/mt7629_rfb_defconfig
disk/part_dos.c
doc/README.android-fastboot-protocol [deleted file]
doc/README.chromium
doc/android/fastboot-protocol.txt [new file with mode: 0644]
doc/android/fastboot.txt
doc/uImage.FIT/signature.txt
drivers/block/blk-uclass.c
drivers/pci_endpoint/sandbox-pci_ep.c
drivers/power/regulator/Kconfig
drivers/power/regulator/Makefile
drivers/power/regulator/fixed.c
drivers/power/regulator/gpio-regulator.c
drivers/power/regulator/regulator_common.c [new file with mode: 0644]
drivers/power/regulator/regulator_common.h [new file with mode: 0644]
drivers/rtc/ds3231.c
env/env.c
env/mmc.c
fs/ext4/ext4_common.c
fs/ext4/ext4_journal.c
fs/ext4/ext4_journal.h
fs/ext4/ext4_write.c
fs/ext4/ext4fs.c
include/configs/qemu-arm.h
include/environment.h
include/ext_common.h
include/power-domain.h
lib/rsa/rsa-sign.c
scripts/config_whitelist.txt
test/py/tests/test_gpt.py
tools/mkenvimage.c
tools/mkimage.c

index d5866443b75900bea75775a88ef4cfdf19aacb94..f20268bde350a5b795244412f3f626e5dc568d6f 100644 (file)
@@ -365,13 +365,11 @@ matrix:
     - name: "test/py sandbox"
       env:
         - TEST_PY_BD="sandbox"
-          TEST_PY_TEST_SPEC="not pci"
           BUILDMAN="^sandbox$"
           TOOLCHAIN="i386"
     - name: "test/py sandbox with clang"
       env:
         - TEST_PY_BD="sandbox"
-          TEST_PY_TEST_SPEC="not pci"
           BUILDMAN="^sandbox$"
           OVERRIDE="clang-7"
     - name: "test/py sandbox_spl"
@@ -384,7 +382,6 @@ matrix:
     - name: "test/py sandbox_flattree"
       env:
         - TEST_PY_BD="sandbox_flattree"
-          TEST_PY_TEST_SPEC="not pci"
           BUILDMAN="^sandbox_flattree$"
           TOOLCHAIN="i386"
     - name: "test/py evb-ast2500"
index 05606d9722e8c5d0718ab4d31b83b028d9caa3bf..51d4acedac4494aea7df6e99bd66838eb7eb75e8 100644 (file)
@@ -840,6 +840,7 @@ config ARCH_OWL
 
 config ARCH_QEMU
        bool "QEMU Virtual Platform"
+       select ARCH_SUPPORT_TFABOOT
        select DM
        select DM_SERIAL
        select OF_CONTROL
@@ -1100,6 +1101,7 @@ config TARGET_LS1088AQDS
        select ARCH_MISC_INIT
        select ARM64
        select ARMV8_MULTIENTRY
+       select ARCH_SUPPORT_TFABOOT
        select BOARD_LATE_INIT
        select SUPPORT_SPL
        select FSL_DDR_INTERACTIVE if !SD_BOOT
@@ -1115,6 +1117,7 @@ config TARGET_LS2080AQDS
        select ARCH_MISC_INIT
        select ARM64
        select ARMV8_MULTIENTRY
+       select ARCH_SUPPORT_TFABOOT
        select BOARD_LATE_INIT
        select SUPPORT_SPL
        imply SCSI
@@ -1133,6 +1136,7 @@ config TARGET_LS2080ARDB
        select ARCH_MISC_INIT
        select ARM64
        select ARMV8_MULTIENTRY
+       select ARCH_SUPPORT_TFABOOT
        select BOARD_LATE_INIT
        select SUPPORT_SPL
        select FSL_DDR_BIST
@@ -1165,6 +1169,7 @@ config TARGET_LX2160ARDB
        select ARCH_MISC_INIT
        select ARM64
        select ARMV8_MULTIENTRY
+       select ARCH_SUPPORT_TFABOOT
        select BOARD_LATE_INIT
        help
          Support for NXP LX2160ARDB platform.
@@ -1178,6 +1183,7 @@ config TARGET_LX2160AQDS
        select ARCH_MISC_INIT
        select ARM64
        select ARMV8_MULTIENTRY
+       select ARCH_SUPPORT_TFABOOT
        select BOARD_LATE_INIT
        help
          Support for NXP LX2160AQDS platform.
@@ -1218,6 +1224,7 @@ config TARGET_LS1012AQDS
        bool "Support ls1012aqds"
        select ARCH_LS1012A
        select ARM64
+       select ARCH_SUPPORT_TFABOOT
        select BOARD_LATE_INIT
        help
          Support for Freescale LS1012AQDS platform.
@@ -1229,6 +1236,7 @@ config TARGET_LS1012ARDB
        bool "Support ls1012ardb"
        select ARCH_LS1012A
        select ARM64
+       select ARCH_SUPPORT_TFABOOT
        select BOARD_LATE_INIT
        imply SCSI
        imply SCSI_AHCI
@@ -1242,6 +1250,7 @@ config TARGET_LS1012A2G5RDB
        bool "Support ls1012a2g5rdb"
        select ARCH_LS1012A
        select ARM64
+       select ARCH_SUPPORT_TFABOOT
        select BOARD_LATE_INIT
        imply SCSI
        help
@@ -1254,6 +1263,7 @@ config TARGET_LS1012AFRWY
        bool "Support ls1012afrwy"
        select ARCH_LS1012A
        select ARM64
+       select ARCH_SUPPORT_TFABOOT
        select BOARD_LATE_INIT
        imply SCSI
        imply SCSI_AHCI
@@ -1267,6 +1277,7 @@ config TARGET_LS1012AFRDM
        bool "Support ls1012afrdm"
        select ARCH_LS1012A
        select ARM64
+       select ARCH_SUPPORT_TFABOOT
        help
          Support for Freescale LS1012AFRDM platform.
          The LS1012A Freedom  board (FRDM) is a high-performance
@@ -1278,6 +1289,7 @@ config TARGET_LS1028AQDS
        select ARCH_LS1028A
        select ARM64
        select ARMV8_MULTIENTRY
+       select ARCH_SUPPORT_TFABOOT
        help
          Support for Freescale LS1028AQDS platform
          The LS1028A Development System (QDS) is a high-performance
@@ -1289,6 +1301,7 @@ config TARGET_LS1028ARDB
        select ARCH_LS1028A
        select ARM64
        select ARMV8_MULTIENTRY
+       select ARCH_SUPPORT_TFABOOT
        help
          Support for Freescale LS1028ARDB platform
          The LS1028A Development System (RDB) is a high-performance
@@ -1301,6 +1314,7 @@ config TARGET_LS1088ARDB
        select ARCH_MISC_INIT
        select ARM64
        select ARMV8_MULTIENTRY
+       select ARCH_SUPPORT_TFABOOT
        select BOARD_LATE_INIT
        select SUPPORT_SPL
        select FSL_DDR_INTERACTIVE if !SD_BOOT
@@ -1359,6 +1373,7 @@ config TARGET_LS1043AQDS
        select ARCH_LS1043A
        select ARM64
        select ARMV8_MULTIENTRY
+       select ARCH_SUPPORT_TFABOOT
        select BOARD_EARLY_INIT_F
        select BOARD_LATE_INIT
        select SUPPORT_SPL
@@ -1373,6 +1388,7 @@ config TARGET_LS1043ARDB
        select ARCH_LS1043A
        select ARM64
        select ARMV8_MULTIENTRY
+       select ARCH_SUPPORT_TFABOOT
        select BOARD_EARLY_INIT_F
        select BOARD_LATE_INIT
        select SUPPORT_SPL
@@ -1384,6 +1400,7 @@ config TARGET_LS1046AQDS
        select ARCH_LS1046A
        select ARM64
        select ARMV8_MULTIENTRY
+       select ARCH_SUPPORT_TFABOOT
        select BOARD_EARLY_INIT_F
        select BOARD_LATE_INIT
        select DM_SPI_FLASH if DM_SPI
@@ -1403,6 +1420,7 @@ config TARGET_LS1046ARDB
        select ARCH_LS1046A
        select ARM64
        select ARMV8_MULTIENTRY
+       select ARCH_SUPPORT_TFABOOT
        select BOARD_EARLY_INIT_F
        select BOARD_LATE_INIT
        select DM_SPI_FLASH if DM_SPI
@@ -1422,6 +1440,7 @@ config TARGET_LS1046AFRWY
        select ARCH_LS1046A
        select ARM64
        select ARMV8_MULTIENTRY
+       select ARCH_SUPPORT_TFABOOT
        select BOARD_EARLY_INIT_F
        select BOARD_LATE_INIT
        select DM_SPI_FLASH if DM_SPI
@@ -1565,6 +1584,17 @@ config ARCH_ASPEED
 
 endchoice
 
+config ARCH_SUPPORT_TFABOOT
+       bool
+
+config TFABOOT
+       bool "Support for booting from TF-A"
+       depends on ARCH_SUPPORT_TFABOOT
+       default n
+       help
+         Enabling this will make a U-Boot binary that is capable of being
+         booted via TF-A.
+
 config TI_SECURE_DEVICE
        bool "HS Device Type Support"
        depends on ARCH_KEYSTONE || ARCH_OMAP2PLUS || ARCH_K3
index 3f6c983aaf41697dbe9ccb5ad5317ff037575288..5c32738fbf3d74473151577b28e08e880e58841c 100644 (file)
@@ -623,10 +623,3 @@ config HAS_FSL_XHCI_USB
        help
          For some SoC(such as LS1043A and LS1046A), USB and QE-HDLC multiplex use
          pins, select it when the pins are assigned to USB.
-
-config TFABOOT
-       bool "Support for booting from TFA"
-       default n
-       help
-         Enabling this will make a U-Boot binary that is capable of being
-         booted via TFA.
index 4612218a1ebf2b9ba236d1d04eae09badf1bdac8..08c3b592223ac2b29ca87189a9d21494b41ef11b 100644 (file)
@@ -18,7 +18,6 @@
 
        chosen {
                stdout-path = &uart0;
-               tick-timer = &timer0;
        };
 };
 
index c87115e0fe4ce382fbfce1077f51df627c465173..ecbd29d7ae430106e1f792ddaa9105a4f5e1c10c 100644 (file)
@@ -82,8 +82,8 @@
                compatible = "mediatek,timer";
                reg = <0x10004000 0x80>;
                interrupts = <GIC_SPI 152 IRQ_TYPE_LEVEL_LOW>;
-               clocks = <&topckgen CLK_TOP_10M_SEL>,
-                        <&topckgen CLK_TOP_CLKXTAL_D4>;
+               clocks = <&topckgen CLK_TOP_CLKXTAL_D4>,
+                        <&topckgen CLK_TOP_10M_SEL>;
                clock-names = "mux", "src";
                u-boot,dm-pre-reloc;
        };
index 183b00a08719fb8a9c024303d5f8ec086d5f545f..e37ad8fd1fe8199c20b999c6a4aff1645f838891 100644 (file)
@@ -86,7 +86,7 @@ struct pt_regs {
 #define user_mode(regs)        \
        (((regs)->ARM_cpsr & 0xf) == 0)
 
-#ifdef CONFIG_ARM_THUMB
+#if CONFIG_IS_ENABLED(SYS_THUMB_BUILD)
 #define thumb_mode(regs) \
        (((regs)->ARM_cpsr & T_BIT))
 #else
index 3375796b79771d73dce5e36e567dff50cd863b5b..0a0672cbea7557b5ce9052bad39686f9d5358f28 100644 (file)
@@ -4,6 +4,7 @@
  */
 
 #include <linux/linkage.h>
+#include <asm/proc-armv/ptrace.h>
 
 #define WAIT_CODE_SRAM_BASE    0x0010ff00
 
@@ -27,6 +28,18 @@ ENTRY(lowlevel_init)
        movt    r0, #0x131
        mcr     p15, 0, r0, c14, c0, 0
 
+       cps     #MON_MODE
+       mrc     p15, 0, r1, c1, c1, 0   @ Get Secure Config
+       orr     r0, r1, #1
+       mcr     p15, 0, r0, c1, c1, 0   @ Set Non Secure bit
+       isb
+       mov     r0, #0
+       mcrr    p15, 4, r0, r0, c14     @ CNTVOFF = 0
+       isb
+       mcr     p15, 0, r1, c1, c1, 0   @ Set Secure bit
+       isb
+       cps     #SVC_MODE
+
        /* enable SMP bit */
        mrc     p15, 0, r0, c1, c0, 1
        orr     r0, r0, #0x40
index 7f9a74dd48e384f0908a599d4ffed12dec1b433a..6cc7c31dc6570d08f6983f1e5d6bbf5352d44cb1 100644 (file)
@@ -24,6 +24,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy
        imply VIRTIO_MMIO
        imply VIRTIO_NET
        imply VIRTIO_BLK
+       imply VIRTIO_PCI
        imply CMD_PING
        imply CMD_FS_GENERIC
        imply DOS_PARTITION
index 67284d8a5f6a2dc24cf86d0577814fdc4ba28272..175c6ad9e3338d0b83062eae932c3e0cd8afc812 100644 (file)
@@ -408,6 +408,14 @@ config CMD_SAVEENV
          Save all environment variables into the compiled-in persistent
          storage.
 
+config CMD_ERASEENV
+       bool "eraseenv"
+       default n
+       depends on CMD_SAVEENV
+       help
+         Erase environment variables from the compiled-in persistent
+         storage.
+
 config CMD_ENV_EXISTS
        bool "env exists"
        default y
@@ -563,6 +571,13 @@ config CMD_MEMORY
            base - print or set address offset
            loop - initialize loop on address range
 
+config CMD_RANDOM
+       bool "random"
+       default y
+       depends on CMD_MEMORY && (LIB_RAND || LIB_HW_RAND)
+       help
+         random - fill memory with random data
+
 config CMD_MEMTEST
        bool "memtest"
        help
index 392ed1756b636ea89bfc40302134ccc05993cf41..c6b8038fc9dd61e7de81eb4a02c76d6805ec6d34 100644 (file)
--- a/cmd/mem.c
+++ b/cmd/mem.c
@@ -1082,6 +1082,49 @@ static int do_mem_crc(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 
 #endif
 
+#ifdef CONFIG_CMD_RANDOM
+static int do_random(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+       unsigned long addr, len;
+       unsigned long seed; // NOT INITIALIZED ON PURPOSE
+       unsigned int *buf, *start;
+       unsigned char *buf8;
+       unsigned int i;
+
+       if (argc < 3 || argc > 4) {
+               printf("usage: %s <addr> <len> [<seed>]\n", argv[0]);
+               return 0;
+       }
+
+       len = simple_strtoul(argv[2], NULL, 16);
+       addr = simple_strtoul(argv[1], NULL, 16);
+
+       if (argc == 4) {
+               seed = simple_strtoul(argv[3], NULL, 16);
+               if (seed == 0) {
+                       printf("The seed cannot be 0. Using 0xDEADBEEF.\n");
+                       seed = 0xDEADBEEF;
+               }
+       } else {
+               seed = get_timer(0) ^ rand();
+       }
+
+       srand(seed);
+       start = map_sysmem(addr, len);
+       buf = start;
+       for (i = 0; i < (len / 4); i++)
+               *buf++ = rand();
+
+       buf8 = (unsigned char *)buf;
+       for (i = 0; i < (len % 4); i++)
+               *buf8++ = rand() & 0xFF;
+
+       unmap_sysmem(start);
+       printf("%lu bytes filled with random data\n", len);
+       return 1;
+}
+#endif
+
 /**************************************************/
 U_BOOT_CMD(
        md,     3,      1,      do_mem_md,
@@ -1250,3 +1293,12 @@ U_BOOT_CMD(
        ""
 );
 #endif
+
+#ifdef CONFIG_CMD_RANDOM
+U_BOOT_CMD(
+       random, 4,      0,      do_random,
+       "fill memory with random pattern",
+       "<addr> <len> [<seed>]\n"
+       "   - Fill 'len' bytes of memory starting at 'addr' with random data\n"
+);
+#endif
index 7e468ab39d6a9e737c10990f46f479a8bced0c8e..46b1e60f0ad92372409fe738902fd2c18ceb3f9a 100644 (file)
@@ -767,6 +767,20 @@ U_BOOT_CMD(
        "save environment variables to persistent storage",
        ""
 );
+
+#if defined(CONFIG_CMD_ERASEENV)
+static int do_env_erase(cmd_tbl_t *cmdtp, int flag, int argc,
+                       char * const argv[])
+{
+       return env_erase() ? 1 : 0;
+}
+
+U_BOOT_CMD(
+       eraseenv, 1, 0, do_env_erase,
+       "erase environment variables from persistent storage",
+       ""
+);
+#endif
 #endif
 #endif /* CONFIG_SPL_BUILD */
 
@@ -1316,6 +1330,9 @@ static cmd_tbl_t cmd_env_sub[] = {
 #endif
 #if defined(CONFIG_CMD_SAVEENV) && defined(ENV_IS_IN_DEVICE)
        U_BOOT_CMD_MKENT(save, 1, 0, do_env_save, "", ""),
+#if defined(CONFIG_CMD_ERASEENV)
+       U_BOOT_CMD_MKENT(erase, 1, 0, do_env_erase, "", ""),
+#endif
 #endif
        U_BOOT_CMD_MKENT(set, CONFIG_SYS_MAXARGS, 0, do_env_set, "", ""),
 #if defined(CONFIG_CMD_ENV_EXISTS)
@@ -1396,6 +1413,9 @@ static char env_help_text[] =
 #endif
 #if defined(CONFIG_CMD_SAVEENV) && defined(ENV_IS_IN_DEVICE)
        "env save - save environment\n"
+#if defined(CONFIG_CMD_ERASEENV)
+       "env erase - erase environment\n"
+#endif
 #endif
 #if defined(CONFIG_CMD_NVEDIT_EFI)
        "env set -e name [arg ...] - set UEFI variable; unset if 'arg' not specified\n"
index e192bb2a619ec5dffe46f4bb0dee7275f8faf35c..db25bf54e0598858559565f475d3d530e105733d 100644 (file)
@@ -356,8 +356,13 @@ int cmd_auto_complete(const char *const prompt, char *buf, int *np, int *colp)
        int i, j, k, len, seplen, argc;
        int cnt;
        char last_char;
+#ifdef CONFIG_CMDLINE_PS_SUPPORT
+       const char *ps_prompt = env_get("PS1");
+#else
+       const char *ps_prompt = CONFIG_SYS_PROMPT;
+#endif
 
-       if (strcmp(prompt, CONFIG_SYS_PROMPT) != 0)
+       if (strcmp(prompt, ps_prompt) != 0)
                return 0;       /* not in normal console */
 
        cnt = strlen(buf);
diff --git a/configs/UCP1020_SPIFLASH_defconfig b/configs/UCP1020_SPIFLASH_defconfig
deleted file mode 100644 (file)
index a2d7e66..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-CONFIG_PPC=y
-CONFIG_SYS_TEXT_BASE=0x11000000
-CONFIG_MPC85xx=y
-CONFIG_TARGET_UCP1020=y
-CONFIG_TARGET_UCP1020_SPIFLASH=y
-CONFIG_FIT=y
-CONFIG_FIT_VERBOSE=y
-CONFIG_OF_BOARD_SETUP=y
-CONFIG_OF_STDOUT_VIA_ALIAS=y
-# CONFIG_MISC_INIT_R is not set
-CONFIG_BOARD_EARLY_INIT_F=y
-CONFIG_BOARD_EARLY_INIT_R=y
-CONFIG_LAST_STAGE_INIT=y
-CONFIG_HUSH_PARSER=y
-# CONFIG_AUTO_COMPLETE is not set
-CONFIG_AUTOBOOT_KEYED=y
-CONFIG_AUTOBOOT_PROMPT="Autobooting in %d seconds, press \"<Esc>\" to stop\n"
-CONFIG_AUTOBOOT_STOP_STR="\x1b"
-CONFIG_CMD_IMLS=y
-CONFIG_CMD_GPIO=y
-CONFIG_CMD_I2C=y
-CONFIG_CMD_MMC=y
-# CONFIG_CMD_NAND is not set
-CONFIG_CMD_MMC_SPI=y
-CONFIG_CMD_SF=y
-CONFIG_CMD_SPI=y
-CONFIG_CMD_USB=y
-CONFIG_CMD_DHCP=y
-CONFIG_CMD_MII=y
-CONFIG_CMD_PING=y
-CONFIG_CMD_DATE=y
-CONFIG_MP=y
-# CONFIG_CMD_HASH is not set
-CONFIG_CMD_CRAMFS=y
-CONFIG_CMD_EXT2=y
-CONFIG_CMD_FAT=y
-CONFIG_ENV_IS_IN_SPI_FLASH=y
-CONFIG_FSL_ESDHC=y
-CONFIG_MTD_NOR_FLASH=y
-CONFIG_FLASH_CFI_DRIVER=y
-CONFIG_SYS_FLASH_USE_BUFFER_WRITE=y
-CONFIG_SYS_FLASH_CFI=y
-CONFIG_SPI_FLASH=y
-CONFIG_SF_DEFAULT_MODE=0
-CONFIG_SF_DEFAULT_SPEED=10000000
-CONFIG_SPI_FLASH_STMICRO=y
-CONFIG_SPI_FLASH_SST=y
-CONFIG_SPI_FLASH_WINBOND=y
-CONFIG_PHY_MARVELL=y
-CONFIG_PHY_GIGE=y
-CONFIG_E1000=y
-CONFIG_MII=y
-CONFIG_TSEC_ENET=y
-CONFIG_SYS_NS16550=y
-CONFIG_SPI=y
-CONFIG_FSL_ESPI=y
-CONFIG_USB=y
-CONFIG_USB_STORAGE=y
-CONFIG_FS_CRAMFS=y
-CONFIG_OF_LIBFDT=y
index 0dceafdaa676894738d9bcfe35bc1c3437179285..d6a7c84df35ea53a7563e5572ec8377e547df28e 100644 (file)
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_SYS_ARCH_TIMER=y
 CONFIG_SYS_THUMB_BUILD=y
 CONFIG_ARCH_MEDIATEK=y
 CONFIG_SYS_TEXT_BASE=0x41e00000
@@ -67,9 +68,6 @@ CONFIG_MTK_QSPI=y
 CONFIG_SYSRESET=y
 CONFIG_SPL_SYSRESET=y
 CONFIG_SYSRESET_WATCHDOG=y
-CONFIG_TIMER=y
-CONFIG_SPL_TIMER=y
-CONFIG_MTK_TIMER=y
 CONFIG_WDT_MTK=y
 CONFIG_LZMA=y
 # CONFIG_EFI_LOADER is not set
index 936cee0d36cedc7ad3fa55180666175582f16bd0..aae9d9590639edfa774fdab47b7dec9494039295 100644 (file)
 
 #define DOS_PART_DEFAULT_SECTOR 512
 
+/* should this be configurable? It looks like it's not very common at all
+ * to use large numbers of partitions */
+#define MAX_EXT_PARTS 256
+
 /* Convert char[4] in little endian format to the host format integer
  */
 static inline unsigned int le32_to_int(unsigned char *le32)
@@ -126,6 +130,13 @@ static void print_partition_extended(struct blk_desc *dev_desc,
        dos_partition_t *pt;
        int i;
 
+       /* set a maximum recursion level */
+       if (part_num > MAX_EXT_PARTS)
+       {
+               printf("** Nested DOS partitions detected, stopping **\n");
+               return;
+    }
+
        if (blk_dread(dev_desc, ext_part_sector, 1, (ulong *)buffer) != 1) {
                printf ("** Can't read partition table on %d:" LBAFU " **\n",
                        dev_desc->devnum, ext_part_sector);
@@ -191,6 +202,13 @@ static int part_get_info_extended(struct blk_desc *dev_desc,
        int i;
        int dos_type;
 
+       /* set a maximum recursion level */
+       if (part_num > MAX_EXT_PARTS)
+       {
+               printf("** Nested DOS partitions detected, stopping **\n");
+               return -1;
+    }
+
        if (blk_dread(dev_desc, ext_part_sector, 1, (ulong *)buffer) != 1) {
                printf ("** Can't read partition table on %d:" LBAFU " **\n",
                        dev_desc->devnum, ext_part_sector);
diff --git a/doc/README.android-fastboot-protocol b/doc/README.android-fastboot-protocol
deleted file mode 100644 (file)
index e9e7166..0000000
+++ /dev/null
@@ -1,170 +0,0 @@
-FastBoot  Version  0.4
-----------------------
-
-The fastboot protocol is a mechanism for communicating with bootloaders
-over USB.  It is designed to be very straightforward to implement, to
-allow it to be used across a wide range of devices and from hosts running
-Linux, Windows, or OSX.
-
-
-Basic Requirements
-------------------
-
-* Two bulk endpoints (in, out) are required
-* Max packet size must be 64 bytes for full-speed and 512 bytes for
-  high-speed USB
-* The protocol is entirely host-driven and synchronous (unlike the
-  multi-channel, bi-directional, asynchronous ADB protocol)
-
-
-Transport and Framing
----------------------
-
-1. Host sends a command, which is an ascii string in a single
-   packet no greater than 64 bytes.
-
-2. Client response with a single packet no greater than 64 bytes.
-   The first four bytes of the response are "OKAY", "FAIL", "DATA",
-   or "INFO".  Additional bytes may contain an (ascii) informative
-   message.
-
-   a. INFO -> the remaining 60 bytes are an informative message
-      (providing progress or diagnostic messages).  They should
-      be displayed and then step #2 repeats
-
-   b. FAIL -> the requested command failed.  The remaining 60 bytes
-      of the response (if present) provide a textual failure message
-      to present to the user.  Stop.
-
-   c. OKAY -> the requested command completed successfully.  Go to #5
-
-   d. DATA -> the requested command is ready for the data phase.
-      A DATA response packet will be 12 bytes long, in the form of
-      DATA00000000 where the 8 digit hexidecimal number represents
-      the total data size to transfer.
-
-3. Data phase.  Depending on the command, the host or client will
-   send the indicated amount of data.  Short packets are always
-   acceptable and zero-length packets are ignored.  This phase continues
-   until the client has sent or received the number of bytes indicated
-   in the "DATA" response above.
-
-4. Client responds with a single packet no greater than 64 bytes.
-   The first four bytes of the response are "OKAY", "FAIL", or "INFO".
-   Similar to #2:
-
-   a. INFO -> display the remaining 60 bytes and return to #4
-
-   b. FAIL -> display the remaining 60 bytes (if present) as a failure
-      reason and consider the command failed.  Stop.
-
-   c. OKAY -> success.  Go to #5
-
-5. Success.  Stop.
-
-
-Example Session
----------------
-
-Host:    "getvar:version"        request version variable
-
-Client:  "OKAY0.4"               return version "0.4"
-
-Host:    "getvar:nonexistant"    request some undefined variable
-
-Client:  "OKAY"                  return value ""
-
-Host:    "download:00001234"     request to send 0x1234 bytes of data
-
-Client:  "DATA00001234"          ready to accept data
-
-Host:    < 0x1234 bytes >        send data
-
-Client:  "OKAY"                  success
-
-Host:    "flash:bootloader"      request to flash the data to the bootloader
-
-Client:  "INFOerasing flash"     indicate status / progress
-         "INFOwriting flash"
-         "OKAY"                  indicate success
-
-Host:    "powerdown"             send a command
-
-Client:  "FAILunknown command"   indicate failure
-
-
-Command Reference
------------------
-
-* Command parameters are indicated by printf-style escape sequences.
-
-* Commands are ascii strings and sent without the quotes (which are
-  for illustration only here) and without a trailing 0 byte.
-
-* Commands that begin with a lowercase letter are reserved for this
-  specification.  OEM-specific commands should not begin with a
-  lowercase letter, to prevent incompatibilities with future specs.
-
- "getvar:%s"           Read a config/version variable from the bootloader.
-                       The variable contents will be returned after the
-                       OKAY response.
-
- "download:%08x"       Write data to memory which will be later used
-                       by "boot", "ramdisk", "flash", etc.  The client
-                       will reply with "DATA%08x" if it has enough
-                       space in RAM or "FAIL" if not.  The size of
-                       the download is remembered.
-
-  "verify:%08x"        Send a digital signature to verify the downloaded
-                       data.  Required if the bootloader is "secure"
-                       otherwise "flash" and "boot" will be ignored.
-
-  "flash:%s"           Write the previously downloaded image to the
-                       named partition (if possible).
-
-  "erase:%s"           Erase the indicated partition (clear to 0xFFs)
-
-  "boot"               The previously downloaded data is a boot.img
-                       and should be booted according to the normal
-                       procedure for a boot.img
-
-  "continue"           Continue booting as normal (if possible)
-
-  "reboot"             Reboot the device.
-
-  "reboot-bootloader"  Reboot back into the bootloader.
-                       Useful for upgrade processes that require upgrading
-                       the bootloader and then upgrading other partitions
-                       using the new bootloader.
-
-  "powerdown"          Power off the device.
-
-
-
-Client Variables
-----------------
-
-The "getvar:%s" command is used to read client variables which
-represent various information about the device and the software
-on it.
-
-The various currently defined names are:
-
-  version             Version of FastBoot protocol supported.
-                      It should be "0.3" for this document.
-
-  version-bootloader  Version string for the Bootloader.
-
-  version-baseband    Version string of the Baseband Software
-
-  product             Name of the product
-
-  serialno            Product serial number
-
-  secure              If the value is "yes", this is a secure
-                      bootloader requiring a signature before
-                      it will install or boot images.
-
-Names starting with a lowercase character are reserved by this
-specification.  OEM-specific names should not start with lowercase
-characters.
index 096bc4f1f7f0f16a9cb4bdae9bb716bfb4efb4f7..8f67da6c7283bdb085aeb76f9949eddc8568361b 100644 (file)
@@ -33,12 +33,18 @@ To obtain:
    cd u-boot
    git checkout cros-master
 
+   cd ..
+   git clone https://chromium.googlesource.com/chromiumos/platform/vboot_reference
+   cd vboot_reference
+   git checkout 45964294
+   #  futility: updater: Correct output version for Snow
+
 To build for sandbox:
 
    UB=/tmp/b/chromeos_sandbox    # U-Boot build directory
-   CROS=/home/sglass/cosarm      # Chromium OS directory
-   make O=$UB/chromeos_sandbox_defconfig
-   make O=$UB -j20 -s VBOOT_SOURCE=$CROS/src/platform/vboot_reference \
+   cd u-boot
+   make O=$UB chromeos_sandbox_defconfig
+   make O=$UB -j20 -s VBOOT_SOURCE=/path/to/vboot_reference \
        MAKEFLAGS_VBOOT=DEBUG=1 QUIET=1
 
 Replace sandbox with another supported target.
diff --git a/doc/android/fastboot-protocol.txt b/doc/android/fastboot-protocol.txt
new file mode 100644 (file)
index 0000000..e9e7166
--- /dev/null
@@ -0,0 +1,170 @@
+FastBoot  Version  0.4
+----------------------
+
+The fastboot protocol is a mechanism for communicating with bootloaders
+over USB.  It is designed to be very straightforward to implement, to
+allow it to be used across a wide range of devices and from hosts running
+Linux, Windows, or OSX.
+
+
+Basic Requirements
+------------------
+
+* Two bulk endpoints (in, out) are required
+* Max packet size must be 64 bytes for full-speed and 512 bytes for
+  high-speed USB
+* The protocol is entirely host-driven and synchronous (unlike the
+  multi-channel, bi-directional, asynchronous ADB protocol)
+
+
+Transport and Framing
+---------------------
+
+1. Host sends a command, which is an ascii string in a single
+   packet no greater than 64 bytes.
+
+2. Client response with a single packet no greater than 64 bytes.
+   The first four bytes of the response are "OKAY", "FAIL", "DATA",
+   or "INFO".  Additional bytes may contain an (ascii) informative
+   message.
+
+   a. INFO -> the remaining 60 bytes are an informative message
+      (providing progress or diagnostic messages).  They should
+      be displayed and then step #2 repeats
+
+   b. FAIL -> the requested command failed.  The remaining 60 bytes
+      of the response (if present) provide a textual failure message
+      to present to the user.  Stop.
+
+   c. OKAY -> the requested command completed successfully.  Go to #5
+
+   d. DATA -> the requested command is ready for the data phase.
+      A DATA response packet will be 12 bytes long, in the form of
+      DATA00000000 where the 8 digit hexidecimal number represents
+      the total data size to transfer.
+
+3. Data phase.  Depending on the command, the host or client will
+   send the indicated amount of data.  Short packets are always
+   acceptable and zero-length packets are ignored.  This phase continues
+   until the client has sent or received the number of bytes indicated
+   in the "DATA" response above.
+
+4. Client responds with a single packet no greater than 64 bytes.
+   The first four bytes of the response are "OKAY", "FAIL", or "INFO".
+   Similar to #2:
+
+   a. INFO -> display the remaining 60 bytes and return to #4
+
+   b. FAIL -> display the remaining 60 bytes (if present) as a failure
+      reason and consider the command failed.  Stop.
+
+   c. OKAY -> success.  Go to #5
+
+5. Success.  Stop.
+
+
+Example Session
+---------------
+
+Host:    "getvar:version"        request version variable
+
+Client:  "OKAY0.4"               return version "0.4"
+
+Host:    "getvar:nonexistant"    request some undefined variable
+
+Client:  "OKAY"                  return value ""
+
+Host:    "download:00001234"     request to send 0x1234 bytes of data
+
+Client:  "DATA00001234"          ready to accept data
+
+Host:    < 0x1234 bytes >        send data
+
+Client:  "OKAY"                  success
+
+Host:    "flash:bootloader"      request to flash the data to the bootloader
+
+Client:  "INFOerasing flash"     indicate status / progress
+         "INFOwriting flash"
+         "OKAY"                  indicate success
+
+Host:    "powerdown"             send a command
+
+Client:  "FAILunknown command"   indicate failure
+
+
+Command Reference
+-----------------
+
+* Command parameters are indicated by printf-style escape sequences.
+
+* Commands are ascii strings and sent without the quotes (which are
+  for illustration only here) and without a trailing 0 byte.
+
+* Commands that begin with a lowercase letter are reserved for this
+  specification.  OEM-specific commands should not begin with a
+  lowercase letter, to prevent incompatibilities with future specs.
+
+ "getvar:%s"           Read a config/version variable from the bootloader.
+                       The variable contents will be returned after the
+                       OKAY response.
+
+ "download:%08x"       Write data to memory which will be later used
+                       by "boot", "ramdisk", "flash", etc.  The client
+                       will reply with "DATA%08x" if it has enough
+                       space in RAM or "FAIL" if not.  The size of
+                       the download is remembered.
+
+  "verify:%08x"        Send a digital signature to verify the downloaded
+                       data.  Required if the bootloader is "secure"
+                       otherwise "flash" and "boot" will be ignored.
+
+  "flash:%s"           Write the previously downloaded image to the
+                       named partition (if possible).
+
+  "erase:%s"           Erase the indicated partition (clear to 0xFFs)
+
+  "boot"               The previously downloaded data is a boot.img
+                       and should be booted according to the normal
+                       procedure for a boot.img
+
+  "continue"           Continue booting as normal (if possible)
+
+  "reboot"             Reboot the device.
+
+  "reboot-bootloader"  Reboot back into the bootloader.
+                       Useful for upgrade processes that require upgrading
+                       the bootloader and then upgrading other partitions
+                       using the new bootloader.
+
+  "powerdown"          Power off the device.
+
+
+
+Client Variables
+----------------
+
+The "getvar:%s" command is used to read client variables which
+represent various information about the device and the software
+on it.
+
+The various currently defined names are:
+
+  version             Version of FastBoot protocol supported.
+                      It should be "0.3" for this document.
+
+  version-bootloader  Version string for the Bootloader.
+
+  version-baseband    Version string of the Baseband Software
+
+  product             Name of the product
+
+  serialno            Product serial number
+
+  secure              If the value is "yes", this is a secure
+                      bootloader requiring a signature before
+                      it will install or boot images.
+
+Names starting with a lowercase character are reserved by this
+specification.  OEM-specific names should not start with lowercase
+characters.
index 431191c473f267e05b4df4774c9de49c020834b1..ea0d1da1fdc1c7d00271944099ed955bf5858752 100644 (file)
@@ -5,8 +5,8 @@ Android Fastboot
 Overview
 ========
 
-The protocol that is used over USB and UDP is described in the
-``README.android-fastboot-protocol`` file in the same directory.
+The protocol that is used over USB and UDP is described in
+``doc/android/fastboot-protocol.txt``.
 
 The current implementation supports the following standard commands:
 
index 78b59e7203fb1ad28aad2903bef82b652e9ec5aa..c9b1802686f4a6ff83861d9342d4980a357b47b8 100644 (file)
@@ -388,8 +388,8 @@ Test Verified Boot Run: signed config with bad hash: OK
 Test passed
 
 
-Hardware Signing with PKCS#11
------------------------------
+Hardware Signing with PKCS#11 or with HSM
+-----------------------------------------
 
 Securely managing private signing keys can challenging, especially when the
 keys are stored on the file system of a computer that is connected to the
@@ -402,14 +402,43 @@ them perform the signing. PKCS#11 is standard for interfacing with these crypto
 device.
 
 Requirements:
-Smartcard/USB token/HSM which can work with the pkcs11 engine
+Smartcard/USB token/HSM which can work with some openssl engine
 openssl
+
+For pkcs11 engine usage:
 libp11 (provides pkcs11 engine)
 p11-kit (recommended to simplify setup)
 opensc (for smartcards and smartcard like USB devices)
 gnutls (recommended for key generation, p11tool)
 
-The following examples use the Nitrokey Pro. Instructions for other devices may vary.
+For generic HSMs respective openssl engine must be installed and locateable by
+openssl. This may require setting up LD_LIBRARY_PATH if engine is not installed
+to openssl's default search paths.
+
+PKCS11 engine support forms "key id" based on "keydir" and with
+"key-name-hint". "key-name-hint" is used as "object" name and "keydir" if
+defined is used to define (prefix for) which PKCS11 source is being used for
+lookup up for the key.
+
+PKCS11 engine key ids:
+   "pkcs11:<keydir>;object=<key-name-hint>;type=<public|private>"
+or
+   "pkcs11:object=<key-name-hint>;type=<public|private>",
+
+Generic HSM engine support forms "key id" based on "keydir" and with
+"key-name-hint". If "keydir" is specified for mkimage it is used as a prefix in
+"key id" and is appended with "key-name-hint".
+
+Generic engine key ids:
+  "<keydir><key-name-hint>"
+or
+  "<key-name-hint>"
+
+As mkimage does not at this time support prompting for passwords HSM may need
+key preloading wrapper to be used when invoking mkimage.
+
+The following examples use the Nitrokey Pro using pkcs11 engine. Instructions
+for other devices may vary.
 
 Notes on pkcs11 engine setup:
 
index baaf431e5e0c3ce64af9b934fa140af496e0b2b5..c23b6682a6cc4857b7a52f5eb0e291e874773a91 100644 (file)
@@ -208,7 +208,11 @@ int blk_select_hwpart_devnum(enum if_type if_type, int devnum, int hwpart)
        if (ret)
                return ret;
 
-       return blk_select_hwpart(dev, hwpart);
+       ret = blk_select_hwpart(dev, hwpart);
+       if (!ret)
+               blkcache_invalidate(if_type, devnum);
+
+       return ret;
 }
 
 int blk_list_part(enum if_type if_type)
@@ -348,7 +352,13 @@ int blk_select_hwpart(struct udevice *dev, int hwpart)
 
 int blk_dselect_hwpart(struct blk_desc *desc, int hwpart)
 {
-       return blk_select_hwpart(desc->bdev, hwpart);
+       int ret;
+
+       ret = blk_select_hwpart(desc->bdev, hwpart);
+       if (!ret)
+               blkcache_invalidate(desc->if_type, desc->devnum);
+
+       return ret;
 }
 
 int blk_first_device(int if_type, struct udevice **devp)
index 0258433d8f93de9ed46cd6f661eecc08cda82c8a..8e05d5ba8906dd1f19dfb5b4b3973b017a7a0091 100644 (file)
@@ -83,14 +83,11 @@ static int sandbox_read_bar(struct udevice *dev, uint fn,
                            struct pci_bar *ep_bar, enum pci_barno barno)
 {
        struct sandbox_pci_ep_priv *priv = dev_get_priv(dev);
-       int bar_idx;
 
        if (fn > 0)
                return -ENODEV;
 
-       bar_idx = ep_bar->barno;
-
-       memcpy(ep_bar, &priv->bars[bar_idx], sizeof(*ep_bar));
+       memcpy(ep_bar, &priv->bars[barno], sizeof(*ep_bar));
 
        return 0;
 }
index 147e68d5c967a06c797fc754c272831dad7c9b7e..337e9e7471c7b09103cdd6ed6e72699fe7dd8cf2 100644 (file)
@@ -92,9 +92,18 @@ config DM_REGULATOR_FAN53555
          or switching the mode is not supported by this driver (at
          this time).
 
+config DM_REGULATOR_COMMON
+       bool
+       depends on DM_REGULATOR
+
+config SPL_DM_REGULATOR_COMMON
+       bool
+       depends on DM_REGULATOR
+
 config DM_REGULATOR_FIXED
        bool "Enable Driver Model for REGULATOR Fixed value"
        depends on DM_REGULATOR
+       select DM_REGULATOR_COMMON
        ---help---
        This config enables implementation of driver-model regulator uclass
        features for fixed value regulators. The driver implements get/set api
@@ -103,6 +112,7 @@ config DM_REGULATOR_FIXED
 config SPL_DM_REGULATOR_FIXED
        bool "Enable Driver Model for REGULATOR Fixed value in SPL"
        depends on DM_REGULATOR_FIXED
+       select SPL_DM_REGULATOR_COMMON
        ---help---
        This config enables implementation of driver-model regulator uclass
        features for fixed value regulators in SPL.
@@ -110,6 +120,7 @@ config SPL_DM_REGULATOR_FIXED
 config DM_REGULATOR_GPIO
        bool "Enable Driver Model for GPIO REGULATOR"
        depends on DM_REGULATOR && DM_GPIO
+       select DM_REGULATOR_COMMON
        ---help---
        This config enables implementation of driver-model regulator uclass
        features for gpio regulators. The driver implements get/set for
@@ -118,6 +129,7 @@ config DM_REGULATOR_GPIO
 config SPL_DM_REGULATOR_GPIO
        bool "Enable Driver Model for GPIO REGULATOR in SPL"
        depends on DM_REGULATOR_GPIO && SPL_GPIO_SUPPORT
+       select SPL_DM_REGULATOR_COMMON
        ---help---
        This config enables implementation of driver-model regulator uclass
        features for gpio regulators in SPL.
index 8c1506c88edb8e8a5c66fefa8d4daffb47046200..e728b73aee33718eb84e96ceae1739149f6acd16 100644 (file)
@@ -11,6 +11,7 @@ obj-$(CONFIG_DM_REGULATOR_MAX77686) += max77686.o
 obj-$(CONFIG_$(SPL_)DM_PMIC_PFUZE100) += pfuze100.o
 obj-$(CONFIG_$(SPL_)REGULATOR_PWM) += pwm_regulator.o
 obj-$(CONFIG_$(SPL_)DM_REGULATOR_FAN53555) += fan53555.o
+obj-$(CONFIG_$(SPL_)DM_REGULATOR_COMMON) += regulator_common.o
 obj-$(CONFIG_$(SPL_)DM_REGULATOR_FIXED) += fixed.o
 obj-$(CONFIG_$(SPL_)DM_REGULATOR_GPIO) += gpio-regulator.o
 obj-$(CONFIG_REGULATOR_RK8XX) += rk8xx.o
index a99aa783107e7e1279c8b4a98b682c829d759aea..763e671d54e936114b1732ee07e8cfc7cf4c909a 100644 (file)
@@ -5,56 +5,26 @@
  *  Przemyslaw Marczak <p.marczak@samsung.com>
  */
 
+#include "regulator_common.h"
 #include <common.h>
 #include <errno.h>
 #include <dm.h>
-#include <i2c.h>
-#include <asm/gpio.h>
 #include <power/pmic.h>
 #include <power/regulator.h>
 
-struct fixed_regulator_platdata {
-       struct gpio_desc gpio; /* GPIO for regulator enable control */
-       unsigned int startup_delay_us;
-       unsigned int off_on_delay_us;
-};
-
 static int fixed_regulator_ofdata_to_platdata(struct udevice *dev)
 {
        struct dm_regulator_uclass_platdata *uc_pdata;
-       struct fixed_regulator_platdata *dev_pdata;
-       struct gpio_desc *gpio;
-       int flags = GPIOD_IS_OUT;
-       int ret;
+       struct regulator_common_platdata *dev_pdata;
 
        dev_pdata = dev_get_platdata(dev);
        uc_pdata = dev_get_uclass_platdata(dev);
        if (!uc_pdata)
                return -ENXIO;
 
-       /* Set type to fixed */
        uc_pdata->type = REGULATOR_TYPE_FIXED;
 
-       if (dev_read_bool(dev, "enable-active-high"))
-               flags |= GPIOD_IS_OUT_ACTIVE;
-
-       /* Get fixed regulator optional enable GPIO desc */
-       gpio = &dev_pdata->gpio;
-       ret = gpio_request_by_name(dev, "gpio", 0, gpio, flags);
-       if (ret) {
-               debug("Fixed regulator optional enable GPIO - not found! Error: %d\n",
-                     ret);
-               if (ret != -ENOENT)
-                       return ret;
-       }
-
-       /* Get optional ramp up delay */
-       dev_pdata->startup_delay_us = dev_read_u32_default(dev,
-                                                       "startup-delay-us", 0);
-       dev_pdata->off_on_delay_us =
-                       dev_read_u32_default(dev, "u-boot,off-on-delay-us", 0);
-
-       return 0;
+       return regulator_common_ofdata_to_platdata(dev, dev_pdata, "gpio");
 }
 
 static int fixed_regulator_get_value(struct udevice *dev)
@@ -91,45 +61,12 @@ static int fixed_regulator_get_current(struct udevice *dev)
 
 static int fixed_regulator_get_enable(struct udevice *dev)
 {
-       struct fixed_regulator_platdata *dev_pdata = dev_get_platdata(dev);
-
-       /* Enable GPIO is optional */
-       if (!dev_pdata->gpio.dev)
-               return true;
-
-       return dm_gpio_get_value(&dev_pdata->gpio);
+       return regulator_common_get_enable(dev, dev_get_platdata(dev));
 }
 
 static int fixed_regulator_set_enable(struct udevice *dev, bool enable)
 {
-       struct fixed_regulator_platdata *dev_pdata = dev_get_platdata(dev);
-       int ret;
-
-       debug("%s: dev='%s', enable=%d, delay=%d, has_gpio=%d\n", __func__,
-             dev->name, enable, dev_pdata->startup_delay_us,
-             dm_gpio_is_valid(&dev_pdata->gpio));
-       /* Enable GPIO is optional */
-       if (!dm_gpio_is_valid(&dev_pdata->gpio)) {
-               if (!enable)
-                       return -ENOSYS;
-               return 0;
-       }
-
-       ret = dm_gpio_set_value(&dev_pdata->gpio, enable);
-       if (ret) {
-               pr_err("Can't set regulator : %s gpio to: %d\n", dev->name,
-                     enable);
-               return ret;
-       }
-
-       if (enable && dev_pdata->startup_delay_us)
-               udelay(dev_pdata->startup_delay_us);
-       debug("%s: done\n", __func__);
-
-       if (!enable && dev_pdata->off_on_delay_us)
-               udelay(dev_pdata->off_on_delay_us);
-
-       return 0;
+       return regulator_common_set_enable(dev, dev_get_platdata(dev), enable);
 }
 
 static const struct dm_regulator_ops fixed_regulator_ops = {
@@ -150,5 +87,5 @@ U_BOOT_DRIVER(fixed_regulator) = {
        .ops = &fixed_regulator_ops,
        .of_match = fixed_regulator_ids,
        .ofdata_to_platdata = fixed_regulator_ofdata_to_platdata,
-       .platdata_auto_alloc_size = sizeof(struct fixed_regulator_platdata),
+       .platdata_auto_alloc_size = sizeof(struct regulator_common_platdata),
 };
index d18e5d8d2cae4840c6d471b758720a21f702ba13..ec1dcb64b3de00b2a592e9a08ae817e723d8cd1d 100644 (file)
@@ -4,6 +4,7 @@
  * Keerthy <j-keerthy@ti.com>
  */
 
+#include "regulator_common.h"
 #include <common.h>
 #include <fdtdec.h>
 #include <errno.h>
@@ -18,6 +19,7 @@
 DECLARE_GLOBAL_DATA_PTR;
 
 struct gpio_regulator_platdata {
+       struct regulator_common_platdata common;
        struct gpio_desc gpio; /* GPIO for regulator voltage control */
        int states[GPIO_REGULATOR_MAX_STATES];
        int voltages[GPIO_REGULATOR_MAX_STATES];
@@ -65,7 +67,7 @@ static int gpio_regulator_ofdata_to_platdata(struct udevice *dev)
                j++;
        }
 
-       return 0;
+       return regulator_common_ofdata_to_platdata(dev, &dev_pdata->common, "enable-gpios");
 }
 
 static int gpio_regulator_get_value(struct udevice *dev)
@@ -116,9 +118,23 @@ static int gpio_regulator_set_value(struct udevice *dev, int uV)
        return 0;
 }
 
+static int gpio_regulator_get_enable(struct udevice *dev)
+{
+       struct gpio_regulator_platdata *dev_pdata = dev_get_platdata(dev);
+       return regulator_common_get_enable(dev, &dev_pdata->common);
+}
+
+static int gpio_regulator_set_enable(struct udevice *dev, bool enable)
+{
+       struct gpio_regulator_platdata *dev_pdata = dev_get_platdata(dev);
+       return regulator_common_set_enable(dev, &dev_pdata->common, enable);
+}
+
 static const struct dm_regulator_ops gpio_regulator_ops = {
        .get_value      = gpio_regulator_get_value,
        .set_value      = gpio_regulator_set_value,
+       .get_enable     = gpio_regulator_get_enable,
+       .set_enable     = gpio_regulator_set_enable,
 };
 
 static const struct udevice_id gpio_regulator_ids[] = {
diff --git a/drivers/power/regulator/regulator_common.c b/drivers/power/regulator/regulator_common.c
new file mode 100644 (file)
index 0000000..3dabbe2
--- /dev/null
@@ -0,0 +1,80 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2019 Disruptive Technologies Research AS
+ * Sven Schwermer <sven.svenschwermer@disruptive-technologies.com>
+ */
+
+#include "regulator_common.h"
+#include <common.h>
+#include <power/regulator.h>
+
+int regulator_common_ofdata_to_platdata(struct udevice *dev,
+       struct regulator_common_platdata *dev_pdata, const char *enable_gpio_name)
+{
+       struct gpio_desc *gpio;
+       int flags = GPIOD_IS_OUT;
+       int ret;
+
+       if (dev_read_bool(dev, "enable-active-high"))
+               flags |= GPIOD_IS_OUT_ACTIVE;
+
+       /* Get optional enable GPIO desc */
+       gpio = &dev_pdata->gpio;
+       ret = gpio_request_by_name(dev, enable_gpio_name, 0, gpio, flags);
+       if (ret) {
+               debug("Regulator '%s' optional enable GPIO - not found! Error: %d\n",
+                     dev->name, ret);
+               if (ret != -ENOENT)
+                       return ret;
+       }
+
+       /* Get optional ramp up delay */
+       dev_pdata->startup_delay_us = dev_read_u32_default(dev,
+                                                       "startup-delay-us", 0);
+       dev_pdata->off_on_delay_us =
+                       dev_read_u32_default(dev, "u-boot,off-on-delay-us", 0);
+
+       return 0;
+}
+
+int regulator_common_get_enable(const struct udevice *dev,
+       struct regulator_common_platdata *dev_pdata)
+{
+       /* Enable GPIO is optional */
+       if (!dev_pdata->gpio.dev)
+               return true;
+
+       return dm_gpio_get_value(&dev_pdata->gpio);
+}
+
+int regulator_common_set_enable(const struct udevice *dev,
+       struct regulator_common_platdata *dev_pdata, bool enable)
+{
+       int ret;
+
+       debug("%s: dev='%s', enable=%d, delay=%d, has_gpio=%d\n", __func__,
+             dev->name, enable, dev_pdata->startup_delay_us,
+             dm_gpio_is_valid(&dev_pdata->gpio));
+       /* Enable GPIO is optional */
+       if (!dm_gpio_is_valid(&dev_pdata->gpio)) {
+               if (!enable)
+                       return -ENOSYS;
+               return 0;
+       }
+
+       ret = dm_gpio_set_value(&dev_pdata->gpio, enable);
+       if (ret) {
+               pr_err("Can't set regulator : %s gpio to: %d\n", dev->name,
+                     enable);
+               return ret;
+       }
+
+       if (enable && dev_pdata->startup_delay_us)
+               udelay(dev_pdata->startup_delay_us);
+       debug("%s: done\n", __func__);
+
+       if (!enable && dev_pdata->off_on_delay_us)
+               udelay(dev_pdata->off_on_delay_us);
+
+       return 0;
+}
diff --git a/drivers/power/regulator/regulator_common.h b/drivers/power/regulator/regulator_common.h
new file mode 100644 (file)
index 0000000..18a5258
--- /dev/null
@@ -0,0 +1,27 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2019 Disruptive Technologies Research AS
+ * Sven Schwermer <sven.svenschwermer@disruptive-technologies.com>
+ */
+
+#ifndef _REGULATOR_COMMON_H
+#define _REGULATOR_COMMON_H
+
+#include <common.h>
+#include <asm/gpio.h>
+#include <dm.h>
+
+struct regulator_common_platdata {
+       struct gpio_desc gpio; /* GPIO for regulator enable control */
+       unsigned int startup_delay_us;
+       unsigned int off_on_delay_us;
+};
+
+int regulator_common_ofdata_to_platdata(struct udevice *dev,
+       struct regulator_common_platdata *dev_pdata, const char *enable_gpio_name);
+int regulator_common_get_enable(const struct udevice *dev,
+       struct regulator_common_platdata *dev_pdata);
+int regulator_common_set_enable(const struct udevice *dev,
+       struct regulator_common_platdata *dev_pdata, bool enable);
+
+#endif /* _REGULATOR_COMMON_H */
index 9352ff87a292e98f7b82310dd0f9e923deff4400..79b026af4b9f434a31f5f8f48ce251aafc40d3bf 100644 (file)
@@ -2,6 +2,9 @@
 /*
  * (C) Copyright 2006
  * Markus Klotzbuecher, mk@denx.de
+ *
+ * (C) Copyright 2019 NXP
+ * Chuanhua Han <chuanhua.han@nxp.com>
  */
 
 /*
@@ -13,6 +16,7 @@
 
 #include <common.h>
 #include <command.h>
+#include <dm.h>
 #include <rtc.h>
 #include <i2c.h>
 
@@ -50,6 +54,7 @@
 #define RTC_STAT_BIT_EN32KHZ   0x8     /* Enable 32KHz Output  */
 
 
+#if !CONFIG_IS_ENABLED(DM_RTC)
 static uchar rtc_read (uchar reg);
 static void rtc_write (uchar reg, uchar val);
 
@@ -164,3 +169,105 @@ static void rtc_write (uchar reg, uchar val)
 {
        i2c_reg_write (CONFIG_SYS_I2C_RTC_ADDR, reg, val);
 }
+#else
+static int ds3231_rtc_get(struct udevice *dev, struct rtc_time *tmp)
+{
+       uchar sec, min, hour, mday, wday, mon_cent, year, status;
+
+       status = dm_i2c_reg_read(dev, RTC_STAT_REG_ADDR);
+       sec = dm_i2c_reg_read(dev, RTC_SEC_REG_ADDR);
+       min = dm_i2c_reg_read(dev, RTC_MIN_REG_ADDR);
+       hour = dm_i2c_reg_read(dev, RTC_HR_REG_ADDR);
+       wday = dm_i2c_reg_read(dev, RTC_DAY_REG_ADDR);
+       mday = dm_i2c_reg_read(dev, RTC_DATE_REG_ADDR);
+       mon_cent = dm_i2c_reg_read(dev, RTC_MON_REG_ADDR);
+       year = dm_i2c_reg_read(dev, RTC_YR_REG_ADDR);
+
+       if (status & RTC_STAT_BIT_OSF) {
+               printf("### Warning: RTC oscillator has stopped\n");
+               /* clear the OSF flag */
+               dm_i2c_reg_write(dev, RTC_STAT_REG_ADDR,
+                                dm_i2c_reg_read(dev, RTC_STAT_REG_ADDR)
+                                               & ~RTC_STAT_BIT_OSF);
+               return -EINVAL;
+       }
+
+       tmp->tm_sec  = bcd2bin(sec & 0x7F);
+       tmp->tm_min  = bcd2bin(min & 0x7F);
+       tmp->tm_hour = bcd2bin(hour & 0x3F);
+       tmp->tm_mday = bcd2bin(mday & 0x3F);
+       tmp->tm_mon  = bcd2bin(mon_cent & 0x1F);
+       tmp->tm_year = bcd2bin(year) + ((mon_cent & 0x80) ? 2000 : 1900);
+       tmp->tm_wday = bcd2bin((wday - 1) & 0x07);
+       tmp->tm_yday = 0;
+       tmp->tm_isdst = 0;
+
+       debug("Get DATE: %4d-%02d-%02d (wday=%d)  TIME: %2d:%02d:%02d\n",
+             tmp->tm_year, tmp->tm_mon, tmp->tm_mday, tmp->tm_wday,
+             tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
+
+       return 0;
+}
+
+static int ds3231_rtc_set(struct udevice *dev, const struct rtc_time *tmp)
+{
+       uchar century;
+
+       debug("Set DATE: %4d-%02d-%02d (wday=%d)  TIME: %2d:%02d:%02d\n",
+             tmp->tm_year, tmp->tm_mon, tmp->tm_mday, tmp->tm_wday,
+             tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
+
+       dm_i2c_reg_write(dev, RTC_YR_REG_ADDR, bin2bcd(tmp->tm_year % 100));
+
+       century = (tmp->tm_year >= 2000) ? 0x80 : 0;
+       dm_i2c_reg_write(dev, RTC_MON_REG_ADDR, bin2bcd(tmp->tm_mon) | century);
+
+       dm_i2c_reg_write(dev, RTC_DAY_REG_ADDR, bin2bcd(tmp->tm_wday + 1));
+       dm_i2c_reg_write(dev, RTC_DATE_REG_ADDR, bin2bcd(tmp->tm_mday));
+       dm_i2c_reg_write(dev, RTC_HR_REG_ADDR, bin2bcd(tmp->tm_hour));
+       dm_i2c_reg_write(dev, RTC_MIN_REG_ADDR, bin2bcd(tmp->tm_min));
+       dm_i2c_reg_write(dev, RTC_SEC_REG_ADDR, bin2bcd(tmp->tm_sec));
+
+       return 0;
+}
+
+static int ds3231_rtc_reset(struct udevice *dev)
+{
+       int ret;
+
+       ret = dm_i2c_reg_write(dev, RTC_CTL_REG_ADDR,
+                              RTC_CTL_BIT_RS1 | RTC_CTL_BIT_RS2);
+       if (ret < 0)
+               return ret;
+
+       return 0;
+}
+
+static int ds3231_probe(struct udevice *dev)
+{
+       i2c_set_chip_flags(dev, DM_I2C_CHIP_RD_ADDRESS |
+                       DM_I2C_CHIP_WR_ADDRESS);
+
+       return 0;
+}
+
+static const struct rtc_ops ds3231_rtc_ops = {
+       .get = ds3231_rtc_get,
+       .set = ds3231_rtc_set,
+       .reset = ds3231_rtc_reset,
+};
+
+static const struct udevice_id ds3231_rtc_ids[] = {
+       { .compatible = "dallas,ds3231" },
+       { .compatible = "dallas,ds3232" },
+       { }
+};
+
+U_BOOT_DRIVER(rtc_ds3231) = {
+       .name   = "rtc-ds3231",
+       .id     = UCLASS_RTC,
+       .probe  = ds3231_probe,
+       .of_match = ds3231_rtc_ids,
+       .ops    = &ds3231_rtc_ops,
+};
+#endif
index 4b417b90a2912c201f201514e840d644f03e45e7..d3cbe2f9158429c95c095c9bed6564d9285702ef 100644 (file)
--- a/env/env.c
+++ b/env/env.c
@@ -24,6 +24,8 @@ void env_fix_drivers(void)
                        entry->load += gd->reloc_off;
                if (entry->save)
                        entry->save += gd->reloc_off;
+               if (entry->erase)
+                       entry->erase += gd->reloc_off;
                if (entry->init)
                        entry->init += gd->reloc_off;
        }
@@ -254,6 +256,34 @@ int env_save(void)
        return -ENODEV;
 }
 
+int env_erase(void)
+{
+       struct env_driver *drv;
+
+       drv = env_driver_lookup(ENVOP_ERASE, gd->env_load_prio);
+       if (drv) {
+               int ret;
+
+               if (!drv->erase)
+                       return -ENODEV;
+
+               if (!env_has_inited(drv->location))
+                       return -ENODEV;
+
+               printf("Erasing Environment on %s... ", drv->name);
+               ret = drv->erase();
+               if (ret)
+                       printf("Failed (%d)\n", ret);
+               else
+                       printf("OK\n");
+
+               if (!ret)
+                       return 0;
+       }
+
+       return -ENODEV;
+}
+
 int env_init(void)
 {
        struct env_driver *drv;
index c3cf35d01b892d2e5abf9a345f747b62637dc833..b7b833f4235273116e19db93743664ee0c2f7037 100644 (file)
--- a/env/mmc.c
+++ b/env/mmc.c
@@ -242,6 +242,54 @@ fini:
        fini_mmc_for_env(mmc);
        return ret;
 }
+
+#if defined(CONFIG_CMD_ERASEENV)
+static inline int erase_env(struct mmc *mmc, unsigned long size,
+                           unsigned long offset)
+{
+       uint blk_start, blk_cnt, n;
+       struct blk_desc *desc = mmc_get_blk_desc(mmc);
+
+       blk_start       = ALIGN(offset, mmc->write_bl_len) / mmc->write_bl_len;
+       blk_cnt         = ALIGN(size, mmc->write_bl_len) / mmc->write_bl_len;
+
+       n = blk_derase(desc, blk_start, blk_cnt);
+       printf("%d blocks erased: %s\n", n, (n == blk_cnt) ? "OK" : "ERROR");
+
+       return (n == blk_cnt) ? 0 : 1;
+}
+
+static int env_mmc_erase(void)
+{
+       int dev = mmc_get_env_dev();
+       struct mmc *mmc = find_mmc_device(dev);
+       int     ret, copy = 0;
+       u32     offset;
+       const char *errmsg;
+
+       errmsg = init_mmc_for_env(mmc);
+       if (errmsg) {
+               printf("%s\n", errmsg);
+               return 1;
+       }
+
+       if (mmc_get_env_addr(mmc, copy, &offset))
+               return CMD_RET_FAILURE;
+
+       ret = erase_env(mmc, CONFIG_ENV_SIZE, offset);
+
+#ifdef CONFIG_ENV_OFFSET_REDUND
+       copy = 1;
+
+       if (mmc_get_env_addr(mmc, copy, &offset))
+               return CMD_RET_FAILURE;
+
+       ret |= erase_env(mmc, CONFIG_ENV_SIZE, offset);
+#endif
+
+       return ret;
+}
+#endif /* CONFIG_CMD_ERASEENV */
 #endif /* CONFIG_CMD_SAVEENV && !CONFIG_SPL_BUILD */
 
 static inline int read_env(struct mmc *mmc, unsigned long size,
@@ -351,5 +399,8 @@ U_BOOT_ENV_LOCATION(mmc) = {
        .load           = env_mmc_load,
 #ifndef CONFIG_SPL_BUILD
        .save           = env_save_ptr(env_mmc_save),
+#if defined(CONFIG_CMD_ERASEENV)
+       .erase          = env_mmc_erase,
+#endif
 #endif
 };
index 464c33d0d74ccbc7c1746b69632f0bdbd73d454a..5bf78b530a989108e9298f4c374f7794de10a9a5 100644 (file)
@@ -570,7 +570,7 @@ restart_read:
                                g_parent_inode->size = cpu_to_le32(new_size);
 
                                new_blockcnt = le32_to_cpu(g_parent_inode->blockcnt);
-                               new_blockcnt += fs->sect_perblk;
+                               new_blockcnt += fs->blksz >> LOG2_SECTOR_SIZE;
                                g_parent_inode->blockcnt = cpu_to_le32(new_blockcnt);
 
                                if (ext4fs_put_metadata
@@ -1571,8 +1571,12 @@ static int ext4fs_blockgroup
        int log2blksz = get_fs()->dev_desc->log2blksz;
        int desc_size = get_fs()->gdsize;
 
+       if (desc_size == 0)
+               return 0;
        desc_per_blk = EXT2_BLOCK_SIZE(data) / desc_size;
 
+       if (desc_per_blk == 0)
+               return 0;
        blkno = le32_to_cpu(data->sblock.first_data_block) + 1 +
                        group / desc_per_blk;
        blkoff = (group % desc_per_blk) * desc_size;
@@ -1602,6 +1606,10 @@ int ext4fs_read_inode(struct ext2_data *data, int ino, struct ext2_inode *inode)
 
        /* It is easier to calculate if the first inode is 0. */
        ino--;
+       if ( le32_to_cpu(sblock->inodes_per_group) == 0 || fs->inodesz == 0) {
+               free(blkgrp);
+               return 0;
+       }
        status = ext4fs_blockgroup(data, ino / le32_to_cpu
                                   (sblock->inodes_per_group), blkgrp);
        if (status == 0) {
@@ -1610,6 +1618,10 @@ int ext4fs_read_inode(struct ext2_data *data, int ino, struct ext2_inode *inode)
        }
 
        inodes_per_block = EXT2_BLOCK_SIZE(data) / fs->inodesz;
+       if ( inodes_per_block == 0 ) {
+               free(blkgrp);
+               return 0;
+       }
        blkno = ext4fs_bg_get_inode_table_id(blkgrp, fs) +
            (ino % le32_to_cpu(sblock->inodes_per_group)) / inodes_per_block;
        blkoff = (ino % inodes_per_block) * fs->inodesz;
index 6adbab93a68fb96cec282b71c8b22716f83d5593..3559daf11d2b2d87f3e28cfe5906951276f2773a 100644 (file)
@@ -645,6 +645,10 @@ void ext4fs_update_journal(void)
        struct ext_filesystem *fs = get_fs();
        long int blknr;
        int i;
+
+       if (!(fs->sb->feature_compatibility & EXT4_FEATURE_COMPAT_HAS_JOURNAL))
+               return;
+
        ext4fs_read_inode(ext4fs_root, EXT2_JOURNAL_INO, &inode_journal);
        blknr = read_allocated_block(&inode_journal, jrnl_blk_idx++, NULL);
        update_descriptor_block(blknr);
index c9cf195f33322dda8a55088147363ee2a95c3b68..43fb8e7664118804e366dc4626acac55fbd0d644 100644 (file)
@@ -17,6 +17,8 @@
 #ifndef __EXT4_JRNL__
 #define __EXT4_JRNL__
 
+#define EXT4_FEATURE_COMPAT_HAS_JOURNAL                0x0004
+
 #define EXT2_JOURNAL_INO               8       /* Journal inode */
 #define EXT2_JOURNAL_SUPERBLOCK        0       /* Journal  Superblock number */
 
index 504d23a8956cc157f843de22a9c15e72c2290595..3368bd8c005ae0a343987558c47f08177b30a383 100644 (file)
@@ -957,7 +957,7 @@ int ext4fs_write(const char *fname, const char *buffer,
        ext4fs_allocate_blocks(file_inode, blocks_remaining,
                               &blks_reqd_for_file);
        file_inode->blockcnt = cpu_to_le32((blks_reqd_for_file * fs->blksz) >>
-               fs->dev_desc->log2blksz);
+                                          LOG2_SECTOR_SIZE);
 
        temp_ptr = zalloc(fs->blksz);
        if (!temp_ptr)
index 26db677a1f172bde1f10ac5297bf7226b6f6ba15..37b31d9f0fcc4d5674ce64277a1e28c0f3035712 100644 (file)
@@ -61,18 +61,21 @@ int ext4fs_read_file(struct ext2fs_node *node, loff_t pos,
        lbaint_t delayed_skipfirst = 0;
        lbaint_t delayed_next = 0;
        char *delayed_buf = NULL;
+       char *start_buf = buf;
        short status;
        struct ext_block_cache cache;
 
        ext_cache_init(&cache);
 
-       if (blocksize <= 0)
-               return -1;
-
        /* Adjust len so it we can't read past the end of the file. */
        if (len + pos > filesize)
                len = (filesize - pos);
 
+       if (blocksize <= 0 || len <= 0) {
+               ext_cache_fini(&cache);
+               return -1;
+       }
+
        blockcnt = lldiv(((len + pos) + blocksize - 1), blocksize);
 
        for (i = lldiv(pos, blocksize); i < blockcnt; i++) {
@@ -137,6 +140,7 @@ int ext4fs_read_file(struct ext2fs_node *node, loff_t pos,
                        }
                } else {
                        int n;
+                       int n_left;
                        if (previous_block_number != -1) {
                                /* spill */
                                status = ext4fs_devread(delayed_start,
@@ -151,8 +155,9 @@ int ext4fs_read_file(struct ext2fs_node *node, loff_t pos,
                        }
                        /* Zero no more than `len' bytes. */
                        n = blocksize - skipfirst;
-                       if (n > len)
-                               n = len;
+                       n_left = len - ( buf - start_buf );
+                       if (n > n_left)
+                               n = n_left;
                        memset(buf, 0, n);
                }
                buf += blocksize - skipfirst;
@@ -286,7 +291,7 @@ int ext_cache_read(struct ext_block_cache *cache, lbaint_t block, int size)
        if (!cache->buf)
                return 0;
        if (!ext4fs_devread(block, 0, size, cache->buf)) {
-               free(cache->buf);
+               ext_cache_fini(cache);
                return 0;
        }
        cache->block = block;
index 65fdb1e9298189ed0128abe2956f8341c526bab1..35e3c5ad7a8da0294c7d5e61d60732f251fd7f07 100644 (file)
 #define CONFIG_SYS_CBSIZE 512
 
 #define CONFIG_SYS_MONITOR_BASE                CONFIG_SYS_TEXT_BASE
+#ifdef CONFIG_TFABOOT
+#define CONFIG_SYS_FLASH_BASE          0x4000000
+#define CONFIG_SYS_MAX_FLASH_BANKS     1
+#else
 #define CONFIG_SYS_FLASH_BASE          0x0
 #define CONFIG_SYS_MAX_FLASH_BANKS     2
+#endif
 #define CONFIG_SYS_MAX_FLASH_SECT      256 /* Sector: 256K, Bank: 64M */
 
 #endif /* __CONFIG_H */
index cd966761416e0456f3dc79abed3afa0b28ce32e8..de67cf4f0ea8f0e7a66cebbdbabe55b62903d607 100644 (file)
@@ -200,6 +200,7 @@ enum env_operation {
        ENVOP_INIT,     /* we want to call the init function */
        ENVOP_LOAD,     /* we want to call the load function */
        ENVOP_SAVE,     /* we want to call the save function */
+       ENVOP_ERASE,    /* we want to call the erase function */
 };
 
 struct env_driver {
@@ -225,6 +226,15 @@ struct env_driver {
         */
        int (*save)(void);
 
+       /**
+        * erase() - Erase the environment on storage
+        *
+        * This method is optional and required for 'eraseenv' to work.
+        *
+        * @return 0 if OK, -ve on error
+        */
+       int (*erase)(void);
+
        /**
         * init() - Set up the initial pre-relocation environment
         *
@@ -303,6 +313,13 @@ int env_load(void);
  */
 int env_save(void);
 
+/**
+ * env_erase() - Erase the environment on storage
+ *
+ * @return 0 if OK, -ve on error
+ */
+int env_erase(void);
+
 /**
  * env_fix_drivers() - Updates envdriver as per relocation
  */
index 17c92f1750b4ec92fb855271a442c887f45bc35c..1c10c50474840cbeccde7c97e7b7fa8e2a762940 100644 (file)
@@ -21,6 +21,7 @@
 #define __EXT_COMMON__
 #include <command.h>
 #define SECTOR_SIZE            0x200
+#define LOG2_SECTOR_SIZE       9
 
 /* Magic value used to identify an ext2 filesystem.  */
 #define        EXT2_MAGIC                      0xEF53
index 00996057b0d4f8fcf86e369baab01c371a3f9aca..07370709fe0b93fd0ae207322e4e3f49c5ac9925 100644 (file)
@@ -151,7 +151,7 @@ static inline int power_domain_on(struct power_domain *power_domain)
 #endif
 
 /**
- * power_domain_off - Disable power ot a power domain.
+ * power_domain_off - Disable power to a power domain.
  *
  * @power_domain:      A power domain struct that was previously successfully
  *             requested by power_domain_get().
index fb5e07b56d8a4d2e979fc2284190062830200f23..5b5905aeb5ffcfd3b9cbbadbae737a97c5d5480e 100644 (file)
@@ -141,6 +141,15 @@ static int rsa_engine_get_pub_key(const char *keydir, const char *name,
                        snprintf(key_id, sizeof(key_id),
                                 "pkcs11:object=%s;type=public",
                                 name);
+       } else if (engine_id) {
+               if (keydir)
+                       snprintf(key_id, sizeof(key_id),
+                                "%s%s",
+                                keydir, name);
+               else
+                       snprintf(key_id, sizeof(key_id),
+                                "%s",
+                                name);
        } else {
                fprintf(stderr, "Engine not supported\n");
                return -ENOTSUP;
@@ -252,6 +261,15 @@ static int rsa_engine_get_priv_key(const char *keydir, const char *name,
                        snprintf(key_id, sizeof(key_id),
                                 "pkcs11:object=%s;type=private",
                                 name);
+       } else if (engine_id) {
+               if (keydir)
+                       snprintf(key_id, sizeof(key_id),
+                                "%s%s",
+                                keydir, name);
+               else
+                       snprintf(key_id, sizeof(key_id),
+                                "%s",
+                                name);
        } else {
                fprintf(stderr, "Engine not supported\n");
                return -ENOTSUP;
index 79872baeda0055f5b2beb8ad334aae54698fa784..bd167959b3fb29f8b1c54fe76ddaca7ddcdd9738 100644 (file)
@@ -61,7 +61,6 @@ CONFIG_ARM_FREQ
 CONFIG_ARM_GIC_BASE_ADDRESS
 CONFIG_ARM_PL180_MMCI_BASE
 CONFIG_ARM_PL180_MMCI_CLOCK_FREQ
-CONFIG_ARM_THUMB
 CONFIG_ARP_TIMEOUT
 CONFIG_ASTRO_COFDMDUOS2
 CONFIG_ASTRO_TWIN7S2
index c8edb336422c450faeea806483e855e25ebfdaf3..229d7eb2c21e09c169723ca035612ed4d5c5a225 100644 (file)
@@ -40,16 +40,19 @@ class GptTestDiskImage(object):
                 fd = os.open(persistent, os.O_RDWR | os.O_CREAT)
                 os.ftruncate(fd, 4194304)
                 os.close(fd)
-                cmd = ('sgdisk', '-U', '375a56f7-d6c9-4e81-b5f0-09d41ca89efe',
+                cmd = ('sgdisk',
+                    '--disk-guid=375a56f7-d6c9-4e81-b5f0-09d41ca89efe',
                     persistent)
                 u_boot_utils.run_and_log(u_boot_console, cmd)
                 # part1 offset 1MB size 1MB
-                cmd = ('sgdisk', '--new=1:2048:4095', '-c 1:part1', persistent)
+                cmd = ('sgdisk', '--new=1:2048:4095', '--change-name=1:part1',
+                    persistent)
                 # part2 offset 2MB size 1.5MB
                 u_boot_utils.run_and_log(u_boot_console, cmd)
-                cmd = ('sgdisk', '--new=2:4096:7167', '-c 2:part2', persistent)
+                cmd = ('sgdisk', '--new=2:4096:7167', '--change-name=2:part2',
+                    persistent)
                 u_boot_utils.run_and_log(u_boot_console, cmd)
-                cmd = ('sgdisk', '-l', persistent)
+                cmd = ('sgdisk', '--load-backup=' + persistent)
                 u_boot_utils.run_and_log(u_boot_console, cmd)
 
         cmd = ('cp', persistent, self.path)
index 75967d0c2d59667da31ada29bc3d7abb3e3b5acc..a8eebab6c33aa5265002f430d8caa11186e7e4f6 100644 (file)
@@ -65,10 +65,12 @@ long int xstrtol(const char *s)
        exit(EXIT_FAILURE);
 }
 
+#define CHUNK_SIZE 4096
+
 int main(int argc, char **argv)
 {
        uint32_t crc, targetendian_crc;
-       const char *txt_filename = NULL, *bin_filename = NULL;
+       const char *bin_filename = NULL;
        int txt_fd, bin_fd;
        unsigned char *dataptr, *envptr;
        unsigned char *filebuf = NULL;
@@ -76,12 +78,11 @@ int main(int argc, char **argv)
        int bigendian = 0;
        int redundant = 0;
        unsigned char padbyte = 0xff;
+       int readbytes = 0;
 
        int option;
        int ret = EXIT_SUCCESS;
 
-       struct stat txt_file_stat;
-
        int fp, ep;
        const char *prg;
 
@@ -156,63 +157,33 @@ int main(int argc, char **argv)
 
        /* Open the input file ... */
        if (optind >= argc || strcmp(argv[optind], "-") == 0) {
-               int readbytes = 0;
-               int readlen = sizeof(*envptr) * 4096;
                txt_fd = STDIN_FILENO;
-
-               do {
-                       filebuf = realloc(filebuf, filesize + readlen);
-                       if (!filebuf) {
-                               fprintf(stderr, "Can't realloc memory for the input file buffer\n");
-                               return EXIT_FAILURE;
-                       }
-                       readbytes = read(txt_fd, filebuf + filesize, readlen);
-                       if (readbytes < 0) {
-                               fprintf(stderr, "Error while reading stdin: %s\n",
-                                               strerror(errno));
-                               return EXIT_FAILURE;
-                       }
-                       filesize += readbytes;
-               } while (readbytes == readlen);
-
        } else {
-               txt_filename = argv[optind];
-               txt_fd = open(txt_filename, O_RDONLY);
+               txt_fd = open(argv[optind], O_RDONLY);
                if (txt_fd == -1) {
                        fprintf(stderr, "Can't open \"%s\": %s\n",
-                                       txt_filename, strerror(errno));
+                                       argv[optind], strerror(errno));
+                       return EXIT_FAILURE;
+               }
+       }
+
+       do {
+               filebuf = realloc(filebuf, filesize + CHUNK_SIZE);
+               if (!filebuf) {
+                       fprintf(stderr, "Can't realloc memory for the input file buffer\n");
                        return EXIT_FAILURE;
                }
-               /* ... and check it */
-               ret = fstat(txt_fd, &txt_file_stat);
-               if (ret == -1) {
-                       fprintf(stderr, "Can't stat() on \"%s\": %s\n",
-                                       txt_filename, strerror(errno));
+               readbytes = read(txt_fd, filebuf + filesize, CHUNK_SIZE);
+               if (readbytes < 0) {
+                       fprintf(stderr, "Error while reading: %s\n",
+                               strerror(errno));
                        return EXIT_FAILURE;
                }
+               filesize += readbytes;
+       } while (readbytes > 0);
 
-               filesize = txt_file_stat.st_size;
-
-               filebuf = mmap(NULL, sizeof(*envptr) * filesize, PROT_READ,
-                              MAP_PRIVATE, txt_fd, 0);
-               if (filebuf == MAP_FAILED) {
-                       fprintf(stderr, "mmap (%zu bytes) failed: %s\n",
-                                       sizeof(*envptr) * filesize,
-                                       strerror(errno));
-                       fprintf(stderr, "Falling back to read()\n");
-
-                       filebuf = malloc(sizeof(*envptr) * filesize);
-                       ret = read(txt_fd, filebuf, sizeof(*envptr) * filesize);
-                       if (ret != sizeof(*envptr) * filesize) {
-                               fprintf(stderr, "Can't read the whole input file (%zu bytes): %s\n",
-                                       sizeof(*envptr) * filesize,
-                                       strerror(errno));
-
-                               return EXIT_FAILURE;
-                       }
-               }
+       if (txt_fd != STDIN_FILENO)
                ret = close(txt_fd);
-       }
 
        /* Parse a byte at time until reaching the file OR until the environment fills
         * up. Check ep against envsize - 1 to allow for extra trailing '\0'. */
index d1e1a6743d15f9f03c59138b11941afda37964d2..42171883109480524c4d0d8c4ffd2f2be5d12359 100644 (file)
@@ -105,7 +105,7 @@ static void usage(const char *msg)
                "          -F => re-sign existing FIT image\n"
                "          -p => place external data at a static position\n"
                "          -r => mark keys used as 'required' in dtb\n"
-               "          -N => engine to use for signing (pkcs11)\n");
+               "          -N => openssl engine to use for signing\n");
 #else
        fprintf(stderr,
                "Signing / verified boot not supported (CONFIG_FIT_SIGNATURE undefined)\n");