Lines Matching full:nfc

281 	struct stm32_fmc2_nfc *nfc = to_stm32_nfc(chip->controller);  in stm32_fmc2_nfc_timings_init()  local
287 regmap_update_bits(nfc->regmap, FMC2_PCR, in stm32_fmc2_nfc_timings_init()
297 regmap_write(nfc->regmap, FMC2_PMEM, pmem); in stm32_fmc2_nfc_timings_init()
304 regmap_write(nfc->regmap, FMC2_PATT, patt); in stm32_fmc2_nfc_timings_init()
309 struct stm32_fmc2_nfc *nfc = to_stm32_nfc(chip->controller); in stm32_fmc2_nfc_setup() local
331 regmap_update_bits(nfc->regmap, FMC2_PCR, pcr_mask, pcr); in stm32_fmc2_nfc_setup()
336 struct stm32_fmc2_nfc *nfc = to_stm32_nfc(chip->controller); in stm32_fmc2_nfc_select_chip() local
341 if (nand->cs_used[chipnr] == nfc->cs_sel) in stm32_fmc2_nfc_select_chip()
344 nfc->cs_sel = nand->cs_used[chipnr]; in stm32_fmc2_nfc_select_chip()
348 if (nfc->dma_tx_ch && nfc->dma_rx_ch) { in stm32_fmc2_nfc_select_chip()
350 dma_cfg.src_addr = nfc->data_phys_addr[nfc->cs_sel]; in stm32_fmc2_nfc_select_chip()
351 dma_cfg.dst_addr = nfc->data_phys_addr[nfc->cs_sel]; in stm32_fmc2_nfc_select_chip()
357 ret = dmaengine_slave_config(nfc->dma_tx_ch, &dma_cfg); in stm32_fmc2_nfc_select_chip()
359 dev_err(nfc->dev, "tx DMA engine slave config failed\n"); in stm32_fmc2_nfc_select_chip()
363 ret = dmaengine_slave_config(nfc->dma_rx_ch, &dma_cfg); in stm32_fmc2_nfc_select_chip()
365 dev_err(nfc->dev, "rx DMA engine slave config failed\n"); in stm32_fmc2_nfc_select_chip()
370 if (nfc->dma_ecc_ch) { in stm32_fmc2_nfc_select_chip()
376 dma_cfg.src_addr = nfc->io_phys_addr; in stm32_fmc2_nfc_select_chip()
381 ret = dmaengine_slave_config(nfc->dma_ecc_ch, &dma_cfg); in stm32_fmc2_nfc_select_chip()
383 dev_err(nfc->dev, "ECC DMA engine slave config failed\n"); in stm32_fmc2_nfc_select_chip()
388 nfc->dma_ecc_len = chip->ecc.strength == FMC2_ECC_HAM ? in stm32_fmc2_nfc_select_chip()
395 static void stm32_fmc2_nfc_set_buswidth_16(struct stm32_fmc2_nfc *nfc, bool set) in stm32_fmc2_nfc_set_buswidth_16() argument
402 regmap_update_bits(nfc->regmap, FMC2_PCR, FMC2_PCR_PWID, pcr); in stm32_fmc2_nfc_set_buswidth_16()
405 static void stm32_fmc2_nfc_set_ecc(struct stm32_fmc2_nfc *nfc, bool enable) in stm32_fmc2_nfc_set_ecc() argument
407 regmap_update_bits(nfc->regmap, FMC2_PCR, FMC2_PCR_ECCEN, in stm32_fmc2_nfc_set_ecc()
411 static void stm32_fmc2_nfc_enable_seq_irq(struct stm32_fmc2_nfc *nfc) in stm32_fmc2_nfc_enable_seq_irq() argument
413 nfc->irq_state = FMC2_IRQ_SEQ; in stm32_fmc2_nfc_enable_seq_irq()
415 regmap_update_bits(nfc->regmap, FMC2_CSQIER, in stm32_fmc2_nfc_enable_seq_irq()
419 static void stm32_fmc2_nfc_disable_seq_irq(struct stm32_fmc2_nfc *nfc) in stm32_fmc2_nfc_disable_seq_irq() argument
421 regmap_update_bits(nfc->regmap, FMC2_CSQIER, FMC2_CSQIER_TCIE, 0); in stm32_fmc2_nfc_disable_seq_irq()
423 nfc->irq_state = FMC2_IRQ_UNKNOWN; in stm32_fmc2_nfc_disable_seq_irq()
426 static void stm32_fmc2_nfc_clear_seq_irq(struct stm32_fmc2_nfc *nfc) in stm32_fmc2_nfc_clear_seq_irq() argument
428 regmap_write(nfc->regmap, FMC2_CSQICR, FMC2_CSQICR_CLEAR_IRQ); in stm32_fmc2_nfc_clear_seq_irq()
431 static void stm32_fmc2_nfc_enable_bch_irq(struct stm32_fmc2_nfc *nfc, int mode) in stm32_fmc2_nfc_enable_bch_irq() argument
433 nfc->irq_state = FMC2_IRQ_BCH; in stm32_fmc2_nfc_enable_bch_irq()
436 regmap_update_bits(nfc->regmap, FMC2_BCHIER, in stm32_fmc2_nfc_enable_bch_irq()
439 regmap_update_bits(nfc->regmap, FMC2_BCHIER, in stm32_fmc2_nfc_enable_bch_irq()
443 static void stm32_fmc2_nfc_disable_bch_irq(struct stm32_fmc2_nfc *nfc) in stm32_fmc2_nfc_disable_bch_irq() argument
445 regmap_update_bits(nfc->regmap, FMC2_BCHIER, in stm32_fmc2_nfc_disable_bch_irq()
448 nfc->irq_state = FMC2_IRQ_UNKNOWN; in stm32_fmc2_nfc_disable_bch_irq()
451 static void stm32_fmc2_nfc_clear_bch_irq(struct stm32_fmc2_nfc *nfc) in stm32_fmc2_nfc_clear_bch_irq() argument
453 regmap_write(nfc->regmap, FMC2_BCHICR, FMC2_BCHICR_CLEAR_IRQ); in stm32_fmc2_nfc_clear_bch_irq()
462 struct stm32_fmc2_nfc *nfc = to_stm32_nfc(chip->controller); in stm32_fmc2_nfc_hwctl() local
464 stm32_fmc2_nfc_set_ecc(nfc, false); in stm32_fmc2_nfc_hwctl()
467 regmap_update_bits(nfc->regmap, FMC2_PCR, FMC2_PCR_WEN, in stm32_fmc2_nfc_hwctl()
470 reinit_completion(&nfc->complete); in stm32_fmc2_nfc_hwctl()
471 stm32_fmc2_nfc_clear_bch_irq(nfc); in stm32_fmc2_nfc_hwctl()
472 stm32_fmc2_nfc_enable_bch_irq(nfc, mode); in stm32_fmc2_nfc_hwctl()
475 stm32_fmc2_nfc_set_ecc(nfc, true); in stm32_fmc2_nfc_hwctl()
493 struct stm32_fmc2_nfc *nfc = to_stm32_nfc(chip->controller); in stm32_fmc2_nfc_ham_calculate() local
497 ret = regmap_read_poll_timeout(nfc->regmap, FMC2_SR, sr, in stm32_fmc2_nfc_ham_calculate()
501 dev_err(nfc->dev, "ham timeout\n"); in stm32_fmc2_nfc_ham_calculate()
505 regmap_read(nfc->regmap, FMC2_HECCR, &heccr); in stm32_fmc2_nfc_ham_calculate()
507 stm32_fmc2_nfc_set_ecc(nfc, false); in stm32_fmc2_nfc_ham_calculate()
572 struct stm32_fmc2_nfc *nfc = to_stm32_nfc(chip->controller); in stm32_fmc2_nfc_bch_calculate() local
576 if (!wait_for_completion_timeout(&nfc->complete, in stm32_fmc2_nfc_bch_calculate()
578 dev_err(nfc->dev, "bch timeout\n"); in stm32_fmc2_nfc_bch_calculate()
579 stm32_fmc2_nfc_disable_bch_irq(nfc); in stm32_fmc2_nfc_bch_calculate()
584 regmap_read(nfc->regmap, FMC2_BCHPBR1, &bchpbr); in stm32_fmc2_nfc_bch_calculate()
590 regmap_read(nfc->regmap, FMC2_BCHPBR2, &bchpbr); in stm32_fmc2_nfc_bch_calculate()
598 regmap_read(nfc->regmap, FMC2_BCHPBR3, &bchpbr); in stm32_fmc2_nfc_bch_calculate()
604 regmap_read(nfc->regmap, FMC2_BCHPBR4, &bchpbr); in stm32_fmc2_nfc_bch_calculate()
608 stm32_fmc2_nfc_set_ecc(nfc, false); in stm32_fmc2_nfc_bch_calculate()
655 struct stm32_fmc2_nfc *nfc = to_stm32_nfc(chip->controller); in stm32_fmc2_nfc_bch_correct() local
659 if (!wait_for_completion_timeout(&nfc->complete, in stm32_fmc2_nfc_bch_correct()
661 dev_err(nfc->dev, "bch timeout\n"); in stm32_fmc2_nfc_bch_correct()
662 stm32_fmc2_nfc_disable_bch_irq(nfc); in stm32_fmc2_nfc_bch_correct()
666 regmap_bulk_read(nfc->regmap, FMC2_BCHDSR0, ecc_sta, 5); in stm32_fmc2_nfc_bch_correct()
668 stm32_fmc2_nfc_set_ecc(nfc, false); in stm32_fmc2_nfc_bch_correct()
739 struct stm32_fmc2_nfc *nfc = to_stm32_nfc(chip->controller); in stm32_fmc2_nfc_rw_page_init() local
748 regmap_update_bits(nfc->regmap, FMC2_PCR, FMC2_PCR_WEN, in stm32_fmc2_nfc_rw_page_init()
811 cfg[4] = FIELD_PREP(FMC2_CSQCAR2_NANDCEN, nfc->cs_sel); in stm32_fmc2_nfc_rw_page_init()
823 regmap_bulk_write(nfc->regmap, FMC2_CSQCFGR1, cfg, 5); in stm32_fmc2_nfc_rw_page_init()
835 struct stm32_fmc2_nfc *nfc = to_stm32_nfc(chip->controller); in stm32_fmc2_nfc_xfer() local
838 struct dma_chan *dma_ch = nfc->dma_rx_ch; in stm32_fmc2_nfc_xfer()
851 dma_ch = nfc->dma_tx_ch; in stm32_fmc2_nfc_xfer()
854 for_each_sg(nfc->dma_data_sg.sgl, sg, eccsteps, s) { in stm32_fmc2_nfc_xfer()
859 ret = dma_map_sg(nfc->dev, nfc->dma_data_sg.sgl, in stm32_fmc2_nfc_xfer()
864 desc_data = dmaengine_prep_slave_sg(dma_ch, nfc->dma_data_sg.sgl, in stm32_fmc2_nfc_xfer()
872 reinit_completion(&nfc->dma_data_complete); in stm32_fmc2_nfc_xfer()
873 reinit_completion(&nfc->complete); in stm32_fmc2_nfc_xfer()
875 desc_data->callback_param = &nfc->dma_data_complete; in stm32_fmc2_nfc_xfer()
884 p = nfc->ecc_buf; in stm32_fmc2_nfc_xfer()
885 for_each_sg(nfc->dma_ecc_sg.sgl, sg, eccsteps, s) { in stm32_fmc2_nfc_xfer()
886 sg_set_buf(sg, p, nfc->dma_ecc_len); in stm32_fmc2_nfc_xfer()
887 p += nfc->dma_ecc_len; in stm32_fmc2_nfc_xfer()
890 ret = dma_map_sg(nfc->dev, nfc->dma_ecc_sg.sgl, in stm32_fmc2_nfc_xfer()
895 desc_ecc = dmaengine_prep_slave_sg(nfc->dma_ecc_ch, in stm32_fmc2_nfc_xfer()
896 nfc->dma_ecc_sg.sgl, in stm32_fmc2_nfc_xfer()
904 reinit_completion(&nfc->dma_ecc_complete); in stm32_fmc2_nfc_xfer()
906 desc_ecc->callback_param = &nfc->dma_ecc_complete; in stm32_fmc2_nfc_xfer()
911 dma_async_issue_pending(nfc->dma_ecc_ch); in stm32_fmc2_nfc_xfer()
914 stm32_fmc2_nfc_clear_seq_irq(nfc); in stm32_fmc2_nfc_xfer()
915 stm32_fmc2_nfc_enable_seq_irq(nfc); in stm32_fmc2_nfc_xfer()
918 regmap_update_bits(nfc->regmap, FMC2_CSQCR, in stm32_fmc2_nfc_xfer()
922 if (!wait_for_completion_timeout(&nfc->complete, timeout)) { in stm32_fmc2_nfc_xfer()
923 dev_err(nfc->dev, "seq timeout\n"); in stm32_fmc2_nfc_xfer()
924 stm32_fmc2_nfc_disable_seq_irq(nfc); in stm32_fmc2_nfc_xfer()
927 dmaengine_terminate_all(nfc->dma_ecc_ch); in stm32_fmc2_nfc_xfer()
933 if (!wait_for_completion_timeout(&nfc->dma_data_complete, timeout)) { in stm32_fmc2_nfc_xfer()
934 dev_err(nfc->dev, "data DMA timeout\n"); in stm32_fmc2_nfc_xfer()
941 if (!wait_for_completion_timeout(&nfc->dma_ecc_complete, in stm32_fmc2_nfc_xfer()
943 dev_err(nfc->dev, "ECC DMA timeout\n"); in stm32_fmc2_nfc_xfer()
944 dmaengine_terminate_all(nfc->dma_ecc_ch); in stm32_fmc2_nfc_xfer()
951 dma_unmap_sg(nfc->dev, nfc->dma_ecc_sg.sgl, in stm32_fmc2_nfc_xfer()
955 dma_unmap_sg(nfc->dev, nfc->dma_data_sg.sgl, eccsteps, dma_data_dir); in stm32_fmc2_nfc_xfer()
1012 static u16 stm32_fmc2_nfc_get_mapping_status(struct stm32_fmc2_nfc *nfc) in stm32_fmc2_nfc_get_mapping_status() argument
1016 regmap_read(nfc->regmap, FMC2_CSQEMSR, &csqemsr); in stm32_fmc2_nfc_get_mapping_status()
1025 struct stm32_fmc2_nfc *nfc = to_stm32_nfc(chip->controller); in stm32_fmc2_nfc_seq_correct() local
1030 u32 *ecc_sta = (u32 *)nfc->ecc_buf; in stm32_fmc2_nfc_seq_correct()
1031 u16 sta_map = stm32_fmc2_nfc_get_mapping_status(nfc); in stm32_fmc2_nfc_seq_correct()
1084 struct stm32_fmc2_nfc *nfc = to_stm32_nfc(chip->controller); in stm32_fmc2_nfc_seq_read_page() local
1102 sta_map = stm32_fmc2_nfc_get_mapping_status(nfc); in stm32_fmc2_nfc_seq_read_page()
1158 struct stm32_fmc2_nfc *nfc = (struct stm32_fmc2_nfc *)dev_id; in stm32_fmc2_nfc_irq() local
1160 if (nfc->irq_state == FMC2_IRQ_SEQ) in stm32_fmc2_nfc_irq()
1162 stm32_fmc2_nfc_disable_seq_irq(nfc); in stm32_fmc2_nfc_irq()
1163 else if (nfc->irq_state == FMC2_IRQ_BCH) in stm32_fmc2_nfc_irq()
1165 stm32_fmc2_nfc_disable_bch_irq(nfc); in stm32_fmc2_nfc_irq()
1167 complete(&nfc->complete); in stm32_fmc2_nfc_irq()
1175 struct stm32_fmc2_nfc *nfc = to_stm32_nfc(chip->controller); in stm32_fmc2_nfc_read_data() local
1176 void __iomem *io_addr_r = nfc->data_base[nfc->cs_sel]; in stm32_fmc2_nfc_read_data()
1180 stm32_fmc2_nfc_set_buswidth_16(nfc, false); in stm32_fmc2_nfc_read_data()
1216 stm32_fmc2_nfc_set_buswidth_16(nfc, true); in stm32_fmc2_nfc_read_data()
1222 struct stm32_fmc2_nfc *nfc = to_stm32_nfc(chip->controller); in stm32_fmc2_nfc_write_data() local
1223 void __iomem *io_addr_w = nfc->data_base[nfc->cs_sel]; in stm32_fmc2_nfc_write_data()
1227 stm32_fmc2_nfc_set_buswidth_16(nfc, false); in stm32_fmc2_nfc_write_data()
1263 stm32_fmc2_nfc_set_buswidth_16(nfc, true); in stm32_fmc2_nfc_write_data()
1269 struct stm32_fmc2_nfc *nfc = to_stm32_nfc(chip->controller); in stm32_fmc2_nfc_waitrdy() local
1274 if (regmap_read_poll_timeout(nfc->regmap, FMC2_SR, sr, in stm32_fmc2_nfc_waitrdy()
1277 dev_warn(nfc->dev, "Waitrdy timeout\n"); in stm32_fmc2_nfc_waitrdy()
1284 regmap_write(nfc->regmap, FMC2_ICR, FMC2_ICR_CIHLF); in stm32_fmc2_nfc_waitrdy()
1287 return regmap_read_poll_timeout(nfc->regmap, FMC2_ISR, isr, in stm32_fmc2_nfc_waitrdy()
1296 struct stm32_fmc2_nfc *nfc = to_stm32_nfc(chip->controller); in stm32_fmc2_nfc_exec_op() local
1314 nfc->cmd_base[nfc->cs_sel]); in stm32_fmc2_nfc_exec_op()
1320 nfc->addr_base[nfc->cs_sel]); in stm32_fmc2_nfc_exec_op()
1345 static void stm32_fmc2_nfc_init(struct stm32_fmc2_nfc *nfc) in stm32_fmc2_nfc_init() argument
1349 regmap_read(nfc->regmap, FMC2_PCR, &pcr); in stm32_fmc2_nfc_init()
1352 nfc->cs_sel = -1; in stm32_fmc2_nfc_init()
1380 if (nfc->dev == nfc->cdev) in stm32_fmc2_nfc_init()
1381 regmap_update_bits(nfc->regmap, FMC2_BCR1, in stm32_fmc2_nfc_init()
1384 regmap_write(nfc->regmap, FMC2_PCR, pcr); in stm32_fmc2_nfc_init()
1385 regmap_write(nfc->regmap, FMC2_PMEM, FMC2_PMEM_DEFAULT); in stm32_fmc2_nfc_init()
1386 regmap_write(nfc->regmap, FMC2_PATT, FMC2_PATT_DEFAULT); in stm32_fmc2_nfc_init()
1392 struct stm32_fmc2_nfc *nfc = to_stm32_nfc(chip->controller); in stm32_fmc2_nfc_calc_timings() local
1395 unsigned long hclk = clk_get_rate(nfc->clk); in stm32_fmc2_nfc_calc_timings()
1537 static int stm32_fmc2_nfc_dma_setup(struct stm32_fmc2_nfc *nfc) in stm32_fmc2_nfc_dma_setup() argument
1541 nfc->dma_tx_ch = dma_request_chan(nfc->dev, "tx"); in stm32_fmc2_nfc_dma_setup()
1542 if (IS_ERR(nfc->dma_tx_ch)) { in stm32_fmc2_nfc_dma_setup()
1543 ret = PTR_ERR(nfc->dma_tx_ch); in stm32_fmc2_nfc_dma_setup()
1545 dev_err(nfc->dev, in stm32_fmc2_nfc_dma_setup()
1547 nfc->dma_tx_ch = NULL; in stm32_fmc2_nfc_dma_setup()
1551 nfc->dma_rx_ch = dma_request_chan(nfc->dev, "rx"); in stm32_fmc2_nfc_dma_setup()
1552 if (IS_ERR(nfc->dma_rx_ch)) { in stm32_fmc2_nfc_dma_setup()
1553 ret = PTR_ERR(nfc->dma_rx_ch); in stm32_fmc2_nfc_dma_setup()
1555 dev_err(nfc->dev, in stm32_fmc2_nfc_dma_setup()
1557 nfc->dma_rx_ch = NULL; in stm32_fmc2_nfc_dma_setup()
1561 nfc->dma_ecc_ch = dma_request_chan(nfc->dev, "ecc"); in stm32_fmc2_nfc_dma_setup()
1562 if (IS_ERR(nfc->dma_ecc_ch)) { in stm32_fmc2_nfc_dma_setup()
1563 ret = PTR_ERR(nfc->dma_ecc_ch); in stm32_fmc2_nfc_dma_setup()
1565 dev_err(nfc->dev, in stm32_fmc2_nfc_dma_setup()
1567 nfc->dma_ecc_ch = NULL; in stm32_fmc2_nfc_dma_setup()
1571 ret = sg_alloc_table(&nfc->dma_ecc_sg, FMC2_MAX_SG, GFP_KERNEL); in stm32_fmc2_nfc_dma_setup()
1576 nfc->ecc_buf = devm_kzalloc(nfc->dev, FMC2_MAX_ECC_BUF_LEN, GFP_KERNEL); in stm32_fmc2_nfc_dma_setup()
1577 if (!nfc->ecc_buf) in stm32_fmc2_nfc_dma_setup()
1580 ret = sg_alloc_table(&nfc->dma_data_sg, FMC2_MAX_SG, GFP_KERNEL); in stm32_fmc2_nfc_dma_setup()
1584 init_completion(&nfc->dma_data_complete); in stm32_fmc2_nfc_dma_setup()
1585 init_completion(&nfc->dma_ecc_complete); in stm32_fmc2_nfc_dma_setup()
1591 dev_warn(nfc->dev, in stm32_fmc2_nfc_dma_setup()
1601 struct stm32_fmc2_nfc *nfc = to_stm32_nfc(chip->controller); in stm32_fmc2_nfc_nand_callbacks_setup() local
1607 if (nfc->dma_tx_ch && nfc->dma_rx_ch && nfc->dma_ecc_ch) { in stm32_fmc2_nfc_nand_callbacks_setup()
1694 struct stm32_fmc2_nfc *nfc = to_stm32_nfc(chip->controller); in stm32_fmc2_nfc_attach_chip() local
1706 dev_err(nfc->dev, in stm32_fmc2_nfc_attach_chip()
1721 dev_err(nfc->dev, "no valid ECC settings set\n"); in stm32_fmc2_nfc_attach_chip()
1726 dev_err(nfc->dev, "nand page size is not supported\n"); in stm32_fmc2_nfc_attach_chip()
1748 static int stm32_fmc2_nfc_parse_child(struct stm32_fmc2_nfc *nfc, in stm32_fmc2_nfc_parse_child() argument
1751 struct stm32_fmc2_nand *nand = &nfc->nand; in stm32_fmc2_nfc_parse_child()
1760 dev_err(nfc->dev, "invalid reg property size\n"); in stm32_fmc2_nfc_parse_child()
1767 dev_err(nfc->dev, "could not retrieve reg property: %d\n", in stm32_fmc2_nfc_parse_child()
1773 dev_err(nfc->dev, "invalid reg value: %d\n", cs); in stm32_fmc2_nfc_parse_child()
1777 if (nfc->cs_assigned & BIT(cs)) { in stm32_fmc2_nfc_parse_child()
1778 dev_err(nfc->dev, "cs already assigned: %d\n", cs); in stm32_fmc2_nfc_parse_child()
1782 nfc->cs_assigned |= BIT(cs); in stm32_fmc2_nfc_parse_child()
1791 static int stm32_fmc2_nfc_parse_dt(struct stm32_fmc2_nfc *nfc) in stm32_fmc2_nfc_parse_dt() argument
1793 struct device_node *dn = nfc->dev->of_node; in stm32_fmc2_nfc_parse_dt()
1799 dev_err(nfc->dev, "NAND chip not defined\n"); in stm32_fmc2_nfc_parse_dt()
1804 dev_err(nfc->dev, "too many NAND chips defined\n"); in stm32_fmc2_nfc_parse_dt()
1809 ret = stm32_fmc2_nfc_parse_child(nfc, child); in stm32_fmc2_nfc_parse_dt()
1819 static int stm32_fmc2_nfc_set_cdev(struct stm32_fmc2_nfc *nfc) in stm32_fmc2_nfc_set_cdev() argument
1821 struct device *dev = nfc->dev; in stm32_fmc2_nfc_set_cdev()
1828 if (of_device_is_compatible(dev->of_node, "st,stm32mp1-fmc2-nfc")) { in stm32_fmc2_nfc_set_cdev()
1830 nfc->cdev = dev->parent; in stm32_fmc2_nfc_set_cdev()
1841 nfc->cdev = dev; in stm32_fmc2_nfc_set_cdev()
1850 struct stm32_fmc2_nfc *nfc; in stm32_fmc2_nfc_probe() local
1859 nfc = devm_kzalloc(dev, sizeof(*nfc), GFP_KERNEL); in stm32_fmc2_nfc_probe()
1860 if (!nfc) in stm32_fmc2_nfc_probe()
1863 nfc->dev = dev; in stm32_fmc2_nfc_probe()
1864 nand_controller_init(&nfc->base); in stm32_fmc2_nfc_probe()
1865 nfc->base.ops = &stm32_fmc2_nfc_controller_ops; in stm32_fmc2_nfc_probe()
1867 ret = stm32_fmc2_nfc_set_cdev(nfc); in stm32_fmc2_nfc_probe()
1871 ret = stm32_fmc2_nfc_parse_dt(nfc); in stm32_fmc2_nfc_probe()
1875 ret = of_address_to_resource(nfc->cdev->of_node, 0, &cres); in stm32_fmc2_nfc_probe()
1879 nfc->io_phys_addr = cres.start; in stm32_fmc2_nfc_probe()
1881 nfc->regmap = device_node_to_regmap(nfc->cdev->of_node); in stm32_fmc2_nfc_probe()
1882 if (IS_ERR(nfc->regmap)) in stm32_fmc2_nfc_probe()
1883 return PTR_ERR(nfc->regmap); in stm32_fmc2_nfc_probe()
1885 if (nfc->dev == nfc->cdev) in stm32_fmc2_nfc_probe()
1890 if (!(nfc->cs_assigned & BIT(chip_cs))) in stm32_fmc2_nfc_probe()
1894 nfc->data_base[chip_cs] = devm_ioremap_resource(dev, res); in stm32_fmc2_nfc_probe()
1895 if (IS_ERR(nfc->data_base[chip_cs])) in stm32_fmc2_nfc_probe()
1896 return PTR_ERR(nfc->data_base[chip_cs]); in stm32_fmc2_nfc_probe()
1898 nfc->data_phys_addr[chip_cs] = res->start; in stm32_fmc2_nfc_probe()
1902 nfc->cmd_base[chip_cs] = devm_ioremap_resource(dev, res); in stm32_fmc2_nfc_probe()
1903 if (IS_ERR(nfc->cmd_base[chip_cs])) in stm32_fmc2_nfc_probe()
1904 return PTR_ERR(nfc->cmd_base[chip_cs]); in stm32_fmc2_nfc_probe()
1908 nfc->addr_base[chip_cs] = devm_ioremap_resource(dev, res); in stm32_fmc2_nfc_probe()
1909 if (IS_ERR(nfc->addr_base[chip_cs])) in stm32_fmc2_nfc_probe()
1910 return PTR_ERR(nfc->addr_base[chip_cs]); in stm32_fmc2_nfc_probe()
1918 dev_name(dev), nfc); in stm32_fmc2_nfc_probe()
1924 init_completion(&nfc->complete); in stm32_fmc2_nfc_probe()
1926 nfc->clk = devm_clk_get(nfc->cdev, NULL); in stm32_fmc2_nfc_probe()
1927 if (IS_ERR(nfc->clk)) in stm32_fmc2_nfc_probe()
1928 return PTR_ERR(nfc->clk); in stm32_fmc2_nfc_probe()
1930 ret = clk_prepare_enable(nfc->clk); in stm32_fmc2_nfc_probe()
1946 ret = stm32_fmc2_nfc_dma_setup(nfc); in stm32_fmc2_nfc_probe()
1950 stm32_fmc2_nfc_init(nfc); in stm32_fmc2_nfc_probe()
1952 nand = &nfc->nand; in stm32_fmc2_nfc_probe()
1957 chip->controller = &nfc->base; in stm32_fmc2_nfc_probe()
1970 platform_set_drvdata(pdev, nfc); in stm32_fmc2_nfc_probe()
1978 if (nfc->dma_ecc_ch) in stm32_fmc2_nfc_probe()
1979 dma_release_channel(nfc->dma_ecc_ch); in stm32_fmc2_nfc_probe()
1980 if (nfc->dma_tx_ch) in stm32_fmc2_nfc_probe()
1981 dma_release_channel(nfc->dma_tx_ch); in stm32_fmc2_nfc_probe()
1982 if (nfc->dma_rx_ch) in stm32_fmc2_nfc_probe()
1983 dma_release_channel(nfc->dma_rx_ch); in stm32_fmc2_nfc_probe()
1985 sg_free_table(&nfc->dma_data_sg); in stm32_fmc2_nfc_probe()
1986 sg_free_table(&nfc->dma_ecc_sg); in stm32_fmc2_nfc_probe()
1989 clk_disable_unprepare(nfc->clk); in stm32_fmc2_nfc_probe()
1996 struct stm32_fmc2_nfc *nfc = platform_get_drvdata(pdev); in stm32_fmc2_nfc_remove() local
1997 struct stm32_fmc2_nand *nand = &nfc->nand; in stm32_fmc2_nfc_remove()
2005 if (nfc->dma_ecc_ch) in stm32_fmc2_nfc_remove()
2006 dma_release_channel(nfc->dma_ecc_ch); in stm32_fmc2_nfc_remove()
2007 if (nfc->dma_tx_ch) in stm32_fmc2_nfc_remove()
2008 dma_release_channel(nfc->dma_tx_ch); in stm32_fmc2_nfc_remove()
2009 if (nfc->dma_rx_ch) in stm32_fmc2_nfc_remove()
2010 dma_release_channel(nfc->dma_rx_ch); in stm32_fmc2_nfc_remove()
2012 sg_free_table(&nfc->dma_data_sg); in stm32_fmc2_nfc_remove()
2013 sg_free_table(&nfc->dma_ecc_sg); in stm32_fmc2_nfc_remove()
2015 clk_disable_unprepare(nfc->clk); in stm32_fmc2_nfc_remove()
2022 struct stm32_fmc2_nfc *nfc = dev_get_drvdata(dev); in stm32_fmc2_nfc_suspend() local
2024 clk_disable_unprepare(nfc->clk); in stm32_fmc2_nfc_suspend()
2033 struct stm32_fmc2_nfc *nfc = dev_get_drvdata(dev); in stm32_fmc2_nfc_resume() local
2034 struct stm32_fmc2_nand *nand = &nfc->nand; in stm32_fmc2_nfc_resume()
2039 ret = clk_prepare_enable(nfc->clk); in stm32_fmc2_nfc_resume()
2045 stm32_fmc2_nfc_init(nfc); in stm32_fmc2_nfc_resume()
2048 if (!(nfc->cs_assigned & BIT(chip_cs))) in stm32_fmc2_nfc_resume()
2062 {.compatible = "st,stm32mp1-fmc2-nfc"},
2080 MODULE_DESCRIPTION("STMicroelectronics STM32 FMC2 NFC driver");