All of lore.kernel.org
 help / color / mirror / Atom feed
From: Otavio Salvador <otavio@ossystems.com.br>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 5/8] mxsboot: stop referring to i.MX28 as this ought to work for all i.MXS SoCs
Date: Fri, 11 May 2012 12:38:03 -0300	[thread overview]
Message-ID: <1336750686-29323-5-git-send-email-otavio@ossystems.com.br> (raw)
In-Reply-To: <1336750686-29323-1-git-send-email-otavio@ossystems.com.br>

Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
---
 tools/mxsboot.c |  110 +++++++++++++++++++++++++++----------------------------
 1 file changed, 55 insertions(+), 55 deletions(-)

diff --git a/tools/mxsboot.c b/tools/mxsboot.c
index 6c05aa4..9661a48 100644
--- a/tools/mxsboot.c
+++ b/tools/mxsboot.c
@@ -1,5 +1,5 @@
 /*
- * Freescale i.MX28 image generator
+ * Freescale i.MXS image generator
  *
  * Copyright (C) 2011 Marek Vasut <marek.vasut@gmail.com>
  * on behalf of DENX Software Engineering GmbH
@@ -60,13 +60,13 @@ uint32_t sd_sector = 2048;
  */
 #define	MAX_BOOTSTREAM_SIZE	(1 * 1024 * 1024)
 
-/* i.MX28 NAND controller-specific constants. DO NOT TWEAK! */
+/* i.MXS NAND controller-specific constants. DO NOT TWEAK! */
 #define	MXS_NAND_DMA_DESCRIPTOR_COUNT		4
 #define	MXS_NAND_CHUNK_DATA_CHUNK_SIZE		512
 #define	MXS_NAND_METADATA_SIZE			10
 #define	MXS_NAND_COMMAND_BUFFER_SIZE		32
 
