Commit 6bb747f3 authored by David Brownell's avatar David Brownell Committed by Kevin Hilman

nand: minor ecc cleanup (mostly)

Minor ECC cleanup for the DaVinci NAND driver:

 - Clarify Kconfig:  this HW_ECC is just the 1-bit flavor
 - Remove needless non-mainline NAND_ECC_HWx_y constants
 - Use BIT(n) in a few places for clarity

And remove pointless DRIVER_NAME define, correcting MODULE_ALIAS
so it could really trigger hotplugging.
Signed-off-by: default avatarDavid Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: default avatarKevin Hilman <khilman@deeprootsystems.com>
parent 9db0089a
......@@ -453,9 +453,11 @@ config MTD_NAND_DAVINCI
Support for NAND flash on Texas Instruments DaVinci SoC.
config NAND_FLASH_HW_ECC
bool "Hardware ECC Support on NAND Device for DaVinci"
bool "1-Bit Hardware ECC on NAND Device for DaVinci"
depends on MTD_NAND_DAVINCI
help
Support for Hardware ECC on NAND device for DaVinci.
Support the single bit Hardware ECC on NAND devices
for DaVinci. This uses three bytes of OOB data for
each 512 bytes of data.
endif # MTD_NAND
......@@ -78,14 +78,8 @@ static inline int mtd_has_cmdlinepart(void) { return 0; }
static inline int is_hw_ecc_1bit(void) { return 1; }
#else
static inline int is_hw_ecc_1bit(void) { return 0; }
#define NAND_ECC_HW3_256 100
#define NAND_ECC_HW3_512 101
#define NAND_ECC_HW6_512 102
#define NAND_ECC_HW8_512 103
#define NAND_ECC_HW12_2048 104
#endif
#define DRIVER_NAME "davinci_nand"
struct davinci_nand_info {
struct mtd_info mtd;
......@@ -179,7 +173,7 @@ static void nand_davinci_enable_hwecc_1bit(struct mtd_info *mtd, int mode)
/* Restart ECC hardware */
retval = davinci_nand_readl(info, NANDFCR_OFFSET);
retval |= (1 << 8);
retval |= BIT(8);
davinci_nand_writel(info, NANDFCR_OFFSET, retval);
}
......@@ -226,7 +220,7 @@ static int nand_davinci_correct_data_1bit(struct mtd_info *mtd, u_char *dat,
if ((((diff >> 12) ^ diff) & 0xfff) == 0xfff) {
/* Correctable error */
if ((diff >> (12 + 3)) < chip->ecc.size) {
dat[diff >> (12 + 3)] ^= (1 << ((diff >> 12) & 7));
dat[diff >> (12 + 3)] ^= BIT((diff >> 12) & 7);
return 1;
} else {
return -1;
......@@ -425,53 +419,6 @@ static int nand_davinci_dev_ready(struct mtd_info *mtd)
return davinci_nand_readl(info, NANDFSR_OFFSET) & NAND_BUSY_FLAG;
}
static void __init nand_davinci_set_eccsize(struct nand_chip *chip)
{
chip->ecc.size = 256;
if (!is_hw_ecc_1bit())
return;
switch (chip->ecc.mode) {
case NAND_ECC_HW12_2048:
chip->ecc.size = 2048;
break;
case NAND_ECC_HW3_512:
case NAND_ECC_HW6_512:
case NAND_ECC_HW8_512:
chip->ecc.size = 512;
break;
case NAND_ECC_HW3_256:
default:
/* do nothing */
break;
}
}
static void __init nand_davinci_set_eccbytes(struct nand_chip *chip)
{
chip->ecc.bytes = 3;
if (!is_hw_ecc_1bit())
return;
switch (chip->ecc.mode) {
case NAND_ECC_HW12_2048:
chip->ecc.bytes += 4;
case NAND_ECC_HW8_512:
chip->ecc.bytes += 2;
case NAND_ECC_HW6_512:
chip->ecc.bytes += 3;
case NAND_ECC_HW3_512:
case NAND_ECC_HW3_256:
default:
/* do nothing */
break;
}
}
static void __init nand_dm355evm_flash_init(struct davinci_nand_info *info)
{
u32 val, tmp;
......@@ -672,12 +619,14 @@ static int __init nand_davinci_probe(struct platform_device *pdev)
* fixed?): Linux seemed to limit ECC data to 32 bytes.
*/
if (is_hw_ecc_1bit()) {
info->chip.ecc.mode = NAND_ECC_HW3_512;
info->chip.ecc.mode = NAND_ECC_HW;
info->chip.ecc.calculate = nand_davinci_calculate_ecc_1bit;
info->chip.ecc.correct = nand_davinci_correct_data_1bit;
info->chip.ecc.hwctl = nand_davinci_enable_hwecc_1bit;
info->chip.ecc.correct = nand_davinci_correct_data_1bit;
info->chip.ecc.hwctl = nand_davinci_enable_hwecc_1bit;
info->chip.ecc.size = 512;
info->chip.ecc.bytes = 3;
} else {
info->chip.ecc.mode = NAND_ECC_SOFT;
info->chip.ecc.mode = NAND_ECC_SOFT;
}
info->clk = clk_get(&pdev->dev, "AEMIFCLK");
......@@ -693,10 +642,6 @@ static int __init nand_davinci_probe(struct platform_device *pdev)
goto err_clk_enable;
}
/* Set ECC size and bytes */
nand_davinci_set_eccsize(&info->chip);
nand_davinci_set_eccbytes(&info->chip);
/* FIXME these don't belong here ... */
if (machine_is_davinci_dm355_evm())
nand_dm355evm_flash_init(info);
......@@ -817,9 +762,10 @@ static int __exit nand_davinci_remove(struct platform_device *pdev)
static struct platform_driver nand_davinci_driver = {
.remove = __exit_p(nand_davinci_remove),
.driver = {
.name = DRIVER_NAME,
.name = "davinci_nand",
},
};
MODULE_ALIAS("platform:davinci_nand");
static int __init nand_davinci_init(void)
{
......@@ -833,7 +779,6 @@ static void __exit nand_davinci_exit(void)
}
module_exit(nand_davinci_exit);
MODULE_ALIAS(DRIVER_NAME);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Texas Instruments");
MODULE_DESCRIPTION("Davinci NAND flash driver");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment