Lines Matching refs:mtd

119 static void mpc5121_nfc_done(struct mtd_info *mtd);
122 static inline u16 nfc_read(struct mtd_info *mtd, uint reg) in nfc_read() argument
124 struct nand_chip *chip = mtd_to_nand(mtd); in nfc_read()
131 static inline void nfc_write(struct mtd_info *mtd, uint reg, u16 val) in nfc_write() argument
133 struct nand_chip *chip = mtd_to_nand(mtd); in nfc_write()
140 static inline void nfc_set(struct mtd_info *mtd, uint reg, u16 bits) in nfc_set() argument
142 nfc_write(mtd, reg, nfc_read(mtd, reg) | bits); in nfc_set()
146 static inline void nfc_clear(struct mtd_info *mtd, uint reg, u16 bits) in nfc_clear() argument
148 nfc_write(mtd, reg, nfc_read(mtd, reg) & ~bits); in nfc_clear()
152 static inline void mpc5121_nfc_send_addr(struct mtd_info *mtd, u16 addr) in mpc5121_nfc_send_addr() argument
154 nfc_write(mtd, NFC_FLASH_ADDR, addr); in mpc5121_nfc_send_addr()
155 nfc_write(mtd, NFC_CONFIG2, NFC_ADDRESS); in mpc5121_nfc_send_addr()
156 mpc5121_nfc_done(mtd); in mpc5121_nfc_send_addr()
160 static inline void mpc5121_nfc_send_cmd(struct mtd_info *mtd, u16 cmd) in mpc5121_nfc_send_cmd() argument
162 nfc_write(mtd, NFC_FLASH_CMD, cmd); in mpc5121_nfc_send_cmd()
163 nfc_write(mtd, NFC_CONFIG2, NFC_COMMAND); in mpc5121_nfc_send_cmd()
164 mpc5121_nfc_done(mtd); in mpc5121_nfc_send_cmd()
168 static inline void mpc5121_nfc_send_prog_page(struct mtd_info *mtd) in mpc5121_nfc_send_prog_page() argument
170 nfc_clear(mtd, NFC_BUF_ADDR, NFC_RBA_MASK); in mpc5121_nfc_send_prog_page()
171 nfc_write(mtd, NFC_CONFIG2, NFC_INPUT); in mpc5121_nfc_send_prog_page()
172 mpc5121_nfc_done(mtd); in mpc5121_nfc_send_prog_page()
176 static inline void mpc5121_nfc_send_read_page(struct mtd_info *mtd) in mpc5121_nfc_send_read_page() argument
178 nfc_clear(mtd, NFC_BUF_ADDR, NFC_RBA_MASK); in mpc5121_nfc_send_read_page()
179 nfc_write(mtd, NFC_CONFIG2, NFC_OUTPUT); in mpc5121_nfc_send_read_page()
180 mpc5121_nfc_done(mtd); in mpc5121_nfc_send_read_page()
184 static inline void mpc5121_nfc_send_read_id(struct mtd_info *mtd) in mpc5121_nfc_send_read_id() argument
186 nfc_clear(mtd, NFC_BUF_ADDR, NFC_RBA_MASK); in mpc5121_nfc_send_read_id()
187 nfc_write(mtd, NFC_CONFIG2, NFC_ID); in mpc5121_nfc_send_read_id()
188 mpc5121_nfc_done(mtd); in mpc5121_nfc_send_read_id()
192 static inline void mpc5121_nfc_send_read_status(struct mtd_info *mtd) in mpc5121_nfc_send_read_status() argument
194 nfc_clear(mtd, NFC_BUF_ADDR, NFC_RBA_MASK); in mpc5121_nfc_send_read_status()
195 nfc_write(mtd, NFC_CONFIG2, NFC_STATUS); in mpc5121_nfc_send_read_status()
196 mpc5121_nfc_done(mtd); in mpc5121_nfc_send_read_status()
202 struct mtd_info *mtd = data; in mpc5121_nfc_irq() local
203 struct nand_chip *chip = mtd_to_nand(mtd); in mpc5121_nfc_irq()
206 nfc_set(mtd, NFC_CONFIG1, NFC_INT_MASK); in mpc5121_nfc_irq()
213 static void mpc5121_nfc_done(struct mtd_info *mtd) in mpc5121_nfc_done() argument
215 struct nand_chip *chip = mtd_to_nand(mtd); in mpc5121_nfc_done()
219 if ((nfc_read(mtd, NFC_CONFIG2) & NFC_INT) == 0) { in mpc5121_nfc_done()
220 nfc_clear(mtd, NFC_CONFIG1, NFC_INT_MASK); in mpc5121_nfc_done()
222 (nfc_read(mtd, NFC_CONFIG2) & NFC_INT), NFC_TIMEOUT); in mpc5121_nfc_done()
229 nfc_clear(mtd, NFC_CONFIG2, NFC_INT); in mpc5121_nfc_done()
233 static void mpc5121_nfc_addr_cycle(struct mtd_info *mtd, int column, int page) in mpc5121_nfc_addr_cycle() argument
235 struct nand_chip *chip = mtd_to_nand(mtd); in mpc5121_nfc_addr_cycle()
239 mpc5121_nfc_send_addr(mtd, column); in mpc5121_nfc_addr_cycle()
240 if (mtd->writesize > 512) in mpc5121_nfc_addr_cycle()
241 mpc5121_nfc_send_addr(mtd, column >> 8); in mpc5121_nfc_addr_cycle()
246 mpc5121_nfc_send_addr(mtd, page & 0xFF); in mpc5121_nfc_addr_cycle()
256 struct mtd_info *mtd = nand_to_mtd(nand); in mpc5121_nfc_select_chip() local
259 nfc_clear(mtd, NFC_CONFIG1, NFC_CE); in mpc5121_nfc_select_chip()
263 nfc_clear(mtd, NFC_BUF_ADDR, NFC_ACTIVE_CS_MASK); in mpc5121_nfc_select_chip()
264 nfc_set(mtd, NFC_BUF_ADDR, (chip << NFC_ACTIVE_CS_SHIFT) & in mpc5121_nfc_select_chip()
266 nfc_set(mtd, NFC_CONFIG1, NFC_CE); in mpc5121_nfc_select_chip()
270 static int ads5121_chipselect_init(struct mtd_info *mtd) in ads5121_chipselect_init() argument
272 struct nand_chip *chip = mtd_to_nand(mtd); in ads5121_chipselect_init()
323 struct mtd_info *mtd = nand_to_mtd(chip); in mpc5121_nfc_command() local
331 mpc5121_nfc_send_prog_page(mtd); in mpc5121_nfc_command()
368 mpc5121_nfc_send_cmd(mtd, command); in mpc5121_nfc_command()
369 mpc5121_nfc_addr_cycle(mtd, column, page); in mpc5121_nfc_command()
373 if (mtd->writesize > 512) in mpc5121_nfc_command()
374 mpc5121_nfc_send_cmd(mtd, NAND_CMD_READSTART); in mpc5121_nfc_command()
375 mpc5121_nfc_send_read_page(mtd); in mpc5121_nfc_command()
379 mpc5121_nfc_send_read_id(mtd); in mpc5121_nfc_command()
383 mpc5121_nfc_send_read_status(mtd); in mpc5121_nfc_command()
393 static void mpc5121_nfc_copy_spare(struct mtd_info *mtd, uint offset, in mpc5121_nfc_copy_spare() argument
396 struct nand_chip *nand = mtd_to_nand(mtd); in mpc5121_nfc_copy_spare()
416 sbsize = (mtd->oobsize / (mtd->writesize / 512)) & ~1; in mpc5121_nfc_copy_spare()
445 static void mpc5121_nfc_buf_copy(struct mtd_info *mtd, u_char *buf, int len, in mpc5121_nfc_buf_copy() argument
448 struct nand_chip *chip = mtd_to_nand(mtd); in mpc5121_nfc_buf_copy()
454 if (prv->spareonly || c >= mtd->writesize) { in mpc5121_nfc_buf_copy()
456 if (c >= mtd->writesize) in mpc5121_nfc_buf_copy()
457 c -= mtd->writesize; in mpc5121_nfc_buf_copy()
460 mpc5121_nfc_copy_spare(mtd, c, buf, len, wr); in mpc5121_nfc_buf_copy()
468 l = min((uint)len, mtd->writesize - c); in mpc5121_nfc_buf_copy()
480 mpc5121_nfc_buf_copy(mtd, buf, len, wr); in mpc5121_nfc_buf_copy()
514 static int mpc5121_nfc_read_hw_config(struct mtd_info *mtd) in mpc5121_nfc_read_hw_config() argument
516 struct nand_chip *chip = mtd_to_nand(mtd); in mpc5121_nfc_read_hw_config()
576 mtd->writesize = rcw_pagesize; in mpc5121_nfc_read_hw_config()
577 mtd->oobsize = rcw_sparesize; in mpc5121_nfc_read_hw_config()
593 static void mpc5121_nfc_free(struct device *dev, struct mtd_info *mtd) in mpc5121_nfc_free() argument
595 struct nand_chip *chip = mtd_to_nand(mtd); in mpc5121_nfc_free()
624 struct mtd_info *mtd; in mpc5121_nfc_probe() local
647 mtd = nand_to_mtd(chip); in mpc5121_nfc_probe()
653 mtd->dev.parent = dev; in mpc5121_nfc_probe()
659 retval = mpc5121_nfc_read_hw_config(mtd); in mpc5121_nfc_probe()
697 mtd->name = "MPC5121 NAND"; in mpc5121_nfc_probe()
710 retval = ads5121_chipselect_init(mtd); in mpc5121_nfc_probe()
734 nfc_set(mtd, NFC_CONFIG1, NFC_RESET); in mpc5121_nfc_probe()
735 while (nfc_read(mtd, NFC_CONFIG1) & NFC_RESET) { in mpc5121_nfc_probe()
746 nfc_write(mtd, NFC_CONFIG, NFC_BLS_UNLOCKED); in mpc5121_nfc_probe()
749 nfc_write(mtd, NFC_UNLOCKSTART_BLK0, 0x0000); in mpc5121_nfc_probe()
750 nfc_write(mtd, NFC_UNLOCKEND_BLK0, 0xFFFF); in mpc5121_nfc_probe()
751 nfc_write(mtd, NFC_WRPROT, NFC_WPC_UNLOCK); in mpc5121_nfc_probe()
758 nfc_write(mtd, NFC_CONFIG1, NFC_BIG_ENDIAN | NFC_INT_MASK | in mpc5121_nfc_probe()
762 nfc_write(mtd, NFC_SPAS, mtd->oobsize >> 1); in mpc5121_nfc_probe()
766 mtd); in mpc5121_nfc_probe()
787 switch (mtd->erasesize / mtd->writesize) { in mpc5121_nfc_probe()
789 nfc_set(mtd, NFC_CONFIG1, NFC_PPB_32); in mpc5121_nfc_probe()
793 nfc_set(mtd, NFC_CONFIG1, NFC_PPB_64); in mpc5121_nfc_probe()
797 nfc_set(mtd, NFC_CONFIG1, NFC_PPB_128); in mpc5121_nfc_probe()
801 nfc_set(mtd, NFC_CONFIG1, NFC_PPB_256); in mpc5121_nfc_probe()
810 dev_set_drvdata(dev, mtd); in mpc5121_nfc_probe()
813 retval = mtd_device_register(mtd, NULL, 0); in mpc5121_nfc_probe()
821 mpc5121_nfc_free(dev, mtd); in mpc5121_nfc_probe()
828 struct mtd_info *mtd = dev_get_drvdata(dev); in mpc5121_nfc_remove() local
831 ret = mtd_device_unregister(mtd); in mpc5121_nfc_remove()
833 nand_cleanup(mtd_to_nand(mtd)); in mpc5121_nfc_remove()
834 mpc5121_nfc_free(dev, mtd); in mpc5121_nfc_remove()