Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 360375
b: refs/heads/master
c: e66b431
h: refs/heads/master
i:
  360373: 11bb650
  360371: 420cb2c
  360367: de2204e
v: v3
  • Loading branch information
Josh Wu authored and Artem Bityutskiy committed Feb 12, 2013
1 parent 7f53ac3 commit ad51e21
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 22 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: c0cf787f10c6ffb050e85c8ac9c0a8161cb06cb9
refs/heads/master: e66b4318f8fc0e12421de6287c557cdd92789010
52 changes: 31 additions & 21 deletions trunk/drivers/mtd/nand/atmel_nand.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ struct atmel_nand_host {
u8 pmecc_corr_cap;
u16 pmecc_sector_size;
u32 pmecc_lookup_table_offset;
u32 pmecc_lookup_table_offset_512;
u32 pmecc_lookup_table_offset_1024;

int pmecc_bytes_per_sector;
int pmecc_sector_number;
Expand Down Expand Up @@ -916,8 +918,16 @@ static int __init atmel_pmecc_nand_init_params(struct platform_device *pdev,
struct resource *regs, *regs_pmerr, *regs_rom;
int cap, sector_size, err_no;

if (host->pmecc_corr_cap == 0 || host->pmecc_sector_size == 0)
/* TODO: Should use ONFI ecc parameters. */
return -EINVAL;

cap = host->pmecc_corr_cap;
sector_size = host->pmecc_sector_size;
host->pmecc_lookup_table_offset = (sector_size == 512) ?
host->pmecc_lookup_table_offset_512 :
host->pmecc_lookup_table_offset_1024;

dev_info(host->dev, "Initialize PMECC params, cap: %d, sector: %d\n",
cap, sector_size);

Expand Down Expand Up @@ -1259,29 +1269,29 @@ static int atmel_of_init_port(struct atmel_nand_host *host,

/* use PMECC, get correction capability, sector size and lookup
* table offset.
* If correction bits and sector size are not specified, then find
* them from NAND ONFI parameters.
*/
if (of_property_read_u32(np, "atmel,pmecc-cap", &val) != 0) {
dev_err(host->dev, "Cannot decide PMECC Capability\n");
return -EINVAL;
} else if ((val != 2) && (val != 4) && (val != 8) && (val != 12) &&
(val != 24)) {
dev_err(host->dev,
"Unsupported PMECC correction capability: %d; should be 2, 4, 8, 12 or 24\n",
val);
return -EINVAL;
if (of_property_read_u32(np, "atmel,pmecc-cap", &val) == 0) {
if ((val != 2) && (val != 4) && (val != 8) && (val != 12) &&
(val != 24)) {
dev_err(host->dev,
"Unsupported PMECC correction capability: %d; should be 2, 4, 8, 12 or 24\n",
val);
return -EINVAL;
}
host->pmecc_corr_cap = (u8)val;
}
host->pmecc_corr_cap = (u8)val;

if (of_property_read_u32(np, "atmel,pmecc-sector-size", &val) != 0) {
dev_err(host->dev, "Cannot decide PMECC Sector Size\n");
return -EINVAL;
} else if ((val != 512) && (val != 1024)) {
dev_err(host->dev,
"Unsupported PMECC sector size: %d; should be 512 or 1024 bytes\n",
val);
return -EINVAL;
if (of_property_read_u32(np, "atmel,pmecc-sector-size", &val) == 0) {
if ((val != 512) && (val != 1024)) {
dev_err(host->dev,
"Unsupported PMECC sector size: %d; should be 512 or 1024 bytes\n",
val);
return -EINVAL;
}
host->pmecc_sector_size = (u16)val;
}
host->pmecc_sector_size = (u16)val;

if (of_property_read_u32_array(np, "atmel,pmecc-lookup-table-offset",
offset, 2) != 0) {
Expand All @@ -1292,8 +1302,8 @@ static int atmel_of_init_port(struct atmel_nand_host *host,
dev_err(host->dev, "Invalid PMECC lookup table offset\n");
return -EINVAL;
}
host->pmecc_lookup_table_offset =
(host->pmecc_sector_size == 512) ? offset[0] : offset[1];
host->pmecc_lookup_table_offset_512 = offset[0];
host->pmecc_lookup_table_offset_1024 = offset[1];

return 0;
}
Expand Down

0 comments on commit ad51e21

Please sign in to comment.