• Home
  • Raw
  • Download

Lines Matching refs:mtd

121 	struct mtd_info		mtd;  member
133 static void mpc5121_nfc_done(struct mtd_info *mtd);
136 static inline u16 nfc_read(struct mtd_info *mtd, uint reg) in nfc_read() argument
138 struct nand_chip *chip = mtd->priv; in nfc_read()
145 static inline void nfc_write(struct mtd_info *mtd, uint reg, u16 val) in nfc_write() argument
147 struct nand_chip *chip = mtd->priv; in nfc_write()
154 static inline void nfc_set(struct mtd_info *mtd, uint reg, u16 bits) in nfc_set() argument
156 nfc_write(mtd, reg, nfc_read(mtd, reg) | bits); in nfc_set()
160 static inline void nfc_clear(struct mtd_info *mtd, uint reg, u16 bits) in nfc_clear() argument
162 nfc_write(mtd, reg, nfc_read(mtd, reg) & ~bits); in nfc_clear()
166 static inline void mpc5121_nfc_send_addr(struct mtd_info *mtd, u16 addr) in mpc5121_nfc_send_addr() argument
168 nfc_write(mtd, NFC_FLASH_ADDR, addr); in mpc5121_nfc_send_addr()
169 nfc_write(mtd, NFC_CONFIG2, NFC_ADDRESS); in mpc5121_nfc_send_addr()
170 mpc5121_nfc_done(mtd); in mpc5121_nfc_send_addr()
174 static inline void mpc5121_nfc_send_cmd(struct mtd_info *mtd, u16 cmd) in mpc5121_nfc_send_cmd() argument
176 nfc_write(mtd, NFC_FLASH_CMD, cmd); in mpc5121_nfc_send_cmd()
177 nfc_write(mtd, NFC_CONFIG2, NFC_COMMAND); in mpc5121_nfc_send_cmd()
178 mpc5121_nfc_done(mtd); in mpc5121_nfc_send_cmd()
182 static inline void mpc5121_nfc_send_prog_page(struct mtd_info *mtd) in mpc5121_nfc_send_prog_page() argument
184 nfc_clear(mtd, NFC_BUF_ADDR, NFC_RBA_MASK); in mpc5121_nfc_send_prog_page()
185 nfc_write(mtd, NFC_CONFIG2, NFC_INPUT); in mpc5121_nfc_send_prog_page()
186 mpc5121_nfc_done(mtd); in mpc5121_nfc_send_prog_page()
190 static inline void mpc5121_nfc_send_read_page(struct mtd_info *mtd) in mpc5121_nfc_send_read_page() argument
192 nfc_clear(mtd, NFC_BUF_ADDR, NFC_RBA_MASK); in mpc5121_nfc_send_read_page()
193 nfc_write(mtd, NFC_CONFIG2, NFC_OUTPUT); in mpc5121_nfc_send_read_page()
194 mpc5121_nfc_done(mtd); in mpc5121_nfc_send_read_page()
198 static inline void mpc5121_nfc_send_read_id(struct mtd_info *mtd) in mpc5121_nfc_send_read_id() argument
200 nfc_clear(mtd, NFC_BUF_ADDR, NFC_RBA_MASK); in mpc5121_nfc_send_read_id()
201 nfc_write(mtd, NFC_CONFIG2, NFC_ID); in mpc5121_nfc_send_read_id()
202 mpc5121_nfc_done(mtd); in mpc5121_nfc_send_read_id()
206 static inline void mpc5121_nfc_send_read_status(struct mtd_info *mtd) in mpc5121_nfc_send_read_status() argument
208 nfc_clear(mtd, NFC_BUF_ADDR, NFC_RBA_MASK); in mpc5121_nfc_send_read_status()
209 nfc_write(mtd, NFC_CONFIG2, NFC_STATUS); in mpc5121_nfc_send_read_status()
210 mpc5121_nfc_done(mtd); in mpc5121_nfc_send_read_status()
216 struct mtd_info *mtd = data; in mpc5121_nfc_irq() local
217 struct nand_chip *chip = mtd->priv; in mpc5121_nfc_irq()
220 nfc_set(mtd, NFC_CONFIG1, NFC_INT_MASK); in mpc5121_nfc_irq()
227 static void mpc5121_nfc_done(struct mtd_info *mtd) in mpc5121_nfc_done() argument
229 struct nand_chip *chip = mtd->priv; in mpc5121_nfc_done()
233 if ((nfc_read(mtd, NFC_CONFIG2) & NFC_INT) == 0) { in mpc5121_nfc_done()
234 nfc_clear(mtd, NFC_CONFIG1, NFC_INT_MASK); in mpc5121_nfc_done()
236 (nfc_read(mtd, NFC_CONFIG2) & NFC_INT), NFC_TIMEOUT); in mpc5121_nfc_done()
243 nfc_clear(mtd, NFC_CONFIG2, NFC_INT); in mpc5121_nfc_done()
247 static void mpc5121_nfc_addr_cycle(struct mtd_info *mtd, int column, int page) in mpc5121_nfc_addr_cycle() argument
249 struct nand_chip *chip = mtd->priv; in mpc5121_nfc_addr_cycle()
253 mpc5121_nfc_send_addr(mtd, column); in mpc5121_nfc_addr_cycle()
254 if (mtd->writesize > 512) in mpc5121_nfc_addr_cycle()
255 mpc5121_nfc_send_addr(mtd, column >> 8); in mpc5121_nfc_addr_cycle()
260 mpc5121_nfc_send_addr(mtd, page & 0xFF); in mpc5121_nfc_addr_cycle()
268 static void mpc5121_nfc_select_chip(struct mtd_info *mtd, int chip) in mpc5121_nfc_select_chip() argument
271 nfc_clear(mtd, NFC_CONFIG1, NFC_CE); in mpc5121_nfc_select_chip()
275 nfc_clear(mtd, NFC_BUF_ADDR, NFC_ACTIVE_CS_MASK); in mpc5121_nfc_select_chip()
276 nfc_set(mtd, NFC_BUF_ADDR, (chip << NFC_ACTIVE_CS_SHIFT) & in mpc5121_nfc_select_chip()
278 nfc_set(mtd, NFC_CONFIG1, NFC_CE); in mpc5121_nfc_select_chip()
282 static int ads5121_chipselect_init(struct mtd_info *mtd) in ads5121_chipselect_init() argument
284 struct nand_chip *chip = mtd->priv; in ads5121_chipselect_init()
304 static void ads5121_select_chip(struct mtd_info *mtd, int chip) in ads5121_select_chip() argument
306 struct nand_chip *nand = mtd->priv; in ads5121_select_chip()
314 mpc5121_nfc_select_chip(mtd, 0); in ads5121_select_chip()
317 mpc5121_nfc_select_chip(mtd, -1); in ads5121_select_chip()
323 static int mpc5121_nfc_dev_ready(struct mtd_info *mtd) in mpc5121_nfc_dev_ready() argument
333 static void mpc5121_nfc_command(struct mtd_info *mtd, unsigned command, in mpc5121_nfc_command() argument
336 struct nand_chip *chip = mtd->priv; in mpc5121_nfc_command()
344 mpc5121_nfc_send_prog_page(mtd); in mpc5121_nfc_command()
367 mpc5121_nfc_command(mtd, NAND_CMD_READ0, column, page); in mpc5121_nfc_command()
381 mpc5121_nfc_send_cmd(mtd, command); in mpc5121_nfc_command()
382 mpc5121_nfc_addr_cycle(mtd, column, page); in mpc5121_nfc_command()
386 if (mtd->writesize > 512) in mpc5121_nfc_command()
387 mpc5121_nfc_send_cmd(mtd, NAND_CMD_READSTART); in mpc5121_nfc_command()
388 mpc5121_nfc_send_read_page(mtd); in mpc5121_nfc_command()
392 mpc5121_nfc_send_read_id(mtd); in mpc5121_nfc_command()
396 mpc5121_nfc_send_read_status(mtd); in mpc5121_nfc_command()
406 static void mpc5121_nfc_copy_spare(struct mtd_info *mtd, uint offset, in mpc5121_nfc_copy_spare() argument
409 struct nand_chip *nand = mtd->priv; in mpc5121_nfc_copy_spare()
429 sbsize = (mtd->oobsize / (mtd->writesize / 512)) & ~1; in mpc5121_nfc_copy_spare()
458 static void mpc5121_nfc_buf_copy(struct mtd_info *mtd, u_char *buf, int len, in mpc5121_nfc_buf_copy() argument
461 struct nand_chip *chip = mtd->priv; in mpc5121_nfc_buf_copy()
467 if (prv->spareonly || c >= mtd->writesize) { in mpc5121_nfc_buf_copy()
469 if (c >= mtd->writesize) in mpc5121_nfc_buf_copy()
470 c -= mtd->writesize; in mpc5121_nfc_buf_copy()
473 mpc5121_nfc_copy_spare(mtd, c, buf, len, wr); in mpc5121_nfc_buf_copy()
481 l = min((uint)len, mtd->writesize - c); in mpc5121_nfc_buf_copy()
493 mpc5121_nfc_buf_copy(mtd, buf, len, wr); in mpc5121_nfc_buf_copy()
498 static void mpc5121_nfc_read_buf(struct mtd_info *mtd, u_char *buf, int len) in mpc5121_nfc_read_buf() argument
500 mpc5121_nfc_buf_copy(mtd, buf, len, 0); in mpc5121_nfc_read_buf()
504 static void mpc5121_nfc_write_buf(struct mtd_info *mtd, in mpc5121_nfc_write_buf() argument
507 mpc5121_nfc_buf_copy(mtd, (u_char *)buf, len, 1); in mpc5121_nfc_write_buf()
511 static u8 mpc5121_nfc_read_byte(struct mtd_info *mtd) in mpc5121_nfc_read_byte() argument
515 mpc5121_nfc_read_buf(mtd, &tmp, sizeof(tmp)); in mpc5121_nfc_read_byte()
521 static u16 mpc5121_nfc_read_word(struct mtd_info *mtd) in mpc5121_nfc_read_word() argument
525 mpc5121_nfc_read_buf(mtd, (u_char *)&tmp, sizeof(tmp)); in mpc5121_nfc_read_word()
537 static int mpc5121_nfc_read_hw_config(struct mtd_info *mtd) in mpc5121_nfc_read_hw_config() argument
539 struct nand_chip *chip = mtd->priv; in mpc5121_nfc_read_hw_config()
599 mtd->writesize = rcw_pagesize; in mpc5121_nfc_read_hw_config()
600 mtd->oobsize = rcw_sparesize; in mpc5121_nfc_read_hw_config()
616 static void mpc5121_nfc_free(struct device *dev, struct mtd_info *mtd) in mpc5121_nfc_free() argument
618 struct nand_chip *chip = mtd->priv; in mpc5121_nfc_free()
635 struct mtd_info *mtd; in mpc5121_nfc_probe() local
658 mtd = &prv->mtd; in mpc5121_nfc_probe()
661 mtd->priv = chip; in mpc5121_nfc_probe()
662 mtd->dev.parent = dev; in mpc5121_nfc_probe()
667 retval = mpc5121_nfc_read_hw_config(mtd); in mpc5121_nfc_probe()
705 mtd->name = "MPC5121 NAND"; in mpc5121_nfc_probe()
720 retval = ads5121_chipselect_init(mtd); in mpc5121_nfc_probe()
746 nfc_set(mtd, NFC_CONFIG1, NFC_RESET); in mpc5121_nfc_probe()
747 while (nfc_read(mtd, NFC_CONFIG1) & NFC_RESET) { in mpc5121_nfc_probe()
758 nfc_write(mtd, NFC_CONFIG, NFC_BLS_UNLOCKED); in mpc5121_nfc_probe()
761 nfc_write(mtd, NFC_UNLOCKSTART_BLK0, 0x0000); in mpc5121_nfc_probe()
762 nfc_write(mtd, NFC_UNLOCKEND_BLK0, 0xFFFF); in mpc5121_nfc_probe()
763 nfc_write(mtd, NFC_WRPROT, NFC_WPC_UNLOCK); in mpc5121_nfc_probe()
770 nfc_write(mtd, NFC_CONFIG1, NFC_BIG_ENDIAN | NFC_INT_MASK | in mpc5121_nfc_probe()
774 nfc_write(mtd, NFC_SPAS, mtd->oobsize >> 1); in mpc5121_nfc_probe()
778 mtd); in mpc5121_nfc_probe()
785 if (nand_scan(mtd, be32_to_cpup(chips_no))) { in mpc5121_nfc_probe()
792 switch (mtd->erasesize / mtd->writesize) { in mpc5121_nfc_probe()
794 nfc_set(mtd, NFC_CONFIG1, NFC_PPB_32); in mpc5121_nfc_probe()
798 nfc_set(mtd, NFC_CONFIG1, NFC_PPB_64); in mpc5121_nfc_probe()
802 nfc_set(mtd, NFC_CONFIG1, NFC_PPB_128); in mpc5121_nfc_probe()
806 nfc_set(mtd, NFC_CONFIG1, NFC_PPB_256); in mpc5121_nfc_probe()
815 dev_set_drvdata(dev, mtd); in mpc5121_nfc_probe()
818 retval = mtd_device_parse_register(mtd, NULL, &ppdata, NULL, 0); in mpc5121_nfc_probe()
826 mpc5121_nfc_free(dev, mtd); in mpc5121_nfc_probe()
833 struct mtd_info *mtd = dev_get_drvdata(dev); in mpc5121_nfc_remove() local
835 nand_release(mtd); in mpc5121_nfc_remove()
836 mpc5121_nfc_free(dev, mtd); in mpc5121_nfc_remove()