summaryrefslogtreecommitdiff
path: root/drivers/mtd/nand
diff options
context:
space:
mode:
authorHuang Shijie <b32955@freescale.com>2011-01-05 10:32:12 +0800
committerAlan Tull <alan.tull@freescale.com>2011-02-03 16:35:38 -0600
commit142bbbe14e415ae6fcf3c073b566ae1ecc1ce405 (patch)
tree7f8547c2c6c8a578d0afa158628003a1f695d55c /drivers/mtd/nand
parent8a892d577347e33ed22d16f268b6fab699a83fff (diff)
ENGR00137600-4 GPMI : remove the structure physical_geometry{} for common files
Use the MTD/NAND structrues to replace the physical_geometry{}. Frankly speaking, the mtd_info{} and nand_chip{} is the real physical geometry of the NAND. Signed-off-by: Huang Shijie <b32955@freescale.com>
Diffstat (limited to 'drivers/mtd/nand')
-rw-r--r--drivers/mtd/nand/gpmi-nfc/gpmi-nfc-hal-common.c37
-rw-r--r--drivers/mtd/nand/gpmi-nfc/gpmi-nfc-mil.c107
2 files changed, 27 insertions, 117 deletions
diff --git a/drivers/mtd/nand/gpmi-nfc/gpmi-nfc-hal-common.c b/drivers/mtd/nand/gpmi-nfc/gpmi-nfc-hal-common.c
index 7685f53c4040..e90a934b5c10 100644
--- a/drivers/mtd/nand/gpmi-nfc/gpmi-nfc-hal-common.c
+++ b/drivers/mtd/nand/gpmi-nfc/gpmi-nfc-hal-common.c
@@ -1,7 +1,7 @@
/*
* Freescale GPMI NFC NAND Flash Driver
*
- * Copyright (C) 2010 Freescale Semiconductor, Inc.
+ * Copyright (C) 2010-2011 Freescale Semiconductor, Inc.
* Copyright (C) 2008 Embedded Alley Solutions, Inc.
*
* This program is free software; you can redistribute it and/or modify
@@ -119,9 +119,9 @@ void gpmi_nfc_dma_exit(struct gpmi_nfc_data *this)
int gpmi_nfc_set_geometry(struct gpmi_nfc_data *this)
{
struct device *dev = this->dev;
- struct physical_geometry *physical = &this->physical_geometry;
struct nfc_geometry *geometry = &this->nfc_geometry;
struct boot_rom_helper *rom = this->rom;
+ struct mtd_info *mtd = &this->mil.mtd;
unsigned int metadata_size;
unsigned int status_size;
unsigned int chunk_data_size_in_bits;
@@ -145,17 +145,15 @@ int gpmi_nfc_set_geometry(struct gpmi_nfc_data *this)
if (is_ddr_nand(&this->device_info))
geometry->ecc_chunk_size_in_bytes = 1024;
- /* Compute the page size based on the physical geometry. */
- geometry->page_size_in_bytes =
- physical->page_data_size_in_bytes +
- physical->page_oob_size_in_bytes ;
+ /* Compute the page size, include page and oob. */
+ geometry->page_size_in_bytes = mtd->writesize + mtd->oobsize;
/*
* Compute the total number of ECC chunks in a page. This includes the
* slightly larger chunk at the beginning of the page, which contains
* both data and metadata.
*/
- geometry->ecc_chunk_count = physical->page_data_size_in_bytes /
+ geometry->ecc_chunk_count = mtd->writesize /
geometry->ecc_chunk_size_in_bytes;
/*
@@ -166,12 +164,12 @@ int gpmi_nfc_set_geometry(struct gpmi_nfc_data *this)
*/
geometry->ecc_strength = 0;
- switch (physical->page_data_size_in_bytes) {
+ switch (mtd->writesize) {
case 2048:
geometry->ecc_strength = 8;
break;
case 4096:
- switch (physical->page_oob_size_in_bytes) {
+ switch (mtd->oobsize) {
case 128:
geometry->ecc_strength = 8;
break;
@@ -189,17 +187,15 @@ int gpmi_nfc_set_geometry(struct gpmi_nfc_data *this)
*/
if (is_ddr_nand(&this->device_info))
geometry->page_size_in_bytes =
- physical->page_data_size_in_bytes +
- geometry->metadata_size_in_bytes +
+ mtd->writesize
+ + geometry->metadata_size_in_bytes +
(geometry->ecc_strength * 14 * 8 /
geometry->ecc_chunk_count);
break;
}
if (!geometry->ecc_strength) {
- dev_err(dev, "Unsupported page geometry: %u:%u\n",
- physical->page_data_size_in_bytes,
- physical->page_oob_size_in_bytes);
+ dev_err(dev, "Unsupported page geometry.\n");
return !0;
}
@@ -207,7 +203,7 @@ int gpmi_nfc_set_geometry(struct gpmi_nfc_data *this)
* The payload buffer contains the data area of a page. The ECC engine
* only needs what's required to hold the data.
*/
- geometry->payload_size_in_bytes = physical->page_data_size_in_bytes;
+ geometry->payload_size_in_bytes = mtd->writesize;
/*
* In principle, computing the auxiliary buffer geometry is NFC
@@ -259,7 +255,7 @@ int gpmi_nfc_set_geometry(struct gpmi_nfc_data *this)
chunk_data_size_in_bits + chunk_ecc_size_in_bits;
/* Compute the bit offset of the block mark within the physical page. */
- block_mark_bit_offset = physical->page_data_size_in_bytes * 8;
+ block_mark_bit_offset = mtd->writesize * 8;
/* Subtract the metadata bits. */
block_mark_bit_offset -= geometry->metadata_size_in_bytes * 8;
@@ -286,8 +282,7 @@ int gpmi_nfc_set_geometry(struct gpmi_nfc_data *this)
*/
dev_err(dev, "Unsupported page geometry "
"(block mark in ECC): %u:%u\n",
- physical->page_data_size_in_bytes,
- physical->page_oob_size_in_bytes);
+ mtd->writesize, mtd->oobsize);
return !0;
}
@@ -430,8 +425,8 @@ int gpmi_nfc_compute_hardware_timing(struct gpmi_nfc_data *this,
struct gpmi_nfc_hardware_timing *hw)
{
struct gpmi_nfc_platform_data *pdata = this->pdata;
- struct physical_geometry *physical = &this->physical_geometry;
struct nfc_hal *nfc = this->nfc;
+ struct nand_chip *nand = &this->mil.nand;
struct gpmi_nfc_timing target = nfc->timing;
bool improved_timing_is_available;
unsigned long clock_frequency_in_hz;
@@ -453,11 +448,11 @@ int gpmi_nfc_compute_hardware_timing(struct gpmi_nfc_data *this,
* If there are multiple chips, we need to relax the timings to allow
* for signal distortion due to higher capacitance.
*/
- if (physical->chip_count > 2) {
+ if (nand->numchips > 2) {
target.data_setup_in_ns += 10;
target.data_hold_in_ns += 10;
target.address_setup_in_ns += 10;
- } else if (physical->chip_count > 1) {
+ } else if (nand->numchips > 1) {
target.data_setup_in_ns += 5;
target.data_hold_in_ns += 5;
target.address_setup_in_ns += 5;
diff --git a/drivers/mtd/nand/gpmi-nfc/gpmi-nfc-mil.c b/drivers/mtd/nand/gpmi-nfc/gpmi-nfc-mil.c
index 98286e17a2a6..efb0f93c234e 100644
--- a/drivers/mtd/nand/gpmi-nfc/gpmi-nfc-mil.c
+++ b/drivers/mtd/nand/gpmi-nfc/gpmi-nfc-mil.c
@@ -867,7 +867,6 @@ static int mil_ecc_read_oob(struct mtd_info *mtd, struct nand_chip *nand,
int page, int sndcmd)
{
struct gpmi_nfc_data *this = nand->priv;
- struct physical_geometry *physical = &this->physical_geometry;
struct boot_rom_helper *rom = this->rom;
DEBUG(MTD_DEBUG_LEVEL2, "[gpmi_nfc ecc_read_oob] "
@@ -877,8 +876,7 @@ static int mil_ecc_read_oob(struct mtd_info *mtd, struct nand_chip *nand,
memset(nand->oob_poi, ~0, mtd->oobsize);
/* Read out the conventional OOB. */
- nand->cmdfunc(mtd, NAND_CMD_READ0,
- physical->page_data_size_in_bytes, page);
+ nand->cmdfunc(mtd, NAND_CMD_READ0, mtd->writesize, page);
nand->read_buf(mtd, nand->oob_poi, mtd->oobsize);
/*
@@ -911,7 +909,6 @@ static int mil_ecc_write_oob(struct mtd_info *mtd,
{
struct gpmi_nfc_data *this = nand->priv;
struct device *dev = this->dev;
- struct physical_geometry *physical = &this->physical_geometry;
struct mil *mil = &this->mil;
struct boot_rom_helper *rom = this->rom;
uint8_t block_mark = 0;
@@ -945,7 +942,7 @@ static int mil_ecc_write_oob(struct mtd_info *mtd,
* appears in the first byte of the page.
*/
if (rom->swap_block_mark)
- block_mark_column = physical->page_data_size_in_bytes;
+ block_mark_column = mtd->writesize;
else
block_mark_column = 0;
@@ -988,82 +985,6 @@ static int mil_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip)
return 0;
}
-/**
- * mil_set_physical_geometry() - Set up the physical medium geometry.
- *
- * This function retrieves the physical geometry information discovered by
- * nand_scan(), corrects it, and records it in the per-device data structure.
- *
- * @this: Per-device data.
- */
-static int mil_set_physical_geometry(struct gpmi_nfc_data *this)
-{
- struct physical_geometry *physical = &this->physical_geometry;
- struct nand_device_info *info = &this->device_info;
- unsigned int block_size_in_pages;
- unsigned int chip_size_in_blocks;
- unsigned int chip_size_in_pages;
-
- /*
- * We know the total size of a page. We need to break that down into the
- * data size and OOB size. The data size is the largest power of two
- * that will fit in the given page size. The OOB size is what's left
- * over.
- */
- physical->page_data_size_in_bytes =
- 1 << (fls(info->page_total_size_in_bytes) - 1);
-
- physical->page_oob_size_in_bytes =
- info->page_total_size_in_bytes -
- physical->page_data_size_in_bytes;
-
- /*
- * Now that we know the page data size, we can multiply this by the
- * number of pages in a block to compute the block size.
- */
- physical->block_size_in_bytes =
- physical->page_data_size_in_bytes * info->block_size_in_pages;
-
- /* Get the chip size. */
- physical->chip_size_in_bytes = info->chip_size_in_bytes;
-
- /* Compute some interesting facts. */
- block_size_in_pages =
- physical->block_size_in_bytes >>
- (fls(physical->page_data_size_in_bytes) - 1);
- chip_size_in_pages =
- physical->chip_size_in_bytes >>
- (fls(physical->page_data_size_in_bytes) - 1);
- chip_size_in_blocks =
- physical->chip_size_in_bytes >>
- (fls(physical->block_size_in_bytes) - 1);
-
- #if defined(DETAILED_INFO)
- pr_info("-----------------\n");
- pr_info("Physical Geometry\n");
- pr_info("-----------------\n");
- pr_info("Page Data Size in Bytes: %u (0x%x)\n",
- physical->page_data_size_in_bytes,
- physical->page_data_size_in_bytes);
- pr_info("Page OOB Size in Bytes : %u\n",
- physical->page_oob_size_in_bytes);
- pr_info("Block Size in Bytes : %u (0x%x)\n",
- physical->block_size_in_bytes,
- physical->block_size_in_bytes);
- pr_info("Block Size in Pages : %u (0x%x)\n",
- block_size_in_pages,
- block_size_in_pages);
- pr_info("Chip Size in Bytes : %llu (0x%llx)\n",
- physical->chip_size_in_bytes,
- physical->chip_size_in_bytes);
- pr_info("Chip Size in Pages : %u (0x%x)\n",
- chip_size_in_pages, chip_size_in_pages);
- pr_info("Chip Size in Blocks : %u (0x%x)\n",
- chip_size_in_blocks, chip_size_in_blocks);
- #endif
-
- return 0;
-}
/**
* mil_set_nfc_geometry() - Set up the NFC geometry.
@@ -1143,10 +1064,7 @@ static int mil_set_geometry(struct gpmi_nfc_data *this)
/* Free the temporary DMA memory for read ID case */
mil_free_dma_buffer(this);
- /* Set up the various layers of geometry, in this specific order. */
- if (mil_set_physical_geometry(this))
- return -ENXIO;
-
+ /* Set up the NFC geometry. */
if (mil_set_nfc_geometry(this))
return -ENXIO;
@@ -1161,13 +1079,8 @@ static int mil_set_geometry(struct gpmi_nfc_data *this)
*/
static int mil_pre_bbt_scan(struct gpmi_nfc_data *this)
{
- struct physical_geometry *physical = &this->physical_geometry;
- struct boot_rom_helper *rom = this->rom;
- struct nand_chip *nand = &this->mil.nand;
- int error = 0;
-
- /* Record the number of physical chips that MTD found. */
- physical->chip_count = nand->numchips;
+ struct boot_rom_helper *rom = this->rom;
+ int error = 0;
if (mil_set_boot_rom_helper_geometry(this))
return -ENXIO;
@@ -1231,11 +1144,11 @@ static int mil_scan_bbt(struct mtd_info *mtd)
static int mil_boot_areas_init(struct gpmi_nfc_data *this)
{
struct device *dev = this->dev;
- struct physical_geometry *physical = &this->physical_geometry;
struct boot_rom_geometry *rom = &this->rom_geometry;
struct mil *mil = &this->mil;
struct mtd_info *mtd = &mil->mtd;
struct nand_chip *nand = &mil->nand;
+ struct nand_device_info *info = &this->device_info;
int mtd_support_is_adequate;
unsigned int i;
struct mtd_partition partitions[4];
@@ -1253,7 +1166,6 @@ static int mil_boot_areas_init(struct gpmi_nfc_data *this)
* static strings, we can simply search the master table for an MTD with
* a name field pointing to a known address.
*/
-
static char *chip_0_boot_name = "gpmi-nfc-0-boot";
static char *chip_0_remainder_name = "gpmi-nfc-0-remainder";
static char *chip_1_boot_name = "gpmi-nfc-1-boot";
@@ -1328,7 +1240,7 @@ static int mil_boot_areas_init(struct gpmi_nfc_data *this)
*/
/* Check if a boot area is larger than a single chip. */
- if (rom->boot_area_size_in_bytes > physical->chip_size_in_bytes) {
+ if (rom->boot_area_size_in_bytes > info->chip_size_in_bytes) {
dev_emerg(dev, "Boot area size is larger than a chip");
return -ENXIO;
}
@@ -1783,7 +1695,10 @@ static int gpmi_init_size(struct mtd_info *mtd, struct nand_chip *nand,
nand_device_print_info(info);
#endif
- /* initialize the right NAND parameters */
+ /*
+ * Init the right NAND/MTD parameters which will be used
+ * in the following mil_set_geometry().
+ */
mtd->writesize = 1 << (fls(info->page_total_size_in_bytes) - 1);
mtd->erasesize = mtd->writesize * info->block_size_in_pages;
mtd->oobsize = info->page_total_size_in_bytes - mtd->writesize;