-struct mx28_nand_fcb {
+struct mxs_nand_fcb {
 	uint32_t		checksum;
 	uint32_t		fingerprint;
 	uint32_t		version;
@@ -111,7 +111,7 @@ struct mx28_nand_fcb {
 	uint32_t		bb_marker_physical_offset;
 };
 
-struct mx28_nand_dbbt {
+struct mxs_nand_dbbt {
 	uint32_t		checksum;
 	uint32_t		fingerprint;
 	uint32_t		version;
@@ -119,13 +119,13 @@ struct mx28_nand_dbbt {
 	uint32_t		number_2k_pages_bb;
 };
 
-struct mx28_nand_bbt {
+struct mxs_nand_bbt {
 	uint32_t		nand;
 	uint32_t		number_bb;
 	uint32_t		badblock[510];
 };
 
-struct mx28_sd_drive_info {
+struct mxs_sd_drive_info {
 	uint32_t		chip_num;
 	uint32_t		drive_type;
 	uint32_t		tag;
@@ -133,20 +133,20 @@ struct mx28_sd_drive_info {
 	uint32_t		sector_count;
 };
 
-struct mx28_sd_config_block {
+struct mxs_sd_config_block {
 	uint32_t			signature;
 	uint32_t			primary_boot_tag;
 	uint32_t			secondary_boot_tag;
 	uint32_t			num_copies;
-	struct mx28_sd_drive_info	drv_info[1];
+	struct mxs_sd_drive_info	drv_info[1];
 };
 
-static inline uint32_t mx28_nand_ecc_size_in_bits(uint32_t ecc_strength)
+static inline uint32_t mxs_nand_ecc_size_in_bits(uint32_t ecc_strength)
 {
 	return ecc_strength * 13;
 }
 
-static inline uint32_t mx28_nand_get_ecc_strength(uint32_t page_data_size,
+static inline uint32_t mxs_nand_get_ecc_strength(uint32_t page_data_size,
 						uint32_t page_oob_size)
 {
 	if (page_data_size == 2048)
@@ -163,7 +163,7 @@ static inline uint32_t mx28_nand_get_ecc_strength(uint32_t page_data_size,
 	return 0;
 }
 
-static inline uint32_t mx28_nand_get_mark_offset(uint32_t page_data_size,
+static inline uint32_t mxs_nand_get_mark_offset(uint32_t page_data_size,
 						uint32_t ecc_strength)
 {
 	uint32_t chunk_data_size_in_bits;
@@ -174,7 +174,7 @@ static inline uint32_t mx28_nand_get_mark_offset(uint32_t page_data_size,
 	uint32_t block_mark_bit_offset;
 
 	chunk_data_size_in_bits = MXS_NAND_CHUNK_DATA_CHUNK_SIZE * 8;
-	chunk_ecc_size_in_bits  = mx28_nand_ecc_size_in_bits(ecc_strength);
+	chunk_ecc_size_in_bits  = mxs_nand_ecc_size_in_bits(ecc_strength);
 
 	chunk_total_size_in_bits =
 			chunk_data_size_in_bits + chunk_ecc_size_in_bits;
@@ -212,21 +212,21 @@ static inline uint32_t mx28_nand_get_mark_offset(uint32_t page_data_size,
 	return block_mark_bit_offset;
 }
 
-static inline uint32_t mx28_nand_mark_byte_offset(void)
+static inline uint32_t mxs_nand_mark_byte_offset(void)
 {
 	uint32_t ecc_strength;
-	ecc_strength = mx28_nand_get_ecc_strength(nand_writesize, nand_oobsize);
-	return mx28_nand_get_mark_offset(nand_writesize, ecc_strength) >> 3;
+	ecc_strength = mxs_nand_get_ecc_strength(nand_writesize, nand_oobsize);
+	return mxs_nand_get_mark_offset(nand_writesize, ecc_strength) >> 3;
 }
 
-static inline uint32_t mx28_nand_mark_bit_offset(void)
+static inline uint32_t mxs_nand_mark_bit_offset(void)
 {
 	uint32_t ecc_strength;
-	ecc_strength = mx28_nand_get_ecc_strength(nand_writesize, nand_oobsize);
-	return mx28_nand_get_mark_offset(nand_writesize, ecc_strength) & 0x7;
+	ecc_strength = mxs_nand_get_ecc_strength(nand_writesize, nand_oobsize);
+	return mxs_nand_get_mark_offset(nand_writesize, ecc_strength) & 0x7;
 }
 
-static uint32_t mx28_nand_block_csum(uint8_t *block, uint32_t size)
+static uint32_t mxs_nand_block_csum(uint8_t *block, uint32_t size)
 {
 	uint32_t csum = 0;
 	int i;
@@ -237,9 +237,9 @@ static uint32_t mx28_nand_block_csum(uint8_t *block, uint32_t size)
 	return csum ^ 0xffffffff;
 }
 
-static struct mx28_nand_fcb *mx28_nand_get_fcb(uint32_t size)
+static struct mxs_nand_fcb *mxs_nand_get_fcb(uint32_t size)
 {
-	struct mx28_nand_fcb *fcb;
+	struct mxs_nand_fcb *fcb;
 	uint32_t bcb_size_bytes;
 	uint32_t stride_size_bytes;
 	uint32_t bootstream_size_pages;
@@ -248,7 +248,7 @@ static struct mx28_nand_fcb *mx28_nand_get_fcb(uint32_t size)
 
 	fcb = malloc(nand_writesize);
 	if (!fcb) {
-		printf("MX28 NAND: Unable to allocate FCB\n");
+		printf("MXS NAND: Unable to allocate FCB\n");
 		return NULL;
 	}
 
@@ -289,15 +289,15 @@ static struct mx28_nand_fcb *mx28_nand_get_fcb(uint32_t size)
 	}
 
 	if (fcb->ecc_block_n_ecc_type == 0) {
-		printf("MX28 NAND: Unsupported NAND geometry\n");
+		printf("MXS NAND: Unsupported NAND geometry\n");
 		goto err;
 	}
 
 	fcb->boot_patch =			0;
 	fcb->patch_sectors =			0;
 
-	fcb->badblock_marker_byte =	mx28_nand_mark_byte_offset();
-	fcb->badblock_marker_start_bit = mx28_nand_mark_bit_offset();
+	fcb->badblock_marker_byte =	mxs_nand_mark_byte_offset();
+	fcb->badblock_marker_start_bit = mxs_nand_mark_bit_offset();
 	fcb->bb_marker_physical_offset = nand_writesize;
 
 	stride_size_bytes = STRIDE_PAGES * nand_writesize;
@@ -324,13 +324,13 @@ err:
 	return NULL;
 }
 
-static struct mx28_nand_dbbt *mx28_nand_get_dbbt(void)
+static struct mxs_nand_dbbt *mxs_nand_get_dbbt(void)
 {
-	struct mx28_nand_dbbt *dbbt;
+	struct mxs_nand_dbbt *dbbt;
 
 	dbbt = malloc(nand_writesize);
 	if (!dbbt) {
-		printf("MX28 NAND: Unable to allocate DBBT\n");
+		printf("MXS NAND: Unable to allocate DBBT\n");
 		return NULL;
 	}
 
@@ -342,7 +342,7 @@ static struct mx28_nand_dbbt *mx28_nand_get_dbbt(void)
 	return dbbt;
 }
 
-static inline uint8_t mx28_nand_parity_13_8(const uint8_t b)
+static inline uint8_t mxs_nand_parity_13_8(const uint8_t b)
 {
 	uint32_t parity = 0, tmp;
 
@@ -365,7 +365,7 @@ static inline uint8_t mx28_nand_parity_13_8(const uint8_t b)
 	return parity;
 }
 
-static uint8_t *mx28_nand_fcb_block(struct mx28_nand_fcb *fcb)
+static uint8_t *mxs_nand_fcb_block(struct mxs_nand_fcb *fcb)
 {
 	uint8_t *block;
 	uint8_t *ecc;
@@ -373,36 +373,36 @@ static uint8_t *mx28_nand_fcb_block(struct mx28_nand_fcb *fcb)
 
 	block = malloc(nand_writesize + nand_oobsize);
 	if (!block) {
-		printf("MX28 NAND: Unable to allocate FCB block\n");
+		printf("MXS NAND: Unable to allocate FCB block\n");
 		return NULL;
 	}
 
 	memset(block, 0, nand_writesize + nand_oobsize);
 
 	/* Update the FCB checksum */
-	fcb->checksum = mx28_nand_block_csum(((uint8_t *)fcb) + 4, 508);
+	fcb->checksum = mxs_nand_block_csum(((uint8_t *)fcb) + 4, 508);
 
-	/* Figure 12-11. in iMX28RM, rev. 1, says FCB is at offset 12 */
-	memcpy(block + 12, fcb, sizeof(struct mx28_nand_fcb));
+	/* Figure 12-11. in iMXSRM, rev. 1, says FCB is at offset 12 */
+	memcpy(block + 12, fcb, sizeof(struct mxs_nand_fcb));
 
 	/* ECC is at offset 12 + 512 */
 	ecc = block + 12 + 512;
 
 	/* Compute the ECC parity */
-	for (i = 0; i < sizeof(struct mx28_nand_fcb); i++)
-		ecc[i] = mx28_nand_parity_13_8(block[i + 12]);
+	for (i = 0; i < sizeof(struct mxs_nand_fcb); i++)
+		ecc[i] = mxs_nand_parity_13_8(block[i + 12]);
 
 	return block;
 }
 
-static int mx28_nand_write_fcb(struct mx28_nand_fcb *fcb, char *buf)
+static int mxs_nand_write_fcb(struct mxs_nand_fcb *fcb, char *buf)
 {
 	uint32_t offset;
 	uint8_t *fcbblock;
 	int ret = 0;
 	int i;
 
-	fcbblock = mx28_nand_fcb_block(fcb);
+	fcbblock = mxs_nand_fcb_block(fcb);
 	if (!fcbblock)
 		return -1;
 
@@ -415,20 +415,20 @@ static int mx28_nand_write_fcb(struct mx28_nand_fcb *fcb, char *buf)
 	return ret;
 }
 
-static int mx28_nand_write_dbbt(struct mx28_nand_dbbt *dbbt, char *buf)
+static int mxs_nand_write_dbbt(struct mxs_nand_dbbt *dbbt, char *buf)
 {
 	uint32_t offset;
 	int i = STRIDE_PAGES * STRIDE_COUNT;
 
 	for (; i < 2 * STRIDE_PAGES * STRIDE_COUNT; i += STRIDE_PAGES) {
 		offset = i * nand_writesize;
-		memcpy(buf + offset, dbbt, sizeof(struct mx28_nand_dbbt));
+		memcpy(buf + offset, dbbt, sizeof(struct mxs_nand_dbbt));
 	}
 
 	return 0;
 }
 
-static int mx28_nand_write_firmware(struct mx28_nand_fcb *fcb, int infd,
+static int mxs_nand_write_firmware(struct mxs_nand_fcb *fcb, int infd,
 					char *buf)
 {
 	int ret;
@@ -454,7 +454,7 @@ void usage(void)
 {
 	printf(
 		"Usage: mxsboot [ops] <type> <infile> <outfile>\n"
-		"Augment BootStream file with a proper header for i.MX28 boot\n"
+		"Augment BootStream file with a proper header for i.MXS boot\n"
 		"\n"
 		"  <type>	type of image:\n"
 		"                 \"nand\" for NAND image\n"
@@ -473,10 +473,10 @@ void usage(void)
 	);
 }
 
-static int mx28_create_nand_image(int infd, int outfd)
+static int mxs_create_nand_image(int infd, int outfd)
 {
-	struct mx28_nand_fcb *fcb;
-	struct mx28_nand_dbbt *dbbt;
+	struct mxs_nand_fcb *fcb;
+	struct mxs_nand_dbbt *dbbt;
 	int ret = -1;
 	char *buf;
 	int size;
@@ -492,31 +492,31 @@ static int mx28_create_nand_image(int infd, int outfd)
 
 	memset(buf, 0, size);
 
-	fcb = mx28_nand_get_fcb(MAX_BOOTSTREAM_SIZE);
+	fcb = mxs_nand_get_fcb(MAX_BOOTSTREAM_SIZE);
 	if (!fcb) {
 		printf("Unable to compile FCB\n");
 		goto err1;
 	}
 
-	dbbt = mx28_nand_get_dbbt();
+	dbbt = mxs_nand_get_dbbt();
 	if (!dbbt) {
 		printf("Unable to compile DBBT\n");
 		goto err2;
 	}
 
-	ret = mx28_nand_write_fcb(fcb, buf);
+	ret = mxs_nand_write_fcb(fcb, buf);
 	if (ret) {
 		printf("Unable to write FCB to buffer\n");
 		goto err3;
 	}
 
-	ret = mx28_nand_write_dbbt(dbbt, buf);
+	ret = mxs_nand_write_dbbt(dbbt, buf);
 	if (ret) {
 		printf("Unable to write DBBT to buffer\n");
 		goto err3;
 	}
 
-	ret = mx28_nand_write_firmware(fcb, infd, buf);
+	ret = mxs_nand_write_firmware(fcb, infd, buf);
 	if (ret) {
 		printf("Unable to write firmware to buffer\n");
 		goto err3;
@@ -540,14 +540,14 @@ err0:
 	return ret;
 }
 
-static int mx28_create_sd_image(int infd, int outfd)
+static int mxs_create_sd_image(int infd, int outfd)
 {
 	int ret = -1;
 	uint32_t *buf;
 	int size;
 	off_t fsize;
 	ssize_t wr_size;
-	struct mx28_sd_config_block *cb;
+	struct mxs_sd_config_block *cb;
 
 	fsize = lseek(infd, 0, SEEK_END);
 	lseek(infd, 0, SEEK_SET);
@@ -565,7 +565,7 @@ static int mx28_create_sd_image(int infd, int outfd)
 		goto err1;
 	}
 
-	cb = (struct mx28_sd_config_block *)buf;
+	cb = (struct mxs_sd_config_block *)buf;
 
 	cb->signature = 0x00112233;
 	cb->primary_boot_tag = 0x1;
@@ -675,9 +675,9 @@ int main(int argc, char **argv)
 	}
 
 	if (!strcmp(argv[offset], "sd"))
-		ret = mx28_create_sd_image(infd, outfd);
+		ret = mxs_create_sd_image(infd, outfd);
 	else if (!strcmp(argv[offset], "nand"))
-		ret = mx28_create_nand_image(infd, outfd);
+		ret = mxs_create_nand_image(infd, outfd);
 
 	close(outfd);
 err2:
-- 
1.7.10

  parent reply	other threads:[~2012-05-11 15:38 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-11 15:37 [U-Boot] [PATCH 1/8] MX28: Fix a typo in mx28_reg_8 macro Otavio Salvador
2012-05-11 15:38 ` [U-Boot] [PATCH 2/8] m28evk: use same notation to alloc the 128kB stack Otavio Salvador
2012-05-11 15:38 ` [U-Boot] [PATCH 3/8] m28evk: use "M28EVK U-Boot =>" as prompt Otavio Salvador
2012-05-11 15:38 ` [U-Boot] [PATCH 4/8] mx28evk: ensure command definition is in alphabetic order Otavio Salvador
2012-05-11 15:38 ` Otavio Salvador [this message]
2012-05-11 15:38 ` [U-Boot] [PATCH 6/8] mxs: reorganize source directory for easy sharing of code among i.MXS SoCs Otavio Salvador
2012-05-11 15:51   ` Otavio Salvador
2012-05-11 15:38 ` [U-Boot] [PATCH 7/8] mxs: prefix register acessor macros with 'mxs' prefix Otavio Salvador
2012-05-11 15:38 ` [U-Boot] [PATCH 8/8] MX28: rename regs-clkctrl.h to regs-clkctrl-mx28.h Otavio Salvador
2012-05-11 21:03 ` [U-Boot] [PATCH 1/8] MX28: Fix a typo in mx28_reg_8 macro Marek Vasut
2012-05-11 21:12   ` Otavio Salvador
2012-06-13  9:06 ` Stefano Babic

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1336750686-29323-5-git-send-email-otavio@ossystems.com.br \
    --to=otavio@ossystems.com.br \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.