From: Jamie Iles <jamie@jamieiles.com>
To: linux-mtd@lists.infradead.org
Cc: Jamie Iles <jamie@jamieiles.com>,
Artem Bityutskiy <dedekind1@gmail.com>,
David Woodhouse <dwmw2@infradead.org>,
Chuanxiao Dong <chuanxiao.dong@intel.com>
Subject: [PATCH 3/6] nand/denali: allow the number of ECC bits to be set by pdata
Date: Fri, 3 Jun 2011 11:17:15 +0100 [thread overview]
Message-ID: <1307096238-25751-4-git-send-email-jamie@jamieiles.com> (raw)
In-Reply-To: <1307096238-25751-1-git-send-email-jamie@jamieiles.com>
Rather than having the number of ECC bits to be used set by a
preprocessor definition, allow it to be set by platform_data. If there
is no platform_data then default to 8 bit ECC.
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Chuanxiao Dong <chuanxiao.dong@intel.com>
Cc: Artem Bityutskiy <dedekind1@gmail.com>
Signed-off-by: Jamie Iles <jamie@jamieiles.com>
---
drivers/mtd/nand/denali.c | 25 +++++++++++++------------
drivers/mtd/nand/denali.h | 1 +
include/linux/platform_data/denali.h | 21 +++++++++++++++++++++
3 files changed, 35 insertions(+), 12 deletions(-)
create mode 100644 include/linux/platform_data/denali.h
diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
index 491458a..f6bbafb 100644
--- a/drivers/mtd/nand/denali.c
+++ b/drivers/mtd/nand/denali.c
@@ -26,6 +26,7 @@
#include <linux/pci.h>
#include <linux/mtd/mtd.h>
#include <linux/module.h>
+#include <linux/platform_data/denali.h>
#include "denali.h"
@@ -60,8 +61,6 @@ MODULE_PARM_DESC(onfi_timing_mode, "Overrides default ONFI setting."
* valid or not */
#define CHIP_SELECT_INVALID -1
-#define SUPPORT_8BITECC 1
-
/* This macro divides two integers and rounds fractional values up
* to the nearest integer value. */
#define CEIL_DIV(X, Y) (((X)%(Y)) ? ((X)/(Y)+1) : ((X)/(Y)))
@@ -357,11 +356,8 @@ static void get_toshiba_nand_para(struct denali_nand_info *denali)
ioread32(denali->flash_reg + DEVICE_SPARE_AREA_SIZE);
iowrite32(tmp,
denali->flash_reg + LOGICAL_PAGE_SPARE_SIZE);
-#if SUPPORT_15BITECC
- iowrite32(15, denali->flash_reg + ECC_CORRECTION);
-#elif SUPPORT_8BITECC
- iowrite32(8, denali->flash_reg + ECC_CORRECTION);
-#endif
+ iowrite32(denali->nr_ecc_bits,
+ denali->flash_reg + ECC_CORRECTION);
}
}
@@ -385,11 +381,8 @@ static void get_hynix_nand_para(struct denali_nand_info *denali,
iowrite32(spare_size,
denali->flash_reg + LOGICAL_PAGE_SPARE_SIZE);
iowrite32(0, denali->flash_reg + DEVICE_WIDTH);
-#if SUPPORT_15BITECC
- iowrite32(15, denali->flash_reg + ECC_CORRECTION);
-#elif SUPPORT_8BITECC
- iowrite32(8, denali->flash_reg + ECC_CORRECTION);
-#endif
+ iowrite32(denali->nr_ecc_bits,
+ denali->flash_reg + ECC_CORRECTION);
break;
default:
dev_warn(denali->dev,
@@ -1414,6 +1407,8 @@ static int denali_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
resource_size_t csr_base, mem_base;
unsigned long csr_len, mem_len;
struct denali_nand_info *denali;
+ int ret;
+ struct denali_nand_pdata *pdata;
denali = kzalloc(sizeof(*denali), GFP_KERNEL);
if (!denali)
@@ -1421,6 +1416,12 @@ static int denali_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
denali->dev = &dev->dev;
+ pdata = dev_get_platdata(denali->dev);
+ if (pdata && pdata->nr_ecc_bits > 8)
+ denali->nr_ecc_bits = pdata->nr_ecc_bits;
+ else
+ denali->nr_ecc_bits = 8;
+
ret = pci_enable_device(dev);
if (ret) {
dev_err(denali->dev, "Spectra: pci_enable_device failed.\n");
diff --git a/drivers/mtd/nand/denali.h b/drivers/mtd/nand/denali.h
index fabb9d5..b428ce3 100644
--- a/drivers/mtd/nand/denali.h
+++ b/drivers/mtd/nand/denali.h
@@ -494,6 +494,7 @@ struct denali_nand_info {
uint32_t blksperchip;
uint32_t bbtskipbytes;
uint32_t max_banks;
+ int nr_ecc_bits;
};
#endif /*_LLD_NAND_*/
diff --git a/include/linux/platform_data/denali.h b/include/linux/platform_data/denali.h
new file mode 100644
index 0000000..cfdb775
--- /dev/null
+++ b/include/linux/platform_data/denali.h
@@ -0,0 +1,21 @@
+/*
+ * NAND flash controller device driver platform data.
+ * Copyright © 2011, Picochip
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ */
+#ifndef __DENALI_PDATA_H__
+#define __DENALI_PDATA_H__
+
+struct denali_nand_pdata {
+ int nr_ecc_bits;
+};
+
+#endif /* __DENALI_PDATA_H__ */
--
1.7.4.1
next prev parent reply other threads:[~2011-06-03 10:17 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-03 10:17 [PATCH 0/6] Further Denali NAND enhancements Jamie Iles
2011-06-03 10:17 ` [PATCH 1/6] nand/denali: convert to dev_() printk helpers Jamie Iles
2011-06-03 10:17 ` [PATCH 2/6] nand/denali: annotate pci init/exit functions with correct section Jamie Iles
2011-06-03 10:17 ` Jamie Iles [this message]
2011-06-03 10:17 ` [PATCH 4/6] nand/denali: support hardware with internal ECC fixup Jamie Iles
2011-06-03 10:17 ` [PATCH 5/6] nand/denali: support MTD partitioning Jamie Iles
2011-06-03 10:17 ` [PATCH 6/6] mtd/denali: support for cmdline partitioning Jamie Iles
2011-06-03 10:31 ` [PATCH 0/6] Further Denali NAND enhancements Jamie Iles
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=1307096238-25751-4-git-send-email-jamie@jamieiles.com \
--to=jamie@jamieiles.com \
--cc=chuanxiao.dong@intel.com \
--cc=dedekind1@gmail.com \
--cc=dwmw2@infradead.org \
--cc=linux-mtd@lists.infradead.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox