OneNAND: introduce chip_probe function for non-generic OneNAND probe
authorKyungmin Park <kyungmin.park@samsung.com>
Mon, 3 May 2010 07:05:45 +0000 (16:05 +0900)
committerKyungmin Park <kyungmin.park@samsung.com>
Mon, 3 May 2010 07:05:45 +0000 (16:05 +0900)
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
board/samsung/universal/onenand.c
drivers/mtd/onenand/onenand_base.c
drivers/mtd/onenand/samsung.c
include/linux/mtd/onenand.h
include/linux/mtd/samsung_onenand.h

index 057bc6a..27c2311 100644 (file)
@@ -40,6 +40,7 @@ void onenand_board_init(struct mtd_info *mtd)
        if (cpu_is_s5pc110()) {
                this->base = (void *) 0xB0000000;
                this->options |= ONENAND_RUNTIME_BADBLOCK_CHECK;
+               this->chip_probe = s5pc110_chip_probe;
        } else {
                struct s5pc100_clock *clk =
                        (struct s5pc100_clock *)S5PC1XX_CLOCK_BASE;
index 384988f..a2c8eda 100644 (file)
@@ -2672,35 +2672,23 @@ out:
 }
 
 /**
- * onenand_probe - [OneNAND Interface] Probe the OneNAND device
+ * onenand_chip_probe - [OneNAND Interface] Probe the OneNAND device
  * @param mtd          MTD device structure
  *
  * OneNAND detection method:
  *   Compare the the values from command with ones from register
  */
-static int onenand_probe(struct mtd_info *mtd)
+static int onenand_chip_probe(struct mtd_info *mtd)
 {
        struct onenand_chip *this = mtd->priv;
-       int bram_maf_id, bram_dev_id, maf_id, dev_id, ver_id;
-       int density;
+       int bram_maf_id, bram_dev_id, maf_id, dev_id;
        int syscfg;
-#if defined(CONFIG_S5PC110) || defined(CONFIG_S5P6442)
-       int onenand_if_ctrl_cfg;
-#endif
 
        /* Save system configuration 1 */
        syscfg = this->read_word(this->base + ONENAND_REG_SYS_CFG1);
 
-#if defined(CONFIG_S5PC110) || defined(CONFIG_S5P6442)
-       if (syscfg & ONENAND_SYS_CFG1_WM) {
-               this->write_word(syscfg & ~(ONENAND_SYS_CFG1_WM), this->base + ONENAND_REG_SYS_CFG1);
-               onenand_if_ctrl_cfg = readl(0xB0600100);
-               writel(onenand_if_ctrl_cfg & ~ONENAND_SYS_CFG1_WM, 0xB0600100);
-       }
-#else
        /* Clear Sync. Burst Read mode to read BootRAM */
        this->write_word((syscfg & ~ONENAND_SYS_CFG1_SYNC_READ), this->base + ONENAND_REG_SYS_CFG1);
-#endif
 
        /* Send the command for reading device ID from BootRAM */
        this->write_word(ONENAND_CMD_READID, this->base + ONENAND_BOOTRAM);
@@ -2718,11 +2706,6 @@ static int onenand_probe(struct mtd_info *mtd)
        /* Restore system configuration 1 */
        this->write_word(syscfg, this->base + ONENAND_REG_SYS_CFG1);
 
-#if defined(CONFIG_S5PC110) || defined(CONFIG_S5P6442)
-       if (syscfg & ONENAND_SYS_CFG1_WM)
-               writel(onenand_if_ctrl_cfg, 0xB0600100);
-#endif
-
        /* Check manufacturer ID */
        if (onenand_check_maf(bram_maf_id))
                return -ENXIO;
@@ -2730,13 +2713,37 @@ static int onenand_probe(struct mtd_info *mtd)
        /* Read manufacturer and device IDs from Register */
        maf_id = this->read_word(this->base + ONENAND_REG_MANUFACTURER_ID);
        dev_id = this->read_word(this->base + ONENAND_REG_DEVICE_ID);
-       ver_id = this->read_word(this->base + ONENAND_REG_VERSION_ID);
-       this->technology = this->read_word(this->base + ONENAND_REG_TECHNOLOGY);
 
        /* Check OneNAND device */
        if (maf_id != bram_maf_id || dev_id != bram_dev_id)
                return -ENXIO;
 
+       return 0;
+}
+
+/**
+ * onenand_probe - [OneNAND Interface] Probe the OneNAND device
+ * @param mtd          MTD device structure
+ *
+ * Setup required OneNAND internal data structures
+ */
+static int onenand_probe(struct mtd_info *mtd)
+{
+       struct onenand_chip *this = mtd->priv;
+       int maf_id, dev_id, ver_id;
+       int density;
+       int ret;
+
+       ret = this->chip_probe(mtd);
+       if (ret)
+               return ret;
+
+       /* Read manufacturer and device IDs from Register */
+       maf_id = this->read_word(this->base + ONENAND_REG_MANUFACTURER_ID);
+       dev_id = this->read_word(this->base + ONENAND_REG_DEVICE_ID);
+       ver_id = this->read_word(this->base + ONENAND_REG_VERSION_ID);
+       this->technology = this->read_word(this->base + ONENAND_REG_TECHNOLOGY);
+
        /* Flash device information */
        mtd->name = onenand_print_device_info(dev_id, ver_id);
        this->device_id = dev_id;
@@ -2844,6 +2851,9 @@ int onenand_scan(struct mtd_info *mtd, int maxchips)
        if (!this->block_islock)
                this->block_islock = onenand_block_islock;
 
+       if (!this->chip_probe)
+               this->chip_probe = onenand_chip_probe;
+
        if (!this->read_bufferram)
                this->read_bufferram = onenand_read_bufferram;
        if (!this->write_bufferram)
index cbcf83b..b70f4d6 100644 (file)
@@ -590,6 +590,11 @@ static void s3c_set_width_regs(struct onenand_chip *this)
 }
 #endif
 
+int s5pc110_chip_probe(struct mtd_info *mtd)
+{
+       return 0;
+}
+
 void s3c_onenand_init(struct mtd_info *mtd)
 {
        struct onenand_chip *this = mtd->priv;
index ce6d1fb..4a19b2b 100644 (file)
@@ -105,6 +105,7 @@ struct onenand_chip {
                                size_t count);
        unsigned short (*read_word) (void __iomem *addr);
        void (*write_word) (unsigned short value, void __iomem *addr);
+       int (*chip_probe)(struct mtd_info *mtd);
        void (*mmcontrol) (struct mtd_info *mtd, int sync_read);
        int (*block_markbad)(struct mtd_info *mtd, loff_t ofs);
        int (*scan_bbt)(struct mtd_info *mtd);
index 021fa27..e52b939 100644 (file)
@@ -126,6 +126,7 @@ struct samsung_onenand {
 #define TSRF           (1 << 0)
 
 /* common initialize function */
+extern int s5pc110_chip_probe(struct mtd_info *);
 extern void s3c_onenand_init(struct mtd_info *);
 
 #endif