colibri_imx6: fix video stdout in default environment
[oweals/u-boot.git] / tools / mxsboot.c
index 185b327920189926a6ecb4ce054b525554f9dafb..04d86f87a86e5050d2e66de92dedd49af1f1ee02 100644 (file)
@@ -1,10 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Freescale i.MX28 image generator
  *
  * Copyright (C) 2011 Marek Vasut <marek.vasut@gmail.com>
  * on behalf of DENX Software Engineering GmbH
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <fcntl.h>
@@ -271,23 +270,10 @@ static struct mx28_nand_fcb *mx28_nand_get_fcb(uint32_t size)
        fcb->ecc_block_0_size =         512;
        fcb->ecc_block_n_size =         512;
        fcb->metadata_bytes =           10;
-
-       if (nand_writesize == 2048) {
-               fcb->ecc_block_n_ecc_type =             4;
-               fcb->ecc_block_0_ecc_type =             4;
-       } else if (nand_writesize == 4096) {
-               if (nand_oobsize == 128) {
-                       fcb->ecc_block_n_ecc_type =     4;
-                       fcb->ecc_block_0_ecc_type =     4;
-               } else if (nand_oobsize == 218) {
-                       fcb->ecc_block_n_ecc_type =     8;
-                       fcb->ecc_block_0_ecc_type =     8;
-               } else if (nand_oobsize == 224) {
-                       fcb->ecc_block_n_ecc_type =     8;
-                       fcb->ecc_block_0_ecc_type =     8;
-               }
-       }
-
+       fcb->ecc_block_n_ecc_type = mx28_nand_get_ecc_strength(
+                                       nand_writesize, nand_oobsize) >> 1;
+       fcb->ecc_block_0_ecc_type = mx28_nand_get_ecc_strength(
+                                       nand_writesize, nand_oobsize) >> 1;
        if (fcb->ecc_block_n_ecc_type == 0) {
                printf("MX28 NAND: Unsupported NAND geometry\n");
                goto err;
@@ -569,15 +555,15 @@ static int mx28_create_sd_image(int infd, int outfd)
 
        cb = (struct mx28_sd_config_block *)buf;
 
-       cb->signature = 0x00112233;
-       cb->primary_boot_tag = 0x1;
-       cb->secondary_boot_tag = 0x1;
-       cb->num_copies = 1;
-       cb->drv_info[0].chip_num = 0x0;
-       cb->drv_info[0].drive_type = 0x0;
-       cb->drv_info[0].tag = 0x1;
-       cb->drv_info[0].first_sector_number = sd_sector + 4;
-       cb->drv_info[0].sector_count = (size - 4) / 512;
+       cb->signature = cpu_to_le32(0x00112233);
+       cb->primary_boot_tag = cpu_to_le32(0x1);
+       cb->secondary_boot_tag = cpu_to_le32(0x1);
+       cb->num_copies = cpu_to_le32(1);
+       cb->drv_info[0].chip_num = cpu_to_le32(0x0);
+       cb->drv_info[0].drive_type = cpu_to_le32(0x0);
+       cb->drv_info[0].tag = cpu_to_le32(0x1);
+       cb->drv_info[0].first_sector_number = cpu_to_le32(sd_sector + 4);
+       cb->drv_info[0].sector_count = cpu_to_le32((size - 4) / 512);
 
        wr_size = write(outfd, buf, size);
        if (wr_size != size) {