]> git.sur5r.net Git - u-boot/commitdiff
Merge git://www.denx.de/git/u-boot-marvell
authorTom Rini <trini@konsulko.com>
Thu, 14 Jan 2016 16:23:05 +0000 (11:23 -0500)
committerTom Rini <trini@konsulko.com>
Thu, 14 Jan 2016 16:23:05 +0000 (11:23 -0500)
Conflicts:
arch/arm/Kconfig

Signed-off-by: Tom Rini <trini@konsulko.com>
104 files changed:
api/api_storage.c
arch/arc/lib/start.S
arch/arm/Kconfig
arch/arm/cpu/arm926ejs/lpc32xx/devices.c
arch/arm/include/asm/arch-lpc32xx/config.h
arch/arm/lib/crt0.S
arch/arm/lib/crt0_64.S
arch/microblaze/cpu/start.S
arch/nios2/cpu/start.S
arch/powerpc/cpu/ppc4xx/start.S
arch/x86/cpu/start.S
arch/x86/lib/fsp/fsp_common.c
board/freescale/common/sdhc_boot.c
board/gdsys/p1022/controlcenterd-id.c
board/gdsys/p1022/sdhc_boot.c
board/lge/sniper/sniper.h
common/Kconfig
common/cli_simple.c
common/cmd_boot.c
common/cmd_disk.c
common/cmd_ide.c
common/cmd_mmc.c
common/cmd_read.c
common/cmd_sata.c
common/cmd_scsi.c
common/cmd_usb.c
common/cmd_usb_mass_storage.c
common/env_flags.c
common/env_mmc.c
common/fb_mmc.c
common/fdt_support.c
common/hash.c
common/init/board_init.c
common/spl/spl.c
common/spl/spl_mmc.c
common/usb_storage.c
configs/devkit3250_defconfig
configs/rpi_2_defconfig
configs/rpi_defconfig
configs/socfpga_arria5_defconfig
configs/socfpga_cyclone5_defconfig
configs/socfpga_sockit_defconfig
configs/socfpga_socrates_defconfig
configs/socfpga_sr1500_defconfig
configs/work_92105_defconfig
configs/zynq_microzed_defconfig
configs/zynq_picozed_defconfig
configs/zynq_zc702_defconfig
configs/zynq_zc706_defconfig
configs/zynq_zc770_xm010_defconfig
configs/zynq_zc770_xm011_defconfig
configs/zynq_zc770_xm012_defconfig
configs/zynq_zc770_xm013_defconfig
configs/zynq_zed_defconfig
configs/zynq_zybo_defconfig
disk/part_amiga.c
disk/part_dos.c
disk/part_efi.c
disk/part_iso.c
disk/part_mac.c
drivers/block/sandbox.c
drivers/block/systemace.c
drivers/core/Kconfig
drivers/core/device.c
drivers/dfu/dfu_mmc.c
drivers/mmc/fsl_esdhc_spl.c
drivers/mmc/mmc.c
drivers/mmc/mmc_private.h
drivers/mmc/mmc_write.c
drivers/mmc/sunxi_mmc.c
drivers/net/e1000.c
drivers/net/e1000.h
drivers/net/e1000_spi.c
drivers/net/fm/fm.c
drivers/net/lpc32xx_eth.c
drivers/net/phy/cortina.c
drivers/serial/lpc32xx_hsuart.c
drivers/usb/gadget/f_mass_storage.c
drivers/usb/gadget/storage_common.c
fs/ext4/dev.c
fs/ext4/ext4_common.c
fs/fat/fat.c
fs/fat/fat_write.c
fs/reiserfs/dev.c
fs/zfs/dev.c
include/command.h
include/common.h
include/config_uncmd_spl.h
include/configs/am335x_evm.h
include/configs/devkit3250.h
include/configs/sniper.h
include/configs/socfpga_common.h
include/configs/ti_armv7_common.h
include/configs/ti_omap4_common.h
include/dm/platform_data/lpc32xx_hsuart.h [new file with mode: 0644]
include/hash.h
include/ide.h
include/mmc.h
include/net.h
include/part.h
include/usb_mass_storage.h
lib/gunzip.c
test/dm/usb.c
test/fs/fs-test.sh

index ec92ae48d1c21fcc5ffae88bc42d9167171fa9ed..bc2b4d6b8cc76de796d98ecb69e1f581212df6b9 100644 (file)
@@ -345,19 +345,6 @@ int dev_close_stor(void *cookie)
 }
 
 
-static int dev_stor_index(block_dev_desc_t *dd)
-{
-       int i, type;
-
-       type = dev_stor_type(dd);
-       for (i = 0; i < specs[type].max_dev; i++)
-               if (dd == get_dev(specs[type].name, i))
-                       return i;
-
-       return (specs[type].max_dev);
-}
-
-
 lbasize_t dev_read_stor(void *cookie, void *buf, lbasize_t len, lbastart_t start)
 {
        int type;
@@ -374,5 +361,5 @@ lbasize_t dev_read_stor(void *cookie, void *buf, lbasize_t len, lbastart_t start
                return 0;
        }
 
-       return (dd->block_read(dev_stor_index(dd), start, len, buf));
+       return dd->block_read(dd, start, len, buf);
 }
index 26a593418938da72e3dcc43ec77ed45d43262d9a..90ee7e0fe4064cffbd57f865aec9ceaa268dfb1b 100644 (file)
@@ -50,18 +50,20 @@ ENTRY(_start)
 1:
 #endif
 
-       /* Setup stack- and frame-pointers */
+       /* Establish C runtime stack and frame */
        mov     %sp, CONFIG_SYS_INIT_SP_ADDR
        mov     %fp, %sp
 
-       /* Allocate and zero GD, update SP */
+       /* Allocate reserved area from current top of stack */
        mov     %r0, %sp
-       bl      board_init_f_mem
-
-       /* Update stack- and frame-pointers */
+       bl      board_init_f_alloc_reserve
+       /* Set stack below reserved area, adjust frame pointer accordingly */
        mov     %sp, %r0
        mov     %fp, %sp
 
+       /* Initialize reserved area - note: r0 already contains address */
+       bl      board_init_f_init_reserve
+
        /* Zero the one and only argument of "board_init_f" */
        mov_s   %r0, 0
        j       board_init_f
index 82e6f2dc91e4cee31921802c4ff53718c85bc4a7..dd9cac91e7e77c43411505d31976e75a81a58472 100644 (file)
@@ -122,6 +122,7 @@ config ARCH_MVEBU
        select DM_SPI
        select DM_SPI_FLASH
        select SPL_DM
+       select SPL_DM_SEQ_ALIAS
        select SPL_OF_CONTROL
        select SPL_SIMPLE_BUS
 
index b1c3f8f4ad8d722234d87cad5bee61d591ce4074..b6db23e981fbd69f5f3cb91cbde60983ef4f1513 100644 (file)
@@ -5,12 +5,14 @@
  */
 
 #include <common.h>
-#include <asm/arch/cpu.h>
+#include <dm.h>
+#include <ns16550.h>
+#include <dm/platform_data/lpc32xx_hsuart.h>
+
 #include <asm/arch/clk.h>
 #include <asm/arch/uart.h>
 #include <asm/arch/mux.h>
 #include <asm/io.h>
-#include <dm.h>
 
 static struct clk_pm_regs    *clk  = (struct clk_pm_regs *)CLK_PM_BASE;
 static struct uart_ctrl_regs *ctrl = (struct uart_ctrl_regs *)UART_CTRL_BASE;
@@ -41,6 +43,37 @@ void lpc32xx_uart_init(unsigned int uart_id)
               &clk->u3clk + (uart_id - 3));
 }
 
+#if !CONFIG_IS_ENABLED(OF_CONTROL)
+static const struct ns16550_platdata lpc32xx_uart[] = {
+       { UART3_BASE, 2, CONFIG_SYS_NS16550_CLK },
+       { UART4_BASE, 2, CONFIG_SYS_NS16550_CLK },
+       { UART5_BASE, 2, CONFIG_SYS_NS16550_CLK },
+       { UART6_BASE, 2, CONFIG_SYS_NS16550_CLK },
+};
+
+#if defined(CONFIG_LPC32XX_HSUART)
+static const struct lpc32xx_hsuart_platdata lpc32xx_hsuart[] = {
+       { HS_UART1_BASE, },
+       { HS_UART2_BASE, },
+       { HS_UART7_BASE, },
+};
+#endif
+
+U_BOOT_DEVICES(lpc32xx_uarts) = {
+#if defined(CONFIG_LPC32XX_HSUART)
+       { "lpc32xx_hsuart", &lpc32xx_hsuart[0], },
+       { "lpc32xx_hsuart", &lpc32xx_hsuart[1], },
+#endif
+       { "ns16550_serial", &lpc32xx_uart[0], },
+       { "ns16550_serial", &lpc32xx_uart[1], },
+       { "ns16550_serial", &lpc32xx_uart[2], },
+       { "ns16550_serial", &lpc32xx_uart[3], },
+#if defined(CONFIG_LPC32XX_HSUART)
+       { "lpc32xx_hsuart", &lpc32xx_hsuart[2], },
+#endif
+};
+#endif
+
 void lpc32xx_dma_init(void)
 {
        /* Enable DMA interface */
index d76514e4cb7f809002daf4429d89f6b2a687119b..3b7f6bdb720fe867be9f83d8388e3e962a250699 100644 (file)
 #define CONFIG_NR_DRAM_BANKS_MAX       2
 
 /* UART configuration */
-#if (CONFIG_SYS_LPC32XX_UART >= 3) && (CONFIG_SYS_LPC32XX_UART <= 6)
-#define CONFIG_SYS_NS16550_SERIAL
-#define CONFIG_CONS_INDEX              (CONFIG_SYS_LPC32XX_UART - 2)
-#elif  (CONFIG_SYS_LPC32XX_UART == 1) || (CONFIG_SYS_LPC32XX_UART == 2) || \
+#if    (CONFIG_SYS_LPC32XX_UART == 1) || (CONFIG_SYS_LPC32XX_UART == 2) || \
        (CONFIG_SYS_LPC32XX_UART == 7)
+#if !defined(CONFIG_LPC32XX_HSUART)
 #define CONFIG_LPC32XX_HSUART
-#else
-#error "define CONFIG_SYS_LPC32XX_UART in the range from 1 to 7"
 #endif
-
-#if defined(CONFIG_SYS_NS16550_SERIAL)
-
-#define CONFIG_SYS_NS16550_REG_SIZE    -4
-#define CONFIG_SYS_NS16550_CLK         get_serial_clock()
-
-#define CONFIG_SYS_NS16550_COM1                UART3_BASE
-#define CONFIG_SYS_NS16550_COM2                UART4_BASE
-#define CONFIG_SYS_NS16550_COM3                UART5_BASE
-#define CONFIG_SYS_NS16550_COM4                UART6_BASE
 #endif
 
-#if defined(CONFIG_LPC32XX_HSUART)
-#if    CONFIG_SYS_LPC32XX_UART == 1
-#define HS_UART_BASE                   HS_UART1_BASE
-#elif  CONFIG_SYS_LPC32XX_UART == 2
-#define HS_UART_BASE                   HS_UART2_BASE
-#else  /* CONFIG_SYS_LPC32XX_UART == 7 */
-#define HS_UART_BASE                   HS_UART7_BASE
+#if !defined(CONFIG_SYS_NS16550_CLK)
+#define CONFIG_SYS_NS16550_CLK         13000000
 #endif
+
+#if !defined(CONFIG_LPC32XX_HSUART)
+#define CONFIG_CONS_INDEX              (CONFIG_SYS_LPC32XX_UART - 2)
+#else
+#define CONFIG_CONS_INDEX              CONFIG_SYS_LPC32XX_UART
 #endif
 
 #define CONFIG_SYS_BAUDRATE_TABLE      \
index 80548ebbf6d2aa686fd52186da5f837f8039c652..2f4c14e96bffac92f02a531932783c8b888adff0 100644 (file)
@@ -83,8 +83,11 @@ ENTRY(_main)
        bic     sp, sp, #7      /* 8-byte alignment for ABI compliance */
 #endif
        mov     r0, sp
-       bl      board_init_f_mem
+       bl      board_init_f_alloc_reserve
        mov     sp, r0
+       /* set up gd here, outside any C code */
+       mov     r9, r0
+       bl      board_init_f_init_reserve
 
        mov     r0, #0
        bl      board_init_f
@@ -133,6 +136,7 @@ here:
        bl      spl_relocate_stack_gd
        cmp     r0, #0
        movne   sp, r0
+       movne   r9, r0
 # endif
        ldr     r0, =__bss_start        /* this is auto-relocated! */
 
index cef1c7171c68db9c9f05183c9031a5442866eff8..b4fc760609700d122e731d0e49e3f20556a4a0a3 100644 (file)
@@ -75,8 +75,10 @@ ENTRY(_main)
        ldr     x0, =(CONFIG_SYS_INIT_SP_ADDR)
 #endif
        bic     sp, x0, #0xf    /* 16-byte alignment for ABI compliance */
-       bl      board_init_f_mem
+       mov     x0, sp
+       bl      board_init_f_alloc_reserve
        mov     sp, x0
+       bl      board_init_f_init_reserve
 
        mov     x0, #0
        bl      board_init_f
index 14f46a8f0464fc7da99cd978467016c1a55ad7e1..206be3e3ee588ed1192d3d4e5fc9e93b3645c602 100644 (file)
@@ -25,7 +25,7 @@ _start:
 
        addi    r8, r0, __end
        mts     rslr, r8
-       /* TODO: Redo this code to call board_init_f_mem() */
+       /* TODO: Redo this code to call board_init_f_*() */
 #if defined(CONFIG_SPL_BUILD)
        addi    r1, r0, CONFIG_SPL_STACK_ADDR
        mts     rshr, r1
@@ -142,7 +142,7 @@ _start:
        ori     r12, r12, 0x1a0
        mts     rmsr, r12
 
-       /* TODO: Redo this code to call board_init_f_mem() */
+       /* TODO: Redo this code to call board_init_f_*() */
 clear_bss:
        /* clear BSS segments */
        addi    r5, r0, __bss_start
index 54787c53ca7e7d661a1bb9910ed6d08918373354..204d0cd9d4a714a56198a7ed80c5ea3c99227ced 100644 (file)
@@ -106,14 +106,18 @@ _reloc:
        stw     r0, 4(sp)
        mov     fp, sp
 
-       /* Allocate and zero GD, update SP */
+       /* Allocate and initialize reserved area, update SP */
        mov     r4, sp
-       movhi   r2, %hi(board_init_f_mem@h)
-       ori     r2, r2, %lo(board_init_f_mem@h)
+       movhi   r2, %hi(board_init_f_alloc_reserve@h)
+       ori     r2, r2, %lo(board_init_f_alloc_reserve@h)
        callr   r2
-
-       /* Update stack- and frame-pointers */
        mov     sp, r2
+       mov     r4, sp
+       movhi   r2, %hi(board_init_f_init_reserve@h)
+       ori     r2, r2, %lo(board_init_f_init_reserve@h)
+       callr   r2
+
+       /* Update frame-pointer */
        mov     fp, sp
 
        /* Call board_init_f -- never returns */
index 3dd0557aa667e9d0a388a4071ea0e5e5cf19599f..137afce37a857532c7b0d323e9823b205d589ae6 100644 (file)
@@ -762,8 +762,9 @@ _start:
        bl      cpu_init_f      /* run low-level CPU init code     (from Flash) */
 #ifdef CONFIG_SYS_GENERIC_BOARD
        mr      r3, r1
-       bl      board_init_f_mem
+       bl      board_init_f_alloc_reserve
        mr      r1, r3
+       bl      board_init_f_init_reserve
        li      r0,0
        stwu    r0, -4(r1)
        stwu    r0, -4(r1)
@@ -1038,8 +1039,9 @@ _start:
        bl      cpu_init_f      /* run low-level CPU init code     (from Flash) */
 #ifdef CONFIG_SYS_GENERIC_BOARD
        mr      r3, r1
-       bl      board_init_f_mem
+       bl      board_init_f_alloc_reserve
        mr      r1, r3
+       bl      board_init_f_init_reserve
        stwu    r0, -4(r1)
        stwu    r0, -4(r1)
 #endif
index 5b4ee79d88473f4a99c29b4e384280a24a1a37ae..485868ff5769ecca47fa01e0028eca14ac4ccdeb 100644 (file)
@@ -123,8 +123,9 @@ car_init_ret:
 #endif
        /* Set up global data */
        mov     %esp, %eax
-       call    board_init_f_mem
+       call    board_init_f_alloc_reserve
        mov     %eax, %esp
+       call    board_init_f_init_reserve
 
 #ifdef CONFIG_DEBUG_UART
        call    debug_uart_init
index 5276ce6ab1a2f967780054860f13d05d096cce91..8479af1d7e40731ecbff4c31bf8e60fde3277b8c 100644 (file)
@@ -90,8 +90,8 @@ int x86_fsp_init(void)
                /*
                 * The second time we enter here, adjust the size of malloc()
                 * pool before relocation. Given gd->malloc_base was adjusted
-                * after the call to board_init_f_mem() in arch/x86/cpu/start.S,
-                * we should fix up gd->malloc_limit here.
+                * after the call to board_init_f_init_reserve() in arch/x86/
+                * cpu/start.S, we should fix up gd->malloc_limit here.
                 */
                gd->malloc_limit += CONFIG_FSP_SYS_MALLOC_F_LEN;
        }
index 022f38b117f2c945cb6e5eb7e1cea21612631cce..e55a03090ab86c00b6765d823910755346b45295 100644 (file)
@@ -29,7 +29,7 @@ int mmc_get_env_addr(struct mmc *mmc, int copy, u32 *env_addr)
                return 1;
 
        /* read out the first block, get the config data information */
