File: atmel_pmecc_params.c

package info (click to toggle)
u-boot 2014.10%2Bdfsg1-5
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 86,340 kB
  • ctags: 382,377
  • sloc: ansic: 1,071,015; asm: 34,076; perl: 8,007; python: 6,290; makefile: 5,210; sh: 2,297; cpp: 1,826; php: 1,299; yacc: 604; lex: 363; sql: 71; tcl: 28; sed: 14; awk: 6
file content (51 lines) | stat: -rw-r--r-- 1,342 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
 * (C) Copyright 2014 Andreas Bießmann <andreas.devel@googlemail.com>
 *
 * SPDX-License-Identifier:	GPL-2.0+
 */

/*
 * This is a host tool for generating an appropriate string out of board
 * configuration. The string is required for correct generation of PMECC
 * header which in turn is required for NAND flash booting of Atmel AT91 style
 * hardware.
 *
 * See doc/README.atmel_pmecc for more information.
 */

#include <config.h>
#include <stdlib.h>

static int pmecc_get_ecc_bytes(int cap, int sector_size)
{
	int m = 12 + sector_size / 512;
	return (m * cap + 7) / 8;
}

int main(int argc, char *argv[])
{
	unsigned int use_pmecc = 0;
	unsigned int sector_per_page;
	unsigned int sector_size = CONFIG_PMECC_SECTOR_SIZE;
	unsigned int oob_size = CONFIG_SYS_NAND_OOBSIZE;
	unsigned int ecc_bits = CONFIG_PMECC_CAP;
	unsigned int ecc_offset;

#ifdef CONFIG_ATMEL_NAND_HW_PMECC
	use_pmecc = 1;
#endif

	sector_per_page = CONFIG_SYS_NAND_PAGE_SIZE / CONFIG_PMECC_SECTOR_SIZE;
	ecc_offset = oob_size -
		pmecc_get_ecc_bytes(ecc_bits, sector_size) * sector_per_page;

	printf("usePmecc=%d,", use_pmecc);
	printf("sectorPerPage=%d,", sector_per_page);
	printf("sectorSize=%d,", sector_size);
	printf("spareSize=%d,", oob_size);
	printf("eccBits=%d,", ecc_bits);
	printf("eccOffset=%d", ecc_offset);
	printf("\n");

	exit(EXIT_SUCCESS);
}