Lines Matching refs:ms

645 	struct mtk_snand *ms = nand_to_mtk_snand(nand);  in mtk_snand_ooblayout_free()  local
647 if (section >= ms->nfi_cfg.nsectors) in mtk_snand_ooblayout_free()
650 oobfree->length = ms->caps->fdm_size - 1; in mtk_snand_ooblayout_free()
651 oobfree->offset = section * ms->caps->fdm_size + 1; in mtk_snand_ooblayout_free()
1258 struct mtk_snand *ms = spi_controller_get_devdata(mem->spi->master); in mtk_snand_adjust_op_size() local
1266 if (ms->autofmt) in mtk_snand_adjust_op_size()
1268 l = ms->caps->sector_size + ms->nfi_cfg.spare_size; in mtk_snand_adjust_op_size()
1269 l *= ms->nfi_cfg.nsectors; in mtk_snand_adjust_op_size()
1285 struct mtk_snand *ms = spi_controller_get_devdata(mem->spi->master); in mtk_snand_exec_op() local
1287 dev_dbg(ms->dev, "OP %02x ADDR %08llX@%d:%u DATA %d:%u", op->cmd.opcode, in mtk_snand_exec_op()
1292 return mtk_snand_read_page_cache(ms, op); in mtk_snand_exec_op()
1294 return mtk_snand_write_page_cache(ms, op); in mtk_snand_exec_op()
1296 return mtk_snand_mac_io(ms, op); in mtk_snand_exec_op()
1335 static int mtk_snand_enable_clk(struct mtk_snand *ms) in mtk_snand_enable_clk() argument
1339 ret = clk_prepare_enable(ms->nfi_clk); in mtk_snand_enable_clk()
1341 dev_err(ms->dev, "unable to enable nfi clk\n"); in mtk_snand_enable_clk()
1344 ret = clk_prepare_enable(ms->pad_clk); in mtk_snand_enable_clk()
1346 dev_err(ms->dev, "unable to enable pad clk\n"); in mtk_snand_enable_clk()
1349 ret = clk_prepare_enable(ms->nfi_hclk); in mtk_snand_enable_clk()
1351 dev_err(ms->dev, "unable to enable nfi hclk\n"); in mtk_snand_enable_clk()
1358 clk_disable_unprepare(ms->pad_clk); in mtk_snand_enable_clk()
1360 clk_disable_unprepare(ms->nfi_clk); in mtk_snand_enable_clk()
1364 static void mtk_snand_disable_clk(struct mtk_snand *ms) in mtk_snand_disable_clk() argument
1366 clk_disable_unprepare(ms->nfi_hclk); in mtk_snand_disable_clk()
1367 clk_disable_unprepare(ms->pad_clk); in mtk_snand_disable_clk()
1368 clk_disable_unprepare(ms->nfi_clk); in mtk_snand_disable_clk()
1376 struct mtk_snand *ms; in mtk_snand_probe() local
1385 ctlr = devm_spi_alloc_master(&pdev->dev, sizeof(*ms)); in mtk_snand_probe()
1390 ms = spi_controller_get_devdata(ctlr); in mtk_snand_probe()
1392 ms->ctlr = ctlr; in mtk_snand_probe()
1393 ms->caps = dev_id->data; in mtk_snand_probe()
1395 ms->ecc = of_mtk_ecc_get(np); in mtk_snand_probe()
1396 if (IS_ERR(ms->ecc)) in mtk_snand_probe()
1397 return PTR_ERR(ms->ecc); in mtk_snand_probe()
1398 else if (!ms->ecc) in mtk_snand_probe()
1401 ms->nfi_base = devm_platform_ioremap_resource(pdev, 0); in mtk_snand_probe()
1402 if (IS_ERR(ms->nfi_base)) { in mtk_snand_probe()
1403 ret = PTR_ERR(ms->nfi_base); in mtk_snand_probe()
1407 ms->dev = &pdev->dev; in mtk_snand_probe()
1409 ms->nfi_clk = devm_clk_get(&pdev->dev, "nfi_clk"); in mtk_snand_probe()
1410 if (IS_ERR(ms->nfi_clk)) { in mtk_snand_probe()
1411 ret = PTR_ERR(ms->nfi_clk); in mtk_snand_probe()
1416 ms->pad_clk = devm_clk_get(&pdev->dev, "pad_clk"); in mtk_snand_probe()
1417 if (IS_ERR(ms->pad_clk)) { in mtk_snand_probe()
1418 ret = PTR_ERR(ms->pad_clk); in mtk_snand_probe()
1423 ms->nfi_hclk = devm_clk_get_optional(&pdev->dev, "nfi_hclk"); in mtk_snand_probe()
1424 if (IS_ERR(ms->nfi_hclk)) { in mtk_snand_probe()
1425 ret = PTR_ERR(ms->nfi_hclk); in mtk_snand_probe()
1430 ret = mtk_snand_enable_clk(ms); in mtk_snand_probe()
1434 init_completion(&ms->op_done); in mtk_snand_probe()
1436 ms->irq = platform_get_irq(pdev, 0); in mtk_snand_probe()
1437 if (ms->irq < 0) { in mtk_snand_probe()
1438 ret = ms->irq; in mtk_snand_probe()
1441 ret = devm_request_irq(ms->dev, ms->irq, mtk_snand_irq, 0x0, in mtk_snand_probe()
1442 "mtk-snand", ms); in mtk_snand_probe()
1444 dev_err(ms->dev, "failed to request snfi irq\n"); in mtk_snand_probe()
1448 ret = dma_set_mask(ms->dev, DMA_BIT_MASK(32)); in mtk_snand_probe()
1450 dev_err(ms->dev, "failed to set dma mask\n"); in mtk_snand_probe()
1455 nfi_write32(ms, SNF_CFG, SPI_MODE); in mtk_snand_probe()
1459 nfi_rmw32(ms, SNF_DLY_CTL3, SFCK_SAM_DLY, in mtk_snand_probe()
1464 spi_freq = clk_get_rate(ms->pad_clk); in mtk_snand_probe()
1466 nfi_rmw32(ms, SNF_MISC_CTL, DATA_READ_LATCH_LAT, in mtk_snand_probe()
1472 ret = mtk_snand_setup_pagefmt(ms, SZ_2K, SZ_64); in mtk_snand_probe()
1474 dev_err(ms->dev, "failed to set initial page format\n"); in mtk_snand_probe()
1479 ms->ecc_eng.dev = &pdev->dev; in mtk_snand_probe()
1480 ms->ecc_eng.integration = NAND_ECC_ENGINE_INTEGRATION_PIPELINED; in mtk_snand_probe()
1481 ms->ecc_eng.ops = &mtk_snfi_ecc_engine_ops; in mtk_snand_probe()
1482 ms->ecc_eng.priv = ms; in mtk_snand_probe()
1484 ret = nand_ecc_register_on_host_hw_engine(&ms->ecc_eng); in mtk_snand_probe()
1504 mtk_snand_disable_clk(ms); in mtk_snand_probe()
1506 mtk_ecc_release(ms->ecc); in mtk_snand_probe()
1513 struct mtk_snand *ms = spi_controller_get_devdata(ctlr); in mtk_snand_remove() local
1516 mtk_snand_disable_clk(ms); in mtk_snand_remove()
1517 mtk_ecc_release(ms->ecc); in mtk_snand_remove()
1518 kfree(ms->buf); in mtk_snand_remove()