summaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi-mtk-snfi.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/spi/spi-mtk-snfi.c')
-rw-r--r--drivers/spi/spi-mtk-snfi.c67
1 files changed, 12 insertions, 55 deletions
diff --git a/drivers/spi/spi-mtk-snfi.c b/drivers/spi/spi-mtk-snfi.c
index 4433a8a929..ddd98ddb79 100644
--- a/drivers/spi/spi-mtk-snfi.c
+++ b/drivers/spi/spi-mtk-snfi.c
@@ -1255,7 +1255,7 @@ static bool mtk_snand_supports_op(struct spi_mem *mem,
static int mtk_snand_adjust_op_size(struct spi_mem *mem, struct spi_mem_op *op)
{
- struct mtk_snand *ms = spi_controller_get_devdata(mem->spi->master);
+ struct mtk_snand *ms = spi_controller_get_devdata(mem->spi->controller);
// page ops transfer size must be exactly ((sector_size + spare_size) *
// nsectors). Limit the op size if the caller requests more than that.
// exec_op will read more than needed and discard the leftover if the
@@ -1282,7 +1282,7 @@ static int mtk_snand_adjust_op_size(struct spi_mem *mem, struct spi_mem_op *op)
static int mtk_snand_exec_op(struct spi_mem *mem, const struct spi_mem_op *op)
{
- struct mtk_snand *ms = spi_controller_get_devdata(mem->spi->master);
+ struct mtk_snand *ms = spi_controller_get_devdata(mem->spi->controller);
dev_dbg(ms->dev, "OP %02x ADDR %08llX@%d:%u DATA %d:%u", op->cmd.opcode,
op->addr.val, op->addr.buswidth, op->addr.nbytes,
@@ -1332,42 +1332,6 @@ static const struct of_device_id mtk_snand_ids[] = {
MODULE_DEVICE_TABLE(of, mtk_snand_ids);
-static int mtk_snand_enable_clk(struct mtk_snand *ms)
-{
- int ret;
-
- ret = clk_prepare_enable(ms->nfi_clk);
- if (ret) {
- dev_err(ms->dev, "unable to enable nfi clk\n");
- return ret;
- }
- ret = clk_prepare_enable(ms->pad_clk);
- if (ret) {
- dev_err(ms->dev, "unable to enable pad clk\n");
- goto err1;
- }
- ret = clk_prepare_enable(ms->nfi_hclk);
- if (ret) {
- dev_err(ms->dev, "unable to enable nfi hclk\n");
- goto err2;
- }
-
- return 0;
-
-err2:
- clk_disable_unprepare(ms->pad_clk);
-err1:
- clk_disable_unprepare(ms->nfi_clk);
- return ret;
-}
-
-static void mtk_snand_disable_clk(struct mtk_snand *ms)
-{
- clk_disable_unprepare(ms->nfi_hclk);
- clk_disable_unprepare(ms->pad_clk);
- clk_disable_unprepare(ms->nfi_clk);
-}
-
static int mtk_snand_probe(struct platform_device *pdev)
{
struct device_node *np = pdev->dev.of_node;
@@ -1382,7 +1346,7 @@ static int mtk_snand_probe(struct platform_device *pdev)
if (!dev_id)
return -EINVAL;
- ctlr = devm_spi_alloc_master(&pdev->dev, sizeof(*ms));
+ ctlr = devm_spi_alloc_host(&pdev->dev, sizeof(*ms));
if (!ctlr)
return -ENOMEM;
platform_set_drvdata(pdev, ctlr);
@@ -1406,49 +1370,45 @@ static int mtk_snand_probe(struct platform_device *pdev)
ms->dev = &pdev->dev;
- ms->nfi_clk = devm_clk_get(&pdev->dev, "nfi_clk");
+ ms->nfi_clk = devm_clk_get_enabled(&pdev->dev, "nfi_clk");
if (IS_ERR(ms->nfi_clk)) {
ret = PTR_ERR(ms->nfi_clk);
dev_err(&pdev->dev, "unable to get nfi_clk, err = %d\n", ret);
goto release_ecc;
}
- ms->pad_clk = devm_clk_get(&pdev->dev, "pad_clk");
+ ms->pad_clk = devm_clk_get_enabled(&pdev->dev, "pad_clk");
if (IS_ERR(ms->pad_clk)) {
ret = PTR_ERR(ms->pad_clk);
dev_err(&pdev->dev, "unable to get pad_clk, err = %d\n", ret);
goto release_ecc;
}
- ms->nfi_hclk = devm_clk_get_optional(&pdev->dev, "nfi_hclk");
+ ms->nfi_hclk = devm_clk_get_optional_enabled(&pdev->dev, "nfi_hclk");
if (IS_ERR(ms->nfi_hclk)) {
ret = PTR_ERR(ms->nfi_hclk);
dev_err(&pdev->dev, "unable to get nfi_hclk, err = %d\n", ret);
goto release_ecc;
}
- ret = mtk_snand_enable_clk(ms);
- if (ret)
- goto release_ecc;
-
init_completion(&ms->op_done);
ms->irq = platform_get_irq(pdev, 0);
if (ms->irq < 0) {
ret = ms->irq;
- goto disable_clk;
+ goto release_ecc;
}
ret = devm_request_irq(ms->dev, ms->irq, mtk_snand_irq, 0x0,
"mtk-snand", ms);
if (ret) {
dev_err(ms->dev, "failed to request snfi irq\n");
- goto disable_clk;
+ goto release_ecc;
}
ret = dma_set_mask(ms->dev, DMA_BIT_MASK(32));
if (ret) {
dev_err(ms->dev, "failed to set dma mask\n");
- goto disable_clk;
+ goto release_ecc;
}
// switch to SNFI mode
@@ -1472,7 +1432,7 @@ static int mtk_snand_probe(struct platform_device *pdev)
ret = mtk_snand_setup_pagefmt(ms, SZ_2K, SZ_64);
if (ret) {
dev_err(ms->dev, "failed to set initial page format\n");
- goto disable_clk;
+ goto release_ecc;
}
// setup ECC engine
@@ -1484,7 +1444,7 @@ static int mtk_snand_probe(struct platform_device *pdev)
ret = nand_ecc_register_on_host_hw_engine(&ms->ecc_eng);
if (ret) {
dev_err(&pdev->dev, "failed to register ecc engine.\n");
- goto disable_clk;
+ goto release_ecc;
}
ctlr->num_chipselect = 1;
@@ -1496,12 +1456,10 @@ static int mtk_snand_probe(struct platform_device *pdev)
ret = spi_register_controller(ctlr);
if (ret) {
dev_err(&pdev->dev, "spi_register_controller failed.\n");
- goto disable_clk;
+ goto release_ecc;
}
return 0;
-disable_clk:
- mtk_snand_disable_clk(ms);
release_ecc:
mtk_ecc_release(ms->ecc);
return ret;
@@ -1513,7 +1471,6 @@ static void mtk_snand_remove(struct platform_device *pdev)
struct mtk_snand *ms = spi_controller_get_devdata(ctlr);
spi_unregister_controller(ctlr);
- mtk_snand_disable_clk(ms);
mtk_ecc_release(ms->ecc);
kfree(ms->buf);
}