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)
289 static int check_int_v3(struct mxc_nand_host *host) in check_int_v3() argument
303 static int check_int_v1_v2(struct mxc_nand_host *host) in check_int_v1_v2() argument
311 if (!host->devtype_data->irqpending_quirk) in check_int_v1_v2()
317 static void irq_control_v1_v2(struct mxc_nand_host *host, int activate) in irq_control_v1_v2() argument
331 static void irq_control_v3(struct mxc_nand_host *host, int activate) in irq_control_v3() argument
345 static void irq_control(struct mxc_nand_host *host, int activate) in irq_control() argument
347 if (host->devtype_data->irqpending_quirk) { in irq_control()
349 enable_irq(host->irq); in irq_control()
351 disable_irq_nosync(host->irq); in irq_control()
353 host->devtype_data->irq_control(host, activate); in irq_control()
357 static u32 get_ecc_status_v1(struct mxc_nand_host *host) in get_ecc_status_v1() argument
362 static u32 get_ecc_status_v2(struct mxc_nand_host *host) in get_ecc_status_v2() argument
367 static u32 get_ecc_status_v3(struct mxc_nand_host *host) in get_ecc_status_v3() argument
374 struct mxc_nand_host *host = dev_id; in mxc_nfc_irq() local
376 if (!host->devtype_data->check_int(host)) in mxc_nfc_irq()
379 irq_control(host, 0); in mxc_nfc_irq()
381 complete(&host->op_completion); in mxc_nfc_irq()
389 static int wait_op_done(struct mxc_nand_host *host, int useirq) in wait_op_done() argument
397 if (host->devtype_data->check_int(host)) in wait_op_done()
403 reinit_completion(&host->op_completion); in wait_op_done()
405 irq_control(host, 1); in wait_op_done()
407 timeout = wait_for_completion_timeout(&host->op_completion, HZ); in wait_op_done()
408 if (!timeout && !host->devtype_data->check_int(host)) { in wait_op_done()
409 dev_dbg(host->dev, "timeout waiting for irq\n"); in wait_op_done()
419 done = host->devtype_data->check_int(host); in wait_op_done()
426 dev_dbg(host->dev, "timeout polling for completion\n"); in wait_op_done()
436 static void send_cmd_v3(struct mxc_nand_host *host, uint16_t cmd, int useirq) in send_cmd_v3() argument
445 wait_op_done(host, useirq); in send_cmd_v3()
450 static void send_cmd_v1_v2(struct mxc_nand_host *host, uint16_t cmd, int useirq) in send_cmd_v1_v2() argument
457 if (host->devtype_data->irqpending_quirk && (cmd == NAND_CMD_RESET)) { in send_cmd_v1_v2()
471 wait_op_done(host, useirq); in send_cmd_v1_v2()
475 static void send_addr_v3(struct mxc_nand_host *host, uint16_t addr, int islast) in send_addr_v3() argument
483 wait_op_done(host, 0); in send_addr_v3()
489 static void send_addr_v1_v2(struct mxc_nand_host *host, uint16_t addr, int islast) in send_addr_v1_v2() argument
497 wait_op_done(host, islast); in send_addr_v1_v2()
503 struct mxc_nand_host *host = nand_chip->priv; in send_page_v3() local
513 wait_op_done(host, false); in send_page_v3()
519 struct mxc_nand_host *host = nand_chip->priv; in send_page_v2() local
522 writew(host->active_cs << 4, NFC_V1_V2_BUF_ADDR); in send_page_v2()
527 wait_op_done(host, true); in send_page_v2()
533 struct mxc_nand_host *host = nand_chip->priv; in send_page_v1() local
544 writew((host->active_cs << 4) | i, NFC_V1_V2_BUF_ADDR); in send_page_v1()
549 wait_op_done(host, true); in send_page_v1()
553 static void send_read_id_v3(struct mxc_nand_host *host) in send_read_id_v3() argument
558 wait_op_done(host, true); in send_read_id_v3()
560 memcpy32_fromio(host->data_buf, host->main_area0, 16); in send_read_id_v3()
564 static void send_read_id_v1_v2(struct mxc_nand_host *host) in send_read_id_v1_v2() argument
567 writew(host->active_cs << 4, NFC_V1_V2_BUF_ADDR); in send_read_id_v1_v2()
572 wait_op_done(host, true); in send_read_id_v1_v2()
574 memcpy32_fromio(host->data_buf, host->main_area0, 16); in send_read_id_v1_v2()
577 static uint16_t get_dev_status_v3(struct mxc_nand_host *host) in get_dev_status_v3() argument
580 wait_op_done(host, true); in get_dev_status_v3()
587 static uint16_t get_dev_status_v1_v2(struct mxc_nand_host *host) in get_dev_status_v1_v2() argument
589 void __iomem *main_buf = host->main_area0; in get_dev_status_v1_v2()
593 writew(host->active_cs << 4, NFC_V1_V2_BUF_ADDR); in get_dev_status_v1_v2()
603 wait_op_done(host, true); in get_dev_status_v1_v2()
634 struct mxc_nand_host *host = nand_chip->priv; in mxc_nand_correct_data_v1() local
641 uint16_t ecc_status = get_ecc_status_v1(host); in mxc_nand_correct_data_v1()
655 struct mxc_nand_host *host = nand_chip->priv; in mxc_nand_correct_data_v2_v3() local
661 ecc_bit_mask = (host->eccsize == 4) ? 0x7 : 0xf; in mxc_nand_correct_data_v2_v3()
662 err_limit = (host->eccsize == 4) ? 0x4 : 0x8; in mxc_nand_correct_data_v2_v3()
666 ecc_stat = host->devtype_data->get_ecc_status(host); in mxc_nand_correct_data_v2_v3()
693 struct mxc_nand_host *host = nand_chip->priv; in mxc_nand_read_byte() local
697 if (host->status_request) in mxc_nand_read_byte()
698 return host->devtype_data->get_dev_status(host) & 0xFF; in mxc_nand_read_byte()
702 ret = *(uint16_t *)(host->data_buf + host->buf_start); in mxc_nand_read_byte()
704 host->buf_start += 2; in mxc_nand_read_byte()
706 ret = *(uint8_t *)(host->data_buf + host->buf_start); in mxc_nand_read_byte()
707 host->buf_start++; in mxc_nand_read_byte()
710 pr_debug("%s: ret=0x%hhx (start=%u)\n", __func__, ret, host->buf_start); in mxc_nand_read_byte()
717 struct mxc_nand_host *host = nand_chip->priv; in mxc_nand_read_word() local
720 ret = *(uint16_t *)(host->data_buf + host->buf_start); in mxc_nand_read_word()
721 host->buf_start += 2; in mxc_nand_read_word()
733 struct mxc_nand_host *host = nand_chip->priv; in mxc_nand_write_buf() local
734 u16 col = host->buf_start; in mxc_nand_write_buf()
739 memcpy(host->data_buf + col, buf, n); in mxc_nand_write_buf()
741 host->buf_start += n; in mxc_nand_write_buf()
751 struct mxc_nand_host *host = nand_chip->priv; in mxc_nand_read_buf() local
752 u16 col = host->buf_start; in mxc_nand_read_buf()
757 memcpy(buf, host->data_buf + col, n); in mxc_nand_read_buf()
759 host->buf_start += n; in mxc_nand_read_buf()
767 struct mxc_nand_host *host = nand_chip->priv; in mxc_nand_select_chip_v1_v3() local
771 if (host->clk_act) { in mxc_nand_select_chip_v1_v3()
772 clk_disable_unprepare(host->clk); in mxc_nand_select_chip_v1_v3()
773 host->clk_act = 0; in mxc_nand_select_chip_v1_v3()
778 if (!host->clk_act) { in mxc_nand_select_chip_v1_v3()
780 clk_prepare_enable(host->clk); in mxc_nand_select_chip_v1_v3()
781 host->clk_act = 1; in mxc_nand_select_chip_v1_v3()
788 struct mxc_nand_host *host = nand_chip->priv; in mxc_nand_select_chip_v2() local
792 if (host->clk_act) { in mxc_nand_select_chip_v2()
793 clk_disable_unprepare(host->clk); in mxc_nand_select_chip_v2()
794 host->clk_act = 0; in mxc_nand_select_chip_v2()
799 if (!host->clk_act) { in mxc_nand_select_chip_v2()
801 clk_prepare_enable(host->clk); in mxc_nand_select_chip_v2()
802 host->clk_act = 1; in mxc_nand_select_chip_v2()
805 host->active_cs = chip; in mxc_nand_select_chip_v2()
806 writew(host->active_cs << 4, NFC_V1_V2_BUF_ADDR); in mxc_nand_select_chip_v2()
815 struct mxc_nand_host *host = this->priv; in copy_spare() local
818 u8 *d = host->data_buf + mtd->writesize; in copy_spare()
819 u8 __iomem *s = host->spare0; in copy_spare()
820 u16 t = host->devtype_data->spare_len; in copy_spare()
848 struct mxc_nand_host *host = nand_chip->priv; in mxc_do_addr_cycle() local
852 host->devtype_data->send_addr(host, column & 0xff, in mxc_do_addr_cycle()
856 host->devtype_data->send_addr(host, in mxc_do_addr_cycle()
864 host->devtype_data->send_addr(host, (page_addr & 0xff), false); in mxc_do_addr_cycle()
869 host->devtype_data->send_addr(host, in mxc_do_addr_cycle()
872 host->devtype_data->send_addr(host, in mxc_do_addr_cycle()
877 host->devtype_data->send_addr(host, in mxc_do_addr_cycle()
883 host->devtype_data->send_addr(host, in mxc_do_addr_cycle()
886 host->devtype_data->send_addr(host, in mxc_do_addr_cycle()
891 host->devtype_data->send_addr(host, in mxc_do_addr_cycle()
917 struct mxc_nand_host *host = nand_chip->priv; in preset_v1() local
923 if (!host->devtype_data->irqpending_quirk) in preset_v1()
926 host->eccsize = 1; in preset_v1()
945 struct mxc_nand_host *host = nand_chip->priv; in preset_v2() local
950 if (!host->devtype_data->irqpending_quirk) in preset_v2()
959 host->eccsize = get_eccsize(mtd); in preset_v2()
960 if (host->eccsize == 4) in preset_v2()
965 host->eccsize = 1; in preset_v2()
991 struct mxc_nand_host *host = chip->priv; in preset_v3() local
1035 host->devtype_data->ppb_shift); in preset_v3()
1036 host->eccsize = get_eccsize(mtd); in preset_v3()
1037 if (host->eccsize == 8) in preset_v3()
1063 struct mxc_nand_host *host = nand_chip->priv; in mxc_nand_command() local
1069 host->status_request = false; in mxc_nand_command()
1074 host->devtype_data->preset(mtd); in mxc_nand_command()
1075 host->devtype_data->send_cmd(host, command, false); in mxc_nand_command()
1079 host->buf_start = 0; in mxc_nand_command()
1080 host->status_request = true; in mxc_nand_command()
1082 host->devtype_data->send_cmd(host, command, true); in mxc_nand_command()
1092 host->buf_start = column; in mxc_nand_command()
1094 host->buf_start = column + mtd->writesize; in mxc_nand_command()
1098 host->devtype_data->send_cmd(host, command, false); in mxc_nand_command()
1105 host->devtype_data->send_cmd(host, in mxc_nand_command()
1108 host->devtype_data->send_page(mtd, NFC_OUTPUT); in mxc_nand_command()
1110 memcpy32_fromio(host->data_buf, host->main_area0, in mxc_nand_command()
1120 host->buf_start = column; in mxc_nand_command()
1122 host->devtype_data->send_cmd(host, command, false); in mxc_nand_command()
1130 memcpy32_toio(host->main_area0, host->data_buf, mtd->writesize); in mxc_nand_command()
1132 host->devtype_data->send_page(mtd, NFC_INPUT); in mxc_nand_command()
1133 host->devtype_data->send_cmd(host, command, true); in mxc_nand_command()
1141 host->devtype_data->send_cmd(host, command, true); in mxc_nand_command()
1143 host->devtype_data->send_read_id(host); in mxc_nand_command()
1144 host->buf_start = 0; in mxc_nand_command()
1149 host->devtype_data->send_cmd(host, command, false); in mxc_nand_command()
1157 host->devtype_data->send_cmd(host, command, false); in mxc_nand_command()
1159 host->devtype_data->send_page(mtd, NFC_OUTPUT); in mxc_nand_command()
1160 memcpy32_fromio(host->data_buf, host->main_area0, 512); in mxc_nand_command()
1161 host->buf_start = 0; in mxc_nand_command()
1328 static inline int is_imx21_nfc(struct mxc_nand_host *host) in is_imx21_nfc() argument
1330 return host->devtype_data == &imx21_nand_devtype_data; in is_imx21_nfc()
1333 static inline int is_imx27_nfc(struct mxc_nand_host *host) in is_imx27_nfc() argument
1335 return host->devtype_data == &imx27_nand_devtype_data; in is_imx27_nfc()
1338 static inline int is_imx25_nfc(struct mxc_nand_host *host) in is_imx25_nfc() argument
1340 return host->devtype_data == &imx25_nand_devtype_data; in is_imx25_nfc()
1343 static inline int is_imx51_nfc(struct mxc_nand_host *host) in is_imx51_nfc() argument
1345 return host->devtype_data == &imx51_nand_devtype_data; in is_imx51_nfc()
1348 static inline int is_imx53_nfc(struct mxc_nand_host *host) in is_imx53_nfc() argument
1350 return host->devtype_data == &imx53_nand_devtype_data; in is_imx53_nfc()
1396 static int __init mxcnd_probe_dt(struct mxc_nand_host *host) in mxcnd_probe_dt() argument
1398 struct device_node *np = host->dev->of_node; in mxcnd_probe_dt()
1399 struct mxc_nand_platform_data *pdata = &host->pdata; in mxcnd_probe_dt()
1401 of_match_device(mxcnd_dt_ids, host->dev); in mxcnd_probe_dt()
1418 host->devtype_data = of_id->data; in mxcnd_probe_dt()
1423 static int __init mxcnd_probe_dt(struct mxc_nand_host *host) in mxcnd_probe_dt() argument
1433 struct mxc_nand_host *host; in mxcnd_probe() local
1438 host = devm_kzalloc(&pdev->dev, sizeof(struct mxc_nand_host), in mxcnd_probe()
1440 if (!host) in mxcnd_probe()
1444 host->data_buf = devm_kzalloc(&pdev->dev, PAGE_SIZE, GFP_KERNEL); in mxcnd_probe()
1445 if (!host->data_buf) in mxcnd_probe()
1448 host->dev = &pdev->dev; in mxcnd_probe()
1450 this = &host->nand; in mxcnd_probe()
1451 mtd = &host->mtd; in mxcnd_probe()
1460 this->priv = host; in mxcnd_probe()
1468 host->clk = devm_clk_get(&pdev->dev, NULL); in mxcnd_probe()
1469 if (IS_ERR(host->clk)) in mxcnd_probe()
1470 return PTR_ERR(host->clk); in mxcnd_probe()
1472 err = mxcnd_probe_dt(host); in mxcnd_probe()
1477 host->pdata = *pdata; in mxcnd_probe()
1478 host->devtype_data = (struct mxc_nand_devtype_data *) in mxcnd_probe()
1487 if (host->devtype_data->needs_ip) { in mxcnd_probe()
1489 host->regs_ip = devm_ioremap_resource(&pdev->dev, res); in mxcnd_probe()
1490 if (IS_ERR(host->regs_ip)) in mxcnd_probe()
1491 return PTR_ERR(host->regs_ip); in mxcnd_probe()
1498 host->base = devm_ioremap_resource(&pdev->dev, res); in mxcnd_probe()
1499 if (IS_ERR(host->base)) in mxcnd_probe()
1500 return PTR_ERR(host->base); in mxcnd_probe()
1502 host->main_area0 = host->base; in mxcnd_probe()
1504 if (host->devtype_data->regs_offset) in mxcnd_probe()
1505 host->regs = host->base + host->devtype_data->regs_offset; in mxcnd_probe()
1506 host->spare0 = host->base + host->devtype_data->spare0_offset; in mxcnd_probe()
1507 if (host->devtype_data->axi_offset) in mxcnd_probe()
1508 host->regs_axi = host->base + host->devtype_data->axi_offset; in mxcnd_probe()
1510 this->ecc.bytes = host->devtype_data->eccbytes; in mxcnd_probe()
1511 host->eccsize = host->devtype_data->eccsize; in mxcnd_probe()
1513 this->select_chip = host->devtype_data->select_chip; in mxcnd_probe()
1515 this->ecc.layout = host->devtype_data->ecclayout_512; in mxcnd_probe()
1517 if (host->pdata.hw_ecc) { in mxcnd_probe()
1520 this->ecc.correct = host->devtype_data->correct_data; in mxcnd_probe()
1527 if (host->pdata.width == 2) in mxcnd_probe()
1530 if (host->pdata.flash_bbt) { in mxcnd_probe()
1537 init_completion(&host->op_completion); in mxcnd_probe()
1539 host->irq = platform_get_irq(pdev, 0); in mxcnd_probe()
1540 if (host->irq < 0) in mxcnd_probe()
1541 return host->irq; in mxcnd_probe()
1548 host->devtype_data->irq_control(host, 0); in mxcnd_probe()
1550 err = devm_request_irq(&pdev->dev, host->irq, mxc_nfc_irq, in mxcnd_probe()
1551 0, DRIVER_NAME, host); in mxcnd_probe()
1555 err = clk_prepare_enable(host->clk); in mxcnd_probe()
1558 host->clk_act = 1; in mxcnd_probe()
1565 if (host->devtype_data->irqpending_quirk) { in mxcnd_probe()
1566 disable_irq_nosync(host->irq); in mxcnd_probe()
1567 host->devtype_data->irq_control(host, 1); in mxcnd_probe()
1571 if (nand_scan_ident(mtd, is_imx25_nfc(host) ? 4 : 1, NULL)) { in mxcnd_probe()
1577 devm_kfree(&pdev->dev, (void *)host->data_buf); in mxcnd_probe()
1578 host->data_buf = devm_kzalloc(&pdev->dev, mtd->writesize + mtd->oobsize, in mxcnd_probe()
1580 if (!host->data_buf) { in mxcnd_probe()
1586 host->devtype_data->preset(mtd); in mxcnd_probe()
1589 this->ecc.layout = host->devtype_data->ecclayout_2k; in mxcnd_probe()
1591 this->ecc.layout = host->devtype_data->ecclayout_4k; in mxcnd_probe()
1594 if (is_imx21_nfc(host) || is_imx27_nfc(host)) in mxcnd_probe()
1597 this->ecc.strength = (host->eccsize == 4) ? 4 : 8; in mxcnd_probe()
1611 host->pdata.parts, in mxcnd_probe()
1612 host->pdata.nr_parts); in mxcnd_probe()
1614 platform_set_drvdata(pdev, host); in mxcnd_probe()
1619 if (host->clk_act) in mxcnd_probe()
1620 clk_disable_unprepare(host->clk); in mxcnd_probe()
1627 struct mxc_nand_host *host = platform_get_drvdata(pdev); in mxcnd_remove() local
1629 nand_release(&host->mtd); in mxcnd_remove()
1630 if (host->clk_act) in mxcnd_remove()
1631 clk_disable_unprepare(host->clk); in mxcnd_remove()