Lines Matching full:nfc

283 	struct stm32_fmc2_nfc *nfc = to_stm32_nfc(chip->controller);  in stm32_fmc2_nfc_timings_init()  local
289 regmap_update_bits(nfc->regmap, FMC2_PCR, in stm32_fmc2_nfc_timings_init()
299 regmap_write(nfc->regmap, FMC2_PMEM, pmem); in stm32_fmc2_nfc_timings_init()
306 regmap_write(nfc->regmap, FMC2_PATT, patt); in stm32_fmc2_nfc_timings_init()
311 struct stm32_fmc2_nfc *nfc = to_stm32_nfc(chip->controller); in stm32_fmc2_nfc_setup() local
333 regmap_update_bits(nfc->regmap, FMC2_PCR, pcr_mask, pcr); in stm32_fmc2_nfc_setup()
338 struct stm32_fmc2_nfc *nfc = to_stm32_nfc(chip->controller); in stm32_fmc2_nfc_select_chip() local
343 if (nand->cs_used[chipnr] == nfc->cs_sel) in stm32_fmc2_nfc_select_chip()
346 nfc->cs_sel = nand->cs_used[chipnr]; in stm32_fmc2_nfc_select_chip()
350 if (nfc->dma_tx_ch && nfc->dma_rx_ch) { in stm32_fmc2_nfc_select_chip()
352 dma_cfg.src_addr = nfc->data_phys_addr[nfc->cs_sel]; in stm32_fmc2_nfc_select_chip()
353 dma_cfg.dst_addr = nfc->data_phys_addr[nfc->cs_sel]; in stm32_fmc2_nfc_select_chip()
359 ret = dmaengine_slave_config(nfc->dma_tx_ch, &dma_cfg); in stm32_fmc2_nfc_select_chip()
361 dev_err(nfc->dev, "tx DMA engine slave config failed\n"); in stm32_fmc2_nfc_select_chip()
365 ret = dmaengine_slave_config(nfc->dma_rx_ch, &dma_cfg); in stm32_fmc2_nfc_select_chip()
367 dev_err(nfc->dev, "rx DMA engine slave config failed\n"); in stm32_fmc2_nfc_select_chip()
372 if (nfc->dma_ecc_ch) { in stm32_fmc2_nfc_select_chip()
378 dma_cfg.src_addr = nfc->io_phys_addr; in stm32_fmc2_nfc_select_chip()
383 ret = dmaengine_slave_config(nfc->dma_ecc_ch, &dma_cfg); in stm32_fmc2_nfc_select_chip()
385 dev_err(nfc->dev, "ECC DMA engine slave config failed\n"); in stm32_fmc2_nfc_select_chip()
390 nfc->dma_ecc_len = chip->ecc.strength == FMC2_ECC_HAM ? in stm32_fmc2_nfc_select_chip()
397 static void stm32_fmc2_nfc_set_buswidth_16(struct stm32_fmc2_nfc *nfc, bool set) in stm32_fmc2_nfc_set_buswidth_16() argument
404 regmap_update_bits(nfc->regmap, FMC2_PCR, FMC2_PCR_PWID, pcr); in stm32_fmc2_nfc_set_buswidth_16()
407 static void stm32_fmc2_nfc_set_ecc(struct stm32_fmc2_nfc *nfc, bool enable) in stm32_fmc2_nfc_set_ecc() argument
409 regmap_update_bits(nfc->regmap, FMC2_PCR, FMC2_PCR_ECCEN, in stm32_fmc2_nfc_set_ecc()
413 static void stm32_fmc2_nfc_enable_seq_irq(struct stm32_fmc2_nfc *nfc) in stm32_fmc2_nfc_enable_seq_irq() argument
415 nfc->irq_state = FMC2_IRQ_SEQ; in stm32_fmc2_nfc_enable_seq_irq()
417 regmap_update_bits(nfc->regmap, FMC2_CSQIER, in stm32_fmc2_nfc_enable_seq_irq()
421 static void stm32_fmc2_nfc_disable_seq_irq(struct stm32_fmc2_nfc *nfc) in stm32_fmc2_nfc_disable_seq_irq() argument
423 regmap_update_bits(nfc->regmap, FMC2_CSQIER, FMC2_CSQIER_TCIE, 0); in stm32_fmc2_nfc_disable_seq_irq()
425 nfc->irq_state = FMC2_IRQ_UNKNOWN; in stm32_fmc2_nfc_disable_seq_irq()
428 static void stm32_fmc2_nfc_clear_seq_irq(struct stm32_fmc2_nfc *nfc) in stm32_fmc2_nfc_clear_seq_irq() argument
430 regmap_write(nfc->regmap, FMC2_CSQICR, FMC2_CSQICR_CLEAR_IRQ); in stm32_fmc2_nfc_clear_seq_irq()
433 static void stm32_fmc2_nfc_enable_bch_irq(struct stm32_fmc2_nfc *nfc, int mode) in stm32_fmc2_nfc_enable_bch_irq() argument
435 nfc->irq_state = FMC2_IRQ_BCH; in stm32_fmc2_nfc_enable_bch_irq()
438 regmap_update_bits(nfc->regmap, FMC2_BCHIER, in stm32_fmc2_nfc_enable_bch_irq()
441 regmap_update_bits(nfc->regmap, FMC2_BCHIER, in stm32_fmc2_nfc_enable_bch_irq()
445 static void stm32_fmc2_nfc_disable_bch_irq(struct stm32_fmc2_nfc *nfc) in stm32_fmc2_nfc_disable_bch_irq() argument
447 regmap_update_bits(nfc->regmap, FMC2_BCHIER, in stm32_fmc2_nfc_disable_bch_irq()
450 nfc->irq_state = FMC2_IRQ_UNKNOWN; in stm32_fmc2_nfc_disable_bch_irq()
453 static void stm32_fmc2_nfc_clear_bch_irq(struct stm32_fmc2_nfc *nfc) in stm32_fmc2_nfc_clear_bch_irq() argument
455 regmap_write(nfc->regmap, FMC2_BCHICR, FMC2_BCHICR_CLEAR_IRQ); in stm32_fmc2_nfc_clear_bch_irq()
464 struct stm32_fmc2_nfc *nfc = to_stm32_nfc(chip->controller); in stm32_fmc2_nfc_hwctl() local
466 stm32_fmc2_nfc_set_ecc(nfc, false); in stm32_fmc2_nfc_hwctl()
469 regmap_update_bits(nfc->regmap, FMC2_PCR, FMC2_PCR_WEN, in stm32_fmc2_nfc_hwctl()
472 reinit_completion(&nfc->complete); in stm32_fmc2_nfc_hwctl()
473 stm32_fmc2_nfc_clear_bch_irq(nfc); in stm32_fmc2_nfc_hwctl()
474 stm32_fmc2_nfc_enable_bch_irq(nfc, mode); in stm32_fmc2_nfc_hwctl()
477 stm32_fmc2_nfc_set_ecc(nfc, true); in stm32_fmc2_nfc_hwctl()
495 struct stm32_fmc2_nfc *nfc = to_stm32_nfc(chip->controller); in stm32_fmc2_nfc_ham_calculate() local
499 ret = regmap_read_poll_timeout(nfc->regmap, FMC2_SR, sr, in stm32_fmc2_nfc_ham_calculate()
503 dev_err(nfc->dev, "ham timeout\n"); in stm32_fmc2_nfc_ham_calculate()
507 regmap_read(nfc->regmap, FMC2_HECCR, &heccr); in stm32_fmc2_nfc_ham_calculate()
509 stm32_fmc2_nfc_set_ecc(nfc, false); in stm32_fmc2_nfc_ham_calculate()
576 struct stm32_fmc2_nfc *nfc = to_stm32_nfc(chip->controller); in stm32_fmc2_nfc_bch_calculate() local
580 if (!wait_for_completion_timeout(&nfc->complete, in stm32_fmc2_nfc_bch_calculate()
582 dev_err(nfc->dev, "bch timeout\n"); in stm32_fmc2_nfc_bch_calculate()
583 stm32_fmc2_nfc_disable_bch_irq(nfc); in stm32_fmc2_nfc_bch_calculate()
588 regmap_read(nfc->regmap, FMC2_BCHPBR1, &bchpbr); in stm32_fmc2_nfc_bch_calculate()
594 regmap_read(nfc->regmap, FMC2_BCHPBR2, &bchpbr); in stm32_fmc2_nfc_bch_calculate()
602 regmap_read(nfc->regmap, FMC2_BCHPBR3, &bchpbr); in stm32_fmc2_nfc_bch_calculate()
608 regmap_read(nfc->regmap, FMC2_BCHPBR4, &bchpbr); in stm32_fmc2_nfc_bch_calculate()
612 stm32_fmc2_nfc_set_ecc(nfc, false); in stm32_fmc2_nfc_bch_calculate()
659 struct stm32_fmc2_nfc *nfc = to_stm32_nfc(chip->controller); in stm32_fmc2_nfc_bch_correct() local
663 if (!wait_for_completion_timeout(&nfc->complete, in stm32_fmc2_nfc_bch_correct()
665 dev_err(nfc->dev, "bch timeout\n"); in stm32_fmc2_nfc_bch_correct()
666 stm32_fmc2_nfc_disable_bch_irq(nfc); in stm32_fmc2_nfc_bch_correct()
670 regmap_bulk_read(nfc->regmap, FMC2_BCHDSR0, ecc_sta, 5); in stm32_fmc2_nfc_bch_correct()
672 stm32_fmc2_nfc_set_ecc(nfc, false); in stm32_fmc2_nfc_bch_correct()
743 struct stm32_fmc2_nfc *nfc = to_stm32_nfc(chip->controller); in stm32_fmc2_nfc_rw_page_init() local
752 regmap_update_bits(nfc->regmap, FMC2_PCR, FMC2_PCR_WEN, in stm32_fmc2_nfc_rw_page_init()
815 cfg[4] = FIELD_PREP(FMC2_CSQCAR2_NANDCEN, nfc->cs_sel); in stm32_fmc2_nfc_rw_page_init()
827 regmap_bulk_write(nfc->regmap, FMC2_CSQCFGR1, cfg, 5); in stm32_fmc2_nfc_rw_page_init()
839 struct stm32_fmc2_nfc *nfc = to_stm32_nfc(chip->controller); in stm32_fmc2_nfc_xfer() local
842 struct dma_chan *dma_ch = nfc->dma_rx_ch; in stm32_fmc2_nfc_xfer()
855 dma_ch = nfc->dma_tx_ch; in stm32_fmc2_nfc_xfer()
858 for_each_sg(nfc->dma_data_sg.sgl, sg, eccsteps, s) { in stm32_fmc2_nfc_xfer()
863 ret = dma_map_sg(nfc->dev, nfc->dma_data_sg.sgl, in stm32_fmc2_nfc_xfer()
868 desc_data = dmaengine_prep_slave_sg(dma_ch, nfc->dma_data_sg.sgl, in stm32_fmc2_nfc_xfer()
876 reinit_completion(&nfc->dma_data_complete); in stm32_fmc2_nfc_xfer()
877 reinit_completion(&nfc->complete); in stm32_fmc2_nfc_xfer()
879 desc_data->callback_param = &nfc->dma_data_complete; in stm32_fmc2_nfc_xfer()
888 p = nfc->ecc_buf; in stm32_fmc2_nfc_xfer()
889 for_each_sg(nfc->dma_ecc_sg.sgl, sg, eccsteps, s) { in stm32_fmc2_nfc_xfer()
890 sg_set_buf(sg, p, nfc->dma_ecc_len); in stm32_fmc2_nfc_xfer()
891 p += nfc->dma_ecc_len; in stm32_fmc2_nfc_xfer()
894 ret = dma_map_sg(nfc->dev, nfc->dma_ecc_sg.sgl, in stm32_fmc2_nfc_xfer()
901 desc_ecc = dmaengine_prep_slave_sg(nfc->dma_ecc_ch, in stm32_fmc2_nfc_xfer()
902 nfc->dma_ecc_sg.sgl, in stm32_fmc2_nfc_xfer()
910 reinit_completion(&nfc->dma_ecc_complete); in stm32_fmc2_nfc_xfer()
912 desc_ecc->callback_param = &nfc->dma_ecc_complete; in stm32_fmc2_nfc_xfer()
917 dma_async_issue_pending(nfc->dma_ecc_ch); in stm32_fmc2_nfc_xfer()
920 stm32_fmc2_nfc_clear_seq_irq(nfc); in stm32_fmc2_nfc_xfer()
921 stm32_fmc2_nfc_enable_seq_irq(nfc); in stm32_fmc2_nfc_xfer()
924 regmap_update_bits(nfc->regmap, FMC2_CSQCR, in stm32_fmc2_nfc_xfer()
928 if (!wait_for_completion_timeout(&nfc->complete, timeout)) { in stm32_fmc2_nfc_xfer()
929 dev_err(nfc->dev, "seq timeout\n"); in stm32_fmc2_nfc_xfer()
930 stm32_fmc2_nfc_disable_seq_irq(nfc); in stm32_fmc2_nfc_xfer()
933 dmaengine_terminate_all(nfc->dma_ecc_ch); in stm32_fmc2_nfc_xfer()
939 if (!wait_for_completion_timeout(&nfc->dma_data_complete, timeout)) { in stm32_fmc2_nfc_xfer()
940 dev_err(nfc->dev, "data DMA timeout\n"); in stm32_fmc2_nfc_xfer()
947 if (!wait_for_completion_timeout(&nfc->dma_ecc_complete, in stm32_fmc2_nfc_xfer()
949 dev_err(nfc->dev, "ECC DMA timeout\n"); in stm32_fmc2_nfc_xfer()
950 dmaengine_terminate_all(nfc->dma_ecc_ch); in stm32_fmc2_nfc_xfer()
957 dma_unmap_sg(nfc->dev, nfc->dma_ecc_sg.sgl, in stm32_fmc2_nfc_xfer()
961 dma_unmap_sg(nfc->dev, nfc->dma_data_sg.sgl, eccsteps, dma_data_dir); in stm32_fmc2_nfc_xfer()
1018 static u16 stm32_fmc2_nfc_get_mapping_status(struct stm32_fmc2_nfc *nfc) in stm32_fmc2_nfc_get_mapping_status() argument
1022 regmap_read(nfc->regmap, FMC2_CSQEMSR, &csqemsr); in stm32_fmc2_nfc_get_mapping_status()
1031 struct stm32_fmc2_nfc *nfc = to_stm32_nfc(chip->controller); in stm32_fmc2_nfc_seq_correct() local
1036 u32 *ecc_sta = (u32 *)nfc->ecc_buf; in stm32_fmc2_nfc_seq_correct()
1037 u16 sta_map = stm32_fmc2_nfc_get_mapping_status(nfc); in stm32_fmc2_nfc_seq_correct()
1090 struct stm32_fmc2_nfc *nfc = to_stm32_nfc(chip->controller); in stm32_fmc2_nfc_seq_read_page() local
1108 sta_map = stm32_fmc2_nfc_get_mapping_status(nfc); in stm32_fmc2_nfc_seq_read_page()
1164 struct stm32_fmc2_nfc *nfc = (struct stm32_fmc2_nfc *)dev_id; in stm32_fmc2_nfc_irq() local
1166 if (nfc->irq_state == FMC2_IRQ_SEQ) in stm32_fmc2_nfc_irq()
1168 stm32_fmc2_nfc_disable_seq_irq(nfc); in stm32_fmc2_nfc_irq()
1169 else if (nfc->irq_state == FMC2_IRQ_BCH) in stm32_fmc2_nfc_irq()
1171 stm32_fmc2_nfc_disable_bch_irq(nfc); in stm32_fmc2_nfc_irq()
1173 complete(&nfc->complete); in stm32_fmc2_nfc_irq()
1181 struct stm32_fmc2_nfc *nfc = to_stm32_nfc(chip->controller); in stm32_fmc2_nfc_read_data() local
1182 void __iomem *io_addr_r = nfc->data_base[nfc->cs_sel]; in stm32_fmc2_nfc_read_data()
1186 stm32_fmc2_nfc_set_buswidth_16(nfc, false); in stm32_fmc2_nfc_read_data()
1222 stm32_fmc2_nfc_set_buswidth_16(nfc, true); in stm32_fmc2_nfc_read_data()
1228 struct stm32_fmc2_nfc *nfc = to_stm32_nfc(chip->controller); in stm32_fmc2_nfc_write_data() local
1229 void __iomem *io_addr_w = nfc->data_base[nfc->cs_sel]; in stm32_fmc2_nfc_write_data()
1233 stm32_fmc2_nfc_set_buswidth_16(nfc, false); in stm32_fmc2_nfc_write_data()
1269 stm32_fmc2_nfc_set_buswidth_16(nfc, true); in stm32_fmc2_nfc_write_data()
1275 struct stm32_fmc2_nfc *nfc = to_stm32_nfc(chip->controller); in stm32_fmc2_nfc_waitrdy() local
1280 if (regmap_read_poll_timeout(nfc->regmap, FMC2_SR, sr, in stm32_fmc2_nfc_waitrdy()
1283 dev_warn(nfc->dev, "Waitrdy timeout\n"); in stm32_fmc2_nfc_waitrdy()
1290 regmap_write(nfc->regmap, FMC2_ICR, FMC2_ICR_CIHLF); in stm32_fmc2_nfc_waitrdy()
1293 return regmap_read_poll_timeout(nfc->regmap, FMC2_ISR, isr, in stm32_fmc2_nfc_waitrdy()
1302 struct stm32_fmc2_nfc *nfc = to_stm32_nfc(chip->controller); in stm32_fmc2_nfc_exec_op() local
1320 nfc->cmd_base[nfc->cs_sel]); in stm32_fmc2_nfc_exec_op()
1326 nfc->addr_base[nfc->cs_sel]); in stm32_fmc2_nfc_exec_op()
1351 static void stm32_fmc2_nfc_init(struct stm32_fmc2_nfc *nfc) in stm32_fmc2_nfc_init() argument
1355 regmap_read(nfc->regmap, FMC2_PCR, &pcr); in stm32_fmc2_nfc_init()
1358 nfc->cs_sel = -1; in stm32_fmc2_nfc_init()
1386 if (nfc->dev == nfc->cdev) in stm32_fmc2_nfc_init()
1387 regmap_update_bits(nfc->regmap, FMC2_BCR1, in stm32_fmc2_nfc_init()
1390 regmap_write(nfc->regmap, FMC2_PCR, pcr); in stm32_fmc2_nfc_init()
1391 regmap_write(nfc->regmap, FMC2_PMEM, FMC2_PMEM_DEFAULT); in stm32_fmc2_nfc_init()
1392 regmap_write(nfc->regmap, FMC2_PATT, FMC2_PATT_DEFAULT); in stm32_fmc2_nfc_init()
1398 struct stm32_fmc2_nfc *nfc = to_stm32_nfc(chip->controller); in stm32_fmc2_nfc_calc_timings() local
1401 unsigned long hclk = clk_get_rate(nfc->clk); in stm32_fmc2_nfc_calc_timings()
1546 static int stm32_fmc2_nfc_dma_setup(struct stm32_fmc2_nfc *nfc) in stm32_fmc2_nfc_dma_setup() argument
1550 nfc->dma_tx_ch = dma_request_chan(nfc->dev, "tx"); in stm32_fmc2_nfc_dma_setup()
1551 if (IS_ERR(nfc->dma_tx_ch)) { in stm32_fmc2_nfc_dma_setup()
1552 ret = PTR_ERR(nfc->dma_tx_ch); in stm32_fmc2_nfc_dma_setup()
1554 dev_err(nfc->dev, in stm32_fmc2_nfc_dma_setup()
1556 nfc->dma_tx_ch = NULL; in stm32_fmc2_nfc_dma_setup()
1560 nfc->dma_rx_ch = dma_request_chan(nfc->dev, "rx"); in stm32_fmc2_nfc_dma_setup()
1561 if (IS_ERR(nfc->dma_rx_ch)) { in stm32_fmc2_nfc_dma_setup()
1562 ret = PTR_ERR(nfc->dma_rx_ch); in stm32_fmc2_nfc_dma_setup()
1564 dev_err(nfc->dev, in stm32_fmc2_nfc_dma_setup()
1566 nfc->dma_rx_ch = NULL; in stm32_fmc2_nfc_dma_setup()
1570 nfc->dma_ecc_ch = dma_request_chan(nfc->dev, "ecc"); in stm32_fmc2_nfc_dma_setup()
1571 if (IS_ERR(nfc->dma_ecc_ch)) { in stm32_fmc2_nfc_dma_setup()
1572 ret = PTR_ERR(nfc->dma_ecc_ch); in stm32_fmc2_nfc_dma_setup()
1574 dev_err(nfc->dev, in stm32_fmc2_nfc_dma_setup()
1576 nfc->dma_ecc_ch = NULL; in stm32_fmc2_nfc_dma_setup()
1580 ret = sg_alloc_table(&nfc->dma_ecc_sg, FMC2_MAX_SG, GFP_KERNEL); in stm32_fmc2_nfc_dma_setup()
1585 nfc->ecc_buf = devm_kzalloc(nfc->dev, FMC2_MAX_ECC_BUF_LEN, GFP_KERNEL); in stm32_fmc2_nfc_dma_setup()
1586 if (!nfc->ecc_buf) in stm32_fmc2_nfc_dma_setup()
1589 ret = sg_alloc_table(&nfc->dma_data_sg, FMC2_MAX_SG, GFP_KERNEL); in stm32_fmc2_nfc_dma_setup()
1593 init_completion(&nfc->dma_data_complete); in stm32_fmc2_nfc_dma_setup()
1594 init_completion(&nfc->dma_ecc_complete); in stm32_fmc2_nfc_dma_setup()
1600 dev_warn(nfc->dev, in stm32_fmc2_nfc_dma_setup()
1610 struct stm32_fmc2_nfc *nfc = to_stm32_nfc(chip->controller); in stm32_fmc2_nfc_nand_callbacks_setup() local
1616 if (nfc->dma_tx_ch && nfc->dma_rx_ch && nfc->dma_ecc_ch) { in stm32_fmc2_nfc_nand_callbacks_setup()
1703 struct stm32_fmc2_nfc *nfc = to_stm32_nfc(chip->controller); in stm32_fmc2_nfc_attach_chip() local
1715 dev_err(nfc->dev, in stm32_fmc2_nfc_attach_chip()
1730 dev_err(nfc->dev, "no valid ECC settings set\n"); in stm32_fmc2_nfc_attach_chip()
1735 dev_err(nfc->dev, "nand page size is not supported\n"); in stm32_fmc2_nfc_attach_chip()
1769 static int stm32_fmc2_nfc_parse_child(struct stm32_fmc2_nfc *nfc, in stm32_fmc2_nfc_parse_child() argument
1772 struct stm32_fmc2_nand *nand = &nfc->nand; in stm32_fmc2_nfc_parse_child()
1781 dev_err(nfc->dev, "invalid reg property size\n"); in stm32_fmc2_nfc_parse_child()
1788 dev_err(nfc->dev, "could not retrieve reg property: %d\n", in stm32_fmc2_nfc_parse_child()
1794 dev_err(nfc->dev, "invalid reg value: %d\n", cs); in stm32_fmc2_nfc_parse_child()
1798 if (nfc->cs_assigned & BIT(cs)) { in stm32_fmc2_nfc_parse_child()
1799 dev_err(nfc->dev, "cs already assigned: %d\n", cs); in stm32_fmc2_nfc_parse_child()
1803 nfc->cs_assigned |= BIT(cs); in stm32_fmc2_nfc_parse_child()
1807 nand->wp_gpio = devm_fwnode_gpiod_get(nfc->dev, of_fwnode_handle(dn), in stm32_fmc2_nfc_parse_child()
1812 return dev_err_probe(nfc->dev, ret, in stm32_fmc2_nfc_parse_child()
1823 static int stm32_fmc2_nfc_parse_dt(struct stm32_fmc2_nfc *nfc) in stm32_fmc2_nfc_parse_dt() argument
1825 struct device_node *dn = nfc->dev->of_node; in stm32_fmc2_nfc_parse_dt()
1831 dev_err(nfc->dev, "NAND chip not defined\n"); in stm32_fmc2_nfc_parse_dt()
1836 dev_err(nfc->dev, "too many NAND chips defined\n"); in stm32_fmc2_nfc_parse_dt()
1841 ret = stm32_fmc2_nfc_parse_child(nfc, child); in stm32_fmc2_nfc_parse_dt()
1851 static int stm32_fmc2_nfc_set_cdev(struct stm32_fmc2_nfc *nfc) in stm32_fmc2_nfc_set_cdev() argument
1853 struct device *dev = nfc->dev; in stm32_fmc2_nfc_set_cdev()
1860 if (of_device_is_compatible(dev->of_node, "st,stm32mp1-fmc2-nfc")) { in stm32_fmc2_nfc_set_cdev()
1862 nfc->cdev = dev->parent; in stm32_fmc2_nfc_set_cdev()
1873 nfc->cdev = dev; in stm32_fmc2_nfc_set_cdev()
1882 struct stm32_fmc2_nfc *nfc; in stm32_fmc2_nfc_probe() local
1891 nfc = devm_kzalloc(dev, sizeof(*nfc), GFP_KERNEL); in stm32_fmc2_nfc_probe()
1892 if (!nfc) in stm32_fmc2_nfc_probe()
1895 nfc->dev = dev; in stm32_fmc2_nfc_probe()
1896 nand_controller_init(&nfc->base); in stm32_fmc2_nfc_probe()
1897 nfc->base.ops = &stm32_fmc2_nfc_controller_ops; in stm32_fmc2_nfc_probe()
1899 ret = stm32_fmc2_nfc_set_cdev(nfc); in stm32_fmc2_nfc_probe()
1903 ret = stm32_fmc2_nfc_parse_dt(nfc); in stm32_fmc2_nfc_probe()
1907 ret = of_address_to_resource(nfc->cdev->of_node, 0, &cres); in stm32_fmc2_nfc_probe()
1911 nfc->io_phys_addr = cres.start; in stm32_fmc2_nfc_probe()
1913 nfc->regmap = device_node_to_regmap(nfc->cdev->of_node); in stm32_fmc2_nfc_probe()
1914 if (IS_ERR(nfc->regmap)) in stm32_fmc2_nfc_probe()
1915 return PTR_ERR(nfc->regmap); in stm32_fmc2_nfc_probe()
1917 if (nfc->dev == nfc->cdev) in stm32_fmc2_nfc_probe()
1922 if (!(nfc->cs_assigned & BIT(chip_cs))) in stm32_fmc2_nfc_probe()
1925 nfc->data_base[chip_cs] = devm_platform_get_and_ioremap_resource(pdev, in stm32_fmc2_nfc_probe()
1927 if (IS_ERR(nfc->data_base[chip_cs])) in stm32_fmc2_nfc_probe()
1928 return PTR_ERR(nfc->data_base[chip_cs]); in stm32_fmc2_nfc_probe()
1930 nfc->data_phys_addr[chip_cs] = res->start; in stm32_fmc2_nfc_probe()
1932 nfc->cmd_base[chip_cs] = devm_platform_ioremap_resource(pdev, mem_region + 1); in stm32_fmc2_nfc_probe()
1933 if (IS_ERR(nfc->cmd_base[chip_cs])) in stm32_fmc2_nfc_probe()
1934 return PTR_ERR(nfc->cmd_base[chip_cs]); in stm32_fmc2_nfc_probe()
1936 nfc->addr_base[chip_cs] = devm_platform_ioremap_resource(pdev, mem_region + 2); in stm32_fmc2_nfc_probe()
1937 if (IS_ERR(nfc->addr_base[chip_cs])) in stm32_fmc2_nfc_probe()
1938 return PTR_ERR(nfc->addr_base[chip_cs]); in stm32_fmc2_nfc_probe()
1946 dev_name(dev), nfc); in stm32_fmc2_nfc_probe()
1952 init_completion(&nfc->complete); in stm32_fmc2_nfc_probe()
1954 nfc->clk = devm_clk_get_enabled(nfc->cdev, NULL); in stm32_fmc2_nfc_probe()
1955 if (IS_ERR(nfc->clk)) { in stm32_fmc2_nfc_probe()
1957 return PTR_ERR(nfc->clk); in stm32_fmc2_nfc_probe()
1970 ret = stm32_fmc2_nfc_dma_setup(nfc); in stm32_fmc2_nfc_probe()
1974 stm32_fmc2_nfc_init(nfc); in stm32_fmc2_nfc_probe()
1976 nand = &nfc->nand; in stm32_fmc2_nfc_probe()
1981 chip->controller = &nfc->base; in stm32_fmc2_nfc_probe()
1996 platform_set_drvdata(pdev, nfc); in stm32_fmc2_nfc_probe()
2007 if (nfc->dma_ecc_ch) in stm32_fmc2_nfc_probe()
2008 dma_release_channel(nfc->dma_ecc_ch); in stm32_fmc2_nfc_probe()
2009 if (nfc->dma_tx_ch) in stm32_fmc2_nfc_probe()
2010 dma_release_channel(nfc->dma_tx_ch); in stm32_fmc2_nfc_probe()
2011 if (nfc->dma_rx_ch) in stm32_fmc2_nfc_probe()
2012 dma_release_channel(nfc->dma_rx_ch); in stm32_fmc2_nfc_probe()
2014 sg_free_table(&nfc->dma_data_sg); in stm32_fmc2_nfc_probe()
2015 sg_free_table(&nfc->dma_ecc_sg); in stm32_fmc2_nfc_probe()
2022 struct stm32_fmc2_nfc *nfc = platform_get_drvdata(pdev); in stm32_fmc2_nfc_remove() local
2023 struct stm32_fmc2_nand *nand = &nfc->nand; in stm32_fmc2_nfc_remove()
2031 if (nfc->dma_ecc_ch) in stm32_fmc2_nfc_remove()
2032 dma_release_channel(nfc->dma_ecc_ch); in stm32_fmc2_nfc_remove()
2033 if (nfc->dma_tx_ch) in stm32_fmc2_nfc_remove()
2034 dma_release_channel(nfc->dma_tx_ch); in stm32_fmc2_nfc_remove()
2035 if (nfc->dma_rx_ch) in stm32_fmc2_nfc_remove()
2036 dma_release_channel(nfc->dma_rx_ch); in stm32_fmc2_nfc_remove()
2038 sg_free_table(&nfc->dma_data_sg); in stm32_fmc2_nfc_remove()
2039 sg_free_table(&nfc->dma_ecc_sg); in stm32_fmc2_nfc_remove()
2046 struct stm32_fmc2_nfc *nfc = dev_get_drvdata(dev); in stm32_fmc2_nfc_suspend() local
2047 struct stm32_fmc2_nand *nand = &nfc->nand; in stm32_fmc2_nfc_suspend()
2049 clk_disable_unprepare(nfc->clk); in stm32_fmc2_nfc_suspend()
2060 struct stm32_fmc2_nfc *nfc = dev_get_drvdata(dev); in stm32_fmc2_nfc_resume() local
2061 struct stm32_fmc2_nand *nand = &nfc->nand; in stm32_fmc2_nfc_resume()
2066 ret = clk_prepare_enable(nfc->clk); in stm32_fmc2_nfc_resume()
2072 stm32_fmc2_nfc_init(nfc); in stm32_fmc2_nfc_resume()
2077 if (!(nfc->cs_assigned & BIT(chip_cs))) in stm32_fmc2_nfc_resume()
2091 {.compatible = "st,stm32mp1-fmc2-nfc"},
2109 MODULE_DESCRIPTION("STMicroelectronics STM32 FMC2 NFC driver");