diff --git a/drivers/mtd/devices/Kconfig b/drivers/mtd/devices/Kconfig index bdc3830..4f59e45 100644 --- a/drivers/mtd/devices/Kconfig +++ b/drivers/mtd/devices/Kconfig @@ -58,6 +58,12 @@ config MTD_MSM_NAND help Support for some NAND chips connected to the MSM NAND controller. +config MTD_MSM_NAND_VSPOPS + bool "MSM NAND VSPops" + depends on MTD_MSM_NAND + help + Virtual subpage functionality. + config MTD_DATAFLASH tristate "Support for AT45xxx DataFlash" depends on SPI_MASTER && EXPERIMENTAL diff --git a/drivers/mtd/devices/msm_nand.c b/drivers/mtd/devices/msm_nand.c index 989ac81..0d40201 100644 --- a/drivers/mtd/devices/msm_nand.c +++ b/drivers/mtd/devices/msm_nand.c @@ -40,7 +40,7 @@ #define NAND_CFG0_RAW 0xA80420C0 #define NAND_CFG1_RAW 0x5045D -#define VERBOSE 0 +#define VERBOSE 1 struct msm_nand_chip { struct device *dev; @@ -705,13 +705,44 @@ err_dma_map_oobbuf_failed: } static int +msm_nand_read_subpage(struct mtd_info *mtd, loff_t from, size_t len, + size_t *retlen, u_char *buf) +{ + int ret; + struct mtd_oob_ops ops; + u_char buf_cache[(mtd->writesize)]; + + printk("%s: %llx %i\n", __func__, from, len); + + ops.mode = MTD_OOB_PLACE; + + ops.len = mtd->writesize; + ops.datbuf = buf_cache; + ops.retlen = 0; + ops.ooblen = 0; + ops.oobbuf = buf_cache; + ret = msm_nand_read_oob(mtd, from, &ops); + + memcpy(buf,buf_cache,len); + ops.retlen = len; + + *retlen = ops.retlen; + return ret; +} + +static int msm_nand_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf) { +#if defined(CONFIG_MTD_MSM_NAND_VSPOPS) + //Check if requested data is a subpage + if((lenwritesize)&&((mtd->writesize % len)==0)) + return msm_nand_read_subpage(mtd, from, len, retlen, buf); +#endif int ret; struct mtd_oob_ops ops; - /* printk("msm_nand_read %llx %x\n", from, len); */ + printk("%s: %llx %i\n", __func__, from, len); ops.mode = MTD_OOB_PLACE; ops.len = len; @@ -1022,9 +1053,22 @@ err_dma_map_oobbuf_failed: return err; } +static int msm_nand_write_subpage(struct mtd_info *mtd, loff_t to, size_t len, + size_t *retlen, const u_char *buf) +{ + printk("to be implemented\n"); + return 0; +} + static int msm_nand_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf) { + printk("%s: writing data %i to %llx",__func__,len,to); +#if defined(CONFIG_MTD_MSM_NAND_VSPOPS) + //Check if requested data is a subpage + if((lenwritesize)&&((mtd->writesize % len)==0)) + return msm_nand_write_subpage(mtd, to, len, retlen, buf); +#endif int ret; struct mtd_oob_ops ops;