| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Driver for EIP97 cryptographic accelerator. |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (c) 2016 Ryder Lee <ryder.lee@mediatek.com> |
|---|
| 5 | | - * |
|---|
| 6 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 7 | | - * it under the terms of the GNU General Public License version 2 as |
|---|
| 8 | | - * published by the Free Software Foundation. |
|---|
| 9 | | - * |
|---|
| 10 | 6 | */ |
|---|
| 11 | 7 | |
|---|
| 12 | 8 | #include <linux/clk.h> |
|---|
| .. | .. |
|---|
| 189 | 185 | |
|---|
| 190 | 186 | static int mtk_dfe_dse_reset(struct mtk_cryp *cryp) |
|---|
| 191 | 187 | { |
|---|
| 192 | | - int err; |
|---|
| 193 | | - |
|---|
| 194 | 188 | /* Reset DSE/DFE and correct system priorities for all rings. */ |
|---|
| 195 | 189 | writel(MTK_DFSE_THR_CTRL_RESET, cryp->base + DFE_THR_CTRL); |
|---|
| 196 | 190 | writel(0, cryp->base + DFE_PRIO_0); |
|---|
| .. | .. |
|---|
| 204 | 198 | writel(0, cryp->base + DSE_PRIO_2); |
|---|
| 205 | 199 | writel(0, cryp->base + DSE_PRIO_3); |
|---|
| 206 | 200 | |
|---|
| 207 | | - err = mtk_dfe_dse_state_check(cryp); |
|---|
| 208 | | - if (err) |
|---|
| 209 | | - return err; |
|---|
| 210 | | - |
|---|
| 211 | | - return 0; |
|---|
| 201 | + return mtk_dfe_dse_state_check(cryp); |
|---|
| 212 | 202 | } |
|---|
| 213 | 203 | |
|---|
| 214 | 204 | static void mtk_cmd_desc_ring_setup(struct mtk_cryp *cryp, |
|---|
| .. | .. |
|---|
| 453 | 443 | if (!ring[i]) |
|---|
| 454 | 444 | goto err_cleanup; |
|---|
| 455 | 445 | |
|---|
| 456 | | - ring[i]->cmd_base = dma_zalloc_coherent(cryp->dev, |
|---|
| 457 | | - MTK_DESC_RING_SZ, |
|---|
| 458 | | - &ring[i]->cmd_dma, |
|---|
| 459 | | - GFP_KERNEL); |
|---|
| 446 | + ring[i]->cmd_base = dma_alloc_coherent(cryp->dev, |
|---|
| 447 | + MTK_DESC_RING_SZ, |
|---|
| 448 | + &ring[i]->cmd_dma, |
|---|
| 449 | + GFP_KERNEL); |
|---|
| 460 | 450 | if (!ring[i]->cmd_base) |
|---|
| 461 | 451 | goto err_cleanup; |
|---|
| 462 | 452 | |
|---|
| 463 | | - ring[i]->res_base = dma_zalloc_coherent(cryp->dev, |
|---|
| 464 | | - MTK_DESC_RING_SZ, |
|---|
| 465 | | - &ring[i]->res_dma, |
|---|
| 466 | | - GFP_KERNEL); |
|---|
| 453 | + ring[i]->res_base = dma_alloc_coherent(cryp->dev, |
|---|
| 454 | + MTK_DESC_RING_SZ, |
|---|
| 455 | + &ring[i]->res_dma, |
|---|
| 456 | + GFP_KERNEL); |
|---|
| 467 | 457 | if (!ring[i]->res_base) |
|---|
| 468 | 458 | goto err_cleanup; |
|---|
| 469 | 459 | |
|---|
| .. | .. |
|---|
| 485 | 475 | |
|---|
| 486 | 476 | static int mtk_crypto_probe(struct platform_device *pdev) |
|---|
| 487 | 477 | { |
|---|
| 488 | | - struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
|---|
| 489 | 478 | struct mtk_cryp *cryp; |
|---|
| 490 | 479 | int i, err; |
|---|
| 491 | 480 | |
|---|
| .. | .. |
|---|
| 493 | 482 | if (!cryp) |
|---|
| 494 | 483 | return -ENOMEM; |
|---|
| 495 | 484 | |
|---|
| 496 | | - cryp->base = devm_ioremap_resource(&pdev->dev, res); |
|---|
| 485 | + cryp->base = devm_platform_ioremap_resource(pdev, 0); |
|---|
| 497 | 486 | if (IS_ERR(cryp->base)) |
|---|
| 498 | 487 | return PTR_ERR(cryp->base); |
|---|
| 499 | 488 | |
|---|
| 500 | 489 | for (i = 0; i < MTK_IRQ_NUM; i++) { |
|---|
| 501 | 490 | cryp->irq[i] = platform_get_irq(pdev, i); |
|---|
| 502 | | - if (cryp->irq[i] < 0) { |
|---|
| 503 | | - dev_err(cryp->dev, "no IRQ:%d resource info\n", i); |
|---|
| 491 | + if (cryp->irq[i] < 0) |
|---|
| 504 | 492 | return cryp->irq[i]; |
|---|
| 505 | | - } |
|---|
| 506 | 493 | } |
|---|
| 507 | 494 | |
|---|
| 508 | 495 | cryp->clk_cryp = devm_clk_get(&pdev->dev, "cryp"); |
|---|