Lines Matching refs:host

45 #define NFC_V1_V2_BUF_SIZE		(host->regs + 0x00)
46 #define NFC_V1_V2_BUF_ADDR (host->regs + 0x04)
47 #define NFC_V1_V2_FLASH_ADDR (host->regs + 0x06)
48 #define NFC_V1_V2_FLASH_CMD (host->regs + 0x08)
49 #define NFC_V1_V2_CONFIG (host->regs + 0x0a)
50 #define NFC_V1_V2_ECC_STATUS_RESULT (host->regs + 0x0c)
51 #define NFC_V1_V2_RSLTMAIN_AREA (host->regs + 0x0e)
52 #define NFC_V1_V2_RSLTSPARE_AREA (host->regs + 0x10)
53 #define NFC_V1_V2_WRPROT (host->regs + 0x12)
54 #define NFC_V1_UNLOCKSTART_BLKADDR (host->regs + 0x14)
55 #define NFC_V1_UNLOCKEND_BLKADDR (host->regs + 0x16)
56 #define NFC_V21_UNLOCKSTART_BLKADDR0 (host->regs + 0x20)
57 #define NFC_V21_UNLOCKSTART_BLKADDR1 (host->regs + 0x24)
58 #define NFC_V21_UNLOCKSTART_BLKADDR2 (host->regs + 0x28)
59 #define NFC_V21_UNLOCKSTART_BLKADDR3 (host->regs + 0x2c)
60 #define NFC_V21_UNLOCKEND_BLKADDR0 (host->regs + 0x22)
61 #define NFC_V21_UNLOCKEND_BLKADDR1 (host->regs + 0x26)
62 #define NFC_V21_UNLOCKEND_BLKADDR2 (host->regs + 0x2a)
63 #define NFC_V21_UNLOCKEND_BLKADDR3 (host->regs + 0x2e)
64 #define NFC_V1_V2_NF_WRPRST (host->regs + 0x18)
65 #define NFC_V1_V2_CONFIG1 (host->regs + 0x1a)
66 #define NFC_V1_V2_CONFIG2 (host->regs + 0x1c)
92 #define NFC_V3_FLASH_CMD (host->regs_axi + 0x00)
93 #define NFC_V3_FLASH_ADDR0 (host->regs_axi + 0x04)
95 #define NFC_V3_CONFIG1 (host->regs_axi + 0x34)
99 #define NFC_V3_ECC_STATUS_RESULT (host->regs_axi + 0x38)
101 #define NFC_V3_LAUNCH (host->regs_axi + 0x40)
103 #define NFC_V3_WRPROT (host->regs_ip + 0x0)
109 #define NFC_V3_WRPROT_UNLOCK_BLK_ADD0 (host->regs_ip + 0x04)
111 #define NFC_V3_CONFIG2 (host->regs_ip + 0x24)
126 #define NFC_V3_CONFIG3 (host->regs_ip + 0x28)
134 #define NFC_V3_IPC (host->regs_ip + 0x2C)
138 #define NFC_V3_DELAY_LINE (host->regs_ip + 0x34)
322 static int check_int_v3(struct mxc_nand_host *host) in check_int_v3() argument
336 static int check_int_v1_v2(struct mxc_nand_host *host) in check_int_v1_v2() argument
344 if (!host->devtype_data->irqpending_quirk) in check_int_v1_v2()
350 static void irq_control_v1_v2(struct mxc_nand_host *host, int activate) in irq_control_v1_v2() argument
364 static void irq_control_v3(struct mxc_nand_host *host, int activate) in irq_control_v3() argument
378 static void irq_control(struct mxc_nand_host *host, int activate) in irq_control() argument
380 if (host->devtype_data->irqpending_quirk) { in irq_control()
382 enable_irq(host->irq); in irq_control()
384 disable_irq_nosync(host->irq); in irq_control()
386 host->devtype_data->irq_control(host, activate); in irq_control()
390 static u32 get_ecc_status_v1(struct mxc_nand_host *host) in get_ecc_status_v1() argument
395 static u32 get_ecc_status_v2(struct mxc_nand_host *host) in get_ecc_status_v2() argument
400 static u32 get_ecc_status_v3(struct mxc_nand_host *host) in get_ecc_status_v3() argument
407 struct mxc_nand_host *host = dev_id; in mxc_nfc_irq() local
409 if (!host->devtype_data->check_int(host)) in mxc_nfc_irq()
412 irq_control(host, 0); in mxc_nfc_irq()
414 complete(&host->op_completion); in mxc_nfc_irq()
422 static int wait_op_done(struct mxc_nand_host *host, int useirq) in wait_op_done() argument
430 if (host->devtype_data->check_int(host)) in wait_op_done()
436 reinit_completion(&host->op_completion); in wait_op_done()
438 irq_control(host, 1); in wait_op_done()
440 timeout = wait_for_completion_timeout(&host->op_completion, HZ); in wait_op_done()
441 if (!timeout && !host->devtype_data->check_int(host)) { in wait_op_done()
442 dev_dbg(host->dev, "timeout waiting for irq\n"); in wait_op_done()
452 done = host->devtype_data->check_int(host); in wait_op_done()
459 dev_dbg(host->dev, "timeout polling for completion\n"); in wait_op_done()
469 static void send_cmd_v3(struct mxc_nand_host *host, uint16_t cmd, int useirq) in send_cmd_v3() argument
478 wait_op_done(host, useirq); in send_cmd_v3()
483 static void send_cmd_v1_v2(struct mxc_nand_host *host, uint16_t cmd, int useirq) in send_cmd_v1_v2() argument
490 if (host->devtype_data->irqpending_quirk && (cmd == NAND_CMD_RESET)) { in send_cmd_v1_v2()
504 wait_op_done(host, useirq); in send_cmd_v1_v2()
508 static void send_addr_v3(struct mxc_nand_host *host, uint16_t addr, int islast) in send_addr_v3() argument
516 wait_op_done(host, 0); in send_addr_v3()
522 static void send_addr_v1_v2(struct mxc_nand_host *host, uint16_t addr, int islast) in send_addr_v1_v2() argument
530 wait_op_done(host, islast); in send_addr_v1_v2()
536 struct mxc_nand_host *host = nand_chip->priv; in send_page_v3() local
546 wait_op_done(host, false); in send_page_v3()
552 struct mxc_nand_host *host = nand_chip->priv; in send_page_v2() local
555 writew(host->active_cs << 4, NFC_V1_V2_BUF_ADDR); in send_page_v2()
560 wait_op_done(host, true); in send_page_v2()
566 struct mxc_nand_host *host = nand_chip->priv; in send_page_v1() local
577 writew((host->active_cs << 4) | i, NFC_V1_V2_BUF_ADDR); in send_page_v1()
582 wait_op_done(host, true); in send_page_v1()
586 static void send_read_id_v3(struct mxc_nand_host *host) in send_read_id_v3() argument
591 wait_op_done(host, true); in send_read_id_v3()
593 memcpy32_fromio(host->data_buf, host->main_area0, 16); in send_read_id_v3()
597 static void send_read_id_v1_v2(struct mxc_nand_host *host) in send_read_id_v1_v2() argument
600 writew(host->active_cs << 4, NFC_V1_V2_BUF_ADDR); in send_read_id_v1_v2()
605 wait_op_done(host, true); in send_read_id_v1_v2()
607 memcpy32_fromio(host->data_buf, host->main_area0, 16); in send_read_id_v1_v2()
610 static uint16_t get_dev_status_v3(struct mxc_nand_host *host) in get_dev_status_v3() argument
613 wait_op_done(host, true); in get_dev_status_v3()
620 static uint16_t get_dev_status_v1_v2(struct mxc_nand_host *host) in get_dev_status_v1_v2() argument
622 void __iomem *main_buf = host->main_area0; in get_dev_status_v1_v2()
626 writew(host->active_cs << 4, NFC_V1_V2_BUF_ADDR); in get_dev_status_v1_v2()
636 wait_op_done(host, true); in get_dev_status_v1_v2()
667 struct mxc_nand_host *host = nand_chip->priv; in mxc_nand_correct_data_v1() local
674 uint16_t ecc_status = get_ecc_status_v1(host); in mxc_nand_correct_data_v1()
688 struct mxc_nand_host *host = nand_chip->priv; in mxc_nand_correct_data_v2_v3() local
694 ecc_bit_mask = (host->eccsize == 4) ? 0x7 : 0xf; in mxc_nand_correct_data_v2_v3()
695 err_limit = (host->eccsize == 4) ? 0x4 : 0x8; in mxc_nand_correct_data_v2_v3()
699 ecc_stat = host->devtype_data->get_ecc_status(host); in mxc_nand_correct_data_v2_v3()
726 struct mxc_nand_host *host = nand_chip->priv; in mxc_nand_read_byte() local
730 if (host->status_request) in mxc_nand_read_byte()
731 return host->devtype_data->get_dev_status(host) & 0xFF; in mxc_nand_read_byte()
735 ret = *(uint16_t *)(host->data_buf + host->buf_start); in mxc_nand_read_byte()
737 host->buf_start += 2; in mxc_nand_read_byte()
739 ret = *(uint8_t *)(host->data_buf + host->buf_start); in mxc_nand_read_byte()
740 host->buf_start++; in mxc_nand_read_byte()
743 pr_debug("%s: ret=0x%hhx (start=%u)\n", __func__, ret, host->buf_start); in mxc_nand_read_byte()
750 struct mxc_nand_host *host = nand_chip->priv; in mxc_nand_read_word() local
753 ret = *(uint16_t *)(host->data_buf + host->buf_start); in mxc_nand_read_word()
754 host->buf_start += 2; in mxc_nand_read_word()
766 struct mxc_nand_host *host = nand_chip->priv; in mxc_nand_write_buf() local
767 u16 col = host->buf_start; in mxc_nand_write_buf()
772 memcpy(host->data_buf + col, buf, n); in mxc_nand_write_buf()
774 host->buf_start += n; in mxc_nand_write_buf()
784 struct mxc_nand_host *host = nand_chip->priv; in mxc_nand_read_buf() local
785 u16 col = host->buf_start; in mxc_nand_read_buf()
790 memcpy(buf, host->data_buf + col, n); in mxc_nand_read_buf()
792 host->buf_start += n; in mxc_nand_read_buf()
800 struct mxc_nand_host *host = nand_chip->priv; in mxc_nand_select_chip_v1_v3() local
804 if (host->clk_act) { in mxc_nand_select_chip_v1_v3()
805 clk_disable_unprepare(host->clk); in mxc_nand_select_chip_v1_v3()
806 host->clk_act = 0; in mxc_nand_select_chip_v1_v3()
811 if (!host->clk_act) { in mxc_nand_select_chip_v1_v3()
813 clk_prepare_enable(host->clk); in mxc_nand_select_chip_v1_v3()
814 host->clk_act = 1; in mxc_nand_select_chip_v1_v3()
821 struct mxc_nand_host *host = nand_chip->priv; in mxc_nand_select_chip_v2() local
825 if (host->clk_act) { in mxc_nand_select_chip_v2()
826 clk_disable_unprepare(host->clk); in mxc_nand_select_chip_v2()
827 host->clk_act = 0; in mxc_nand_select_chip_v2()
832 if (!host->clk_act) { in mxc_nand_select_chip_v2()
834 clk_prepare_enable(host->clk); in mxc_nand_select_chip_v2()
835 host->clk_act = 1; in mxc_nand_select_chip_v2()
838 host->active_cs = chip; in mxc_nand_select_chip_v2()
839 writew(host->active_cs << 4, NFC_V1_V2_BUF_ADDR); in mxc_nand_select_chip_v2()
854 struct mxc_nand_host *host = this->priv; in copy_spare() local
858 u8 *d = host->data_buf + mtd->writesize; in copy_spare()
859 u8 __iomem *s = host->spare0; in copy_spare()
860 u16 sparebuf_size = host->devtype_data->spare_len; in copy_spare()
863 oob_chunk_size = (host->used_oobsize / num_chunks) & ~1; in copy_spare()
874 host->used_oobsize - i * oob_chunk_size); in copy_spare()
884 host->used_oobsize - i * oob_chunk_size); in copy_spare()
897 struct mxc_nand_host *host = nand_chip->priv; in mxc_do_addr_cycle() local
901 host->devtype_data->send_addr(host, column & 0xff, in mxc_do_addr_cycle()
905 host->devtype_data->send_addr(host, in mxc_do_addr_cycle()
913 host->devtype_data->send_addr(host, (page_addr & 0xff), false); in mxc_do_addr_cycle()
918 host->devtype_data->send_addr(host, in mxc_do_addr_cycle()
921 host->devtype_data->send_addr(host, in mxc_do_addr_cycle()
926 host->devtype_data->send_addr(host, in mxc_do_addr_cycle()
932 host->devtype_data->send_addr(host, in mxc_do_addr_cycle()
935 host->devtype_data->send_addr(host, in mxc_do_addr_cycle()
940 host->devtype_data->send_addr(host, in mxc_do_addr_cycle()
983 struct mxc_nand_host *host = nand_chip->priv; in preset_v1() local
989 if (!host->devtype_data->irqpending_quirk) in preset_v1()
992 host->eccsize = 1; in preset_v1()
1011 struct mxc_nand_host *host = nand_chip->priv; in preset_v2() local
1016 if (!host->devtype_data->irqpending_quirk) in preset_v2()
1025 host->eccsize = get_eccsize(mtd); in preset_v2()
1026 if (host->eccsize == 4) in preset_v2()
1031 host->eccsize = 1; in preset_v2()
1057 struct mxc_nand_host *host = chip->priv; in preset_v3() local
1101 host->devtype_data->ppb_shift); in preset_v3()
1102 host->eccsize = get_eccsize(mtd); in preset_v3()
1103 if (host->eccsize == 8) in preset_v3()
1129 struct mxc_nand_host *host = nand_chip->priv; in mxc_nand_command() local
1135 host->status_request = false; in mxc_nand_command()
1140 host->devtype_data->preset(mtd); in mxc_nand_command()
1141 host->devtype_data->send_cmd(host, command, false); in mxc_nand_command()
1145 host->buf_start = 0; in mxc_nand_command()
1146 host->status_request = true; in mxc_nand_command()
1148 host->devtype_data->send_cmd(host, command, true); in mxc_nand_command()
1158 host->buf_start = column; in mxc_nand_command()
1160 host->buf_start = column + mtd->writesize; in mxc_nand_command()
1164 host->devtype_data->send_cmd(host, command, false); in mxc_nand_command()
1171 host->devtype_data->send_cmd(host, in mxc_nand_command()
1174 host->devtype_data->send_page(mtd, NFC_OUTPUT); in mxc_nand_command()
1176 memcpy32_fromio(host->data_buf, host->main_area0, in mxc_nand_command()
1186 host->buf_start = column; in mxc_nand_command()
1188 host->devtype_data->send_cmd(host, command, false); in mxc_nand_command()
1196 memcpy32_toio(host->main_area0, host->data_buf, mtd->writesize); in mxc_nand_command()
1198 host->devtype_data->send_page(mtd, NFC_INPUT); in mxc_nand_command()
1199 host->devtype_data->send_cmd(host, command, true); in mxc_nand_command()
1207 host->devtype_data->send_cmd(host, command, true); in mxc_nand_command()
1209 host->devtype_data->send_read_id(host); in mxc_nand_command()
1210 host->buf_start = 0; in mxc_nand_command()
1215 host->devtype_data->send_cmd(host, command, false); in mxc_nand_command()
1223 host->devtype_data->send_cmd(host, command, false); in mxc_nand_command()
1225 host->devtype_data->send_page(mtd, NFC_OUTPUT); in mxc_nand_command()
1226 memcpy32_fromio(host->data_buf, host->main_area0, 512); in mxc_nand_command()
1227 host->buf_start = 0; in mxc_nand_command()
1394 static inline int is_imx21_nfc(struct mxc_nand_host *host) in is_imx21_nfc() argument
1396 return host->devtype_data == &imx21_nand_devtype_data; in is_imx21_nfc()
1399 static inline int is_imx27_nfc(struct mxc_nand_host *host) in is_imx27_nfc() argument
1401 return host->devtype_data == &imx27_nand_devtype_data; in is_imx27_nfc()
1404 static inline int is_imx25_nfc(struct mxc_nand_host *host) in is_imx25_nfc() argument
1406 return host->devtype_data == &imx25_nand_devtype_data; in is_imx25_nfc()
1409 static inline int is_imx51_nfc(struct mxc_nand_host *host) in is_imx51_nfc() argument
1411 return host->devtype_data == &imx51_nand_devtype_data; in is_imx51_nfc()
1414 static inline int is_imx53_nfc(struct mxc_nand_host *host) in is_imx53_nfc() argument
1416 return host->devtype_data == &imx53_nand_devtype_data; in is_imx53_nfc()
1463 static int __init mxcnd_probe_dt(struct mxc_nand_host *host) in mxcnd_probe_dt() argument
1465 struct device_node *np = host->dev->of_node; in mxcnd_probe_dt()
1466 struct mxc_nand_platform_data *pdata = &host->pdata; in mxcnd_probe_dt()
1468 of_match_device(mxcnd_dt_ids, host->dev); in mxcnd_probe_dt()
1485 host->devtype_data = of_id->data; in mxcnd_probe_dt()
1490 static int __init mxcnd_probe_dt(struct mxc_nand_host *host) in mxcnd_probe_dt() argument
1500 struct mxc_nand_host *host; in mxcnd_probe() local
1505 host = devm_kzalloc(&pdev->dev, sizeof(struct mxc_nand_host), in mxcnd_probe()
1507 if (!host) in mxcnd_probe()
1511 host->data_buf = devm_kzalloc(&pdev->dev, PAGE_SIZE, GFP_KERNEL); in mxcnd_probe()
1512 if (!host->data_buf) in mxcnd_probe()
1515 host->dev = &pdev->dev; in mxcnd_probe()
1517 this = &host->nand; in mxcnd_probe()
1518 mtd = &host->mtd; in mxcnd_probe()
1526 this->priv = host; in mxcnd_probe()
1534 host->clk = devm_clk_get(&pdev->dev, NULL); in mxcnd_probe()
1535 if (IS_ERR(host->clk)) in mxcnd_probe()
1536 return PTR_ERR(host->clk); in mxcnd_probe()
1538 err = mxcnd_probe_dt(host); in mxcnd_probe()
1543 host->pdata = *pdata; in mxcnd_probe()
1544 host->devtype_data = (struct mxc_nand_devtype_data *) in mxcnd_probe()
1553 if (host->devtype_data->needs_ip) { in mxcnd_probe()
1555 host->regs_ip = devm_ioremap_resource(&pdev->dev, res); in mxcnd_probe()
1556 if (IS_ERR(host->regs_ip)) in mxcnd_probe()
1557 return PTR_ERR(host->regs_ip); in mxcnd_probe()
1564 host->base = devm_ioremap_resource(&pdev->dev, res); in mxcnd_probe()
1565 if (IS_ERR(host->base)) in mxcnd_probe()
1566 return PTR_ERR(host->base); in mxcnd_probe()
1568 host->main_area0 = host->base; in mxcnd_probe()
1570 if (host->devtype_data->regs_offset) in mxcnd_probe()
1571 host->regs = host->base + host->devtype_data->regs_offset; in mxcnd_probe()
1572 host->spare0 = host->base + host->devtype_data->spare0_offset; in mxcnd_probe()
1573 if (host->devtype_data->axi_offset) in mxcnd_probe()
1574 host->regs_axi = host->base + host->devtype_data->axi_offset; in mxcnd_probe()
1576 this->ecc.bytes = host->devtype_data->eccbytes; in mxcnd_probe()
1577 host->eccsize = host->devtype_data->eccsize; in mxcnd_probe()
1579 this->select_chip = host->devtype_data->select_chip; in mxcnd_probe()
1581 this->ecc.layout = host->devtype_data->ecclayout_512; in mxcnd_probe()
1583 if (host->pdata.hw_ecc) { in mxcnd_probe()
1586 this->ecc.correct = host->devtype_data->correct_data; in mxcnd_probe()
1593 if (host->pdata.width == 2) in mxcnd_probe()
1596 if (host->pdata.flash_bbt) { in mxcnd_probe()
1603 init_completion(&host->op_completion); in mxcnd_probe()
1605 host->irq = platform_get_irq(pdev, 0); in mxcnd_probe()
1606 if (host->irq < 0) in mxcnd_probe()
1607 return host->irq; in mxcnd_probe()
1614 host->devtype_data->irq_control(host, 0); in mxcnd_probe()
1616 err = devm_request_irq(&pdev->dev, host->irq, mxc_nfc_irq, in mxcnd_probe()
1617 0, DRIVER_NAME, host); in mxcnd_probe()
1621 err = clk_prepare_enable(host->clk); in mxcnd_probe()
1624 host->clk_act = 1; in mxcnd_probe()
1631 if (host->devtype_data->irqpending_quirk) { in mxcnd_probe()
1632 disable_irq_nosync(host->irq); in mxcnd_probe()
1633 host->devtype_data->irq_control(host, 1); in mxcnd_probe()
1637 if (nand_scan_ident(mtd, is_imx25_nfc(host) ? 4 : 1, NULL)) { in mxcnd_probe()
1643 devm_kfree(&pdev->dev, (void *)host->data_buf); in mxcnd_probe()
1644 host->data_buf = devm_kzalloc(&pdev->dev, mtd->writesize + mtd->oobsize, in mxcnd_probe()
1646 if (!host->data_buf) { in mxcnd_probe()
1652 host->devtype_data->preset(mtd); in mxcnd_probe()
1655 this->ecc.layout = host->devtype_data->ecclayout_2k; in mxcnd_probe()
1657 this->ecc.layout = host->devtype_data->ecclayout_4k; in mxcnd_probe()
1669 host->used_oobsize = min(mtd->oobsize, 218U); in mxcnd_probe()
1672 if (is_imx21_nfc(host) || is_imx27_nfc(host)) in mxcnd_probe()
1675 this->ecc.strength = (host->eccsize == 4) ? 4 : 8; in mxcnd_probe()
1689 host->pdata.parts, in mxcnd_probe()
1690 host->pdata.nr_parts); in mxcnd_probe()
1692 platform_set_drvdata(pdev, host); in mxcnd_probe()
1697 if (host->clk_act) in mxcnd_probe()
1698 clk_disable_unprepare(host->clk); in mxcnd_probe()
1705 struct mxc_nand_host *host = platform_get_drvdata(pdev); in mxcnd_remove() local
1707 nand_release(&host->mtd); in mxcnd_remove()
1708 if (host->clk_act) in mxcnd_remove()
1709 clk_disable_unprepare(host->clk); in mxcnd_remove()