mtd: nand: omap_gpmc: rename struct nand_bch_priv to struct omap_nand_info
This patch renames 'struct nand_bch_priv' which currently holds private data only for BCH ECC schemes, into 'struct omap_nand_info' so that same can be used for all ECC schemes Signed-off-by: Pekon Gupta <pekon@ti.com> Reviewed-by: Stefan Roese <sr@denx.de>
This commit is contained in:
parent
d21e77ff84
commit
9233279f8e
@ -148,9 +148,9 @@ static int __maybe_unused omap_correct_data(struct mtd_info *mtd, uint8_t *dat,
|
||||
}
|
||||
|
||||
/*
|
||||
* Generic BCH interface
|
||||
* Driver configurations
|
||||
*/
|
||||
struct nand_bch_priv {
|
||||
struct omap_nand_info {
|
||||
struct bch_control *control;
|
||||
enum omap_ecc ecc_scheme;
|
||||
};
|
||||
@ -161,7 +161,7 @@ struct nand_bch_priv {
|
||||
* library).
|
||||
* When some users with other BCH strength will exists this have to change!
|
||||
*/
|
||||
static __maybe_unused struct nand_bch_priv bch_priv = {
|
||||
static __maybe_unused struct omap_nand_info omap_nand_info = {
|
||||
.control = NULL
|
||||
};
|
||||
|
||||
@ -191,7 +191,7 @@ __maybe_unused
|
||||
static void omap_enable_hwecc(struct mtd_info *mtd, int32_t mode)
|
||||
{
|
||||
struct nand_chip *nand = mtd->priv;
|
||||
struct nand_bch_priv *bch = nand->priv;
|
||||
struct omap_nand_info *info = nand->priv;
|
||||
unsigned int dev_width = (nand->options & NAND_BUSWIDTH_16) ? 1 : 0;
|
||||
unsigned int ecc_algo = 0;
|
||||
unsigned int bch_type = 0;
|
||||
@ -200,7 +200,7 @@ static void omap_enable_hwecc(struct mtd_info *mtd, int32_t mode)
|
||||
u32 ecc_config_val = 0;
|
||||
|
||||
/* configure GPMC for specific ecc-scheme */
|
||||
switch (bch->ecc_scheme) {
|
||||
switch (info->ecc_scheme) {
|
||||
case OMAP_ECC_HAM1_CODE_SW:
|
||||
return;
|
||||
case OMAP_ECC_HAM1_CODE_HW:
|
||||
@ -262,11 +262,11 @@ static int omap_calculate_ecc(struct mtd_info *mtd, const uint8_t *dat,
|
||||
uint8_t *ecc_code)
|
||||
{
|
||||
struct nand_chip *chip = mtd->priv;
|
||||
struct nand_bch_priv *bch = chip->priv;
|
||||
struct omap_nand_info *info = chip->priv;
|
||||
uint32_t *ptr, val = 0;
|
||||
int8_t i = 0, j;
|
||||
|
||||
switch (bch->ecc_scheme) {
|
||||
switch (info->ecc_scheme) {
|
||||
case OMAP_ECC_HAM1_CODE_HW:
|
||||
val = readl(&gpmc_cfg->ecc1_result);
|
||||
ecc_code[0] = val & 0xFF;
|
||||
@ -294,7 +294,7 @@ static int omap_calculate_ecc(struct mtd_info *mtd, const uint8_t *dat,
|
||||
return -EINVAL;
|
||||
}
|
||||
/* ECC scheme specific syndrome customizations */
|
||||
switch (bch->ecc_scheme) {
|
||||
switch (info->ecc_scheme) {
|
||||
case OMAP_ECC_HAM1_CODE_HW:
|
||||
break;
|
||||
#ifdef CONFIG_BCH
|
||||
@ -330,7 +330,7 @@ static int omap_correct_data_bch(struct mtd_info *mtd, uint8_t *dat,
|
||||
uint8_t *read_ecc, uint8_t *calc_ecc)
|
||||
{
|
||||
struct nand_chip *chip = mtd->priv;
|
||||
struct nand_bch_priv *bch = chip->priv;
|
||||
struct omap_nand_info *info = chip->priv;
|
||||
uint32_t eccbytes = chip->ecc.bytes;
|
||||
uint32_t error_count = 0, error_max;
|
||||
uint32_t error_loc[8];
|
||||
@ -360,7 +360,7 @@ static int omap_correct_data_bch(struct mtd_info *mtd, uint8_t *dat,
|
||||
* while reading ECC result we read it in big endian.
|
||||
* Hence while loading to ELM we have rotate to get the right endian.
|
||||
*/
|
||||
switch (bch->ecc_scheme) {
|
||||
switch (info->ecc_scheme) {
|
||||
case OMAP_ECC_BCH8_CODE_HW:
|
||||
bch_type = BCH_8_BIT;
|
||||
omap_reverse_list(calc_ecc, eccbytes - 1);
|
||||
@ -376,7 +376,7 @@ static int omap_correct_data_bch(struct mtd_info *mtd, uint8_t *dat,
|
||||
}
|
||||
/* correct bch error */
|
||||
for (count = 0; count < error_count; count++) {
|
||||
switch (bch->ecc_scheme) {
|
||||
switch (info->ecc_scheme) {
|
||||
case OMAP_ECC_BCH8_CODE_HW:
|
||||
/* 14th byte in ECC is reserved to match ROM layout */
|
||||
error_max = SECTOR_BYTES + (eccbytes - 1);
|
||||
@ -483,10 +483,10 @@ static int omap_correct_data_bch_sw(struct mtd_info *mtd, u_char *data,
|
||||
/* cannot correct more than 8 errors */
|
||||
unsigned int errloc[8];
|
||||
struct nand_chip *chip = mtd->priv;
|
||||
struct nand_bch_priv *chip_priv = chip->priv;
|
||||
struct bch_control *bch = chip_priv->control;
|
||||
struct omap_nand_info *info = chip->priv;
|
||||
|
||||
count = decode_bch(bch, NULL, 512, read_ecc, calc_ecc, NULL, errloc);
|
||||
count = decode_bch(info->control, NULL, 512, read_ecc, calc_ecc,
|
||||
NULL, errloc);
|
||||
if (count > 0) {
|
||||
/* correct errors */
|
||||
for (i = 0; i < count; i++) {
|
||||
@ -522,15 +522,11 @@ static int omap_correct_data_bch_sw(struct mtd_info *mtd, u_char *data,
|
||||
static void __maybe_unused omap_free_bch(struct mtd_info *mtd)
|
||||
{
|
||||
struct nand_chip *chip = mtd->priv;
|
||||
struct nand_bch_priv *chip_priv = chip->priv;
|
||||
struct bch_control *bch = NULL;
|
||||
struct omap_nand_info *info = chip->priv;
|
||||
|
||||
if (chip_priv)
|
||||
bch = chip_priv->control;
|
||||
|
||||
if (bch) {
|
||||
free_bch(bch);
|
||||
chip_priv->control = NULL;
|
||||
if (info->control) {
|
||||
free_bch(info->control);
|
||||
info->control = NULL;
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_BCH */
|
||||
@ -544,7 +540,7 @@ static void __maybe_unused omap_free_bch(struct mtd_info *mtd)
|
||||
*/
|
||||
static int omap_select_ecc_scheme(struct nand_chip *nand,
|
||||
enum omap_ecc ecc_scheme, unsigned int pagesize, unsigned int oobsize) {
|
||||
struct nand_bch_priv *bch = nand->priv;
|
||||
struct omap_nand_info *info = nand->priv;
|
||||
struct nand_ecclayout *ecclayout = &omap_ecclayout;
|
||||
int eccsteps = pagesize / SECTOR_BYTES;
|
||||
int i;
|
||||
@ -554,11 +550,10 @@ static int omap_select_ecc_scheme(struct nand_chip *nand,
|
||||
debug("nand: selected OMAP_ECC_HAM1_CODE_SW\n");
|
||||
/* For this ecc-scheme, ecc.bytes, ecc.layout, ... are
|
||||
* initialized in nand_scan_tail(), so just set ecc.mode */
|
||||
bch_priv.control = NULL;
|
||||
info->control = NULL;
|
||||
nand->ecc.mode = NAND_ECC_SOFT;
|
||||
nand->ecc.layout = NULL;
|
||||
nand->ecc.size = 0;
|
||||
bch->ecc_scheme = OMAP_ECC_HAM1_CODE_SW;
|
||||
break;
|
||||
|
||||
case OMAP_ECC_HAM1_CODE_HW:
|
||||
@ -569,7 +564,7 @@ static int omap_select_ecc_scheme(struct nand_chip *nand,
|
||||
(3 * eccsteps) + BADBLOCK_MARKER_LENGTH));
|
||||
return -EINVAL;
|
||||
}
|
||||
bch_priv.control = NULL;
|
||||
info->control = NULL;
|
||||
/* populate ecc specific fields */
|
||||
memset(&nand->ecc, 0, sizeof(struct nand_ecc_ctrl));
|
||||
nand->ecc.mode = NAND_ECC_HW;
|
||||
@ -590,7 +585,6 @@ static int omap_select_ecc_scheme(struct nand_chip *nand,
|
||||
ecclayout->oobfree[0].offset = i + BADBLOCK_MARKER_LENGTH;
|
||||
ecclayout->oobfree[0].length = oobsize - ecclayout->eccbytes -
|
||||
BADBLOCK_MARKER_LENGTH;
|
||||
bch->ecc_scheme = OMAP_ECC_HAM1_CODE_HW;
|
||||
break;
|
||||
|
||||
case OMAP_ECC_BCH8_CODE_HW_DETECTION_SW:
|
||||
@ -603,8 +597,8 @@ static int omap_select_ecc_scheme(struct nand_chip *nand,
|
||||
return -EINVAL;
|
||||
}
|
||||
/* check if BCH S/W library can be used for error detection */
|
||||
bch_priv.control = init_bch(13, 8, 0x201b);
|
||||
if (!bch_priv.control) {
|
||||
info->control = init_bch(13, 8, 0x201b);
|
||||
if (!info->control) {
|
||||
printf("nand: error: could not init_bch()\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
@ -631,7 +625,6 @@ static int omap_select_ecc_scheme(struct nand_chip *nand,
|
||||
ecclayout->oobfree[0].offset = i + BADBLOCK_MARKER_LENGTH;
|
||||
ecclayout->oobfree[0].length = oobsize - ecclayout->eccbytes -
|
||||
BADBLOCK_MARKER_LENGTH;
|
||||
bch->ecc_scheme = OMAP_ECC_BCH8_CODE_HW_DETECTION_SW;
|
||||
break;
|
||||
#else
|
||||
printf("nand: error: CONFIG_BCH required for ECC\n");
|
||||
@ -649,6 +642,7 @@ static int omap_select_ecc_scheme(struct nand_chip *nand,
|
||||
}
|
||||
/* intialize ELM for ECC error detection */
|
||||
elm_init();
|
||||
info->control = NULL;
|
||||
/* populate ecc specific fields */
|
||||
memset(&nand->ecc, 0, sizeof(struct nand_ecc_ctrl));
|
||||
nand->ecc.mode = NAND_ECC_HW;
|
||||
@ -666,7 +660,6 @@ static int omap_select_ecc_scheme(struct nand_chip *nand,
|
||||
ecclayout->oobfree[0].offset = i + BADBLOCK_MARKER_LENGTH;
|
||||
ecclayout->oobfree[0].length = oobsize - ecclayout->eccbytes -
|
||||
BADBLOCK_MARKER_LENGTH;
|
||||
bch->ecc_scheme = OMAP_ECC_BCH8_CODE_HW;
|
||||
break;
|
||||
#else
|
||||
printf("nand: error: CONFIG_NAND_OMAP_ELM required for ECC\n");
|
||||
@ -682,6 +675,7 @@ static int omap_select_ecc_scheme(struct nand_chip *nand,
|
||||
if (ecc_scheme != OMAP_ECC_HAM1_CODE_SW)
|
||||
nand->ecc.layout = ecclayout;
|
||||
|
||||
info->ecc_scheme = ecc_scheme;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -785,7 +779,7 @@ int board_nand_init(struct nand_chip *nand)
|
||||
|
||||
nand->IO_ADDR_R = (void __iomem *)&gpmc_cfg->cs[cs].nand_dat;
|
||||
nand->IO_ADDR_W = (void __iomem *)&gpmc_cfg->cs[cs].nand_cmd;
|
||||
nand->priv = &bch_priv;
|
||||
nand->priv = &omap_nand_info;
|
||||
nand->cmd_ctrl = omap_nand_hwcontrol;
|
||||
nand->options |= NAND_NO_PADDING | NAND_CACHEPRG;
|
||||
/* If we are 16 bit dev, our gpmc config tells us that */
|
||||
|
Loading…
Reference in New Issue
Block a user