Lines Matching full:host
28 #define NFC_V1_V2_BUF_SIZE (host->regs + 0x00)
29 #define NFC_V1_V2_BUF_ADDR (host->regs + 0x04)
30 #define NFC_V1_V2_FLASH_ADDR (host->regs + 0x06)
31 #define NFC_V1_V2_FLASH_CMD (host->regs + 0x08)
32 #define NFC_V1_V2_CONFIG (host->regs + 0x0a)
33 #define NFC_V1_V2_ECC_STATUS_RESULT (host->regs + 0x0c)
34 #define NFC_V1_V2_RSLTMAIN_AREA (host->regs + 0x0e)
35 #define NFC_V21_RSLTSPARE_AREA (host->regs + 0x10)
36 #define NFC_V1_V2_WRPROT (host->regs + 0x12)
37 #define NFC_V1_UNLOCKSTART_BLKADDR (host->regs + 0x14)
38 #define NFC_V1_UNLOCKEND_BLKADDR (host->regs + 0x16)
39 #define NFC_V21_UNLOCKSTART_BLKADDR0 (host->regs + 0x20)
40 #define NFC_V21_UNLOCKSTART_BLKADDR1 (host->regs + 0x24)
41 #define NFC_V21_UNLOCKSTART_BLKADDR2 (host->regs + 0x28)
42 #define NFC_V21_UNLOCKSTART_BLKADDR3 (host->regs + 0x2c)
43 #define NFC_V21_UNLOCKEND_BLKADDR0 (host->regs + 0x22)
44 #define NFC_V21_UNLOCKEND_BLKADDR1 (host->regs + 0x26)
45 #define NFC_V21_UNLOCKEND_BLKADDR2 (host->regs + 0x2a)
46 #define NFC_V21_UNLOCKEND_BLKADDR3 (host->regs + 0x2e)
47 #define NFC_V1_V2_NF_WRPRST (host->regs + 0x18)
48 #define NFC_V1_V2_CONFIG1 (host->regs + 0x1a)
49 #define NFC_V1_V2_CONFIG2 (host->regs + 0x1c)
77 #define NFC_V3_FLASH_CMD (host->regs_axi + 0x00)
78 #define NFC_V3_FLASH_ADDR0 (host->regs_axi + 0x04)
80 #define NFC_V3_CONFIG1 (host->regs_axi + 0x34)
84 #define NFC_V3_ECC_STATUS_RESULT (host->regs_axi + 0x38)
86 #define NFC_V3_LAUNCH (host->regs_axi + 0x40)
88 #define NFC_V3_WRPROT (host->regs_ip + 0x0)
94 #define NFC_V3_WRPROT_UNLOCK_BLK_ADD0 (host->regs_ip + 0x04)
96 #define NFC_V3_CONFIG2 (host->regs_ip + 0x24)
111 #define NFC_V3_CONFIG3 (host->regs_ip + 0x28)
119 #define NFC_V3_IPC (host->regs_ip + 0x2C)
123 #define NFC_V3_DELAY_LINE (host->regs_ip + 0x34)
245 * This function handles the needed shuffling between host->data_buf (which
252 struct mxc_nand_host *host = nand_get_controller_data(this); in copy_spare() local
257 u8 __iomem *s = host->spare0; in copy_spare()
258 u16 sparebuf_size = host->devtype_data->spare_len; in copy_spare()
261 oob_chunk_size = (host->used_oobsize / num_chunks) & ~1; in copy_spare()
272 host->used_oobsize - i * oob_chunk_size); in copy_spare()
282 host->used_oobsize - i * oob_chunk_size); in copy_spare()
286 static int check_int_v3(struct mxc_nand_host *host) in check_int_v3() argument
300 static int check_int_v1_v2(struct mxc_nand_host *host) in check_int_v1_v2() argument
308 if (!host->devtype_data->irqpending_quirk) in check_int_v1_v2()
314 static void irq_control_v1_v2(struct mxc_nand_host *host, int activate) in irq_control_v1_v2() argument
328 static void irq_control_v3(struct mxc_nand_host *host, int activate) in irq_control_v3() argument
342 static void irq_control(struct mxc_nand_host *host, int activate) in irq_control() argument
344 if (host->devtype_data->irqpending_quirk) { in irq_control()
346 enable_irq(host->irq); in irq_control()
348 disable_irq_nosync(host->irq); in irq_control()
350 host->devtype_data->irq_control(host, activate); in irq_control()
357 struct mxc_nand_host *host = nand_get_controller_data(chip); in get_ecc_status_v1() local
363 ecc_stats = host->ecc_stats_v1; in get_ecc_status_v1()
388 struct mxc_nand_host *host = nand_get_controller_data(chip); in get_ecc_status_v2_v3() local
393 ecc_bit_mask = (host->eccsize == 4) ? 0x7 : 0xf; in get_ecc_status_v2_v3()
394 err_limit = (host->eccsize == 4) ? 0x4 : 0x8; in get_ecc_status_v2_v3()
415 struct mxc_nand_host *host = nand_get_controller_data(chip); in get_ecc_status_v2() local
424 struct mxc_nand_host *host = nand_get_controller_data(chip); in get_ecc_status_v3() local
433 struct mxc_nand_host *host = dev_id; in mxc_nfc_irq() local
435 if (!host->devtype_data->check_int(host)) in mxc_nfc_irq()
438 irq_control(host, 0); in mxc_nfc_irq()
440 complete(&host->op_completion); in mxc_nfc_irq()
448 static int wait_op_done(struct mxc_nand_host *host, int useirq) in wait_op_done() argument
456 if (host->devtype_data->check_int(host)) in wait_op_done()
462 reinit_completion(&host->op_completion); in wait_op_done()
464 irq_control(host, 1); in wait_op_done()
466 time_left = wait_for_completion_timeout(&host->op_completion, HZ); in wait_op_done()
467 if (!time_left && !host->devtype_data->check_int(host)) { in wait_op_done()
468 dev_dbg(host->dev, "timeout waiting for irq\n"); in wait_op_done()
478 done = host->devtype_data->check_int(host); in wait_op_done()
485 dev_dbg(host->dev, "timeout polling for completion\n"); in wait_op_done()
495 static void send_cmd_v3(struct mxc_nand_host *host, uint16_t cmd, int useirq) in send_cmd_v3() argument
504 wait_op_done(host, useirq); in send_cmd_v3()
509 static void send_cmd_v1_v2(struct mxc_nand_host *host, uint16_t cmd, int useirq) in send_cmd_v1_v2() argument
511 dev_dbg(host->dev, "send_cmd(host, 0x%x, %d)\n", cmd, useirq); in send_cmd_v1_v2()
516 if (host->devtype_data->irqpending_quirk && (cmd == NAND_CMD_RESET)) { in send_cmd_v1_v2()
527 dev_dbg(host->dev, "%s: RESET failed\n", __func__); in send_cmd_v1_v2()
530 wait_op_done(host, useirq); in send_cmd_v1_v2()
534 static void send_addr_v3(struct mxc_nand_host *host, uint16_t addr, int islast) in send_addr_v3() argument
542 wait_op_done(host, 0); in send_addr_v3()
548 static void send_addr_v1_v2(struct mxc_nand_host *host, uint16_t addr, int islast) in send_addr_v1_v2() argument
550 dev_dbg(host->dev, "send_addr(host, 0x%x %d)\n", addr, islast); in send_addr_v1_v2()
556 wait_op_done(host, islast); in send_addr_v1_v2()
562 struct mxc_nand_host *host = nand_get_controller_data(nand_chip); in send_page_v3() local
572 wait_op_done(host, false); in send_page_v3()
578 struct mxc_nand_host *host = nand_get_controller_data(nand_chip); in send_page_v2() local
581 writew(host->active_cs << 4, NFC_V1_V2_BUF_ADDR); in send_page_v2()
586 wait_op_done(host, true); in send_page_v2()
592 struct mxc_nand_host *host = nand_get_controller_data(nand_chip); in send_page_v1() local
603 writew((host->active_cs << 4) | i, NFC_V1_V2_BUF_ADDR); in send_page_v1()
608 wait_op_done(host, true); in send_page_v1()
612 static void send_read_id_v3(struct mxc_nand_host *host) in send_read_id_v3() argument
617 wait_op_done(host, true); in send_read_id_v3()
619 memcpy32_fromio(host->data_buf, host->main_area0, 16); in send_read_id_v3()
623 static void send_read_id_v1_v2(struct mxc_nand_host *host) in send_read_id_v1_v2() argument
626 writew(host->active_cs << 4, NFC_V1_V2_BUF_ADDR); in send_read_id_v1_v2()
631 wait_op_done(host, true); in send_read_id_v1_v2()
633 memcpy32_fromio(host->data_buf, host->main_area0, 16); in send_read_id_v1_v2()
636 static uint16_t get_dev_status_v3(struct mxc_nand_host *host) in get_dev_status_v3() argument
639 wait_op_done(host, true); in get_dev_status_v3()
646 static uint16_t get_dev_status_v1_v2(struct mxc_nand_host *host) in get_dev_status_v1_v2() argument
648 void __iomem *main_buf = host->main_area0; in get_dev_status_v1_v2()
652 writew(host->active_cs << 4, NFC_V1_V2_BUF_ADDR); in get_dev_status_v1_v2()
662 wait_op_done(host, true); in get_dev_status_v1_v2()
673 struct mxc_nand_host *host = nand_get_controller_data(chip); in mxc_nand_enable_hwecc_v1_v2() local
691 struct mxc_nand_host *host = nand_get_controller_data(chip); in mxc_nand_enable_hwecc_v3() local
710 struct mxc_nand_host *host = nand_get_controller_data(chip); in mxc_nand_read_page_v1() local
723 writew((host->active_cs << 4) | i, NFC_V1_V2_BUF_ADDR); in mxc_nand_read_page_v1()
728 wait_op_done(host, true); in mxc_nand_read_page_v1()
734 host->ecc_stats_v1 = ecc_stats; in mxc_nand_read_page_v1()
742 struct mxc_nand_host *host = nand_get_controller_data(chip); in mxc_nand_read_page_v2_v3() local
744 host->devtype_data->send_page(mtd, NFC_OUTPUT); in mxc_nand_read_page_v2_v3()
753 struct mxc_nand_host *host = nand_get_controller_data(chip); in mxc_nand_read_page() local
756 host->devtype_data->enable_hwecc(chip, true); in mxc_nand_read_page()
760 host->devtype_data->enable_hwecc(chip, false); in mxc_nand_read_page()
768 return host->devtype_data->get_ecc_status(chip); in mxc_nand_read_page()
790 struct mxc_nand_host *host = nand_get_controller_data(chip); in mxc_nand_read_oob() local
793 ret = nand_read_page_op(chip, page, 0, host->data_buf, mtd->writesize); in mxc_nand_read_oob()
806 struct mxc_nand_host *host = nand_get_controller_data(chip); in mxc_nand_write_page_ecc() local
811 host->devtype_data->enable_hwecc(chip, true); in mxc_nand_write_page_ecc()
815 host->devtype_data->enable_hwecc(chip, false); in mxc_nand_write_page_ecc()
833 struct mxc_nand_host *host = nand_get_controller_data(chip); in mxc_nand_write_oob() local
835 memset(host->data_buf, 0xff, mtd->writesize); in mxc_nand_write_oob()
838 return nand_prog_page_op(chip, page, 0, host->data_buf, mtd->writesize); in mxc_nand_write_oob()
845 struct mxc_nand_host *host = nand_get_controller_data(nand_chip); in mxc_nand_select_chip_v1_v3() local
849 if (host->clk_act) { in mxc_nand_select_chip_v1_v3()
850 clk_disable_unprepare(host->clk); in mxc_nand_select_chip_v1_v3()
851 host->clk_act = 0; in mxc_nand_select_chip_v1_v3()
856 if (!host->clk_act) { in mxc_nand_select_chip_v1_v3()
858 clk_prepare_enable(host->clk); in mxc_nand_select_chip_v1_v3()
859 host->clk_act = 1; in mxc_nand_select_chip_v1_v3()
865 struct mxc_nand_host *host = nand_get_controller_data(nand_chip); in mxc_nand_select_chip_v2() local
869 if (host->clk_act) { in mxc_nand_select_chip_v2()
870 clk_disable_unprepare(host->clk); in mxc_nand_select_chip_v2()
871 host->clk_act = 0; in mxc_nand_select_chip_v2()
876 if (!host->clk_act) { in mxc_nand_select_chip_v2()
878 clk_prepare_enable(host->clk); in mxc_nand_select_chip_v2()
879 host->clk_act = 1; in mxc_nand_select_chip_v2()
882 host->active_cs = chip; in mxc_nand_select_chip_v2()
883 writew(host->active_cs << 4, NFC_V1_V2_BUF_ADDR); in mxc_nand_select_chip_v2()
1000 struct mxc_nand_host *host = nand_get_controller_data(nand_chip); in preset_v1() local
1007 if (!host->devtype_data->irqpending_quirk) in preset_v1()
1010 host->eccsize = 1; in preset_v1()
1029 struct mxc_nand_host *host = nand_get_controller_data(chip); in mxc_nand_v2_setup_interface() local
1051 rate_round = clk_round_rate(host->clk, rate); in mxc_nand_v2_setup_interface()
1056 rate_round = clk_round_rate(host->clk, rate); in mxc_nand_v2_setup_interface()
1080 dev_dbg(host->dev, "Timing out of bounds\n"); in mxc_nand_v2_setup_interface()
1087 ret = clk_set_rate(host->clk, rate); in mxc_nand_v2_setup_interface()
1093 dev_dbg(host->dev, "Setting rate to %ldHz, %s mode\n", rate_round, in mxc_nand_v2_setup_interface()
1103 struct mxc_nand_host *host = nand_get_controller_data(nand_chip); in preset_v2() local
1108 if (!host->devtype_data->irqpending_quirk) in preset_v2()
1117 host->eccsize = get_eccsize(mtd); in preset_v2()
1118 if (host->eccsize == 4) in preset_v2()
1123 host->eccsize = 1; in preset_v2()
1152 struct mxc_nand_host *host = nand_get_controller_data(chip); in preset_v3() local
1195 host->devtype_data->ppb_shift); in preset_v3()
1196 host->eccsize = get_eccsize(mtd); in preset_v3()
1197 if (host->eccsize == 8) in preset_v3()
1371 static inline int is_imx21_nfc(struct mxc_nand_host *host) in is_imx21_nfc() argument
1373 return host->devtype_data == &imx21_nand_devtype_data; in is_imx21_nfc()
1376 static inline int is_imx27_nfc(struct mxc_nand_host *host) in is_imx27_nfc() argument
1378 return host->devtype_data == &imx27_nand_devtype_data; in is_imx27_nfc()
1381 static inline int is_imx25_nfc(struct mxc_nand_host *host) in is_imx25_nfc() argument
1383 return host->devtype_data == &imx25_nand_devtype_data; in is_imx25_nfc()
1399 struct mxc_nand_host *host = nand_get_controller_data(chip); in mxcnd_attach_chip() local
1402 chip->ecc.bytes = host->devtype_data->eccbytes; in mxcnd_attach_chip()
1403 host->eccsize = host->devtype_data->eccsize; in mxcnd_attach_chip()
1408 mtd_set_ooblayout(mtd, host->devtype_data->ooblayout); in mxcnd_attach_chip()
1432 devm_kfree(dev, (void *)host->data_buf); in mxcnd_attach_chip()
1433 host->data_buf = devm_kzalloc(dev, mtd->writesize + mtd->oobsize, in mxcnd_attach_chip()
1435 if (!host->data_buf) in mxcnd_attach_chip()
1439 host->devtype_data->preset(mtd); in mxcnd_attach_chip()
1442 if (host->eccsize == 8) in mxcnd_attach_chip()
1444 else if (host->eccsize == 4) in mxcnd_attach_chip()
1455 host->used_oobsize = min(mtd->oobsize, 218U); in mxcnd_attach_chip()
1458 if (is_imx21_nfc(host) || is_imx27_nfc(host)) in mxcnd_attach_chip()
1461 chip->ecc.strength = (host->eccsize == 4) ? 4 : 8; in mxcnd_attach_chip()
1470 struct mxc_nand_host *host = nand_get_controller_data(chip); in mxcnd_setup_interface() local
1472 return host->devtype_data->setup_interface(chip, chipnr, conf); in mxcnd_setup_interface()
1487 struct mxc_nand_host *host = nand_get_controller_data(this); in copy_page_to_sram() local
1511 memcpy16_toio(host->main_area0 + i * 512, buf, now); in copy_page_to_sram()
1514 memff16_toio(host->main_area0 + i * 512 + now, 512 - now); in copy_page_to_sram()
1521 memcpy16_toio(host->spare0 + i * host->devtype_data->spare_len, in copy_page_to_sram()
1525 memff16_toio(host->spare0 + i * host->devtype_data->spare_len + now, in copy_page_to_sram()
1536 struct mxc_nand_host *host = nand_get_controller_data(this); in copy_page_from_sram() local
1537 void *buf = host->data_buf; in copy_page_from_sram()
1548 memcpy16_fromio(buf, host->main_area0 + i * 512, 512); in copy_page_from_sram()
1551 memcpy16_fromio(buf, host->spare0 + i * host->devtype_data->spare_len, in copy_page_from_sram()
1560 struct mxc_nand_host *host = nand_get_controller_data(chip); in mxcnd_do_exec_op() local
1577 host->devtype_data->send_cmd(host, instr->ctx.cmd.opcode, true); in mxcnd_do_exec_op()
1588 host->devtype_data->send_addr(host, instr->ctx.addr.addrs[j], islast); in mxcnd_do_exec_op()
1596 memcpy32_toio(host->main_area0, buf_write, buf_len); in mxcnd_do_exec_op()
1600 host->devtype_data->send_page(mtd, NFC_INPUT); in mxcnd_do_exec_op()
1609 host->devtype_data->send_read_id(host); in mxcnd_do_exec_op()
1612 memcpy32_fromio(host->data_buf, host->main_area0, buf_len * 2); in mxcnd_do_exec_op()
1616 u16 *bufw = host->data_buf; in mxcnd_do_exec_op()
1620 memcpy(buf_read, host->data_buf, buf_len); in mxcnd_do_exec_op()
1626 *(u8*)buf_read = host->devtype_data->get_dev_status(host); in mxcnd_do_exec_op()
1631 host->devtype_data->read_page(chip); in mxcnd_do_exec_op()
1635 memcpy32_fromio(buf_read, host->main_area0, buf_len); in mxcnd_do_exec_op()
1637 memcpy32_fromio(host->data_buf, host->main_area0, mtd->writesize); in mxcnd_do_exec_op()
1638 memcpy(buf_read, host->data_buf, buf_len); in mxcnd_do_exec_op()
1642 memcpy(buf_read, host->data_buf, buf_len); in mxcnd_do_exec_op()
1692 struct mxc_nand_host *host; in mxcnd_probe() local
1696 host = devm_kzalloc(&pdev->dev, sizeof(struct mxc_nand_host), in mxcnd_probe()
1698 if (!host) in mxcnd_probe()
1702 host->data_buf = devm_kzalloc(&pdev->dev, PAGE_SIZE, GFP_KERNEL); in mxcnd_probe()
1703 if (!host->data_buf) in mxcnd_probe()
1706 host->dev = &pdev->dev; in mxcnd_probe()
1708 this = &host->nand; in mxcnd_probe()
1716 nand_set_controller_data(this, host); in mxcnd_probe()
1719 host->clk = devm_clk_get(&pdev->dev, NULL); in mxcnd_probe()
1720 if (IS_ERR(host->clk)) in mxcnd_probe()
1721 return PTR_ERR(host->clk); in mxcnd_probe()
1723 host->devtype_data = device_get_match_data(&pdev->dev); in mxcnd_probe()
1725 if (!host->devtype_data->setup_interface) in mxcnd_probe()
1728 if (host->devtype_data->needs_ip) { in mxcnd_probe()
1729 host->regs_ip = devm_platform_ioremap_resource(pdev, 0); in mxcnd_probe()
1730 if (IS_ERR(host->regs_ip)) in mxcnd_probe()
1731 return PTR_ERR(host->regs_ip); in mxcnd_probe()
1733 host->base = devm_platform_ioremap_resource(pdev, 1); in mxcnd_probe()
1735 host->base = devm_platform_ioremap_resource(pdev, 0); in mxcnd_probe()
1738 if (IS_ERR(host->base)) in mxcnd_probe()
1739 return PTR_ERR(host->base); in mxcnd_probe()
1741 host->main_area0 = host->base; in mxcnd_probe()
1743 if (host->devtype_data->regs_offset) in mxcnd_probe()
1744 host->regs = host->base + host->devtype_data->regs_offset; in mxcnd_probe()
1745 host->spare0 = host->base + host->devtype_data->spare0_offset; in mxcnd_probe()
1746 if (host->devtype_data->axi_offset) in mxcnd_probe()
1747 host->regs_axi = host->base + host->devtype_data->axi_offset; in mxcnd_probe()
1749 this->legacy.select_chip = host->devtype_data->select_chip; in mxcnd_probe()
1751 init_completion(&host->op_completion); in mxcnd_probe()
1753 host->irq = platform_get_irq(pdev, 0); in mxcnd_probe()
1754 if (host->irq < 0) in mxcnd_probe()
1755 return host->irq; in mxcnd_probe()
1758 * Use host->devtype_data->irq_control() here instead of irq_control() in mxcnd_probe()
1762 host->devtype_data->irq_control(host, 0); in mxcnd_probe()
1764 err = devm_request_irq(&pdev->dev, host->irq, mxc_nfc_irq, in mxcnd_probe()
1765 0, DRIVER_NAME, host); in mxcnd_probe()
1769 err = clk_prepare_enable(host->clk); in mxcnd_probe()
1772 host->clk_act = 1; in mxcnd_probe()
1779 if (host->devtype_data->irqpending_quirk) { in mxcnd_probe()
1780 disable_irq_nosync(host->irq); in mxcnd_probe()
1781 host->devtype_data->irq_control(host, 1); in mxcnd_probe()
1786 err = nand_scan(this, is_imx25_nfc(host) ? 4 : 1); in mxcnd_probe()
1795 platform_set_drvdata(pdev, host); in mxcnd_probe()
1802 if (host->clk_act) in mxcnd_probe()
1803 clk_disable_unprepare(host->clk); in mxcnd_probe()
1810 struct mxc_nand_host *host = platform_get_drvdata(pdev); in mxcnd_remove() local
1811 struct nand_chip *chip = &host->nand; in mxcnd_remove()
1817 if (host->clk_act) in mxcnd_remove()
1818 clk_disable_unprepare(host->clk); in mxcnd_remove()