-       n = mmc->block_dev.block_read(mmc->block_dev.dev, 0, 1, tmp_buf);
+       n = mmc->block_dev.block_read(&mmc->block_dev, 0, 1, tmp_buf);
        if (!n) {
                free(tmp_buf);
                return 1;
index 11d075c38593c91d0ce588ff7c11ee56796427fd..46a46c0d86834502b2cbf16f3e4a768ee51e2db4 100644 (file)
@@ -232,7 +232,7 @@ static int ccdm_mmc_read(struct mmc *mmc, u64 src, u8 *dst, int size)
        ofs = src % blk_len;
 
        if (ofs) {
-               n = mmc->block_dev.block_read(mmc->block_dev.dev, block_no++, 1,
+               n = mmc->block_dev.block_read(&mmc->block_dev, block_no++, 1,
                        tmp_buf);
                if (!n)
                        goto failure;
@@ -243,7 +243,7 @@ static int ccdm_mmc_read(struct mmc *mmc, u64 src, u8 *dst, int size)
        }
        cnt = size / blk_len;
        if (cnt) {
-               n = mmc->block_dev.block_read(mmc->block_dev.dev, block_no, cnt,
+               n = mmc->block_dev.block_read(&mmc->block_dev, block_no, cnt,
                        dst);
                if (n != cnt)
                        goto failure;
@@ -253,7 +253,7 @@ static int ccdm_mmc_read(struct mmc *mmc, u64 src, u8 *dst, int size)
                block_no += cnt;
        }
        if (size) {
-               n = mmc->block_dev.block_read(mmc->block_dev.dev, block_no++, 1,
+               n = mmc->block_dev.block_read(&mmc->block_dev, block_no++, 1,
                        tmp_buf);
                if (!n)
                        goto failure;
index fd0e910d7ba7cd08a3f9fee88f9ff52e5c9b7c4f..6a4a6ef6af2498cc3475b959eeb608a0d89229f8 100644 (file)
@@ -43,7 +43,7 @@ int mmc_get_env_addr(struct mmc *mmc, int copy, u32 *env_addr)
                return 1;
 
        /* read out the first block, get the config data information */
-       n = mmc->block_dev.block_read(mmc->block_dev.dev, 0, 1, tmp_buf);
+       n = mmc->block_dev.block_read(&mmc->block_dev, 0, 1, tmp_buf);
        if (!n) {
                free(tmp_buf);
                return 1;
index b2a09b3cd04b9c793775baece4b23989c6249d5f..e5d0774e784827d27ce51af288f1eb98552b509d 100644 (file)
        MUX_VAL(CP(SDRC_DQS2),          (IEN  | PTD | DIS | M0)) /* SDRC_DQS2 */\
        MUX_VAL(CP(SDRC_DQS3),          (IEN  | PTD | DIS | M0)) /* SDRC_DQS3 */ \
        /* GPMC */ \
-       MUX_VAL(CP(GPMC_A1),            (IDIS | PTU | DIS | M4)) /* GPIO_34: LCD_RESET_N */ \
-       MUX_VAL(CP(GPMC_A2),            (IEN  | PTU | DIS | M4)) /* GPIO_35: TOUCH_INT_N */ \
-       MUX_VAL(CP(GPMC_A3),            (IDIS | PTU | DIS | M4)) /* GPIO_36: VT_CAM_PWDN */ \
-       MUX_VAL(CP(GPMC_A4),            (IDIS | PTU | DIS | M4)) /* GPIO_37: CAM_SUBPM_EN */\
+       MUX_VAL(CP(GPMC_A1),            (IDIS | PTD | DIS | M4)) /* GPIO_34: LCD_RESET_N */ \
+       MUX_VAL(CP(GPMC_A2),            (IEN  | PTD | DIS | M4)) /* GPIO_35: TOUCH_INT_N */ \
+       MUX_VAL(CP(GPMC_A3),            (IDIS | PTD | DIS | M4)) /* GPIO_36: VT_CAM_PWDN */ \
+       MUX_VAL(CP(GPMC_A4),            (IDIS | PTD | DIS | M4)) /* GPIO_37: CAM_SUBPM_EN */\
        MUX_VAL(CP(GPMC_A5),            (IEN  | PTD | DIS | M4)) /* GPIO_38: MODEM_PWR_CHK */\
        MUX_VAL(CP(GPMC_A6),            (IDIS | PTD | DIS | M4)) /* GPIO_39: MODEM_WAKE */\
-       MUX_VAL(CP(GPMC_A7),            (IEN  | PTU | DIS | M4)) /* GPIO_40: MUIC_INT_N */\
+       MUX_VAL(CP(GPMC_A7),            (IEN  | PTD | DIS | M4)) /* GPIO_40: MUIC_INT_N */\
        MUX_VAL(CP(GPMC_A8),            (IEN  | PTD | DIS | M4)) /* GPIO_41: GYRO_INT_N */\
        MUX_VAL(CP(GPMC_A9),            (IEN  | PTD | EN  | M4)) /* GPIO_42: MOTION_INT_N */\
        MUX_VAL(CP(GPMC_A10),           (IEN  | PTD | DIS | M4)) /* GPIO_43: BT_HOST_WAKEUP */\
        MUX_VAL(CP(CAM_VS),             (IEN  | PTD | EN  | M0)) /* CAM_VS */ \
        MUX_VAL(CP(CAM_XCLKA),          (IDIS | PTD | DIS | M0)) /* CAM_XCLKA */ \
        MUX_VAL(CP(CAM_PCLK),           (IEN  | PTD | EN  | M0)) /* CAM_PCLK */ \
-       MUX_VAL(CP(CAM_FLD),            (IDIS | PTU | DIS | M4)) /* GPIO_98: 5M_RESET_N */ \
+       MUX_VAL(CP(CAM_FLD),            (IDIS | PTD | DIS | M4)) /* GPIO_98: 5M_RESET_N */ \
        MUX_VAL(CP(CAM_D0),             (IEN  | PTD | DIS | M2)) /* CSI2_DX2 */ \
        MUX_VAL(CP(CAM_D1),             (IEN  | PTD | DIS | M2)) /* CSI2_DY2 */ \
        MUX_VAL(CP(CAM_D2),             (IDIS | PTD | EN  | M4)) /* GPIO_101: IFX_USB_VBUS_EN */ \
        MUX_VAL(CP(MCBSP2_DR),          (IEN  | PTD | DIS | M0)) /* MCBSP2_DR */ \
        MUX_VAL(CP(MCBSP2_DX),          (IDIS | PTD | DIS | M0)) /* MCBSP2_DX */ \
        /* MMC1 */ \
-       MUX_VAL(CP(MMC1_CLK),           (IDIS | PTD | DIS | M0)) /* MMC1_CLK */ \
-       MUX_VAL(CP(MMC1_CMD),           (IEN  | PTU | DIS | M0)) /* MMC1_CMD */ \
-       MUX_VAL(CP(MMC1_DAT0),          (IEN  | PTU | DIS | M0)) /* MMC1_DAT0 */ \
-       MUX_VAL(CP(MMC1_DAT1),          (IEN  | PTU | DIS | M0)) /* MMC1_DAT1 */ \
-       MUX_VAL(CP(MMC1_DAT2),          (IEN  | PTU | DIS | M0)) /* MMC1_DAT2 */ \
-       MUX_VAL(CP(MMC1_DAT3),          (IEN  | PTU | DIS | M0)) /* MMC1_DAT3 */ \
+       MUX_VAL(CP(MMC1_CLK),           (IEN  | PTD | DIS | M0)) /* MMC1_CLK */ \
+       MUX_VAL(CP(MMC1_CMD),           (IEN  | PTD | DIS | M0)) /* MMC1_CMD */ \
+       MUX_VAL(CP(MMC1_DAT0),          (IEN  | PTD | DIS | M0)) /* MMC1_DAT0 */ \
+       MUX_VAL(CP(MMC1_DAT1),          (IEN  | PTD | DIS | M0)) /* MMC1_DAT1 */ \
+       MUX_VAL(CP(MMC1_DAT2),          (IEN  | PTD | DIS | M0)) /* MMC1_DAT2 */ \
+       MUX_VAL(CP(MMC1_DAT3),          (IEN  | PTD | DIS | M0)) /* MMC1_DAT3 */ \
        MUX_VAL(CP(MMC1_DAT4),          (IEN  | PTD | DIS | M7)) /* SAFE_MODE */ \
        MUX_VAL(CP(MMC1_DAT5),          (IEN  | PTD | DIS | M7)) /* SAFE_MODE */ \
        MUX_VAL(CP(MMC1_DAT6),          (IEN  | PTD | DIS | M7)) /* SAFE_MODE */ \
        MUX_VAL(CP(MCBSP3_CLKX),        (IEN  | PTD | DIS | M0)) /* MCBSP3_CLKX */ \
        MUX_VAL(CP(MCBSP3_FSX),         (IEN  | PTD | DIS | M0)) /* MCBSP3_FSX */ \
        /* UART2 */ \
-       MUX_VAL(CP(UART2_CTS),          (IEN  | PTU | DIS | M0)) /* UART2_CTS */ \
-       MUX_VAL(CP(UART2_RTS),          (IDIS | PTU | DIS | M0)) /* UART2_RTS */ \
+       MUX_VAL(CP(UART2_CTS),          (IEN  | PTD | DIS | M0)) /* UART2_CTS */ \
+       MUX_VAL(CP(UART2_RTS),          (IDIS | PTD | DIS | M0)) /* UART2_RTS */ \
        MUX_VAL(CP(UART2_TX),           (IDIS | PTD | DIS | M0)) /* UART2_TX */ \
        MUX_VAL(CP(UART2_RX),           (IEN  | PTD | DIS | M0)) /* UART2_RX */ \
        /* UART1 */ \
-       MUX_VAL(CP(UART1_TX),           (IDIS | PTU | DIS | M0)) /* UART1_TX */ \
-       MUX_VAL(CP(UART1_RTS),          (IDIS | PTU | DIS | M0)) /* UART1_RTS */ \
-       MUX_VAL(CP(UART1_CTS),          (IEN  | PTU | DIS | M0)) /* UART1_CTS */ \
-       MUX_VAL(CP(UART1_RX),           (IEN  | PTU | DIS | M0)) /* UART1_RX */ \
+       MUX_VAL(CP(UART1_TX),           (IDIS | PTD | DIS | M0)) /* UART1_TX */ \
+       MUX_VAL(CP(UART1_RTS),          (IDIS | PTD | DIS | M0)) /* UART1_RTS */ \
+       MUX_VAL(CP(UART1_CTS),          (IEN  | PTD | DIS | M0)) /* UART1_CTS */ \
+       MUX_VAL(CP(UART1_RX),           (IEN  | PTD | DIS | M0)) /* UART1_RX */ \
        /* MCBSP4 */ \
        MUX_VAL(CP(MCBSP4_CLKX),        (IDIS | PTD | DIS | M4)) /* GPIO_152: GPS_PWR_ON */ \
        MUX_VAL(CP(MCBSP4_DR),          (IDIS | PTD | DIS | M4)) /* GPIO_153: GPS_RESET_N */ \
        MUX_VAL(CP(I2C1_SCL),           (IEN  | PTU | EN  | M0)) /* I2C1_SCL */ \
        MUX_VAL(CP(I2C1_SDA),           (IEN  | PTU | EN  | M0)) /* I2C1_SDA */ \
        /* I2C2 */ \
-       MUX_VAL(CP(I2C2_SCL),           (IEN  | PTU | DIS | M0)) /* I2C2_SCL */ \
-       MUX_VAL(CP(I2C2_SDA),           (IEN  | PTU | DIS | M0)) /* I2C2_SDA */ \
+       MUX_VAL(CP(I2C2_SCL),           (IEN  | PTD | DIS | M0)) /* I2C2_SCL */ \
+       MUX_VAL(CP(I2C2_SDA),           (IEN  | PTD | DIS | M0)) /* I2C2_SDA */ \
        /* I2C3 */ \
-       MUX_VAL(CP(I2C3_SCL),           (IEN  | PTU | DIS | M0)) /* I2C3_SCL */ \
-       MUX_VAL(CP(I2C3_SDA),           (IEN  | PTU | DIS | M0)) /* I2C3_SDA */ \
+       MUX_VAL(CP(I2C3_SCL),           (IEN  | PTD | DIS | M0)) /* I2C3_SCL */ \
+       MUX_VAL(CP(I2C3_SDA),           (IEN  | PTD | DIS | M0)) /* I2C3_SDA */ \
        /* I2C4 */ \
        MUX_VAL(CP(I2C4_SCL),           (IEN  | PTU | EN  | M0)) /* I2C4_SCL */ \
        MUX_VAL(CP(I2C4_SDA),           (IEN  | PTU | EN  | M0)) /* I2C4_SDA */ \
        MUX_VAL(CP(MCSPI1_SIMO),        (IEN  | PTD | EN  | M7)) /* SAFE_MODE */ \
        MUX_VAL(CP(MCSPI1_SOMI),        (IEN  | PTD | EN  | M7)) /* SAFE_MODE */ \
        MUX_VAL(CP(MCSPI1_CS0),         (IEN  | PTD | EN  | M7)) /* SAFE_MODE */ \
-       MUX_VAL(CP(MCSPI1_CS1),         (IEN  | PTU | DIS | M4)) /* GPIO_175: GAUGE_INT  */ \
-       MUX_VAL(CP(MCSPI1_CS2),         (IEN  | PTU | DIS | M4)) /* GPIO_176: MODEM_SEND */ \
-       MUX_VAL(CP(MCSPI1_CS3),         (IDIS | PTU | DIS | M4)) /* GPIO_177: MODEM_CHK */ \
+       MUX_VAL(CP(MCSPI1_CS1),         (IEN  | PTD | DIS | M4)) /* GPIO_175: GAUGE_INT  */ \
+       MUX_VAL(CP(MCSPI1_CS2),         (IEN  | PTD | DIS | M4)) /* GPIO_176: MODEM_SEND */ \
+       MUX_VAL(CP(MCSPI1_CS3),         (IDIS | PTD | DIS | M4)) /* GPIO_177: MODEM_CHK */ \
        MUX_VAL(CP(MCSPI2_CLK),         (IEN  | PTD | EN  | M0)) /* MCSPI2_CLK */ \
        MUX_VAL(CP(MCSPI2_SIMO),        (IDIS | PTD | DIS | M0)) /* MCSPI2_SIMO */ \
        MUX_VAL(CP(MCSPI2_SOMI),        (IEN  | PTD | DIS | M0)) /* MCSPI2_SOMI */ \
-       MUX_VAL(CP(MCSPI2_CS0),         (IDIS | PTU | DIS | M4)) /* GPIO_181: WLAN_WAKEUP */ \
+       MUX_VAL(CP(MCSPI2_CS0),         (IDIS | PTD | DIS | M4)) /* GPIO_181: WLAN_WAKEUP */ \
        MUX_VAL(CP(MCSPI2_CS1),         (IDIS | PTD | DIS | M4)) /* GPIO_182: USIF1_SW */ \
        /* SYS */ \
        MUX_VAL(CP(SYS_32K),            (IEN  | PTD | DIS | M0)) /* SYS_32K */ \
        MUX_VAL(CP(SYS_BOOT5),          (IEN  | PTD | EN  | M7)) /* SAFE_MODE */ \
        MUX_VAL(CP(SYS_BOOT6),          (IEN  | PTU | EN  | M7)) /* SAFE_MODE */ \
        MUX_VAL(CP(SYS_OFF_MODE),       (IDIS | PTD | DIS | M0)) /* SYS_OFF_MODE */ \
-       MUX_VAL(CP(SYS_CLKOUT1),        (IEN  | PTU | DIS | M4)) /* GPIO_10: MICROSD_DET_N */ \
+       MUX_VAL(CP(SYS_CLKOUT1),        (IEN  | PTD | DIS | M4)) /* GPIO_10: MICROSD_DET_N */ \
        MUX_VAL(CP(SYS_CLKOUT2),        (IDIS | PTD | EN  | M7)) /* SAFE_MODE */ \
        /* JTAG */ \
        MUX_VAL(CP(JTAG_NTRST),         (IEN  | PTD | DIS | M0)) /* JTAG_NTRST */ \
        MUX_VAL(CP(JTAG_TCK),           (IEN  | PTD | DIS | M0)) /* JTAG_TCK */ \
        MUX_VAL(CP(JTAG_TMS),           (IEN  | PTU | EN  | M0)) /* JTAG_TMS */ \
        MUX_VAL(CP(JTAG_TDI),           (IEN  | PTU | EN  | M0)) /* JTAG_TDI */ \
-       MUX_VAL(CP(JTAG_EMU0),          (IEN  | PTU | DIS | M0)) /* JTAG_EMU0 */ \
-       MUX_VAL(CP(JTAG_EMU1),          (IEN  | PTU | DIS | M0)) /* JTAG_EMU1 */ \
+       MUX_VAL(CP(JTAG_EMU0),          (IEN  | PTD | DIS | M0)) /* JTAG_EMU0 */ \
+       MUX_VAL(CP(JTAG_EMU1),          (IEN  | PTD | DIS | M0)) /* JTAG_EMU1 */ \
        /* ETK */ \
        MUX_VAL(CP(ETK_CLK_ES2),        (IEN  | PTD | DIS | M2)) /* SDMMC3_CLK */ \
        MUX_VAL(CP(ETK_CTL_ES2),        (IEN  | PTU | EN  | M2)) /* SDMMC3_CMD */ \
        MUX_VAL(CP(ETK_D0_ES2),         (IEN  | PTD | EN  | M4)) /* GPIO_14: PROX_OUT */ \
-       MUX_VAL(CP(ETK_D1_ES2),         (IEN  | PTU | DIS | M4)) /* GPIO_15: CHG_STATUS_N_OMAP */ \
+       MUX_VAL(CP(ETK_D1_ES2),         (IEN  | PTD | DIS | M4)) /* GPIO_15: CHG_STATUS_N_OMAP */ \
        MUX_VAL(CP(ETK_D2_ES2),         (IEN  | PTD | DIS | M4)) /* GPIO_16: BT_EN */ \
-       MUX_VAL(CP(ETK_D3_ES2),         (IEN  | PTU | DIS | M2)) /* SDMMC3_DAT3 */ \
-       MUX_VAL(CP(ETK_D4_ES2),         (IEN  | PTU | DIS | M2)) /* SDMMC3_DAT0 */ \
-       MUX_VAL(CP(ETK_D5_ES2),         (IEN  | PTU | DIS | M2)) /* SDMMC3_DAT1 */ \
-       MUX_VAL(CP(ETK_D6_ES2),         (IEN  | PTU | DIS | M2)) /* SDMMC3_DAT2 */ \
+       MUX_VAL(CP(ETK_D3_ES2),         (IEN  | PTD | DIS | M2)) /* SDMMC3_DAT3 */ \
+       MUX_VAL(CP(ETK_D4_ES2),         (IEN  | PTD | DIS | M2)) /* SDMMC3_DAT0 */ \
+       MUX_VAL(CP(ETK_D5_ES2),         (IEN  | PTD | DIS | M2)) /* SDMMC3_DAT1 */ \
+       MUX_VAL(CP(ETK_D6_ES2),         (IEN  | PTD | DIS | M2)) /* SDMMC3_DAT2 */ \
        MUX_VAL(CP(ETK_D7_ES2),         (IEN  | PTD | EN  | M4)) /* GPIO_21: IPC_SRDY */ \
        MUX_VAL(CP(ETK_D8_ES2),         (IDIS | PTD | DIS | M4)) /* GPIO_22: IPC_MRDY */ \
        MUX_VAL(CP(ETK_D9_ES2),         (IDIS | PTD | DIS | M4)) /* GPIO_23: WLAN_EN */ \
        MUX_VAL(CP(D2D_MCAD36),         (IEN  | PTD | EN  | M0)) /* D2D_MCAD36 */ \
        MUX_VAL(CP(D2D_CLK26MI),        (IDIS | PTD | DIS | M0)) /* D2D_CLK26MI */ \
        MUX_VAL(CP(D2D_NRESPWRON),      (IEN  | PTU | EN  | M0)) /* D2D_NRESPWRON */ \
-       MUX_VAL(CP(D2D_NRESWARM),       (IDIS | PTU | DIS | M0)) /* D2D_NRESWARM */ \
+       MUX_VAL(CP(D2D_NRESWARM),       (IDIS | PTD | DIS | M0)) /* D2D_NRESWARM */ \
        MUX_VAL(CP(D2D_ARM9NIRQ),       (IDIS | PTD | DIS | M0)) /* D2D_ARM9NIRQ */ \
        MUX_VAL(CP(D2D_UMA2P6FIQ),      (IDIS | PTD | DIS | M0)) /* D2D_UMA2P6FIQ */ \
        MUX_VAL(CP(D2D_SPINT),          (IEN  | PTD | DIS | M0)) /* D2D_SPINT */ \
        MUX_VAL(CP(D2D_SREAD),          (IEN  | PTD | DIS | M0)) /* D2D_SREAD */ \
        MUX_VAL(CP(D2D_MBUSFLAG),       (IEN  | PTD | DIS | M0)) /* D2D_MBUSFLAG */ \
        MUX_VAL(CP(D2D_SBUSFLAG),       (IEN  | PTD | DIS | M0)) /* D2D_SBUSFLAG */ \
-       MUX_VAL(CP(SDRC_CKE0),          (IDIS | PTU | DIS | M0)) /* SDRC_CKE0 */ \
-       MUX_VAL(CP(SDRC_CKE1),          (IDIS | PTU | DIS | M0)) /* SDRC_CKE1 */ \
+       MUX_VAL(CP(SDRC_CKE0),          (IDIS | PTD | DIS | M0)) /* SDRC_CKE0 */ \
+       MUX_VAL(CP(SDRC_CKE1),          (IDIS | PTD | DIS | M0)) /* SDRC_CKE1 */ \
        MUX_VAL(CP(GPIO127),            (IEN  | PTD | DIS | M7)) /* SAFE_MODE */ \
        MUX_VAL(CP(GPIO126),            (IDIS | PTD | DIS | M4)) /* GPIO_126: OMAP_SEND */ \
        MUX_VAL(CP(GPIO128),            (IDIS | PTD | DIS | M4)) /* GPIO_128: KEY_LED_RESET */ \
index ccf5475bac63ae4b2e2ff54ed1afe4b258f996b3..9d446bf86b01116956d5b612047c23be738cbc8a 100644 (file)
@@ -184,6 +184,9 @@ config CMD_XIMG
        help
          Extract a part of a multi-image.
 
+config CMD_POWEROFF
+       bool
+
 endmenu
 
 menu "Environment commands"
index 9c3d073d583b818b9afe8e17e10380d6b76e6349..bb96aaead60452b87cf44979b9dc586630855cf7 100644 (file)
@@ -276,7 +276,8 @@ void cli_simple_loop(void)
 
                flag = 0;       /* assume no special flags for now */
                if (len > 0)
-                       strcpy(lastcommand, console_buffer);
+                       strlcpy(lastcommand, console_buffer,
+                               CONFIG_SYS_CBSIZE + 1);
                else if (len == 0)
                        flag |= CMD_FLAG_REPEAT;
 #ifdef CONFIG_BOOT_RETRY_TIME
index 8f2e0701b540387b01906d26b622d3a239580b2d..72f2cf362d46eeb84113cd4d96942c376549c417 100644 (file)
@@ -61,3 +61,11 @@ U_BOOT_CMD(
        "Perform RESET of the CPU",
        ""
 );
+
+#ifdef CONFIG_CMD_POWEROFF
+U_BOOT_CMD(
+       poweroff, 1, 0, do_poweroff,
+       "Perform POWEROFF of the device",
+       ""
+);
+#endif
index 8a1fda9f68a412a0afa232df5a6e3c0ed7d69890..3025225c764264a899d2ecd40e4081ccbc713228 100644 (file)
@@ -56,7 +56,7 @@ int common_diskboot(cmd_tbl_t *cmdtp, const char *intf, int argc,
              ", Block Size: %ld\n",
              info.start, info.size, info.blksz);
 
-       if (dev_desc->block_read(dev, info.start, 1, (ulong *) addr) != 1) {
+       if (dev_desc->block_read(dev_desc, info.start, 1, (ulong *)addr) != 1) {
                printf("** Read error on %d:%d\n", dev, part);
                bootstage_error(BOOTSTAGE_ID_IDE_PART_READ);
                return 1;
@@ -100,8 +100,8 @@ int common_diskboot(cmd_tbl_t *cmdtp, const char *intf, int argc,
        cnt /= info.blksz;
        cnt -= 1;
 
-       if (dev_desc->block_read(dev, info.start + 1, cnt,
-                                        (ulong *)(addr + info.blksz)) != cnt) {
+       if (dev_desc->block_read(dev_desc, info.start + 1, cnt,
+                                (ulong *)(addr + info.blksz)) != cnt) {
                printf("** Read error on %d:%d\n", dev, part);
                bootstage_error(BOOTSTAGE_ID_IDE_READ);
                return 1;
index ecd3e9d64f086318578af7579e125dabdf0c381b..f19a7ce42a728895ecb3582bd35d7487c2ef559e 100644 (file)
@@ -79,8 +79,8 @@ static void ident_cpy (unsigned char *dest, unsigned char *src, unsigned int len
 
 #ifdef CONFIG_ATAPI
 static void    atapi_inquiry(block_dev_desc_t *dev_desc);
-static ulong atapi_read(int device, lbaint_t blknr, lbaint_t blkcnt,
-                       void *buffer);
+static ulong atapi_read(block_dev_desc_t *block_dev, lbaint_t blknr,
+                       lbaint_t blkcnt, void *buffer);
 #endif
 
 
@@ -187,6 +187,7 @@ int do_ide(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
                if (strcmp(argv[1], "read") == 0) {
                        ulong addr = simple_strtoul(argv[2], NULL, 16);
                        ulong cnt = simple_strtoul(argv[4], NULL, 16);
+                       block_dev_desc_t *dev_desc;
                        ulong n;
 
 #ifdef CONFIG_SYS_64BIT_LBA
@@ -201,9 +202,9 @@ int do_ide(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
                                curr_device, blk, cnt);
 #endif
 
-                       n = ide_dev_desc[curr_device].block_read(curr_device,
-                                                                blk, cnt,
-                                                                (ulong *)addr);
+                       dev_desc = &ide_dev_desc[curr_device];
+                       n = dev_desc->block_read(dev_desc, blk, cnt,
+                                                (ulong *)addr);
                        /* flush cache after read */
                        flush_cache(addr,
                                    cnt * ide_dev_desc[curr_device].blksz);
@@ -230,7 +231,8 @@ int do_ide(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
                        printf("\nIDE write: device %d block # %ld, count %ld ... ",
                                curr_device, blk, cnt);
 #endif
-                       n = ide_write(curr_device, blk, cnt, (ulong *) addr);
+                       n = ide_write(&ide_dev_desc[curr_device], blk, cnt,
+                                     (ulong *)addr);
 
                        printf("%ld blocks written: %s\n",
                                n, (n == cnt) ? "OK" : "ERROR");
@@ -711,8 +713,10 @@ static void ide_ident(block_dev_desc_t *dev_desc)
 
 /* ------------------------------------------------------------------------- */
 
-ulong ide_read(int device, lbaint_t blknr, lbaint_t blkcnt, void *buffer)
+ulong ide_read(block_dev_desc_t *block_dev, lbaint_t blknr, lbaint_t blkcnt,
+              void *buffer)
 {
+       int device = block_dev->dev;
        ulong n = 0;
        unsigned char c;
        unsigned char pwrsave = 0;      /* power save */
@@ -835,8 +839,10 @@ IDE_READ_E:
 /* ------------------------------------------------------------------------- */
 
 
-ulong ide_write(int device, lbaint_t blknr, lbaint_t blkcnt, const void *buffer)
+ulong ide_write(block_dev_desc_t *block_dev, lbaint_t blknr, lbaint_t blkcnt,
+               const void *buffer)
 {
+       int device = block_dev->dev;
        ulong n = 0;
        unsigned char c;
 
@@ -1388,8 +1394,10 @@ static void atapi_inquiry(block_dev_desc_t *dev_desc)
 #define ATAPI_READ_BLOCK_SIZE  2048    /* assuming CD part */
 #define ATAPI_READ_MAX_BLOCK   (ATAPI_READ_MAX_BYTES/ATAPI_READ_BLOCK_SIZE)
 
-ulong atapi_read(int device, lbaint_t blknr, lbaint_t blkcnt, void *buffer)
+ulong atapi_read(block_dev_desc_t *block_dev, lbaint_t blknr, lbaint_t blkcnt,
+                void *buffer)
 {
+       int device = block_dev->dev;
        ulong n = 0;
        unsigned char ccb[12];  /* Command descriptor block */
        ulong cnt;
index a6b7313e4a44d1f895a6a9e2a55311b85bcf5487..1c7156f19c5939867c30d52fdba0ffdcf3583c55 100644 (file)
@@ -312,20 +312,14 @@ static int do_mmcrpmb(cmd_tbl_t *cmdtp, int flag,
                return CMD_RET_FAILURE;
        }
        /* Switch to the RPMB partition */
-       original_part = mmc->part_num;
-       if (mmc->part_num != MMC_PART_RPMB) {
-               if (mmc_switch_part(curr_device, MMC_PART_RPMB) != 0)
-                       return CMD_RET_FAILURE;
-               mmc->part_num = MMC_PART_RPMB;
-       }
+       original_part = mmc->block_dev.part_num;
+       if (mmc_select_hwpart(curr_device, MMC_PART_RPMB) != 0)
+               return CMD_RET_FAILURE;
        ret = cp->cmd(cmdtp, flag, argc, argv);
 
        /* Return to original partition */
-       if (mmc->part_num != original_part) {
-               if (mmc_switch_part(curr_device, original_part) != 0)
-                       return CMD_RET_FAILURE;
-               mmc->part_num = original_part;
-       }
+       if (mmc_select_hwpart(curr_device, original_part) != 0)
+               return CMD_RET_FAILURE;
        return ret;
 }
 #endif
@@ -351,7 +345,7 @@ static int do_mmc_read(cmd_tbl_t *cmdtp, int flag,
        printf("\nMMC read: dev # %d, block # %d, count %d ... ",
               curr_device, blk, cnt);
 
-       n = mmc->block_dev.block_read(curr_device, blk, cnt, addr);
+       n = mmc->block_dev.block_read(&mmc->block_dev, blk, cnt, addr);
        /* flush cache after read */
        flush_cache((ulong)addr, cnt * 512); /* FIXME */
        printf("%d blocks read: %s\n", n, (n == cnt) ? "OK" : "ERROR");
@@ -383,7 +377,7 @@ static int do_mmc_write(cmd_tbl_t *cmdtp, int flag,
                printf("Error: card is write protected!\n");
                return CMD_RET_FAILURE;
        }
-       n = mmc->block_dev.block_write(curr_device, blk, cnt, addr);
+       n = mmc->block_dev.block_write(&mmc->block_dev, blk, cnt, addr);
        printf("%d blocks written: %s\n", n, (n == cnt) ? "OK" : "ERROR");
 
        return (n == cnt) ? CMD_RET_SUCCESS : CMD_RET_FAILURE;
@@ -411,7 +405,7 @@ static int do_mmc_erase(cmd_tbl_t *cmdtp, int flag,
                printf("Error: card is write protected!\n");
                return CMD_RET_FAILURE;
        }
-       n = mmc->block_dev.block_erase(curr_device, blk, cnt);
+       n = mmc->block_dev.block_erase(&mmc->block_dev, blk, cnt);
        printf("%d blocks erased: %s\n", n, (n == cnt) ? "OK" : "ERROR");
 
        return (n == cnt) ? CMD_RET_SUCCESS : CMD_RET_FAILURE;
@@ -483,7 +477,7 @@ static int do_mmc_dev(cmd_tbl_t *cmdtp, int flag,
                printf("mmc%d is current device\n", curr_device);
        else
                printf("mmc%d(part %d) is current device\n",
-                      curr_device, mmc->part_num);
+                      curr_device, mmc->block_dev.hwpart);
 
        return CMD_RET_SUCCESS;
 }
index f0fc9bfe17adaf01147a4ef32de8d35b72125d95..8710288781747d9f0bc32a4d2ac18a9e61b893e4 100644 (file)
@@ -66,7 +66,7 @@ int do_read(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
                return 1;
        }
 
-       if (dev_desc->block_read(dev, offset + blk, cnt, addr) < 0) {
+       if (dev_desc->block_read(dev_desc, offset + blk, cnt, addr) < 0) {
                printf("Error reading blocks\n");
                return 1;
        }
index 51f67033ae32026d973e8944685839587c855e5e..76baceae8c939eff77fcd45d46c820f3feb8a5d5 100644 (file)
 static int sata_curr_device = -1;
 block_dev_desc_t sata_dev_desc[CONFIG_SYS_SATA_MAX_DEVICE];
 
+static unsigned long sata_bread(block_dev_desc_t *block_dev, lbaint_t start,
+                               lbaint_t blkcnt, void *dst)
+{
+       return sata_read(block_dev->dev, start, blkcnt, dst);
+}
+
+static unsigned long sata_bwrite(block_dev_desc_t *block_dev, lbaint_t start,
+                                lbaint_t blkcnt, const void *buffer)
+{
+       return sata_write(block_dev->dev, start, blkcnt, buffer);
+}
+
 int __sata_initialize(void)
 {
        int rc;
@@ -32,8 +44,8 @@ int __sata_initialize(void)
                sata_dev_desc[i].lba = 0;
                sata_dev_desc[i].blksz = 512;
                sata_dev_desc[i].log2blksz = LOG2(sata_dev_desc[i].blksz);
-               sata_dev_desc[i].block_read = sata_read;
-               sata_dev_desc[i].block_write = sata_write;
+               sata_dev_desc[i].block_read = sata_bread;
+               sata_dev_desc[i].block_write = sata_bwrite;
 
                rc = init_sata(i);
                if (!rc) {
index 86954089fe78aa234434306e37aba9bee9ec1d91..bc7d1b6c53007801eb24e298629040aa6c7ed2c5 100644 (file)
@@ -66,9 +66,9 @@ void scsi_ident_cpy (unsigned char *dest, unsigned char *src, unsigned int len);
 
 static int scsi_read_capacity(ccb *pccb, lbaint_t *capacity,
                              unsigned long *blksz);
-static ulong scsi_read(int device, lbaint_t blknr, lbaint_t blkcnt,
-                      void *buffer);
-static ulong scsi_write(int device, lbaint_t blknr,
+static ulong scsi_read(block_dev_desc_t *block_dev, lbaint_t blknr,
+                      lbaint_t blkcnt, void *buffer);
+static ulong scsi_write(block_dev_desc_t *block_dev, lbaint_t blknr,
                        lbaint_t blkcnt, const void *buffer);
 
 
@@ -346,7 +346,8 @@ int do_scsi (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
                                ulong n;
                                printf ("\nSCSI read: device %d block # %ld, count %ld ... ",
                                                scsi_curr_dev, blk, cnt);
-                               n = scsi_read(scsi_curr_dev, blk, cnt, (ulong *)addr);
+                               n = scsi_read(&scsi_dev_desc[scsi_curr_dev],
+                                             blk, cnt, (ulong *)addr);
                                printf ("%ld blocks read: %s\n",n,(n==cnt) ? "OK" : "ERROR");
                                return 0;
                        } else if (strcmp(argv[1], "write") == 0) {
@@ -357,8 +358,8 @@ int do_scsi (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
                                printf("\nSCSI write: device %d block # %ld, "
                                       "count %ld ... ",
                                       scsi_curr_dev, blk, cnt);
-                               n = scsi_write(scsi_curr_dev, blk, cnt,
-                                              (ulong *)addr);
+                               n = scsi_write(&scsi_dev_desc[scsi_curr_dev],
+                                              blk, cnt, (ulong *)addr);
                                printf("%ld blocks written: %s\n", n,
                                       (n == cnt) ? "OK" : "ERROR");
                                return 0;
@@ -375,9 +376,10 @@ int do_scsi (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 #define SCSI_MAX_READ_BLK 0xFFFF
 #define SCSI_LBA48_READ        0xFFFFFFF
 
-static ulong scsi_read(int device, lbaint_t blknr, lbaint_t blkcnt,
-                      void *buffer)
+static ulong scsi_read(block_dev_desc_t *block_dev, lbaint_t blknr,
+                      lbaint_t blkcnt, void *buffer)
 {
+       int device = block_dev->dev;
        lbaint_t start, blks;
        uintptr_t buf_addr;
        unsigned short smallblks = 0;
@@ -441,9 +443,10 @@ static ulong scsi_read(int device, lbaint_t blknr, lbaint_t blkcnt,
 /* Almost the maximum amount of the scsi_ext command.. */
 #define SCSI_MAX_WRITE_BLK 0xFFFF
 
-static ulong scsi_write(int device, lbaint_t blknr,
+static ulong scsi_write(block_dev_desc_t *block_dev, lbaint_t blknr,
                        lbaint_t blkcnt, const void *buffer)
 {
+       int device = block_dev->dev;
        lbaint_t start, blks;
        uintptr_t buf_addr;
        unsigned short smallblks;
index a540b422db3abb9c9498f74aa26fbf701bb08f84..c7b642c40af969885d0d782bcf010740e613f16f 100644 (file)
@@ -759,7 +759,7 @@ static int do_usb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
                        printf("\nUSB read: device %d block # %ld, count %ld"
                                " ... ", usb_stor_curr_dev, blk, cnt);
                        stor_dev = usb_stor_get_dev(usb_stor_curr_dev);
-                       n = stor_dev->block_read(usb_stor_curr_dev, blk, cnt,
+                       n = stor_dev->block_read(stor_dev, blk, cnt,
                                                 (ulong *)addr);
                        printf("%ld blocks read: %s\n", n,
                                (n == cnt) ? "OK" : "ERROR");
@@ -781,7 +781,7 @@ static int do_usb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
                        printf("\nUSB write: device %d block # %ld, count %ld"
                                " ... ", usb_stor_curr_dev, blk, cnt);
                        stor_dev = usb_stor_get_dev(usb_stor_curr_dev);
-                       n = stor_dev->block_write(usb_stor_curr_dev, blk, cnt,
+                       n = stor_dev->block_write(stor_dev, blk, cnt,
                                                (ulong *)addr);
                        printf("%ld blocks write: %s\n", n,
                                (n == cnt) ? "OK" : "ERROR");
index 040738911290c63f86715ba93b8df963424e459f..041559172d9560407df9249ef5de3d57ff1125e1 100644 (file)
@@ -2,6 +2,8 @@
  * Copyright (C) 2011 Samsung Electronics
  * Lukasz Majewski <l.majewski@samsung.com>
  *
+ * Copyright (c) 2015, NVIDIA CORPORATION. All rights reserved.
+ *
  * SPDX-License-Identifier:    GPL-2.0+
  */
 
 static int ums_read_sector(struct ums *ums_dev,
                           ulong start, lbaint_t blkcnt, void *buf)
 {
-       block_dev_desc_t *block_dev = ums_dev->block_dev;
+       block_dev_desc_t *block_dev = &ums_dev->block_dev;
        lbaint_t blkstart = start + ums_dev->start_sector;
-       int dev_num = block_dev->dev;
 
-       return block_dev->block_read(dev_num, blkstart, blkcnt, buf);
+       return block_dev->block_read(block_dev, blkstart, blkcnt, buf);
 }
 
 static int ums_write_sector(struct ums *ums_dev,
                            ulong start, lbaint_t blkcnt, const void *buf)
 {
-       block_dev_desc_t *block_dev = ums_dev->block_dev;
+       block_dev_desc_t *block_dev = &ums_dev->block_dev;
        lbaint_t blkstart = start + ums_dev->start_sector;
-       int dev_num = block_dev->dev;
 
-       return block_dev->block_write(dev_num, blkstart, blkcnt, buf);
+       return block_dev->block_write(block_dev, blkstart, blkcnt, buf);
+}
+
+static struct ums *ums;
+static int ums_count;
+
+static void ums_fini(void)
+{
+       int i;
+
+       for (i = 0; i < ums_count; i++)
+               free((void *)ums[i].name);
+       free(ums);
+       ums = 0;
+       ums_count = 0;
 }
 
-static struct ums ums_dev = {
-       .read_sector = ums_read_sector,
-       .write_sector = ums_write_sector,
-       .name = "UMS disk",
-};
+#define UMS_NAME_LEN 16
 
-struct ums *ums_init(const char *devtype, const char *devnum)
+static int ums_init(const char *devtype, const char *devnums)
 {
+       char *s, *t, *devnum, *name;
        block_dev_desc_t *block_dev;
        int ret;
+       struct ums *ums_new;
 
-       ret = get_device(devtype, devnum, &block_dev);
-       if (ret < 0)
-               return NULL;
+       s = strdup(devnums);
+       if (!s)
+               return -1;
+
+       t = s;
+       ums_count = 0;
+
+       for (;;) {
+               devnum = strsep(&t, ",");
+               if (!devnum)
+                       break;
+
+               ret = get_device(devtype, devnum, &block_dev);
+               if (ret < 0)
+                       goto cleanup;
+
+               /* f_mass_storage.c assumes SECTOR_SIZE sectors */
+               if (block_dev->blksz != SECTOR_SIZE) {
+                       ret = -1;
+                       goto cleanup;
+               }
 
-       /* f_mass_storage.c assumes SECTOR_SIZE sectors */
-       if (block_dev->blksz != SECTOR_SIZE)
-               return NULL;
+               ums_new = realloc(ums, (ums_count + 1) * sizeof(*ums));
+               if (!ums_new) {
+                       ret = -1;
+                       goto cleanup;
+               }
+               ums = ums_new;
+
+               ums[ums_count].read_sector = ums_read_sector;
+               ums[ums_count].write_sector = ums_write_sector;
+               ums[ums_count].start_sector = 0;
+               ums[ums_count].num_sectors = block_dev->lba;
+               name = malloc(UMS_NAME_LEN);
+               if (!name) {
+                       ret = -1;
+                       goto cleanup;
+               }
+               snprintf(name, UMS_NAME_LEN, "UMS disk %d", ums_count);
+               ums[ums_count].name = name;
+               ums[ums_count].block_dev = *block_dev;
+
+               printf("UMS: LUN %d, dev %d, hwpart %d, sector %#x, count %#x\n",
+                      ums_count, ums[ums_count].block_dev.dev,
+                      ums[ums_count].block_dev.hwpart,
+                      ums[ums_count].start_sector,
+                      ums[ums_count].num_sectors);
+
+               ums_count++;
+       }
+
+       if (!ums_count)
+               ret = -1;
+       else
+               ret = 0;
 
-       ums_dev.block_dev = block_dev;
-       ums_dev.start_sector = 0;
-       ums_dev.num_sectors = block_dev->lba;
+cleanup:
+       free(s);
 
-       printf("UMS: disk start sector: %#x, count: %#x\n",
-              ums_dev.start_sector, ums_dev.num_sectors);
+       if (ret < 0)
+               ums_fini();
 
-       return &ums_dev;
+       return ret;
 }
 
 int do_usb_mass_storage(cmd_tbl_t *cmdtp, int flag,
@@ -69,7 +128,6 @@ int do_usb_mass_storage(cmd_tbl_t *cmdtp, int flag,
        const char *usb_controller;
        const char *devtype;
        const char *devnum;
-       struct ums *ums;
        unsigned int controller_index;
        int rc;
        int cable_ready_timeout __maybe_unused;
@@ -86,27 +144,30 @@ int do_usb_mass_storage(cmd_tbl_t *cmdtp, int flag,
                devnum  = argv[2];
        }
 
-       ums = ums_init(devtype, devnum);
-       if (!ums)
+       rc = ums_init(devtype, devnum);
+       if (rc < 0)
                return CMD_RET_FAILURE;
 
        controller_index = (unsigned int)(simple_strtoul(
                                usb_controller, NULL, 0));
        if (board_usb_init(controller_index, USB_INIT_DEVICE)) {
                error("Couldn't init USB controller.");
-               return CMD_RET_FAILURE;
+               rc = CMD_RET_FAILURE;
+               goto cleanup_ums_init;
        }
 
-       rc = fsg_init(ums);
+       rc = fsg_init(ums, ums_count);
        if (rc) {
                error("fsg_init failed");
-               return CMD_RET_FAILURE;
+               rc = CMD_RET_FAILURE;
+               goto cleanup_board;
        }
 
        rc = g_dnl_register("usb_dnl_ums");
        if (rc) {
                error("g_dnl_register failed");
-               return CMD_RET_FAILURE;
+               rc = CMD_RET_FAILURE;
+               goto cleanup_board;
        }
 
        /* Timeout unit: seconds */
@@ -122,12 +183,14 @@ int do_usb_mass_storage(cmd_tbl_t *cmdtp, int flag,
                while (!g_dnl_board_usb_cable_connected()) {
                        if (ctrlc()) {
                                puts("\rCTRL+C - Operation aborted.\n");
-                               goto exit;
+                               rc = CMD_RET_SUCCESS;
+                               goto cleanup_register;
                        }
                        if (!cable_ready_timeout) {
                                puts("\rUSB cable not detected.\n" \
                                     "Command exit.\n");
-                               goto exit;
+                               rc = CMD_RET_SUCCESS;
+                               goto cleanup_register;
                        }
 
                        printf("\rAuto exit in: %.2d s.", cable_ready_timeout);
@@ -150,13 +213,19 @@ int do_usb_mass_storage(cmd_tbl_t *cmdtp, int flag,
                        if (rc == -EPIPE)
                                printf("\rCTRL+C - Operation aborted\n");
 
-                       goto exit;
+                       rc = CMD_RET_SUCCESS;
+                       goto cleanup_register;
                }
        }
-exit:
+
+cleanup_register:
        g_dnl_unregister();
+cleanup_board:
        board_usb_cleanup(controller_index, USB_INIT_DEVICE);
-       return CMD_RET_SUCCESS;
+cleanup_ums_init:
+       ums_fini();
+
+       return rc;
 }
 
 U_BOOT_CMD(ums, 4, 1, do_usb_mass_storage,
index 771935508cb352b6d4f6a9a55c8042e51ba8a749..9c3aed15278dc2fc53ba1bc8571c7da840681731 100644 (file)
@@ -152,7 +152,7 @@ enum env_flags_varaccess env_flags_parse_varaccess_from_binflags(int binflags)
 {
        int i;
 
-       for (i = 0; i < sizeof(env_flags_varaccess_mask); i++)
+       for (i = 0; i < ARRAY_SIZE(env_flags_varaccess_mask); i++)
                if (env_flags_varaccess_mask[i] ==
                    (binflags & ENV_FLAGS_VARACCESS_BIN_MASK))
                        return (enum env_flags_varaccess)i;
index 96398224cc849577a4150edf281337070e06d94b..15aa43d5e1628bcc0ab8508c0b36922565bc06f3 100644 (file)
@@ -69,6 +69,8 @@ __weak uint mmc_get_env_part(struct mmc *mmc)
        return CONFIG_SYS_MMC_ENV_PART;
 }
 
+static unsigned char env_mmc_orig_hwpart;
+
 static int mmc_set_env_part(struct mmc *mmc)
 {
        uint part = mmc_get_env_part(mmc);
@@ -79,11 +81,10 @@ static int mmc_set_env_part(struct mmc *mmc)
        dev = 0;
 #endif
 
-       if (part != mmc->part_num) {
-               ret = mmc_switch_part(dev, part);
-               if (ret)
-                       puts("MMC partition switch failed\n");
-       }
+       env_mmc_orig_hwpart = mmc->block_dev.hwpart;
+       ret = mmc_select_hwpart(dev, part);
+       if (ret)
+               puts("MMC partition switch failed\n");
 
        return ret;
 }
@@ -113,8 +114,7 @@ static void fini_mmc_for_env(struct mmc *mmc)
 #ifdef CONFIG_SPL_BUILD
        dev = 0;
 #endif
-       if (mmc_get_env_part(mmc) != mmc->part_num)
-               mmc_switch_part(dev, mmc->part_num);
+       mmc_select_hwpart(dev, env_mmc_orig_hwpart);
 #endif
 }
 
@@ -127,7 +127,7 @@ static inline int write_env(struct mmc *mmc, unsigned long size,
        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 = mmc->block_dev.block_write(CONFIG_SYS_MMC_ENV_DEV, blk_start,
+       n = mmc->block_dev.block_write(&mmc->block_dev, blk_start,
                                        blk_cnt, (u_char *)buffer);
 
        return (n == blk_cnt) ? 0 : -1;
@@ -192,16 +192,12 @@ static inline int read_env(struct mmc *mmc, unsigned long size,
                           unsigned long offset, const void *buffer)
 {
        uint blk_start, blk_cnt, n;
-       int dev = CONFIG_SYS_MMC_ENV_DEV;
-
-#ifdef CONFIG_SPL_BUILD
-       dev = 0;
-#endif
 
        blk_start       = ALIGN(offset, mmc->read_bl_len) / mmc->read_bl_len;
        blk_cnt         = ALIGN(size, mmc->read_bl_len) / mmc->read_bl_len;
 
-       n = mmc->block_dev.block_read(dev, blk_start, blk_cnt, (uchar *)buffer);
+       n = mmc->block_dev.block_read(&mmc->block_dev, blk_start, blk_cnt,
+                                     (uchar *)buffer);
 
        return (n == blk_cnt) ? 0 : -1;
 }
index b480e76554bca8d1debe33103f38249e7401439e..6e742dac56f7884ebd866ab35730412b4e255b15 100644 (file)
@@ -58,7 +58,7 @@ static int fb_mmc_sparse_write(struct sparse_storage *storage,
        block_dev_desc_t *dev_desc = sparse->dev_desc;
        int ret;
 
-       ret = dev_desc->block_write(dev_desc->dev, offset, size, data);
+       ret = dev_desc->block_write(dev_desc, offset, size, data);
        if (!ret)
                return -EIO;
 
@@ -84,8 +84,7 @@ static void write_raw_image(block_dev_desc_t *dev_desc, disk_partition_t *info,
 
        puts("Flashing Raw Image\n");
 
-       blks = dev_desc->block_write(dev_desc->dev, info->start, blkcnt,
-                                    buffer);
+       blks = dev_desc->block_write(dev_desc, info->start, blkcnt, buffer);
        if (blks != blkcnt) {
                error("failed writing to device %d\n", dev_desc->dev);
                fastboot_fail(response_str, "failed writing to device");
@@ -206,7 +205,7 @@ void fb_mmc_erase(const char *cmd, char *response)
        printf("Erasing blocks " LBAFU " to " LBAFU " due to alignment\n",
               blks_start, blks_start + blks_size);
 
-       blks = dev_desc->block_erase(dev_desc->dev, blks_start, blks_size);
+       blks = dev_desc->block_erase(dev_desc, blks_start, blks_size);
        if (blks != blks_size) {
                error("failed erasing from device %d", dev_desc->dev);
                fastboot_fail(response_str, "failed erasing from device");
index a539389a9e88b5eb75a36b73de45c5214ea256a1..09f923716ca1888d8b4e00bf44a2d1af7a594681 100644 (file)
@@ -482,47 +482,49 @@ int fdt_fixup_memory(void *blob, u64 start, u64 size)
 void fdt_fixup_ethernet(void *fdt)
 {
        int node, i, j;
-       char enet[16], *tmp, *end;
+       char *tmp, *end;
        char mac[16];
        const char *path;
        unsigned char mac_addr[6];
+       int offset;
 
        node = fdt_path_offset(fdt, "/aliases");
        if (node < 0)
                return;
 
-       if (!getenv("ethaddr")) {
-               if (getenv("usbethaddr")) {
-                       strcpy(mac, "usbethaddr");
-               } else {
-                       debug("No ethernet MAC Address defined\n");
-                       return;
-               }
-       } else {
-               strcpy(mac, "ethaddr");
-       }
-
-       i = 0;
-       while ((tmp = getenv(mac)) != NULL) {
-               sprintf(enet, "ethernet%d", i);
-               path = fdt_getprop(fdt, node, enet, NULL);
-               if (!path) {
-                       debug("No alias for %s\n", enet);
-                       sprintf(mac, "eth%daddr", ++i);
-                       continue;
-               }
+       for (offset = fdt_first_property_offset(fdt, node);
+            offset > 0;
+            offset = fdt_next_property_offset(fdt, offset)) {
+               const char *name;
+               int len = strlen("ethernet");
+
+               path = fdt_getprop_by_offset(fdt, offset, &name, NULL);
+               if (!strncmp(name, "ethernet", len)) {
+                       i = trailing_strtol(name);
+                       if (i != -1) {
+                               if (i == 0)
+                                       strcpy(mac, "ethaddr");
+                               else
+                                       sprintf(mac, "eth%daddr", i);
+                       } else {
+                               continue;
+                       }
+                       tmp = getenv(mac);
+                       if (!tmp)
+                               continue;
+
+                       for (j = 0; j < 6; j++) {
+                               mac_addr[j] = tmp ?
+                                             simple_strtoul(tmp, &end, 16) : 0;
+                               if (tmp)
+                                       tmp = (*end) ? end + 1 : end;
+                       }
 
-               for (j = 0; j < 6; j++) {
-                       mac_addr[j] = tmp ? simple_strtoul(tmp, &end, 16) : 0;
-                       if (tmp)
-                               tmp = (*end) ? end+1 : end;
+                       do_fixup_by_path(fdt, path, "mac-address",
+                                        &mac_addr, 6, 0);
+                       do_fixup_by_path(fdt, path, "local-mac-address",
+                                        &mac_addr, 6, 1);
                }
-
-               do_fixup_by_path(fdt, path, "mac-address", &mac_addr, 6, 0);
-               do_fixup_by_path(fdt, path, "local-mac-address",
-                               &mac_addr, 6, 1);
-
-               sprintf(mac, "eth%daddr", ++i);
        }
 }
 
index a1b048204d36e8065749db2bdc652b10ab16b5d3..41de4df536864a2e4ddf550b35afe4252f064c44 100644 (file)
@@ -247,6 +247,29 @@ int hash_parse_string(const char *algo_name, const char *str, uint8_t *result)
        return 0;
 }
 
+int hash_block(const char *algo_name, const void *data, unsigned int len,
+              uint8_t *output, int *output_size)
+{
+       struct hash_algo *algo;
+       int ret;
+
+       ret = hash_lookup_algo(algo_name, &algo);
+       if (ret)
+               return ret;
+
+       if (output_size && *output_size < algo->digest_size) {
+               debug("Output buffer size %d too small (need %d bytes)",
+                     *output_size, algo->digest_size);
+               return -ENOSPC;
+       }
+       if (output_size)
+               *output_size = algo->digest_size;
+       algo->hash_func_ws(data, len, output, algo->chunk_size);
+
+       return 0;
+}
+
+#if defined(CONFIG_CMD_HASH) || defined(CONFIG_CMD_SHA1SUM) || defined(CONFIG_CMD_CRC32)
 /**
  * store_result: Store the resulting sum to an address or variable
  *
@@ -359,7 +382,7 @@ static int parse_verify_sum(struct hash_algo *algo, char *verify_str,
        return 0;
 }
 
-void hash_show(struct hash_algo *algo, ulong addr, ulong len, uint8_t *output)
+static void hash_show(struct hash_algo *algo, ulong addr, ulong len, uint8_t *output)
 {
        int i;
 
@@ -368,28 +391,6 @@ void hash_show(struct hash_algo *algo, ulong addr, ulong len, uint8_t *output)
                printf("%02x", output[i]);
 }
 
-int hash_block(const char *algo_name, const void *data, unsigned int len,
-              uint8_t *output, int *output_size)
-{
-       struct hash_algo *algo;
-       int ret;
-
-       ret = hash_lookup_algo(algo_name, &algo);
-       if (ret)
-               return ret;
-
-       if (output_size && *output_size < algo->digest_size) {
-               debug("Output buffer size %d too small (need %d bytes)",
-                     *output_size, algo->digest_size);
-               return -ENOSPC;
-       }
-       if (output_size)
-               *output_size = algo->digest_size;
-       algo->hash_func_ws(data, len, output, algo->chunk_size);
-
-       return 0;
-}
-
 int hash_command(const char *algo_name, int flags, cmd_tbl_t *cmdtp, int flag,
                 int argc, char * const argv[])
 {
@@ -473,3 +474,4 @@ int hash_command(const char *algo_name, int flags, cmd_tbl_t *cmdtp, int flag,
        return 0;
 }
 #endif
+#endif
index 1c6126d8ce55a08c85f8e0d576672fdf7f16f8bf..d98648eaa6fc26fbb9836622fbfee2552534d826 100644 (file)
@@ -21,39 +21,128 @@ DECLARE_GLOBAL_DATA_PTR;
 #define _USE_MEMCPY
 #endif
 
-/* Unfortunately x86 can't compile this code as gd cannot be assigned */
-#ifndef CONFIG_X86
+/* Unfortunately x86 or ARM can't compile this code as gd cannot be assigned */
+#if !defined(CONFIG_X86) && !defined(CONFIG_ARM)
 __weak void arch_setup_gd(struct global_data *gd_ptr)
 {
        gd = gd_ptr;
 }
-#endif /* !CONFIG_X86 */
+#endif /* !CONFIG_X86 && !CONFIG_ARM */
 
-ulong board_init_f_mem(ulong top)
+/*
+ * Allocate reserved space for use as 'globals' from 'top' address and
+ * return 'bottom' address of allocated space
+ *
+ * Notes:
+ *
+ * Actual reservation cannot be done from within this function as
+ * it requires altering the C stack pointer, so this will be done by
+ * the caller upon return from this function.
+ *
+ * IMPORTANT:
+ *
+ * Alignment constraints may differ for each 'chunk' allocated. For now:
+ *
+ * - GD is aligned down on a 16-byte boundary
+ *
+ *  - the early malloc arena is not aligned, therefore it follows the stack
+ *   alignment constraint of the architecture for which we are bulding.
+ *
+ *  - GD is allocated last, so that the return value of this functions is
+ *   both the bottom of the reserved area and the address of GD, should
+ *   the calling context need it.
+ */
+
+ulong board_init_f_alloc_reserve(ulong top)
+{
+       /* Reserve early malloc arena */
+#if defined(CONFIG_SYS_MALLOC_F)
+       top -= CONFIG_SYS_MALLOC_F_LEN;
+#endif
+       /* LAST : reserve GD (rounded up to a multiple of 16 bytes) */
+       top = rounddown(top-sizeof(struct global_data), 16);
+
+       return top;
+}
+
+/*
+ * Initialize reserved space (which has been safely allocated on the C
+ * stack from the C runtime environment handling code).
+ *
+ * Notes:
+ *
+ * Actual reservation was done by the caller; the locations from base
+ * to base+size-1 (where 'size' is the value returned by the allocation
+ * function above) can be accessed freely without risk of corrupting the
+ * C runtime environment.
+ *
+ * IMPORTANT:
+ *
+ * Upon return from the allocation function above, on some architectures
+ * the caller will set gd to the lowest reserved location. Therefore, in
+ * this initialization function, the global data MUST be placed at base.
+ *
+ * ALSO IMPORTANT:
+ *
+ * On some architectures, gd will already be good when entering this
+ * function. On others, it will only be good once arch_setup_gd() returns.
+ * Therefore, global data accesses must be done:
+ *
+ * - through gd_ptr if before the call to arch_setup_gd();
+ *
+ * - through gd once arch_setup_gd() has been called.
+ *
+ * Do not use 'gd->' until arch_setup_gd() has been called!
+ *
+ * IMPORTANT TOO:
+ *
+ * Initialization for each "chunk" (GD, early malloc arena...) ends with
+ * an incrementation line of the form 'base += <some size>'. The last of
+ * these incrementations seems useless, as base will not be used any
+ * more after this incrementation; but if/when a new "chunk" is appended,
+ * this increment will be essential as it will give base right value for
+ * this new chunk (which will have to end with its own incrementation
+ * statement). Besides, the compiler's optimizer will silently detect
+ * and remove the last base incrementation, therefore leaving that last
+ * (seemingly useless) incrementation causes no code increase.
+ */
+
+void board_init_f_init_reserve(ulong base)
 {
        struct global_data *gd_ptr;
 #ifndef _USE_MEMCPY
        int *ptr;
 #endif
 
-       /* Leave space for the stack we are running with now */
-       top -= 0x40;
+       /*
+        * clear GD entirely and set it up.
+        * Use gd_ptr, as gd may not be properly set yet.
+        */
 
-       top -= sizeof(struct global_data);
-       top = ALIGN(top, 16);
-       gd_ptr = (struct global_data *)top;
+       gd_ptr = (struct global_data *)base;
+       /* zero the area */
 #ifdef _USE_MEMCPY
        memset(gd_ptr, '\0', sizeof(*gd));
 #else
        for (ptr = (int *)gd_ptr; ptr < (int *)(gd_ptr + 1); )
                *ptr++ = 0;
 #endif
+       /* set GD unless architecture did it already */
+#if !defined(CONFIG_X86) && !defined(CONFIG_ARM)
        arch_setup_gd(gd_ptr);
+#endif
+       /* next alloc will be higher by one GD plus 16-byte alignment */
+       base += roundup(sizeof(struct global_data), 16);
+
+       /*
+        * record early malloc arena start.
+        * Use gd as it is now properly set for all architectures.
+        */
 
 #if defined(CONFIG_SYS_MALLOC_F)
-       top -= CONFIG_SYS_MALLOC_F_LEN;
-       gd->malloc_base = top;
+       /* go down one 'early malloc arena' */
+       gd->malloc_base = base;
+       /* next alloc will be higher by one 'early malloc arena' size */
+       base += CONFIG_SYS_MALLOC_F_LEN;
 #endif
-
-       return top;
 }
index 6e6dee7ec9b1d9b8ccd2cee17239557c88a28250..e5167bf73e4c3181ef7c74b7736431e0df121668 100644 (file)
@@ -431,8 +431,13 @@ void preloader_console_init(void)
  * more stack space for things like the MMC sub-system.
  *
  * This function calculates the stack position, copies the global_data into
- * place and returns the new stack position. The caller is responsible for
- * setting up the sp register.
+ * place, sets the new gd (except for ARM, for which setting GD within a C
+ * function may not always work) and returns the new stack position. The
+ * caller is responsible for setting up the sp register and, in the case
+ * of ARM, setting up gd.
+ *
+ * All of this is done using the same layout and alignments as done in
+ * board_init_f_init_reserve() / board_init_f_alloc_reserve().
  *
  * @return new stack location, or 0 to use the same stack
  */
@@ -440,14 +445,7 @@ ulong spl_relocate_stack_gd(void)
 {
 #ifdef CONFIG_SPL_STACK_R
        gd_t *new_gd;
-       ulong ptr;
-
-       /* Get stack position: use 8-byte alignment for ABI compliance */
-       ptr = CONFIG_SPL_STACK_R_ADDR - sizeof(gd_t);
-       ptr &= ~7;
-       new_gd = (gd_t *)ptr;
-       memcpy(new_gd, (void *)gd, sizeof(gd_t));
-       gd = new_gd;
+       ulong ptr = CONFIG_SPL_STACK_R_ADDR;
 
 #ifdef CONFIG_SPL_SYS_MALLOC_SIMPLE
        if (CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN) {
@@ -460,7 +458,13 @@ ulong spl_relocate_stack_gd(void)
                gd->malloc_ptr = 0;
        }
 #endif
-
+       /* Get stack position: use 8-byte alignment for ABI compliance */
+       ptr = CONFIG_SPL_STACK_R_ADDR - roundup(sizeof(gd_t),16);
+       new_gd = (gd_t *)ptr;
+       memcpy(new_gd, (void *)gd, sizeof(gd_t));
+#if !defined(CONFIG_ARM)
+       gd = new_gd;
+#endif
        return ptr;
 #else
        return 0;
index c1c29c02d7edec75b5d64a186679e7755f079607..c3931c6c4d7761c598d45312e2b5ffc01a676231 100644 (file)
@@ -23,13 +23,12 @@ static int mmc_load_image_raw_sector(struct mmc *mmc, unsigned long sector)
        unsigned long count;
        u32 image_size_sectors;
        struct image_header *header;
-       int dev_num = mmc->block_dev.dev;
 
        header = (struct image_header *)(CONFIG_SYS_TEXT_BASE -
                                         sizeof(struct image_header));
 
        /* read image header to find the image size & load address */
-       count = mmc->block_dev.block_read(dev_num, sector, 1, header);
+       count = mmc->block_dev.block_read(&mmc->block_dev, sector, 1, header);
        debug("read sector %lx, count=%lu\n", sector, count);
        if (count == 0)
                goto end;
@@ -46,7 +45,8 @@ static int mmc_load_image_raw_sector(struct mmc *mmc, unsigned long sector)
                             mmc->read_bl_len;
 
        /* Read the header too to avoid extra memcpy */
-       count = mmc->block_dev.block_read(dev_num, sector, image_size_sectors,
+       count = mmc->block_dev.block_read(&mmc->block_dev, sector,
+                                         image_size_sectors,
                                          (void *)(ulong)spl_image.load_addr);
        debug("read %x sectors to %x\n", image_size_sectors,
              spl_image.load_addr);
@@ -150,8 +150,7 @@ static int mmc_load_image_raw_os(struct mmc *mmc)
 {
        unsigned long count;
 
-       count = mmc->block_dev.block_read(
-               mmc->block_dev.dev,
+       count = mmc->block_dev.block_read(&mmc->block_dev,
                CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTOR,
                CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTORS,
                (void *) CONFIG_SYS_SPL_ARGS_ADDR);
index e61a8c8adfd02e82c320169dc6da9e28f515d8ef..4fdb55f9faf9061f730abb02710094aed2f5f547 100644 (file)
@@ -119,10 +119,10 @@ int usb_stor_get_info(struct usb_device *dev, struct us_data *us,
                      block_dev_desc_t *dev_desc);
 int usb_storage_probe(struct usb_device *dev, unsigned int ifnum,
                      struct us_data *ss);
-unsigned long usb_stor_read(int device, lbaint_t blknr,
-                           lbaint_t blkcnt, void *buffer);
-unsigned long usb_stor_write(int device, lbaint_t blknr,
-                            lbaint_t blkcnt, const void *buffer);
+static unsigned long usb_stor_read(block_dev_desc_t *block_dev, lbaint_t blknr,
+                                  lbaint_t blkcnt, void *buffer);
+static unsigned long usb_stor_write(block_dev_desc_t *block_dev, lbaint_t blknr,
+                                   lbaint_t blkcnt, const void *buffer);
 void uhci_show_temp_int_td(void);
 
 #ifdef CONFIG_PARTITIONS
@@ -1027,9 +1027,10 @@ static void usb_bin_fixup(struct usb_device_descriptor descriptor,
 }
 #endif /* CONFIG_USB_BIN_FIXUP */
 
-unsigned long usb_stor_read(int device, lbaint_t blknr,
-                           lbaint_t blkcnt, void *buffer)
+static unsigned long usb_stor_read(block_dev_desc_t *block_dev, lbaint_t blknr,
+                                  lbaint_t blkcnt, void *buffer)
 {
+       int device = block_dev->dev;
        lbaint_t start, blks;
        uintptr_t buf_addr;
        unsigned short smallblks;
@@ -1097,9 +1098,10 @@ retry_it:
        return blkcnt;
 }
 
-unsigned long usb_stor_write(int device, lbaint_t blknr,
-                               lbaint_t blkcnt, const void *buffer)
+static unsigned long usb_stor_write(block_dev_desc_t *block_dev, lbaint_t blknr,
+                                   lbaint_t blkcnt, const void *buffer)
 {
+       int device = block_dev->dev;
        lbaint_t start, blks;
        uintptr_t buf_addr;
        unsigned short smallblks;
index 64a0fb01b360a7e884a100972b4fc24040e44fe1..ddf09fe5eb879a9dd7b02f01ff9fa9e7d2035f3f 100644 (file)
@@ -1,5 +1,8 @@
 CONFIG_ARM=y
 CONFIG_TARGET_DEVKIT3250=y
+CONFIG_SPL_SYS_MALLOC_SIMPLE=y
+CONFIG_SPL_DM=y
+CONFIG_DM_SERIAL=y
 CONFIG_DM_GPIO=y
 CONFIG_SPL=y
 # CONFIG_CMD_FPGA is not set
index 5c9e69af3b759d7cea1289aee0718156497dc298..bd81ee6a1d078176568b302771002e77fea111e8 100644 (file)
@@ -6,5 +6,4 @@ CONFIG_SYS_PROMPT="U-Boot> "
 # CONFIG_CMD_FLASH is not set
 # CONFIG_CMD_FPGA is not set
 CONFIG_CMD_GPIO=y
-# CONFIG_CMD_SETEXPR is not set
 CONFIG_PHYS_TO_BUS=y
index b8b267f371c2732197d109f1c50cf7ec8aacd120..5d27909ebe7c7bdc54e9b213e89f5832b1732c8b 100644 (file)
@@ -6,5 +6,4 @@ CONFIG_SYS_PROMPT="U-Boot> "
 # CONFIG_CMD_FLASH is not set
 # CONFIG_CMD_FPGA is not set
 CONFIG_CMD_GPIO=y
-# CONFIG_CMD_SETEXPR is not set
 CONFIG_PHYS_TO_BUS=y
index 68d12df404ca3c516d63a593b85363a843f84e54..6e8976fcc35966ba646f5a799f65a7e44a9fc23b 100644 (file)
@@ -7,6 +7,7 @@ CONFIG_TARGET_SOCFPGA_ARRIA5_SOCDK=y
 CONFIG_SPL_STACK_R_ADDR=0x00800000
 CONFIG_DEFAULT_DEVICE_TREE="socfpga_arria5_socdk"
 CONFIG_SPL=y
+CONFIG_SPL_DM_SEQ_ALIAS=y
 CONFIG_SPL_STACK_R=y
 # CONFIG_CMD_IMLS is not set
 # CONFIG_CMD_FLASH is not set
index accee924a32a8975c59ed340fb9afe273f345157..e31aa716893a1a60d9cd3b169d495eeb2b2b1898 100644 (file)
@@ -7,6 +7,7 @@ CONFIG_TARGET_SOCFPGA_CYCLONE5_SOCDK=y
 CONFIG_SPL_STACK_R_ADDR=0x00800000
 CONFIG_DEFAULT_DEVICE_TREE="socfpga_cyclone5_socdk"
 CONFIG_SPL=y
+CONFIG_SPL_DM_SEQ_ALIAS=y
 CONFIG_SPL_STACK_R=y
 # CONFIG_CMD_IMLS is not set
 # CONFIG_CMD_FLASH is not set
index b4f41a939d1ab1c77071ec39a65769b86cc9cb69..59fbb2c3c1292e461ab273e7b3e87e7b207ce482 100644 (file)
@@ -7,6 +7,7 @@ CONFIG_TARGET_SOCFPGA_TERASIC_SOCKIT=y
 CONFIG_SPL_STACK_R_ADDR=0x00800000
 CONFIG_DEFAULT_DEVICE_TREE="socfpga_cyclone5_sockit"
 CONFIG_SPL=y
+CONFIG_SPL_DM_SEQ_ALIAS=y
 CONFIG_SPL_STACK_R=y
 # CONFIG_CMD_IMLS is not set
 # CONFIG_CMD_FLASH is not set
index fe940f967a6cab9433c44baadcd95ac7a6ee19f6..aaba8cb29d5336e365a1e5550d3624f1afc8c55b 100644 (file)
@@ -7,6 +7,7 @@ CONFIG_TARGET_SOCFPGA_EBV_SOCRATES=y
 CONFIG_SPL_STACK_R_ADDR=0x00800000
 CONFIG_DEFAULT_DEVICE_TREE="socfpga_cyclone5_socrates"
 CONFIG_SPL=y
+CONFIG_SPL_DM_SEQ_ALIAS=y
 CONFIG_SPL_STACK_R=y
 # CONFIG_CMD_IMLS is not set
 # CONFIG_CMD_FLASH is not set
index 3d98a636d911796b2f090617a794bc2a817e7662..a4f0835e9da3bad3cfd869f58e8069d4e7b4fa46 100644 (file)
@@ -6,6 +6,7 @@ CONFIG_DM_GPIO=y
 CONFIG_TARGET_SOCFPGA_SR1500=y
 CONFIG_DEFAULT_DEVICE_TREE="socfpga_cyclone5_sr1500"
 CONFIG_SPL=y
+CONFIG_SPL_DM_SEQ_ALIAS=y
 CONFIG_SPL_STACK_R=y
 CONFIG_SPL_STACK_R_ADDR=0x00800000
 # CONFIG_CMD_IMLS is not set
index 1cad3a2d0c4af87e5a4836ecfdd2bcdd590f4079..1a9097a9a684ec5c41da6e701f4c607cac52b71f 100644 (file)
@@ -1,5 +1,8 @@
 CONFIG_ARM=y
 CONFIG_TARGET_WORK_92105=y
+CONFIG_SPL_SYS_MALLOC_SIMPLE=y
+CONFIG_SPL_DM=y
+CONFIG_DM_SERIAL=y
 CONFIG_DM_GPIO=y
 CONFIG_SPL=y
 # CONFIG_CMD_IMLS is not set
index e577c931735e84069b4e178bb8b7cbd8b0cabe89..30995babd4b63ae9f21d176f7e232b710ec671fa 100644 (file)
@@ -11,6 +11,7 @@ CONFIG_FIT_SIGNATURE=y
 CONFIG_CMD_GPIO=y
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_NET_RANDOM_ETHADDR=y
+CONFIG_SPL_DM_SEQ_ALIAS=y
 CONFIG_SPI_FLASH=y
 CONFIG_SPI_FLASH_SPANSION=y
 CONFIG_SPI_FLASH_STMICRO=y
index 7d52d8e941b7ec90d9794c52e33211b88397f037..339e399889be8f122c99cda99e4ea7c5db0d3d73 100644 (file)
@@ -8,4 +8,5 @@ CONFIG_SPL=y
 CONFIG_CMD_GPIO=y
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_NET_RANDOM_ETHADDR=y
+CONFIG_SPL_DM_SEQ_ALIAS=y
 CONFIG_ZYNQ_GEM=y
index 9d1b40d76ef6f15bf27c9ab48bcc6afd6ba73b44..065f8551945f0bd9642f2349c19a499b98e3d6ff 100644 (file)
@@ -10,6 +10,7 @@ CONFIG_FIT_SIGNATURE=y
 CONFIG_CMD_GPIO=y
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_NET_RANDOM_ETHADDR=y
+CONFIG_SPL_DM_SEQ_ALIAS=y
 CONFIG_SPI_FLASH=y
 CONFIG_SPI_FLASH_SPANSION=y
 CONFIG_SPI_FLASH_STMICRO=y
index bba91dfdfa784891795874d04497cbf027e93afa..1059689aad45f20e10fde22af98159271e036224 100644 (file)
@@ -11,6 +11,7 @@ CONFIG_FIT_SIGNATURE=y
 CONFIG_CMD_GPIO=y
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_NET_RANDOM_ETHADDR=y
+CONFIG_SPL_DM_SEQ_ALIAS=y
 CONFIG_SPI_FLASH=y
 CONFIG_SPI_FLASH_SPANSION=y
 CONFIG_SPI_FLASH_STMICRO=y
index 96f0a794a382402fc999e751bce2a2cba10890b3..a9dbda5eaa0b84aaedc2627dbfc3d0c98ea08a16 100644 (file)
@@ -12,6 +12,7 @@ CONFIG_SYS_EXTRA_OPTIONS="ZC770_XM010"
 CONFIG_CMD_GPIO=y
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_NET_RANDOM_ETHADDR=y
+CONFIG_SPL_DM_SEQ_ALIAS=y
 CONFIG_SPI_FLASH=y
 CONFIG_SPI_FLASH_SPANSION=y
 CONFIG_SPI_FLASH_STMICRO=y
index b0c535e88e1995c102bf45fa8204c3d3244487c9..6ff00c64b4276df7b8700c77904008af97afc6b6 100644 (file)
@@ -12,4 +12,5 @@ CONFIG_SYS_EXTRA_OPTIONS="ZC770_XM011"
 CONFIG_CMD_GPIO=y
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_NET_RANDOM_ETHADDR=y
+CONFIG_SPL_DM_SEQ_ALIAS=y
 CONFIG_ZYNQ_GEM=y
index 7fb03eb0491be22d0c17b994c8a7bd56d599f34b..75d6c5531c92e3a3f09304f027931315c6109084 100644 (file)
@@ -10,4 +10,5 @@ CONFIG_SYS_EXTRA_OPTIONS="ZC770_XM012"
 CONFIG_CMD_GPIO=y
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_NET_RANDOM_ETHADDR=y
+CONFIG_SPL_DM_SEQ_ALIAS=y
 CONFIG_ZYNQ_GEM=y
index 67665127b5ba47e3ae4ab1061532ccbf473ad758..dd65929958e782c3785a2a01af0dd41b6369052f 100644 (file)
@@ -12,4 +12,5 @@ CONFIG_SYS_EXTRA_OPTIONS="ZC770_XM013"
 CONFIG_CMD_GPIO=y
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_NET_RANDOM_ETHADDR=y
+CONFIG_SPL_DM_SEQ_ALIAS=y
 CONFIG_ZYNQ_GEM=y
index 058bb05ba65811be2fd1fdfd285773acbd27dc5d..73b17e20b27c80c0b0096a05ccd7962ba85cf1f5 100644 (file)
@@ -11,6 +11,7 @@ CONFIG_FIT_SIGNATURE=y
 CONFIG_CMD_GPIO=y
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_NET_RANDOM_ETHADDR=y
+CONFIG_SPL_DM_SEQ_ALIAS=y
 CONFIG_SPI_FLASH=y
 CONFIG_SPI_FLASH_SPANSION=y
 CONFIG_SPI_FLASH_STMICRO=y
index 231483e3dbd3ea52d77cdef9f5efadd7fbd3c928..577c5a958e11f223638ba02a51f8469bce48c1fc 100644 (file)
@@ -11,6 +11,7 @@ CONFIG_FIT_SIGNATURE=y
 CONFIG_CMD_GPIO=y
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_NET_RANDOM_ETHADDR=y
+CONFIG_SPL_DM_SEQ_ALIAS=y
 CONFIG_ZYNQ_GEM=y
 CONFIG_DEBUG_UART=y
 CONFIG_DEBUG_UART_ZYNQ=y
index 260a3d5e87c8eac903403fc904e73e440ed61111..57c1b9d055f0d1d1ca255bc7e9f4dfd1a4542b29 100644 (file)
@@ -140,8 +140,7 @@ struct rigid_disk_block *get_rdisk(block_dev_desc_t *dev_desc)
 
     for (i=0; i<limit; i++)
     {
-       ulong res = dev_desc->block_read(dev_desc->dev, i, 1,
-                                        (ulong *)block_buffer);
+       ulong res = dev_desc->block_read(dev_desc, i, 1, (ulong *)block_buffer);
        if (res == 1)
        {
            struct rigid_disk_block *trdb = (struct rigid_disk_block *)block_buffer;
@@ -183,7 +182,7 @@ struct bootcode_block *get_bootcode(block_dev_desc_t *dev_desc)
 
     for (i = 0; i < limit; i++)
     {
-       ulong res = dev_desc->block_read(dev_desc->dev, i, 1, (ulong *)block_buffer);
+       ulong res = dev_desc->block_read(dev_desc, i, 1, (ulong *)block_buffer);
        if (res == 1)
        {
            struct bootcode_block *boot = (struct bootcode_block *)block_buffer;
@@ -258,7 +257,7 @@ static struct partition_block *find_partition(block_dev_desc_t *dev_desc, int pa
 
     while (block != 0xFFFFFFFF)
     {
-       ulong res = dev_desc->block_read(dev_desc->dev, block, 1,
+       ulong res = dev_desc->block_read(dev_desc, block, 1,
                                         (ulong *)block_buffer);
        if (res == 1)
        {
@@ -354,8 +353,7 @@ void print_part_amiga (block_dev_desc_t *dev_desc)
 
        PRINTF("Trying to load block #0x%X\n", block);
 
-       res = dev_desc->block_read(dev_desc->dev, block, 1,
-                                  (ulong *)block_buffer);
+       res = dev_desc->block_read(dev_desc, block, 1, (ulong *)block_buffer);
        if (res == 1)
        {
            p = (struct partition_block *)block_buffer;
index 628066041bb4a05930be989539c95f4a77728a64..1e5cb330cd5566f3d638ce2ad1f9a2378f802263 100644 (file)
@@ -91,7 +91,7 @@ int test_part_dos (block_dev_desc_t *dev_desc)
 {
        ALLOC_CACHE_ALIGN_BUFFER(unsigned char, buffer, dev_desc->blksz);
 
-       if (dev_desc->block_read(dev_desc->dev, 0, 1, (ulong *) buffer) != 1)
+       if (dev_desc->block_read(dev_desc, 0, 1, (ulong *)buffer) != 1)
                return -1;
 
        if (test_block_type(buffer) != DOS_MBR)
@@ -111,7 +111,8 @@ static void print_partition_extended(block_dev_desc_t *dev_desc,
        dos_partition_t *pt;
        int i;
 
-       if (dev_desc->block_read(dev_desc->dev, ext_part_sector, 1, (ulong *) buffer) != 1) {
+       if (dev_desc->block_read(dev_desc, ext_part_sector, 1,
+                                (ulong *)buffer) != 1) {
                printf ("** Can't read partition table on %d:" LBAFU " **\n",
                        dev_desc->dev, ext_part_sector);
                return;
@@ -177,7 +178,8 @@ static int get_partition_info_extended (block_dev_desc_t *dev_desc,
        int i;
        int dos_type;
 
-       if (dev_desc->block_read (dev_desc->dev, ext_part_sector, 1, (ulong *) buffer) != 1) {
+       if (dev_desc->block_read(dev_desc, ext_part_sector, 1,
+                                (ulong *)buffer) != 1) {
                printf ("** Can't read partition table on %d:" LBAFU " **\n",
                        dev_desc->dev, ext_part_sector);
                return -1;
index b1e01558a69f67a8a16b5bdf9a3fbe7454ba09a9..22dfbb16b56c0ad36932ebfeca431af20498d658 100644 (file)
@@ -324,7 +324,7 @@ int test_part_efi(block_dev_desc_t * dev_desc)
        ALLOC_CACHE_ALIGN_BUFFER_PAD(legacy_mbr, legacymbr, 1, dev_desc->blksz);
 
        /* Read legacy MBR from block 0 and validate it */
-       if ((dev_desc->block_read(dev_desc->dev, 0, 1, (ulong *)legacymbr) != 1)
+       if ((dev_desc->block_read(dev_desc, 0, 1, (ulong *)legacymbr) != 1)
                || (is_pmbr_valid(legacymbr) != 1)) {
                return -1;
        }
@@ -354,7 +354,7 @@ static int set_protective_mbr(block_dev_desc_t *dev_desc)
        p_mbr->partition_record[0].nr_sects = (u32) dev_desc->lba - 1;
 
        /* Write MBR sector to the MMC device */
-       if (dev_desc->block_write(dev_desc->dev, 0, 1, p_mbr) != 1) {
+       if (dev_desc->block_write(dev_desc, 0, 1, p_mbr) != 1) {
                printf("** Can't write to device %d **\n",
                        dev_desc->dev);
                return -1;
@@ -386,22 +386,22 @@ int write_gpt_table(block_dev_desc_t *dev_desc,
        gpt_h->header_crc32 = cpu_to_le32(calc_crc32);
 
        /* Write the First GPT to the block right after the Legacy MBR */
-       if (dev_desc->block_write(dev_desc->dev, 1, 1, gpt_h) != 1)
+       if (dev_desc->block_write(dev_desc, 1, 1, gpt_h) != 1)
                goto err;
 
-       if (dev_desc->block_write(dev_desc->dev, 2, pte_blk_cnt, gpt_e)
+       if (dev_desc->block_write(dev_desc, 2, pte_blk_cnt, gpt_e)
            != pte_blk_cnt)
                goto err;
 
        prepare_backup_gpt_header(gpt_h);
 
-       if (dev_desc->block_write(dev_desc->dev,
+       if (dev_desc->block_write(dev_desc,
                                  (lbaint_t)le64_to_cpu(gpt_h->last_usable_lba)
                                  + 1,
                                  pte_blk_cnt, gpt_e) != pte_blk_cnt)
                goto err;
 
-       if (dev_desc->block_write(dev_desc->dev,
+       if (dev_desc->block_write(dev_desc,
                                  (lbaint_t)le64_to_cpu(gpt_h->my_lba), 1,
                                  gpt_h) != 1)
                goto err;
@@ -737,7 +737,7 @@ int write_mbr_and_gpt_partitions(block_dev_desc_t *dev_desc, void *buf)
        /* write MBR */
        lba = 0;        /* MBR is always at 0 */
        cnt = 1;        /* MBR (1 block) */
-       if (dev_desc->block_write(dev_desc->dev, lba, cnt, buf) != cnt) {
+       if (dev_desc->block_write(dev_desc, lba, cnt, buf) != cnt) {
                printf("%s: failed writing '%s' (%d blks at 0x" LBAF ")\n",
                       __func__, "MBR", cnt, lba);
                return 1;
@@ -746,7 +746,7 @@ int write_mbr_and_gpt_partitions(block_dev_desc_t *dev_desc, void *buf)
        /* write Primary GPT */
        lba = GPT_PRIMARY_PARTITION_TABLE_LBA;
        cnt = 1;        /* GPT Header (1 block) */
-       if (dev_desc->block_write(dev_desc->dev, lba, cnt, gpt_h) != cnt) {
+       if (dev_desc->block_write(dev_desc, lba, cnt, gpt_h) != cnt) {
                printf("%s: failed writing '%s' (%d blks at 0x" LBAF ")\n",
                       __func__, "Primary GPT Header", cnt, lba);
                return 1;
@@ -754,7 +754,7 @@ int write_mbr_and_gpt_partitions(block_dev_desc_t *dev_desc, void *buf)
 
        lba = le64_to_cpu(gpt_h->partition_entry_lba);
        cnt = gpt_e_blk_cnt;
-       if (dev_desc->block_write(dev_desc->dev, lba, cnt, gpt_e) != cnt) {
+       if (dev_desc->block_write(dev_desc, lba, cnt, gpt_e) != cnt) {
                printf("%s: failed writing '%s' (%d blks at 0x" LBAF ")\n",
                       __func__, "Primary GPT Entries", cnt, lba);
                return 1;
@@ -765,7 +765,7 @@ int write_mbr_and_gpt_partitions(block_dev_desc_t *dev_desc, void *buf)
        /* write Backup GPT */
        lba = le64_to_cpu(gpt_h->partition_entry_lba);
        cnt = gpt_e_blk_cnt;
-       if (dev_desc->block_write(dev_desc->dev, lba, cnt, gpt_e) != cnt) {
+       if (dev_desc->block_write(dev_desc, lba, cnt, gpt_e) != cnt) {
                printf("%s: failed writing '%s' (%d blks at 0x" LBAF ")\n",
                       __func__, "Backup GPT Entries", cnt, lba);
                return 1;
@@ -773,7 +773,7 @@ int write_mbr_and_gpt_partitions(block_dev_desc_t *dev_desc, void *buf)
 
        lba = le64_to_cpu(gpt_h->my_lba);
        cnt = 1;        /* GPT Header (1 block) */
-       if (dev_desc->block_write(dev_desc->dev, lba, cnt, gpt_h) != cnt) {
+       if (dev_desc->block_write(dev_desc, lba, cnt, gpt_h) != cnt) {
                printf("%s: failed writing '%s' (%d blks at 0x" LBAF ")\n",
                       __func__, "Backup GPT Header", cnt, lba);
                return 1;
@@ -843,8 +843,7 @@ static int is_gpt_valid(block_dev_desc_t *dev_desc, u64 lba,
        }
 
        /* Read GPT Header from device */
-       if (dev_desc->block_read(dev_desc->dev, (lbaint_t)lba, 1, pgpt_head)
-                       != 1) {
+       if (dev_desc->block_read(dev_desc, (lbaint_t)lba, 1, pgpt_head) != 1) {
                printf("*** ERROR: Can't read GPT header ***\n");
                return 0;
        }
@@ -881,6 +880,7 @@ static gpt_entry *alloc_read_gpt_entries(block_dev_desc_t * dev_desc,
                                         gpt_header * pgpt_head)
 {
        size_t count = 0, blk_cnt;
+       lbaint_t blk;
        gpt_entry *pte = NULL;
 
        if (!dev_desc || !pgpt_head) {
@@ -909,12 +909,10 @@ static gpt_entry *alloc_read_gpt_entries(block_dev_desc_t * dev_desc,
        }
 
        /* Read GPT Entries from device */
+       blk = le64_to_cpu(pgpt_head->partition_entry_lba);
        blk_cnt = BLOCK_CNT(count, dev_desc);
-       if (dev_desc->block_read (dev_desc->dev,
-               (lbaint_t)le64_to_cpu(pgpt_head->partition_entry_lba),
-               (lbaint_t) (blk_cnt), pte)
-               != blk_cnt) {
-
+       if (dev_desc->block_read(dev_desc, blk, (lbaint_t)blk_cnt, pte)
+           != blk_cnt) {
                printf("*** ERROR: Can't read GPT Entries ***\n");
                free(pte);
                return NULL;
index 2547c703db54d02dd12ae891ec299042b4906e94..0b1ac606374bbbf781e95dbe0ebf886335703bf7 100644 (file)
@@ -62,8 +62,8 @@ int get_partition_info_iso_verb(block_dev_desc_t * dev_desc, int part_num, disk_
 
        /* the first sector (sector 0x10) must be a primary volume desc */
        blkaddr=PVD_OFFSET;
-       if (dev_desc->block_read (dev_desc->dev, PVD_OFFSET, 1, (ulong *) tmpbuf) != 1)
-       return (-1);
+       if (dev_desc->block_read(dev_desc, PVD_OFFSET, 1, (ulong *)tmpbuf) != 1)
+               return -1;
        if(ppr->desctype!=0x01) {
                if(verb)
                        printf ("** First descriptor is NOT a primary desc on %d:%d **\n",
@@ -84,8 +84,8 @@ int get_partition_info_iso_verb(block_dev_desc_t * dev_desc, int part_num, disk_
        PRINTF(" Lastsect:%08lx\n",lastsect);
        for(i=blkaddr;i<lastsect;i++) {
                PRINTF("Reading block %d\n", i);
-               if (dev_desc->block_read (dev_desc->dev, i, 1, (ulong *) tmpbuf) != 1)
-               return (-1);
+               if (dev_desc->block_read(dev_desc, i, 1, (ulong *)tmpbuf) != 1)
+                       return -1;
                if(ppr->desctype==0x00)
                        break; /* boot entry found */
                if(ppr->desctype==0xff) {
@@ -104,7 +104,7 @@ int get_partition_info_iso_verb(block_dev_desc_t * dev_desc, int part_num, disk_
        }
        bootaddr=le32_to_int(pbr->pointer);
        PRINTF(" Boot Entry at: %08lX\n",bootaddr);
-       if (dev_desc->block_read (dev_desc->dev, bootaddr, 1, (ulong *) tmpbuf) != 1) {
+       if (dev_desc->block_read(dev_desc, bootaddr, 1, (ulong *)tmpbuf) != 1) {
                if(verb)
                        printf ("** Can't read Boot Entry at %lX on %d:%d **\n",
                                bootaddr,dev_desc->dev, part_num);
index 099e0a0035be07303ac6b69a646ab59ba6260819..f3bc8dd55535b843850df201c534456a396a99a8 100644 (file)
@@ -51,7 +51,8 @@ int test_part_mac (block_dev_desc_t *dev_desc)
 
        n = 1;  /* assuming at least one partition */
        for (i=1; i<=n; ++i) {
-               if ((dev_desc->block_read(dev_desc->dev, i, 1, (ulong *)mpart) != 1) ||
+               if ((dev_desc->block_read(dev_desc, i, 1,
+                                         (ulong *)mpart) != 1) ||
                    (mpart->signature != MAC_PARTITION_MAGIC) ) {
                        return (-1);
                }
@@ -104,7 +105,7 @@ void print_part_mac (block_dev_desc_t *dev_desc)
                char c;
 
                printf ("%4ld: ", i);
-               if (dev_desc->block_read (dev_desc->dev, i, 1, (ulong *)mpart) != 1) {
+               if (dev_desc->block_read(dev_desc, i, 1, (ulong *)mpart) != 1) {
                        printf ("** Can't read Partition Map on %d:%ld **\n",
                                dev_desc->dev, i);
                        return;
@@ -150,7 +151,7 @@ void print_part_mac (block_dev_desc_t *dev_desc)
  */
 static int part_mac_read_ddb (block_dev_desc_t *dev_desc, mac_driver_desc_t *ddb_p)
 {
-       if (dev_desc->block_read(dev_desc->dev, 0, 1, (ulong *)ddb_p) != 1) {
+       if (dev_desc->block_read(dev_desc, 0, 1, (ulong *)ddb_p) != 1) {
                printf ("** Can't read Driver Desriptor Block **\n");
                return (-1);
        }
@@ -178,7 +179,7 @@ static int part_mac_read_pdb (block_dev_desc_t *dev_desc, int part, mac_partitio
                 * partition 1 first since this is the only way to
                 * know how many partitions we have.
                 */
-               if (dev_desc->block_read (dev_desc->dev, n, 1, (ulong *)pdb_p) != 1) {
+               if (dev_desc->block_read(dev_desc, n, 1, (ulong *)pdb_p) != 1) {
                        printf ("** Can't read Partition Map on %d:%d **\n",
                                dev_desc->dev, n);
                        return (-1);
index 73f4c4a9e98c52141118791dbf786c8dbfff70c0..170f0fa5bf20bf3394c08c19f89eb75b4a5fc415 100644 (file)
@@ -22,9 +22,11 @@ static struct host_block_dev *find_host_device(int dev)
        return NULL;
 }
 
-static unsigned long host_block_read(int dev, unsigned long start,
-                                    lbaint_t blkcnt, void *buffer)
+static unsigned long host_block_read(block_dev_desc_t *block_dev,
+                                    unsigned long start, lbaint_t blkcnt,
+                                    void *buffer)
 {
+       int dev = block_dev->dev;
        struct host_block_dev *host_dev = find_host_device(dev);
 
        if (!host_dev)
@@ -42,9 +44,11 @@ static unsigned long host_block_read(int dev, unsigned long start,
        return -1;
 }
 
-static unsigned long host_block_write(int dev, unsigned long start,
-                                     lbaint_t blkcnt, const void *buffer)
+static unsigned long host_block_write(block_dev_desc_t *block_dev,
+                                     unsigned long start, lbaint_t blkcnt,
+                                     const void *buffer)
 {
+       int dev = block_dev->dev;
        struct host_block_dev *host_dev = find_host_device(dev);
        if (os_lseek(host_dev->fd,
                     start * host_dev->blk_dev.blksz,
index fdf75b5abfc90ea2b9eb4d6afcc53d880ebd81c1..b974e80167e961dbf6934cdcd74c6a3588dd77c1 100644 (file)
@@ -69,8 +69,9 @@ static u16 ace_readw(unsigned off)
        return in16(base + off);
 }
 
-static unsigned long systemace_read(int dev, unsigned long start,
-                                       lbaint_t blkcnt, void *buffer);
+static unsigned long systemace_read(block_dev_desc_t *block_dev,
+                                   unsigned long start, lbaint_t blkcnt,
+                                   void *buffer);
 
 static block_dev_desc_t systemace_dev = { 0 };
 
@@ -136,8 +137,9 @@ block_dev_desc_t *systemace_get_dev(int dev)
  * the dev_desc) to read blocks of data. The return value is the
  * number of blocks read. A zero return indicates an error.
  */
-static unsigned long systemace_read(int dev, unsigned long start,
-                                       lbaint_t blkcnt, void *buffer)
+static unsigned long systemace_read(block_dev_desc_t *block_dev,
+                                   unsigned long start, lbaint_t blkcnt,
+                                   void *buffer)
 {
        int retry;
        unsigned blk_countdown;
index f332480e1d89eebeef28a2305468b57f3f3a577d..c5c9d2a42e5c943572740feac34042915696b266 100644 (file)
@@ -57,6 +57,15 @@ config DM_SEQ_ALIAS
        bool "Support numbered aliases in device tree"
        depends on DM
        default y
+       help
+         Most boards will have a '/aliases' node containing the path to
+         numbered devices (e.g. serial0 = &serial0). This feature can be
+         disabled if it is not required.
+
+config SPL_DM_SEQ_ALIAS
+       bool "Support numbered aliases in device tree in SPL"
+       depends on DM
+       default n
        help
          Most boards will have a '/aliases' node containing the path to
          numbered devices (e.g. serial0 = &serial0). This feature can be
index 8c6e6b067e70eb5c6f457d8eb71f5a79f2d11a06..818d03fac15de55a331ed07c4bb6d8a8d31e25df 100644 (file)
@@ -64,7 +64,7 @@ int device_bind(struct udevice *parent, const struct driver *drv,
 
        dev->seq = -1;
        dev->req_seq = -1;
-       if (CONFIG_IS_ENABLED(OF_CONTROL) && IS_ENABLED(CONFIG_DM_SEQ_ALIAS)) {
+       if (CONFIG_IS_ENABLED(OF_CONTROL) && CONFIG_IS_ENABLED(DM_SEQ_ALIAS)) {
                /*
                * Some devices, such as a SPI bus, I2C bus and serial ports
                * are numbered using aliases.
index 5a9fb4a6e24780ed3fda556ca522cd697d5f90dc..395d472e0bd995e7a7e863f786ae0c7fdfa1ca24 100644 (file)
@@ -20,23 +20,6 @@ static unsigned char *dfu_file_buf;
 static long dfu_file_buf_len;
 static long dfu_file_buf_filled;
 
-static int mmc_access_part(struct dfu_entity *dfu, struct mmc *mmc, int part)
-{
-       int ret;
-
-       if (part == mmc->part_num)
-               return 0;
-
-       ret = mmc_switch_part(dfu->data.mmc.dev_num, part);
-       if (ret) {
-               error("Cannot switch to partition %d\n", part);
-               return ret;
-       }
-       mmc->part_num = part;
-
-       return 0;
-}
-
 static int mmc_block_op(enum dfu_op op, struct dfu_entity *dfu,
                        u64 offset, void *buf, long *len)
 {
@@ -66,8 +49,9 @@ static int mmc_block_op(enum dfu_op op, struct dfu_entity *dfu,
        }
 
        if (dfu->data.mmc.hw_partition >= 0) {
-               part_num_bkp = mmc->part_num;
-               ret = mmc_access_part(dfu, mmc, dfu->data.mmc.hw_partition);
+               part_num_bkp = mmc->block_dev.hwpart;
+               ret = mmc_select_hwpart(dfu->data.mmc.dev_num,
+                                       dfu->data.mmc.hw_partition);
                if (ret)
                        return ret;
        }
@@ -77,11 +61,11 @@ static int mmc_block_op(enum dfu_op op, struct dfu_entity *dfu,
              dfu->data.mmc.dev_num, blk_start, blk_count, buf);
        switch (op) {
        case DFU_OP_READ:
-               n = mmc->block_dev.block_read(dfu->data.mmc.dev_num, blk_start,
+               n = mmc->block_dev.block_read(&mmc->block_dev, blk_start,
                                              blk_count, buf);
                break;
        case DFU_OP_WRITE:
-               n = mmc->block_dev.block_write(dfu->data.mmc.dev_num, blk_start,
+               n = mmc->block_dev.block_write(&mmc->block_dev, blk_start,
                                               blk_count, buf);
                break;
        default:
@@ -91,12 +75,12 @@ static int mmc_block_op(enum dfu_op op, struct dfu_entity *dfu,
        if (n != blk_count) {
                error("MMC operation failed");
                if (dfu->data.mmc.hw_partition >= 0)
-                       mmc_access_part(dfu, mmc, part_num_bkp);
+                       mmc_select_hwpart(dfu->data.mmc.dev_num, part_num_bkp);
                return -EIO;
        }
 
        if (dfu->data.mmc.hw_partition >= 0) {
-               ret = mmc_access_part(dfu, mmc, part_num_bkp);
+               ret = mmc_select_hwpart(dfu->data.mmc.dev_num, part_num_bkp);
                if (ret)
                        return ret;
        }
index b1cb4b3534f8e68b2576d30cb5f021fde8a80133..301d9b3ab996b1eb3fd8e284aee5ec14d1c1d8ac 100644 (file)
@@ -38,7 +38,8 @@ void mmc_spl_load_image(uint32_t offs, unsigned int size, void *vdst)
        blk_start = ALIGN(offs, mmc->read_bl_len) / mmc->read_bl_len;
        blk_cnt = ALIGN(size, mmc->read_bl_len) / mmc->read_bl_len;
 
-       err = mmc->block_dev.block_read(0, blk_start, blk_cnt, vdst);
+       err = mmc->block_dev.block_read(&mmc->block_dev, blk_start, blk_cnt,
+                                       vdst);
        if (err != blk_cnt) {
                puts("spl: mmc read failed!!\n");
                hang();
@@ -85,7 +86,8 @@ void __noreturn mmc_boot(void)
        /*
        * Read source addr from sd card
        */
-       err = mmc->block_dev.block_read(0, CONFIG_CFG_DATA_SECTOR, 1, tmp_buf);
+       err = mmc->block_dev.block_read(&mmc->block_dev,
+                                       CONFIG_CFG_DATA_SECTOR, 1, tmp_buf);
        if (err != 1) {
                puts("spl: mmc read failed!!\n");
                free(tmp_buf);
@@ -126,7 +128,7 @@ void __noreturn mmc_boot(void)
 #endif
        blk_start = ALIGN(offset, mmc->read_bl_len) / mmc->read_bl_len;
        blk_cnt = ALIGN(code_len, mmc->read_bl_len) / mmc->read_bl_len;
-       err = mmc->block_dev.block_read(0, blk_start, blk_cnt,
+       err = mmc->block_dev.block_read(&mmc->block_dev, blk_start, blk_cnt,
                                        (uchar *)CONFIG_SYS_MMC_U_BOOT_DST);
        if (err != blk_cnt) {
                puts("spl: mmc read failed!!\n");
index 3a34028c9177ef1d917910dfd61a7c4b14e12749..e6028d503f279ee6617b29e9657d1c8a17e39a85 100644 (file)
@@ -234,8 +234,11 @@ static int mmc_read_blocks(struct mmc *mmc, void *dst, lbaint_t start,
        return blkcnt;
 }
 
-static ulong mmc_bread(int dev_num, lbaint_t start, lbaint_t blkcnt, void *dst)
+static ulong mmc_bread(block_dev_desc_t *block_dev, lbaint_t start,
+                      lbaint_t blkcnt, void *dst)
 {
+       int dev_num = block_dev->dev;
+       int err;
        lbaint_t cur, blocks_todo = blkcnt;
 
        if (blkcnt == 0)
@@ -245,6 +248,10 @@ static ulong mmc_bread(int dev_num, lbaint_t start, lbaint_t blkcnt, void *dst)
        if (!mmc)
                return 0;
 
+       err = mmc_select_hwpart(dev_num, block_dev->hwpart);
+       if (err < 0)
+               return 0;
+
        if ((start + blkcnt) > mmc->block_dev.lba) {
 #if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT)
                printf("MMC: block number 0x" LBAF " exceeds max(0x" LBAF ")\n",
@@ -579,7 +586,7 @@ int mmc_select_hwpart(int dev_num, int hwpart)
        if (!mmc)
                return -ENODEV;
 
-       if (mmc->part_num == hwpart)
+       if (mmc->block_dev.hwpart == hwpart)
                return 0;
 
        if (mmc->part_config == MMCPART_NOAVAILABLE) {
@@ -591,8 +598,6 @@ int mmc_select_hwpart(int dev_num, int hwpart)
        if (ret)
                return ret;
 
-       mmc->part_num = hwpart;
-
        return 0;
 }
 
@@ -613,8 +618,10 @@ int mmc_switch_part(int dev_num, unsigned int part_num)
         * Set the capacity if the switch succeeded or was intended
         * to return to representing the raw device.
         */
-       if ((ret == 0) || ((ret == -ENODEV) && (part_num == 0)))
+       if ((ret == 0) || ((ret == -ENODEV) && (part_num == 0))) {
                ret = mmc_set_capacity(mmc, part_num);
+               mmc->block_dev.hwpart = part_num;
+       }
 
        return ret;
 }
@@ -1324,7 +1331,7 @@ static int mmc_startup(struct mmc *mmc)
                mmc->wr_rel_set = ext_csd[EXT_CSD_WR_REL_SET];
        }
 
-       err = mmc_set_capacity(mmc, mmc->part_num);
+       err = mmc_set_capacity(mmc, mmc->block_dev.hwpart);
        if (err)
                return err;
 
@@ -1465,6 +1472,7 @@ static int mmc_startup(struct mmc *mmc)
 
        /* fill in device description */
        mmc->block_dev.lun = 0;
+       mmc->block_dev.hwpart = 0;
        mmc->block_dev.type = 0;
        mmc->block_dev.blksz = mmc->read_bl_len;
        mmc->block_dev.log2blksz = LOG2(mmc->block_dev.blksz);
@@ -1624,7 +1632,7 @@ int mmc_start_init(struct mmc *mmc)
                return err;
 
        /* The internal partition reset to user partition(0) at every CMD0*/
-       mmc->part_num = 0;
+       mmc->block_dev.hwpart = 0;
 
        /* Test for SD version 2 */
        err = mmc_send_if_cond(mmc);
index 447a7001dbd986719aca1c39acbf0e5cd58dc80c..6a7063976ceaa01fe32418f50a60861a29b2d52d 100644 (file)
@@ -22,23 +22,24 @@ void mmc_adapter_card_type_ident(void);
 
 #ifndef CONFIG_SPL_BUILD
 
-extern unsigned long mmc_berase(int dev_num, lbaint_t start, lbaint_t blkcnt);
+unsigned long mmc_berase(block_dev_desc_t *block_dev, lbaint_t start,
+                        lbaint_t blkcnt);
 
-extern ulong mmc_bwrite(int dev_num, lbaint_t start, lbaint_t blkcnt,
-               const void *src);
+unsigned long mmc_bwrite(block_dev_desc_t *block_dev, lbaint_t start,
+                        lbaint_t blkcnt, const void *src);
 
 #else /* CONFIG_SPL_BUILD */
 
 /* SPL will never write or erase, declare dummies to reduce code size. */
 
-static inline unsigned long mmc_berase(int dev_num, lbaint_t start,
-               lbaint_t blkcnt)
+static inline unsigned long mmc_berase(block_dev_desc_t *block_dev,
+                                      lbaint_t start, lbaint_t blkcnt)
 {
        return 0;
 }
 
-static inline ulong mmc_bwrite(int dev_num, lbaint_t start, lbaint_t blkcnt,
-               const void *src)
+static inline ulong mmc_bwrite(block_dev_desc_t *block_dev, lbaint_t start,
+                              lbaint_t blkcnt, const void *src)
 {
        return 0;
 }
index 221bf306cc5c6ec4d5d6c24d10d06f3a59432ad4..79b8c4d808fb32c79605dc046417135aed1def9c 100644 (file)
@@ -65,8 +65,10 @@ err_out:
        return err;
 }
 
-unsigned long mmc_berase(int dev_num, lbaint_t start, lbaint_t blkcnt)
+unsigned long mmc_berase(block_dev_desc_t *block_dev, lbaint_t start,
+                        lbaint_t blkcnt)
 {
+       int dev_num = block_dev->dev;
        int err = 0;
        u32 start_rem, blkcnt_rem;
        struct mmc *mmc = find_mmc_device(dev_num);
@@ -76,6 +78,10 @@ unsigned long mmc_berase(int dev_num, lbaint_t start, lbaint_t blkcnt)
        if (!mmc)
                return -1;
 
+       err = mmc_select_hwpart(dev_num, block_dev->hwpart);
+       if (err < 0)
+               return -1;
+
        /*
         * We want to see if the requested start or total block count are
         * unaligned.  We discard the whole numbers and only care about the
@@ -165,14 +171,21 @@ static ulong mmc_write_blocks(struct mmc *mmc, lbaint_t start,
        return blkcnt;
 }
 
-ulong mmc_bwrite(int dev_num, lbaint_t start, lbaint_t blkcnt, const void *src)
+ulong mmc_bwrite(block_dev_desc_t *block_dev, lbaint_t start, lbaint_t blkcnt,
+                const void *src)
 {
+       int dev_num = block_dev->dev;
        lbaint_t cur, blocks_todo = blkcnt;
+       int err;
 
        struct mmc *mmc = find_mmc_device(dev_num);
        if (!mmc)
                return 0;
 
+       err = mmc_select_hwpart(dev_num, block_dev->hwpart);
+       if (err < 0)
+               return 0;
+
        if (mmc_set_blocklen(mmc, mmc->write_bl_len))
                return 0;
 
index e717c44216297fba3583098fad6cb20da8c58d98..7b33094d8486d0650f6328039254eca258d20121 100644 (file)
@@ -454,7 +454,7 @@ int sunxi_mmc_has_egon_boot_signature(struct mmc *mmc)
                panic("Failed to allocate memory\n");
 
        if (mmc_getcd(mmc) && mmc_init(mmc) == 0 &&
-           mmc->block_dev.block_read(mmc->block_dev.dev, 16, 1, buf) == 1 &&
+           mmc->block_dev.block_read(&mmc->block_dev, 16, 1, buf) == 1 &&
            strncmp(&buf[4], "eGON.BT0", 8) == 0)
                valid_signature = 1;
 
index 027f2bfd11f7c273f9ebf3aec14872af68e8d218..70fc02ee5ca6bb9bb28abf9361eb359398e6089e 100644 (file)
@@ -551,43 +551,6 @@ static int32_t e1000_init_eeprom_params(struct e1000_hw *hw)
                eeprom->use_eerd = true;
                eeprom->use_eewr = false;
                break;
-
-       /* ich8lan does not support currently. if needed, please
-        * add corresponding code and functions.
-        */
-#if 0
-       case e1000_ich8lan:
-               {
-               int32_t  i = 0;
-
-               eeprom->type = e1000_eeprom_ich8;
-               eeprom->use_eerd = false;
-               eeprom->use_eewr = false;
-               eeprom->word_size = E1000_SHADOW_RAM_WORDS;
-               uint32_t flash_size = E1000_READ_ICH_FLASH_REG(hw,
-                               ICH_FLASH_GFPREG);
-               /* Zero the shadow RAM structure. But don't load it from NVM
-                * so as to save time for driver init */
-               if (hw->eeprom_shadow_ram != NULL) {
-                       for (i = 0; i < E1000_SHADOW_RAM_WORDS; i++) {
-                               hw->eeprom_shadow_ram[i].modified = false;
-                               hw->eeprom_shadow_ram[i].eeprom_word = 0xFFFF;
-                       }
-               }
-
-               hw->flash_base_addr = (flash_size & ICH_GFPREG_BASE_MASK) *
-                               ICH_FLASH_SECTOR_SIZE;
-
-               hw->flash_bank_size = ((flash_size >> 16)
-                               & ICH_GFPREG_BASE_MASK) + 1;
-               hw->flash_bank_size -= (flash_size & ICH_GFPREG_BASE_MASK);
-
-               hw->flash_bank_size *= ICH_FLASH_SECTOR_SIZE;
-
-               hw->flash_bank_size /= 2 * sizeof(uint16_t);
-               break;
-               }
-#endif
        default:
                break;
        }
@@ -838,14 +801,6 @@ e1000_read_eeprom(struct e1000_hw *hw, uint16_t offset,
        if (eeprom->use_eerd == true)
                return e1000_read_eeprom_eerd(hw, offset, words, data);
 
-       /* ich8lan does not support currently. if needed, please
-        * add corresponding code and functions.
-        */
-#if 0
-       /* ICH EEPROM access is done via the ICH flash controller */
-       if (eeprom->type == e1000_eeprom_ich8)
-               return e1000_read_eeprom_ich8(hw, offset, words, data);
-#endif
        /* Set up the SPI or Microwire EEPROM for bit-bang reading.  We have
         * acquired the EEPROM at this point, so any returns should relase it */
        if (eeprom->type == e1000_eeprom_spi) {
@@ -1732,17 +1687,7 @@ e1000_init_hw(struct e1000_hw *hw, unsigned char enetaddr[6])
                 * occuring when accessing our register space */
                E1000_WRITE_FLUSH(hw);
        }
-#if 0
-       /* Set the PCI priority bit correctly in the CTRL register.  This
-        * determines if the adapter gives priority to receives, or if it
-        * gives equal priority to transmits and receives.  Valid only on
-        * 82542 and 82543 silicon.
-        */
-       if (hw->dma_fairness && hw->mac_type <= e1000_82543) {
-               ctrl = E1000_READ_REG(hw, CTRL);
-               E1000_WRITE_REG(hw, CTRL, ctrl | E1000_CTRL_PRIOR);
-       }
-#endif
+
        switch (hw->mac_type) {
        case e1000_82545_rev_3:
        case e1000_82546_rev_3:
@@ -1842,20 +1787,6 @@ e1000_init_hw(struct e1000_hw *hw, unsigned char enetaddr[6])
                break;
        }
 
-#if 0
-       /* Clear all of the statistics registers (clear on read).  It is
-        * important that we do this after we have tried to establish link
-        * because the symbol error count will increment wildly if there
-        * is no link.
-        */
-       e1000_clear_hw_cntrs(hw);
-
-       /* ICH8 No-snoop bits are opposite polarity.
-        * Set to snoop by default after reset. */
-       if (hw->mac_type == e1000_ich8lan)
-               e1000_set_pci_ex_no_snoop(hw, PCI_EX_82566_SNOOP_ALL);
-#endif
-
        if (hw->device_id == E1000_DEV_ID_82546GB_QUAD_COPPER ||
                hw->device_id == E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3) {
                ctrl_ext = E1000_READ_REG(hw, CTRL_EXT);
@@ -5230,10 +5161,6 @@ _e1000_disable(struct e1000_hw *hw)
        E1000_WRITE_REG(hw, RDH, 0);
        E1000_WRITE_REG(hw, RDT, 0);
 
-       /* put the card in its initial state */
-#if 0
-       E1000_WRITE_REG(hw, CTRL, E1000_CTRL_RST);
-#endif
        mdelay(10);
 }
 
@@ -5359,7 +5286,6 @@ static int e1000_init_one(struct e1000_hw *hw, int cardnum, pci_dev_t devno,
 
 #ifndef CONFIG_E1000_NO_NVM
        /* Validate the EEPROM and get chipset information */
-#if !defined(CONFIG_MVBC_1G)
        if (e1000_init_eeprom_params(hw)) {
                E1000_ERR(hw, "EEPROM is invalid!\n");
                return -EINVAL;
@@ -5367,7 +5293,6 @@ static int e1000_init_one(struct e1000_hw *hw, int cardnum, pci_dev_t devno,
        if ((E1000_READ_REG(hw, I210_EECD) & E1000_EECD_FLUPD) &&
            e1000_validate_eeprom_checksum(hw))
                return -ENXIO;
-#endif
        e1000_read_mac_addr(hw, enetaddr);
 #endif
        e1000_get_bus_type(hw);
index c851922ae5c791670778b9111e96cade2fea3419..e46edcd4e1d845e17a5e07739e7166eea2353a77 100644 (file)
@@ -1093,11 +1093,6 @@ struct e1000_hw {
        e1000_media_type media_type;
        e1000_fc_type fc;
        e1000_bus_type bus_type;
-#if 0
-       e1000_bus_speed bus_speed;
-       e1000_bus_width bus_width;
-       uint32_t io_base;
-#endif
        uint32_t                asf_firmware_present;
 #ifndef CONFIG_E1000_NO_NVM
        uint32_t                eeprom_semaphore_present;
@@ -1116,29 +1111,11 @@ struct e1000_hw {
        uint32_t original_fc;
        uint32_t txcw;
        uint32_t autoneg_failed;
-#if 0
-       uint32_t max_frame_size;
-       uint32_t min_frame_size;
-       uint32_t mc_filter_type;
-       uint32_t num_mc_addrs;
-       uint32_t collision_delta;
-       uint32_t tx_packet_delta;
-       uint32_t ledctl_default;
-       uint32_t ledctl_mode1;
-       uint32_t ledctl_mode2;
-#endif
        uint16_t autoneg_advertised;
        uint16_t pci_cmd_word;
        uint16_t fc_high_water;
        uint16_t fc_low_water;
        uint16_t fc_pause_time;
-#if 0
-       uint16_t current_ifs_val;
-       uint16_t ifs_min_val;
-       uint16_t ifs_max_val;
-       uint16_t ifs_step_size;
-       uint16_t ifs_ratio;
-#endif
        uint16_t device_id;
        uint16_t vendor_id;
        uint16_t subsystem_id;
@@ -1149,9 +1126,6 @@ struct e1000_hw {
        uint8_t forced_speed_duplex;
        uint8_t wait_autoneg_complete;
        uint8_t dma_fairness;
-#if 0
-       uint8_t perm_mac_addr[NODE_ADDRESS_SIZE];
-#endif
        bool disable_polarity_correction;
        bool            speed_downgraded;
        bool get_link_status;
@@ -1162,11 +1136,6 @@ struct e1000_hw {
        bool report_tx_early;
        bool phy_reset_disable;
        bool            initialize_hw_bits_disable;
-#if 0
-       bool adaptive_ifs;
-       bool ifs_params_forced;
-       bool in_ifs_mode;
-#endif
        e1000_smart_speed       smart_speed;
        e1000_dsp_config        dsp_config_state;
 };
index df72375238f5814e873d1a69b6389c61ac03c625..576ddb8b24290f6a20220553b5cb2d60a4e97b26 100644 (file)
@@ -182,22 +182,21 @@ static int e1000_spi_eeprom_enable_wr(struct e1000_hw *hw, bool intr)
  * These have been tested to perform correctly, but they are not used by any
  * of the EEPROM commands at this time.
  */
-#if 0
-static int e1000_spi_eeprom_disable_wr(struct e1000_hw *hw, bool intr)
+static __maybe_unused int e1000_spi_eeprom_disable_wr(struct e1000_hw *hw,
+                                                     bool intr)
 {
        u8 op[] = { SPI_EEPROM_DISABLE_WR };
        e1000_standby_eeprom(hw);
        return e1000_spi_xfer(hw, 8*sizeof(op), op, NULL, intr);
 }
 
-static int e1000_spi_eeprom_write_status(struct e1000_hw *hw,
-               u8 status, bool intr)
+static __maybe_unused int e1000_spi_eeprom_write_status(struct e1000_hw *hw,
+                                                       u8 status, bool intr)
 {
        u8 op[] = { SPI_EEPROM_WRITE_STATUS, status };
        e1000_standby_eeprom(hw);
        return e1000_spi_xfer(hw, 8*sizeof(op), op, NULL, intr);
 }
-#endif
 
 static int e1000_spi_eeprom_read_status(struct e1000_hw *hw, bool intr)
 {
index df5db723ba23ad47a5820858e7367fff91979c07..40fbf19c75729f9a3d8bd6192d0222c6f200fd3d 100644 (file)
@@ -395,7 +395,8 @@ int fm_init_common(int index, struct ccsr_fman *reg)
                printf("\nMMC read: dev # %u, block # %u, count %u ...\n",
                                dev, blk, cnt);
                mmc_init(mmc);
-               (void)mmc->block_dev.block_read(dev, blk, cnt, addr);
+               (void)mmc->block_dev.block_read(&mmc->block_dev, blk, cnt,
+                                               addr);
                /* flush cache after read */
                flush_cache((ulong)addr, cnt * 512);
        }
index e76e9bc2b5bdee62116ac3246e5d04520115293c..3ba5b4b1f9b32ba44145e8842913c423ba9ff397 100644 (file)
@@ -304,6 +304,13 @@ static int mii_reg_write(const char *devname, u8 phy_adr, u8 reg_ofs, u16 data)
                return -EFAULT;
        }
 
+       /* write the phy and reg addressse into the MII address reg */
+       writel((phy_adr << MADR_PHY_OFFSET) | (reg_ofs << MADR_REG_OFFSET),
+              &regs->madr);
+
+       /* write data to the MII write register */
+       writel(data, &regs->mwtd);
+
        /* wait till the MII is not busy */
        timeout = MII_TIMEOUT;
        do {
@@ -319,13 +326,6 @@ static int mii_reg_write(const char *devname, u8 phy_adr, u8 reg_ofs, u16 data)
                return -EFAULT;
        }
 
-       /* write the phy and reg addressse into the MII address reg */
-       writel((phy_adr << MADR_PHY_OFFSET) | (reg_ofs << MADR_REG_OFFSET),
-              &regs->madr);
-
-       /* write data to the MII write register */
-       writel(data, &regs->mwtd);
-
        /*debug("%s:(adr %d, off %d) <= %04x\n", __func__, phy_adr,
                reg_ofs, data);*/
 
index 3a2b3bba995282ebd8a96fb61d9ad742df5c246b..447ecfbeb6dfe9b378d3c7c5789f33a5518b38f9 100644 (file)
@@ -174,7 +174,8 @@ void cs4340_upload_firmware(struct phy_device *phydev)
                printf("MMC read: dev # %u, block # %u, count %u ...\n",
                       dev, blk, cnt);
                mmc_init(mmc);
-               (void)mmc->block_dev.block_read(dev, blk, cnt, addr);
+               (void)mmc->block_dev.block_read(&mmc->block_dev, blk, cnt,
+                                               addr);
                /* flush cache after read */
                flush_cache((ulong)addr, cnt * 512);
        }
index c8926a8945ac6c84e81ff651a18ed0b2eb8566ef..b42537529de85c10e44c522e2a5775523473e0cb 100644 (file)
 /*
- * Copyright (C) 2011 Vladimir Zapolskiy <vz@mleia.com>
+ * Copyright (C) 2011-2015 Vladimir Zapolskiy <vz@mleia.com>
  *
  * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
-#include <asm/arch/cpu.h>
-#include <asm/arch/clk.h>
-#include <asm/arch/uart.h>
-#include <asm/io.h>
+#include <dm.h>
 #include <serial.h>
+#include <dm/platform_data/lpc32xx_hsuart.h>
+
+#include <asm/arch/uart.h>
 #include <linux/compiler.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
-static struct hsuart_regs *hsuart = (struct hsuart_regs *)HS_UART_BASE;
+struct lpc32xx_hsuart_priv {
+       struct hsuart_regs *hsuart;
+};
 
-static void lpc32xx_serial_setbrg(void)
+static int lpc32xx_serial_setbrg(struct udevice *dev, int baudrate)
 {
+       struct lpc32xx_hsuart_priv *priv = dev_get_priv(dev);
+       struct hsuart_regs *hsuart = priv->hsuart;
        u32 div;
 
        /* UART rate = PERIPH_CLK / ((HSU_RATE + 1) x 14) */
-       div = (get_serial_clock() / 14 + gd->baudrate / 2) / gd->baudrate - 1;
+       div = (get_serial_clock() / 14 + baudrate / 2) / baudrate - 1;
        if (div > 255)
                div = 255;
 
        writel(div, &hsuart->rate);
+
+       return 0;
 }
 
-static int lpc32xx_serial_getc(void)
+static int lpc32xx_serial_getc(struct udevice *dev)
 {
-       while (!(readl(&hsuart->level) & HSUART_LEVEL_RX))
-               /* NOP */;
+       struct lpc32xx_hsuart_priv *priv = dev_get_priv(dev);
+       struct hsuart_regs *hsuart = priv->hsuart;
+
+       if (!(readl(&hsuart->level) & HSUART_LEVEL_RX))
+               return -EAGAIN;
 
        return readl(&hsuart->rx) & HSUART_RX_DATA;
 }
 
-static void lpc32xx_serial_putc(const char c)
+static int lpc32xx_serial_putc(struct udevice *dev, const char c)
 {
-       if (c == '\n')
-               serial_putc('\r');
+       struct lpc32xx_hsuart_priv *priv = dev_get_priv(dev);
+       struct hsuart_regs *hsuart = priv->hsuart;
+
+       /* Wait for empty FIFO */
+       if (readl(&hsuart->level) & HSUART_LEVEL_TX)
+               return -EAGAIN;
 
        writel(c, &hsuart->tx);
 
-       /* Wait for character to be sent */
-       while (readl(&hsuart->level) & HSUART_LEVEL_TX)
-               /* NOP */;
+       return 0;
 }
 
-static int lpc32xx_serial_tstc(void)
+static int lpc32xx_serial_pending(struct udevice *dev, bool input)
 {
-       if (readl(&hsuart->level) & HSUART_LEVEL_RX)
-               return 1;
+       struct lpc32xx_hsuart_priv *priv = dev_get_priv(dev);
+       struct hsuart_regs *hsuart = priv->hsuart;
+
+       if (input) {
+               if (readl(&hsuart->level) & HSUART_LEVEL_RX)
+                       return 1;
+       } else {
+               if (readl(&hsuart->level) & HSUART_LEVEL_TX)
+                       return 1;
+       }
 
        return 0;
 }
 
-static int lpc32xx_serial_init(void)
+static int lpc32xx_serial_init(struct hsuart_regs *hsuart)
 {
-       lpc32xx_serial_setbrg();
-
        /* Disable hardware RTS and CTS flow control, set up RX and TX FIFO */
        writel(HSUART_CTRL_TMO_16 | HSUART_CTRL_HSU_OFFSET(20) |
               HSUART_CTRL_HSU_RX_TRIG_32 | HSUART_CTRL_HSU_TX_TRIG_0,
               &hsuart->ctrl);
+
        return 0;
 }
 
-static struct serial_device lpc32xx_serial_drv = {
-       .name   = "lpc32xx_serial",
-       .start  = lpc32xx_serial_init,
-       .stop   = NULL,
+static int lpc32xx_hsuart_probe(struct udevice *dev)
+{
+       struct lpc32xx_hsuart_platdata *platdata = dev_get_platdata(dev);
+       struct lpc32xx_hsuart_priv *priv = dev_get_priv(dev);
+
+       priv->hsuart = (struct hsuart_regs *)platdata->base;
+
+       lpc32xx_serial_init(priv->hsuart);
+
+       return 0;
+}
+
+static const struct dm_serial_ops lpc32xx_hsuart_ops = {
        .setbrg = lpc32xx_serial_setbrg,
-       .putc   = lpc32xx_serial_putc,
-       .puts   = default_serial_puts,
        .getc   = lpc32xx_serial_getc,
-       .tstc   = lpc32xx_serial_tstc,
+       .putc   = lpc32xx_serial_putc,
+       .pending = lpc32xx_serial_pending,
 };
 
-void lpc32xx_serial_initialize(void)
-{
-       serial_register(&lpc32xx_serial_drv);
-}
-
-__weak struct serial_device *default_serial_console(void)
-{
-       return &lpc32xx_serial_drv;
-}
+U_BOOT_DRIVER(lpc32xx_hsuart) = {
+       .name   = "lpc32xx_hsuart",
+       .id     = UCLASS_SERIAL,
+       .probe  = lpc32xx_hsuart_probe,
+       .ops    = &lpc32xx_hsuart_ops,
+       .priv_auto_alloc_size = sizeof(struct lpc32xx_hsuart_priv),
+       .flags  = DM_FLAG_PRE_RELOC,
+};
index ec1f23a0cf3f953a8a46c39f2da2f2a1a0328cf7..1ecb92ac6b81ed3db82a08b6e1a7d554003c0aec 100644 (file)
@@ -444,8 +444,9 @@ static void set_bulk_out_req_length(struct fsg_common *common,
 
 /*-------------------------------------------------------------------------*/
 
-struct ums *ums;
-struct fsg_common *the_fsg_common;
+static struct ums *ums;
+static int ums_count;
+static struct fsg_common *the_fsg_common;
 
 static int fsg_set_halt(struct fsg_dev *fsg, struct usb_ep *ep)
 {
@@ -772,7 +773,7 @@ static int do_read(struct fsg_common *common)
                }
 
                /* Perform the read */
-               rc = ums->read_sector(ums,
+               rc = ums[common->lun].read_sector(&ums[common->lun],
                                      file_offset / SECTOR_SIZE,
                                      amount / SECTOR_SIZE,
                                      (char __user *)bh->buf);
@@ -946,7 +947,7 @@ static int do_write(struct fsg_common *common)
                        amount = bh->outreq->actual;
 
                        /* Perform the write */
-                       rc = ums->write_sector(ums,
+                       rc = ums[common->lun].write_sector(&ums[common->lun],
                                               file_offset / SECTOR_SIZE,
                                               amount / SECTOR_SIZE,
                                               (char __user *)bh->buf);
@@ -1062,7 +1063,7 @@ static int do_verify(struct fsg_common *common)
                }
 
                /* Perform the read */
-               rc = ums->read_sector(ums,
+               rc = ums[common->lun].read_sector(&ums[common->lun],
                                      file_offset / SECTOR_SIZE,
                                      amount / SECTOR_SIZE,
                                      (char __user *)bh->buf);
@@ -1117,7 +1118,7 @@ static int do_inquiry(struct fsg_common *common, struct fsg_buffhd *bh)
        buf[4] = 31;            /* Additional length */
                                /* No special options */
        sprintf((char *) (buf + 8), "%-8s%-16s%04x", (char*) vendor_id ,
-                       ums->name, (u16) 0xffff);
+                       ums[common->lun].name, (u16) 0xffff);
 
        return 36;
 }
@@ -2456,7 +2457,7 @@ static struct fsg_common *fsg_common_init(struct fsg_common *common,
        int nluns, i, rc;
 
        /* Find out how many LUNs there should be */
-       nluns = 1;
+       nluns = ums_count;
        if (nluns < 1 || nluns > FSG_MAX_LUNS) {
                printf("invalid number of LUNs: %u\n", nluns);
                return ERR_PTR(-EINVAL);
@@ -2501,7 +2502,7 @@ static struct fsg_common *fsg_common_init(struct fsg_common *common,
        for (i = 0; i < nluns; i++) {
                common->luns[i].removable = 1;
 
-               rc = fsg_lun_open(&common->luns[i], "");
+               rc = fsg_lun_open(&common->luns[i], ums[i].num_sectors, "");
                if (rc)
                        goto error_luns;
        }
@@ -2775,9 +2776,10 @@ int fsg_add(struct usb_configuration *c)
        return fsg_bind_config(c->cdev, c, fsg_common);
 }
 
-int fsg_init(struct ums *ums_dev)
+int fsg_init(struct ums *ums_devs, int count)
 {
-       ums = ums_dev;
+       ums = ums_devs;
+       ums_count = count;
 
        return 0;
 }
index b55e40bbda947bb1c1c4f6f9c25ee03d0237df0f..b6df130a1405bc94328084f519de0c7fe56eda8f 100644 (file)
@@ -564,7 +564,8 @@ static struct usb_gadget_strings    fsg_stringtab = {
  * the caller must own fsg->filesem for writing.
  */
 
-static int fsg_lun_open(struct fsg_lun *curlun, const char *filename)
+static int fsg_lun_open(struct fsg_lun *curlun, unsigned int num_sectors,
+                       const char *filename)
 {
        int                             ro;
 
@@ -572,8 +573,8 @@ static int fsg_lun_open(struct fsg_lun *curlun, const char *filename)
        ro = curlun->initially_ro;
 
        curlun->ro = ro;
-       curlun->file_length = ums->num_sectors << 9;
-       curlun->num_sectors = ums->num_sectors;
+       curlun->file_length = num_sectors << 9;
+       curlun->num_sectors = num_sectors;
        debug("open backing file: %s\n", filename);
 
        return 0;
index 20f52566f09c03bfeaa869855aa81649e109dc2c..9fd10de0776b82028c8ccdc547a03e6188eb5812 100644 (file)
@@ -76,10 +76,10 @@ int ext4fs_devread(lbaint_t sector, int byte_offset, int byte_len, char *buf)
        if (byte_offset != 0) {
                int readlen;
                /* read first part which isn't aligned with start of sector */
-               if (ext4fs_block_dev_desc->
-                   block_read(ext4fs_block_dev_desc->dev,
-                               part_info->start + sector, 1,
-                               (unsigned long *) sec_buf) != 1) {
+               if (ext4fs_block_dev_desc->block_read(ext4fs_block_dev_desc,
+                                                     part_info->start + sector,
+                                                     1, (void *)sec_buf)
+                   != 1) {
                        printf(" ** ext2fs_devread() read error **\n");
                        return 0;
                }
@@ -101,18 +101,18 @@ int ext4fs_devread(lbaint_t sector, int byte_offset, int byte_len, char *buf)
                ALLOC_CACHE_ALIGN_BUFFER(u8, p, ext4fs_block_dev_desc->blksz);
 
                block_len = ext4fs_block_dev_desc->blksz;
-               ext4fs_block_dev_desc->block_read(ext4fs_block_dev_desc->dev,
+               ext4fs_block_dev_desc->block_read(ext4fs_block_dev_desc,
                                                  part_info->start + sector,
-                                                 1, (unsigned long *)p);
+                                                 1, (void *)p);
                memcpy(buf, p, byte_len);
                return 1;
        }
 
-       if (ext4fs_block_dev_desc->block_read(ext4fs_block_dev_desc->dev,
-                                              part_info->start + sector,
-                                              block_len >> log2blksz,
-                                              (unsigned long *) buf) !=
-                                              block_len >> log2blksz) {
+       if (ext4fs_block_dev_desc->block_read(ext4fs_block_dev_desc,
+                                             part_info->start + sector,
+                                             block_len >> log2blksz,
+                                             (void *)buf) !=
+                                             block_len >> log2blksz) {
                printf(" ** %s read error - block\n", __func__);
                return 0;
        }
@@ -123,10 +123,10 @@ int ext4fs_devread(lbaint_t sector, int byte_offset, int byte_len, char *buf)
 
        if (byte_len != 0) {
                /* read rest of data which are not in whole sector */
-               if (ext4fs_block_dev_desc->
-                   block_read(ext4fs_block_dev_desc->dev,
-                               part_info->start + sector, 1,
-                               (unsigned long *) sec_buf) != 1) {
+               if (ext4fs_block_dev_desc->block_read(ext4fs_block_dev_desc,
+                                                     part_info->start + sector,
+                                                     1, (void *)sec_buf)
+                   != 1) {
                        printf("* %s read error - last part\n", __func__);
                        return 0;
                }
index e73223ac22c99a8687d065e5f91732f7f6deab98..294a46eadfded68c3da42f44477e6239a480131c 100644 (file)
@@ -82,26 +82,26 @@ void put_ext4(uint64_t off, void *buf, uint32_t size)
 
        if (remainder) {
                if (fs->dev_desc->block_read) {
-                       fs->dev_desc->block_read(fs->dev_desc->dev,
+                       fs->dev_desc->block_read(fs->dev_desc,
                                                 startblock, 1, sec_buf);
                        temp_ptr = sec_buf;
                        memcpy((temp_ptr + remainder),
                               (unsigned char *)buf, size);
-                       fs->dev_desc->block_write(fs->dev_desc->dev,
+                       fs->dev_desc->block_write(fs->dev_desc,
                                                  startblock, 1, sec_buf);
                }
        } else {
                if (size >> log2blksz != 0) {
-                       fs->dev_desc->block_write(fs->dev_desc->dev,
+                       fs->dev_desc->block_write(fs->dev_desc,
                                                  startblock,
                                                  size >> log2blksz,
                                                  (unsigned long *)buf);
                } else {
-                       fs->dev_desc->block_read(fs->dev_desc->dev,
+                       fs->dev_desc->block_read(fs->dev_desc,
                                                 startblock, 1, sec_buf);
                        temp_ptr = sec_buf;
                        memcpy(temp_ptr, buf, size);
-                       fs->dev_desc->block_write(fs->dev_desc->dev,
+                       fs->dev_desc->block_write(fs->dev_desc,
                                                  startblock, 1,
                                                  (unsigned long *)sec_buf);
                }
@@ -1287,11 +1287,11 @@ static void alloc_triple_indirect_block(struct ext2_inode *file_inode,
                ti_gp_blockno = ext4fs_get_new_blk_no();
                if (ti_gp_blockno == -1) {
                        printf("no block left to assign\n");
-                       goto fail;
+                       return;
                }
                ti_gp_buff = zalloc(fs->blksz);
                if (!ti_gp_buff)
-                       goto fail;
+                       return;
 
                ti_gp_buff_start_addr = ti_gp_buff;
                (*no_blks_reqd)++;
@@ -1321,11 +1321,11 @@ static void alloc_triple_indirect_block(struct ext2_inode *file_inode,
                                ti_child_blockno = ext4fs_get_new_blk_no();
                                if (ti_child_blockno == -1) {
                                        printf("no block left assign\n");
-                                       goto fail;
+                                       goto fail1;
                                }
                                ti_child_buff = zalloc(fs->blksz);
                                if (!ti_child_buff)
-                                       goto fail;
+                                       goto fail1;
 
                                ti_cbuff_start_addr = ti_child_buff;
                                *ti_parent_buff = ti_child_blockno;
@@ -1341,7 +1341,8 @@ static void alloc_triple_indirect_block(struct ext2_inode *file_inode,
                                            ext4fs_get_new_blk_no();
                                        if (actual_block_no == -1) {
                                                printf("no block left\n");
-                                               goto fail;
+                                               free(ti_cbuff_start_addr);
+                                               goto fail1;
                                        }
                                        *ti_child_buff = actual_block_no;
                                        debug("TIAB %ld: %u\n", actual_block_no,
@@ -1373,7 +1374,11 @@ static void alloc_triple_indirect_block(struct ext2_inode *file_inode,
                put_ext4(((uint64_t) ((uint64_t)ti_gp_blockno * (uint64_t)fs->blksz)),
                         ti_gp_buff_start_addr, fs->blksz);
                file_inode->b.blocks.triple_indir_block = ti_gp_blockno;
+               free(ti_gp_buff_start_addr);
+               return;
        }
+fail1:
+       free(ti_pbuff_start_addr);
 fail:
        free(ti_gp_buff_start_addr);
 }
index f939bc5deed2770e84c98dcfd4bc8fe056070655..472a63e8bb0af7fb47f9467b40a781d1744a1ecd 100644 (file)
@@ -51,8 +51,8 @@ static int disk_read(__u32 block, __u32 nr_blocks, void *buf)
        if (!cur_dev || !cur_dev->block_read)
                return -1;
 
-       ret = cur_dev->block_read(cur_dev->dev,
-                                 cur_part_info.start + block, nr_blocks, buf);
+       ret = cur_dev->block_read(cur_dev, cur_part_info.start + block,
+                                 nr_blocks, buf);
 
        if (nr_blocks && ret == 0)
                return -1;
index af828d07bd0a7377b3a783550756ff9242e1a08a..5ed324ce1a022241a9a43c1a257f7f6ab11279d3 100644 (file)
@@ -41,8 +41,7 @@ static int disk_write(__u32 block, __u32 nr_blocks, void *buf)
                return -1;
        }
 
-       ret = cur_dev->block_write(cur_dev->dev,
-                                  cur_part_info.start + block,
+       ret = cur_dev->block_write(cur_dev, cur_part_info.start + block,
                                   nr_blocks, buf);
        if (nr_blocks && ret == 0)
                return -1;
index 68255458d5101a9cd302563bd6b97352d8aa2ea2..7b24d6aa715c275b107b2c54eb5318fcd45aa517 100644 (file)
@@ -59,9 +59,11 @@ int reiserfs_devread (int sector, int byte_offset, int byte_len, char *buf)
 
        if (byte_offset != 0) {
                /* read first part which isn't aligned with start of sector */
-               if (reiserfs_block_dev_desc->block_read(reiserfs_block_dev_desc->dev,
-                   part_info->start + sector, 1,
-                   (unsigned long *)sec_buf) != 1) {
+               if (reiserfs_block_dev_desc->block_read(reiserfs_block_dev_desc,
+                                                       part_info->start +
+                                                               sector,
+                                                       1, (void *)sec_buf)
+                   != 1) {
                        printf (" ** reiserfs_devread() read error\n");
                        return 0;
                }
@@ -73,9 +75,11 @@ int reiserfs_devread (int sector, int byte_offset, int byte_len, char *buf)
 
        /* read sector aligned part */
        block_len = byte_len & ~(SECTOR_SIZE-1);
-       if (reiserfs_block_dev_desc->block_read(reiserfs_block_dev_desc->dev,
-           part_info->start + sector, block_len/SECTOR_SIZE,
-           (unsigned long *)buf) != block_len/SECTOR_SIZE) {
+       if (reiserfs_block_dev_desc->block_read(reiserfs_block_dev_desc,
+                                               part_info->start + sector,
+                                               block_len / SECTOR_SIZE,
+                                               (void *)buf)
+           != block_len/SECTOR_SIZE) {
                printf (" ** reiserfs_devread() read error - block\n");
                return 0;
        }
@@ -85,9 +89,11 @@ int reiserfs_devread (int sector, int byte_offset, int byte_len, char *buf)
 
        if ( byte_len != 0 ) {
                /* read rest of data which are not in whole sector */
-               if (reiserfs_block_dev_desc->block_read(reiserfs_block_dev_desc->dev,
-                   part_info->start + sector, 1,
-                   (unsigned long *)sec_buf) != 1) {
+               if (reiserfs_block_dev_desc->block_read(reiserfs_block_dev_desc,
+                                                       part_info->start +
+                                                           sector,
+                                                       1, (void *)sec_buf)
+                   != 1) {
                        printf (" ** reiserfs_devread() read error - last part\n");
                        return 0;
                }
index 3a1fa5685afe0540b9e111971c4285d12389cda1..67d12652b01e27a5f94b3fc4f62a079baf0e61c1 100644 (file)
@@ -55,9 +55,10 @@ int zfs_devread(int sector, int byte_offset, int byte_len, char *buf)
 
        if (byte_offset != 0) {
                /* read first part which isn't aligned with start of sector */
-               if (zfs_block_dev_desc->block_read(zfs_block_dev_desc->dev,
-                       part_info->start + sector, 1,
-                       (unsigned long *)sec_buf) != 1) {
+               if (zfs_block_dev_desc->block_read(zfs_block_dev_desc,
+                                                  part_info->start + sector, 1,
+                                                  (void *)sec_buf)
+                   != 1) {
                        printf(" ** zfs_devread() read error **\n");
                        return 1;
                }
@@ -78,16 +79,18 @@ int zfs_devread(int sector, int byte_offset, int byte_len, char *buf)
                u8 p[SECTOR_SIZE];
 
                block_len = SECTOR_SIZE;
-               zfs_block_dev_desc->block_read(zfs_block_dev_desc->dev,
-                       part_info->start + sector,
-                       1, (unsigned long *)p);
+               zfs_block_dev_desc->block_read(zfs_block_dev_desc,
+                                              part_info->start + sector,
+                                              1, (void *)p);
                memcpy(buf, p, byte_len);
                return 0;
        }
 
-       if (zfs_block_dev_desc->block_read(zfs_block_dev_desc->dev,
-               part_info->start + sector, block_len / SECTOR_SIZE,
-               (unsigned long *) buf) != block_len / SECTOR_SIZE) {
+       if (zfs_block_dev_desc->block_read(zfs_block_dev_desc,
+                                          part_info->start + sector,
+                                          block_len / SECTOR_SIZE,
+                                          (void *)buf)
+           != block_len / SECTOR_SIZE) {
                printf(" ** zfs_devread() read error - block\n");
                return 1;
        }
@@ -99,10 +102,9 @@ int zfs_devread(int sector, int byte_offset, int byte_len, char *buf)
 
        if (byte_len != 0) {
                /* read rest of data which are not in whole sector */
-               if (zfs_block_dev_desc->
-                       block_read(zfs_block_dev_desc->dev,
-                                          part_info->start + sector, 1,
-                                          (unsigned long *) sec_buf) != 1) {
+               if (zfs_block_dev_desc->block_read(zfs_block_dev_desc,
+                                                  part_info->start + sector,
+                                                  1, (void *)sec_buf) != 1) {
                        printf(" ** zfs_devread() read error - last part\n");
                        return 1;
                }
index 2ae9b6c2e6e582eef50e6d115ed66b65ea9fe053..0524c0beb091051343c3384fc7131f7431c7160c 100644 (file)
@@ -110,6 +110,7 @@ extern int common_diskboot(cmd_tbl_t *cmdtp, const char *intf, int argc,
                           char *const argv[]);
 
 extern int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
+extern int do_poweroff(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
 
 /*
  * Error codes that commands return to cmd_process(). We use the standard 0
index 75c78d5ac2f77cfa03894d3841dd5726b1f8a08a..7bed0cc0d120e5f31a51cc5af41d9195cc818621 100644 (file)
@@ -224,32 +224,26 @@ void board_init_f(ulong);
 void board_init_r(gd_t *, ulong) __attribute__ ((noreturn));
 
 /**
- * board_init_f_mem() - Allocate global data and set stack position
+ * ulong board_init_f_alloc_reserve - allocate reserved area
  *
  * This function is called by each architecture very early in the start-up
- * code to set up the environment for board_init_f(). It allocates space for
- * global_data (see include/asm-generic/global_data.h) and places the stack
- * below this.
+ * code to allow the C runtime to reserve space on the stack for writable
+ * 'globals' such as GD and the malloc arena.
  *
- * This function requires a stack[1] Normally this is at @top. The function
- * starts allocating space from 64 bytes below @top. First it creates space
- * for global_data. Then it calls arch_setup_gd() which sets gd to point to
- * the global_data space and can reserve additional bytes of space if
- * required). Finally it allocates early malloc() memory
- * (CONFIG_SYS_MALLOC_F_LEN). The new top of the stack is just below this,
- * and it returned by this function.
+ * @top:       top of the reserve area, growing down.
+ * @return:    bottom of reserved area
+ */
+ulong board_init_f_alloc_reserve(ulong top);
+
+/**
+ * board_init_f_init_reserve - initialize the reserved area(s)
  *
- * [1] Strictly speaking it would be possible to implement this function
- * in C on many archs such that it does not require a stack. However this
- * does not seem hugely important as only 64 byte are wasted. The 64 bytes
- * are used to handle the calling standard which generally requires pushing
- * addresses or registers onto the stack. We should be able to get away with
- * less if this becomes important.
+ * This function is called once the C runtime has allocated the reserved
+ * area on the stack. It must initialize the GD at the base of that area.
  *
- * @top:       Top of available memory, also normally the top of the stack
- * @return:    New stack location
+ * @base:      top from which reservation was done
  */
-ulong board_init_f_mem(ulong top);
+void board_init_f_init_reserve(ulong base);
 
 /**
  * arch_setup_gd() - Set up the global_data pointer
index 6e299f69ae48a82ea770c077597ada36397476c0..3b198ae3ced6820b9c744cf9d948cc46d024fbaa 100644 (file)
@@ -29,7 +29,6 @@
 #endif
 
 #undef CONFIG_DM_WARN
-#undef CONFIG_DM_SEQ_ALIAS
 #undef CONFIG_DM_STDIO
 
 #endif /* CONFIG_SPL_BUILD */
index c51db8c5c33788bcf6277c83ae9b464b109282ab..cf6a6063b5e3ec899b5fa88cfc11be75b7afe5c8 100644 (file)
 
 #include <configs/ti_am335x_common.h>
 
-/* Don't override the distro default bootdelay */
-#undef CONFIG_BOOTDELAY
-#include <config_distro_defaults.h>
-
 #ifndef CONFIG_SPL_BUILD
 #ifndef CONFIG_FIT
 # define CONFIG_FIT
index d89e661b6b5a131f513e502eec67cda602d0a2b6..99d91486113f4495595509ec77279725788215e7 100644 (file)
@@ -33,7 +33,7 @@
 #define CONFIG_SYS_MALLOC_LEN          SZ_1M
 #define CONFIG_SYS_SDRAM_BASE          EMC_DYCS0_BASE
 #define CONFIG_SYS_SDRAM_SIZE          SZ_64M
-#define CONFIG_SYS_TEXT_BASE           0x83FA0000
+#define CONFIG_SYS_TEXT_BASE           0x83F00000
 #define CONFIG_SYS_MEMTEST_START       (CONFIG_SYS_SDRAM_BASE + SZ_32K)
 #define CONFIG_SYS_MEMTEST_END         (CONFIG_SYS_TEXT_BASE - SZ_1M)
 
 #define CONFIG_SYS_LPC32XX_UART                5   /* UART5 */
 #define CONFIG_BAUDRATE                        115200
 
+/*
+ * DMA
+ */
+#if !defined(CONFIG_SPL_BUILD)
+#define CONFIG_DMA_LPC32XX
+#endif
+
 /*
  * I2C
  */
 #define CONFIG_SYS_NAND_PAGE_SIZE              NAND_LARGE_BLOCK_PAGE_SIZE
 #define CONFIG_SYS_NAND_USE_FLASH_BBT
 
+#define CONFIG_CMD_JFFS2
 #define CONFIG_CMD_NAND
 
+/*
+ * USB
+ */
+#define CONFIG_USB_OHCI_LPC32XX
+#define CONFIG_USB_ISP1301_I2C_ADDR            0x2d
+#define CONFIG_USB_STORAGE
+#define CONFIG_CMD_FAT
+#define CONFIG_CMD_USB
+
 /*
  * U-Boot General Configurations
  */
index 08046b5e995dd62a4712e8eafe7898a138c0b18f..a995415432cf69021f0f8b5885d620ea42b06fd5 100644 (file)
  */
 
 #define CONFIG_PARTITION_UUIDS
-#define CONFIG_DOS_PARTITION
-#define CONFIG_EFI_PARTITION
-
 #define CONFIG_CMD_PART
 
-/*
- * Filesystems
- */
-
-#define CONFIG_CMD_FS_GENERIC
-#define CONFIG_CMD_EXT2
-#define CONFIG_CMD_EXT4
-#define CONFIG_CMD_FAT
-
 /*
  * SPL
  */
 
 #define CONFIG_EXTRA_ENV_SETTINGS \
        "kernel_addr_r=0x82000000\0" \
+       "loadaddr=0x82000000\0" \
+       "fdt_addr_r=0x88000000\0" \
+       "fdtaddr=0x88000000\0" \
+       "ramdisk_addr_r=0x88080000\0" \
+       "pxefile_addr_r=0x80100000\0" \
+       "scriptaddr=0x80000000\0" \
+       "bootm_size=0x10000000\0" \
        "boot_mmc_dev=0\0" \
        "kernel_mmc_part=3\0" \
        "recovery_mmc_part=4\0" \
+       "fdtfile=omap3-sniper.dtb\0" \
+       "bootfile=/boot/extlinux/extlinux.conf\0" \
        "bootargs=console=ttyO2 vram=5M,0x9FA00000 omapfb.vram=0:5M\0"
 
 /*
- * ATAGs / Device Tree
+ * ATAGs
  */
 
-#define CONFIG_OF_LIBFDT
 #define CONFIG_SETUP_MEMORY_TAGS
 #define CONFIG_CMDLINE_TAG
 #define CONFIG_INITRD_TAG
  */
 
 #define CONFIG_SYS_LOAD_ADDR   0x82000000
-#define CONFIG_BOOTDELAY       1
 
 #define CONFIG_ANDROID_BOOT_IMAGE
 
  */
 
 #include <config_defaults.h>
+#include <config_distro_defaults.h>
 
 #endif
index a09e906a6be944c7f14fce511b637c8dec3de10f..8de0ab90469d6e35952cefef8fb59cea01affb09 100644 (file)
@@ -370,7 +370,6 @@ unsigned int cm_get_qspi_controller_clk_hz(void);
 
 /* SPL QSPI boot support */
 #ifdef CONFIG_SPL_SPI_SUPPORT
-#define CONFIG_DM_SEQ_ALIAS            1
 #define CONFIG_SPL_SPI_FLASH_SUPPORT
 #define CONFIG_SPL_SPI_LOAD
 #define CONFIG_SYS_SPI_U_BOOT_OFFS     0x40000
index 2087eb194cf6423fa1600134c089ffc3799ab8f2..199612be84bcb390ee2b950e630ca9fa5dc643cc 100644 (file)
 #endif
 
 #include <config_distro_defaults.h>
+#define CONFIG_CMD_EXT4_WRITE
 
 #endif /* __CONFIG_TI_ARMV7_COMMON_H__ */
index 08130ebd1b6cbd8b44befabaaac58519b5972930..8b6c0658e85e9c5ffc2e756f70a10e5a64c8732e 100644 (file)
 /*
  * Environment setup
  */
+#define BOOTENV_DEV_LEGACY_MMC(devtypeu, devtypel, instance) \
+       "bootcmd_" #devtypel #instance "=" \
+       "setenv mmcdev " #instance"; "\
+       "setenv bootpart " #instance":2 ; "\
+       "run mmcboot\0"
+
+#define BOOTENV_DEV_NAME_LEGACY_MMC(devtypeu, devtypel, instance) \
+       #devtypel #instance " "
+
+#define BOOTENV_DEV_NAME_NAND(devtypeu, devtypel, instance) \
+       #devtypel #instance " "
+
+#define BOOT_TARGET_DEVICES(func) \
+       func(MMC, mmc, 0) \
+       func(LEGACY_MMC, legacy_mmc, 0) \
+       func(MMC, mmc, 1) \
+       func(LEGACY_MMC, legacy_mmc, 1) \
+       func(PXE, pxe, na) \
+       func(DHCP, dhcp, na)
+
+#define CONFIG_BOOTCOMMAND \
+       "run findfdt; " \
+       "run distro_bootcmd"
+
+#include <config_distro_bootcmd.h>
+
 #define CONFIG_EXTRA_ENV_SETTINGS \
        DEFAULT_LINUX_BOOT_ENV \
        DEFAULT_MMC_TI_ARGS \
                "if test $fdtfile = undefined; then " \
                        "echo WARNING: Could not determine device tree to use; fi; \0" \
        "loadfdt=load mmc ${bootpart} ${fdtaddr} ${bootdir}/${fdtfile}\0" \
-
-#define CONFIG_BOOTCOMMAND \
-       "run findfdt; " \
-       "mmc dev ${mmcdev}; if mmc rescan; then " \
-               "echo SD/MMC found on device ${mmcdev};" \
-               "if run loadbootscript; then " \
-                       "run bootscript; " \
-               "else " \
-                       "if run loadbootenv; then " \
-                               "run importbootenv; " \
-                       "fi;" \
-                       "if test -n ${uenvcmd}; then " \
-                               "echo Running uenvcmd ...;" \
-                               "run uenvcmd;" \
-                       "fi;" \
-               "fi;" \
-               "if run loadimage; then " \
-                       "run loadfdt;" \
-                       "run mmcboot; " \
-               "fi; " \
-               "if run loaduimage; then " \
-                       "run uimageboot;" \
-               "fi; " \
-       "fi"
+       BOOTENV
 
 /*
  * Defines for SPL
diff --git a/include/dm/platform_data/lpc32xx_hsuart.h b/include/dm/platform_data/lpc32xx_hsuart.h
new file mode 100644 (file)
index 0000000..fd191b5
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * Copyright (c) 2015 Vladimir Zapolskiy <vz@mleia.com>
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef _LPC32XX_HSUART_PLAT_H
+#define _LPC32XX_HSUART_PLAT_H
+
+/**
+ * struct lpc32xx_hsuart_platdata - NXP LPC32xx HSUART platform data
+ *
+ * @base:               Base register address
+ */
+struct lpc32xx_hsuart_platdata {
+       unsigned long base;
+};
+
+#endif
index e6d0f1db92ef27a1a39c554611b9bb0081429ace..d81433772fc83e444a91111bf2ec9dd313dddaf6 100644 (file)
@@ -114,21 +114,6 @@ int hash_command(const char *algo_name, int flags, cmd_tbl_t *cmdtp, int flag,
 int hash_block(const char *algo_name, const void *data, unsigned int len,
               uint8_t *output, int *output_size);
 
-/**
- * hash_show() - Print out a hash algorithm and value
- *
- * You will get a message like this (without a newline at the end):
- *
- * "sha1 for 9eb3337c ... 9eb3338f ==> 7942ef1df479fd3130f716eb9613d107dab7e257"
- *
- * @algo:              Algorithm used for hash
- * @addr:              Address of data that was hashed
- * @len:               Length of data that was hashed
- * @output:            Hash value to display
- */
-void hash_show(struct hash_algo *algo, ulong addr, ulong len,
-              uint8_t *output);
-
 #endif /* !USE_HOSTCC */
 
 /**
index f9b43cb23a657828e281646e6c09dc5ebc82373a..f9357bee76220d9066ace1f697040e43da810e51 100644 (file)
@@ -41,8 +41,10 @@ typedef ulong lbaint_t;
  */
 
 void ide_init(void);
-ulong ide_read(int device, lbaint_t blknr, lbaint_t blkcnt, void *buffer);
-ulong ide_write(int device, lbaint_t blknr, lbaint_t blkcnt,
+typedef struct block_dev_desc block_dev_desc_t;
+ulong ide_read(block_dev_desc_t *block_dev, lbaint_t blknr, lbaint_t blkcnt,
+              void *buffer);
+ulong ide_write(block_dev_desc_t *block_dev, lbaint_t blknr, lbaint_t blkcnt,
                const void *buffer);
 
 #ifdef CONFIG_IDE_PREINIT
index 9254b716b959785c7e17c128b2e78b78aada14c5..465daeb0852a4f1168bb09f2603bea8afec3cd28 100644 (file)
@@ -364,7 +364,6 @@ struct mmc {
        u8 part_attr;
        u8 wr_rel_set;
        char part_config;
-       char part_num;
        uint tran_speed;
        uint read_bl_len;
        uint write_bl_len;
index ebed29ad577e898aecfefcfad784510f7ff6ea28..ac44d614ca335e390d801e3be50aaac6acccac71 100644 (file)
@@ -181,8 +181,7 @@ int eth_unregister(struct eth_device *dev);/* Remove network device */
 
 extern struct eth_device *eth_current;
 
-static inline __attribute__((always_inline))
-struct eth_device *eth_get_dev(void)
+static __always_inline struct eth_device *eth_get_dev(void)
 {
        return eth_current;
 }
@@ -200,14 +199,14 @@ static inline unsigned char *eth_get_ethaddr(void)
 /* Used only when NetConsole is enabled */
 int eth_is_active(struct eth_device *dev); /* Test device for active state */
 /* Set active state */
-static inline __attribute__((always_inline)) int eth_init_state_only(void)
+static __always_inline int eth_init_state_only(void)
 {
        eth_get_dev()->state = ETH_STATE_ACTIVE;
 
        return 0;
 }
 /* Set passive state */
-static inline __attribute__((always_inline)) void eth_halt_state_only(void)
+static __always_inline void eth_halt_state_only(void)
 {
        eth_get_dev()->state = ETH_STATE_PASSIVE;
 }
@@ -657,7 +656,7 @@ int nc_input_packet(uchar *pkt, struct in_addr src_ip, unsigned dest_port,
        unsigned src_port, unsigned len);
 #endif
 
-static inline __attribute__((always_inline)) int eth_is_on_demand_init(void)
+static __always_inline int eth_is_on_demand_init(void)
 {
 #ifdef CONFIG_NETCONSOLE
        extern enum proto_t net_loop_last_protocol;
index 720a867783c41f89b9d1fa6d22cdca56ac9d1c1c..4d00e220e4c8867c6312044c05a497ec77aaf262 100644 (file)
 #include <ide.h>
 #include <common.h>
 
-typedef struct block_dev_desc {
+typedef struct block_dev_desc block_dev_desc_t;
+
+struct block_dev_desc {
        int             if_type;        /* type of the interface */
        int             dev;            /* device number */
        unsigned char   part_type;      /* partition type */
        unsigned char   target;         /* target SCSI ID */
        unsigned char   lun;            /* target LUN */
+       unsigned char   hwpart;         /* HW partition, e.g. for eMMC */
        unsigned char   type;           /* device type */
        unsigned char   removable;      /* removable device */
 #ifdef CONFIG_LBA48
@@ -27,19 +30,19 @@ typedef struct block_dev_desc {
        char            vendor [40+1];  /* IDE model, SCSI Vendor */
        char            product[20+1];  /* IDE Serial no, SCSI product */
        char            revision[8+1];  /* firmware revision */
-       unsigned long   (*block_read)(int dev,
+       unsigned long   (*block_read)(block_dev_desc_t *block_dev,
                                      lbaint_t start,
                                      lbaint_t blkcnt,
                                      void *buffer);
-       unsigned long   (*block_write)(int dev,
+       unsigned long   (*block_write)(block_dev_desc_t *block_dev,
                                       lbaint_t start,
                                       lbaint_t blkcnt,
                                       const void *buffer);
-       unsigned long   (*block_erase)(int dev,
+       unsigned long   (*block_erase)(block_dev_desc_t *block_dev,
                                       lbaint_t start,
                                       lbaint_t blkcnt);
        void            *priv;          /* driver private struct pointer */
-}block_dev_desc_t;
+};
 
 #define BLOCK_CNT(size, block_dev_desc) (PAD_COUNT(size, block_dev_desc->blksz))
 #define PAD_TO_BLOCKSIZE(size, block_dev_desc) \
index 69b80cd1a367a602d97e5efb16f67777c15caa20..5804b70c354d571c3c3bce8fdbd8f560ea088b8e 100644 (file)
@@ -23,12 +23,10 @@ struct ums {
        unsigned int start_sector;
        unsigned int num_sectors;
        const char *name;
-       block_dev_desc_t *block_dev;
+       block_dev_desc_t block_dev;
 };
 
-extern struct ums *ums;
-
-int fsg_init(struct ums *);
+int fsg_init(struct ums *ums_devs, int count);
 void fsg_cleanup(void);
 int fsg_main_thread(void *);
 int fsg_add(struct usb_configuration *c);
index bdd85c4c17526eadc9d8303225f3629779763f4b..d86aa87f688477219a16550f69ba6c3cdb1cebba 100644 (file)
@@ -231,8 +231,7 @@ int gzwrite(unsigned char *src, int len,
                        gzwrite_progress(iteration++,
                                         totalfilled,
                                         szexpected);
-                       blocks_written = dev->block_write(dev->dev,
-                                                         outblock,
+                       blocks_written = dev->block_write(dev, outblock,
                                                          writeblocks,
                                                          writebuf);
                        outblock += blocks_written;
index cbc7899ff971ef78770039a80db62c4ae23cf654..3a2e52b2b57d32f5142f8e261d7f0df83f00bca6 100644 (file)
@@ -50,7 +50,7 @@ static int dm_test_usb_flash(struct unit_test_state *uts)
        /* Read a few blocks and look for the string we expect */
        ut_asserteq(512, dev_desc->blksz);
        memset(cmp, '\0', sizeof(cmp));
-       ut_asserteq(2, dev_desc->block_read(dev_desc->dev, 0, 2, cmp));
+       ut_asserteq(2, dev_desc->block_read(dev_desc, 0, 2, cmp));
        ut_assertok(strcmp(cmp, "this is a test"));
 
        return 0;
index fc41c04c15e66c14e2a0272be39fe8211bc1a069..043e5d0c0e49f1eabe882c92c991effc82b5a580 100755 (executable)
@@ -100,7 +100,7 @@ function compile_sandbox() {
 # We save time by not deleting and recreating the file system images
 function prepare_env() {
        rm -f ${MD5_FILE}.* ${OUT}.*
-       mkdir ${OUT_DIR}
+       mkdir -p ${OUT_DIR}
 }
 
 # 1st parameter is the name of the image file to be created
@@ -115,11 +115,23 @@ function create_image() {
        fi
        if [ ! -f "$1" ]; then
                fallocate -l 3G "$1" &> /dev/null
+               if [ $? -ne 0 ]; then
+                       echo fallocate failed - using dd instead
+                       dd if=/dev/zero of=$1 bs=1024 count=$((3 * 1024 * 1024))
+                       if [ $? -ne 0 ]; then
+                               echo Could not create empty disk image
+                               exit $?
+                       fi
+               fi
                mkfs -t "$2" $MKFS_OPTION "$1" &> /dev/null
                if [ $? -ne 0 -a "$2" = "fat" ]; then
                        # If we fail and we did fat, try vfat.
                        mkfs -t vfat $MKFS_OPTION "$1" &> /dev/null
                fi
+               if [ $? -ne 0 ]; then
+                       echo Could not create filesystem
+                       exit $?
+               fi
        fi
 }