hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/dma/mv_xor_v2.c
....@@ -1,15 +1,7 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Copyright (C) 2015-2016 Marvell International Ltd.
34
4
- * This program is free software: you can redistribute it and/or
5
- * modify it under the terms of the GNU General Public License as
6
- * published by the Free Software Foundation, either version 2 of the
7
- * License, or any later version.
8
- *
9
- * This program is distributed in the hope that it will be useful, but
10
- * WITHOUT ANY WARRANTY; without even the implied warranty of
11
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
- * General Public License for more details.
135 */
146
157 #include <linux/clk.h>
....@@ -41,7 +33,6 @@
4133 #define MV_XOR_V2_DMA_IMSG_CDAT_OFF 0x014
4234 #define MV_XOR_V2_DMA_IMSG_THRD_OFF 0x018
4335 #define MV_XOR_V2_DMA_IMSG_THRD_MASK 0x7FFF
44
-#define MV_XOR_V2_DMA_IMSG_THRD_SHIFT 0x0
4536 #define MV_XOR_V2_DMA_IMSG_TIMER_EN BIT(18)
4637 #define MV_XOR_V2_DMA_DESQ_AWATTR_OFF 0x01C
4738 /* Same flags as MV_XOR_V2_DMA_DESQ_ARATTR_OFF */
....@@ -58,7 +49,6 @@
5849 #define MV_XOR_V2_DMA_DESQ_ADD_OFF 0x808
5950 #define MV_XOR_V2_DMA_IMSG_TMOT 0x810
6051 #define MV_XOR_V2_DMA_IMSG_TIMER_THRD_MASK 0x1FFF
61
-#define MV_XOR_V2_DMA_IMSG_TIMER_THRD_SHIFT 0
6252
6353 /* XOR Global registers */
6454 #define MV_XOR_V2_GLOB_BW_CTRL 0x4
....@@ -145,9 +135,11 @@
145135 /**
146136 * struct mv_xor_v2_device - implements a xor device
147137 * @lock: lock for the engine
138
+ * @clk: reference to the 'core' clock
139
+ * @reg_clk: reference to the 'reg' clock
148140 * @dma_base: memory mapped DMA register base
149141 * @glob_base: memory mapped global register base
150
- * @irq_tasklet:
142
+ * @irq_tasklet: tasklet used for IRQ handling call-backs
151143 * @free_sw_desc: linked list of free SW descriptors
152144 * @dmadev: dma device
153145 * @dmachan: dma channel
....@@ -156,6 +148,8 @@
156148 * @sw_desq: SW descriptors queue
157149 * @desc_size: HW descriptor size
158150 * @npendings: number of pending descriptors (for which tx_submit has
151
+ * @hw_queue_idx: HW queue index
152
+ * @msi_desc: local interrupt descriptor information
159153 * been called, but not yet issue_pending)
160154 */
161155 struct mv_xor_v2_device {
....@@ -269,16 +263,15 @@
269263
270264 /* Configure threshold of number of descriptors, and enable timer */
271265 reg = readl(xor_dev->dma_base + MV_XOR_V2_DMA_IMSG_THRD_OFF);
272
- reg &= (~MV_XOR_V2_DMA_IMSG_THRD_MASK << MV_XOR_V2_DMA_IMSG_THRD_SHIFT);
273
- reg |= (MV_XOR_V2_DONE_IMSG_THRD << MV_XOR_V2_DMA_IMSG_THRD_SHIFT);
266
+ reg &= ~MV_XOR_V2_DMA_IMSG_THRD_MASK;
267
+ reg |= MV_XOR_V2_DONE_IMSG_THRD;
274268 reg |= MV_XOR_V2_DMA_IMSG_TIMER_EN;
275269 writel(reg, xor_dev->dma_base + MV_XOR_V2_DMA_IMSG_THRD_OFF);
276270
277271 /* Configure Timer Threshold */
278272 reg = readl(xor_dev->dma_base + MV_XOR_V2_DMA_IMSG_TMOT);
279
- reg &= (~MV_XOR_V2_DMA_IMSG_TIMER_THRD_MASK <<
280
- MV_XOR_V2_DMA_IMSG_TIMER_THRD_SHIFT);
281
- reg |= (MV_XOR_V2_TIMER_THRD << MV_XOR_V2_DMA_IMSG_TIMER_THRD_SHIFT);
273
+ reg &= ~MV_XOR_V2_DMA_IMSG_TIMER_THRD_MASK;
274
+ reg |= MV_XOR_V2_TIMER_THRD;
282275 writel(reg, xor_dev->dma_base + MV_XOR_V2_DMA_IMSG_TMOT);
283276 }
284277
....@@ -560,9 +553,10 @@
560553 /*
561554 * handle the descriptors after HW process
562555 */
563
-static void mv_xor_v2_tasklet(unsigned long data)
556
+static void mv_xor_v2_tasklet(struct tasklet_struct *t)
564557 {
565
- struct mv_xor_v2_device *xor_dev = (struct mv_xor_v2_device *) data;
558
+ struct mv_xor_v2_device *xor_dev = from_tasklet(xor_dev, t,
559
+ irq_tasklet);
566560 int pending_ptr, num_of_pending, i;
567561 struct mv_xor_v2_sw_desc *next_pending_sw_desc = NULL;
568562
....@@ -761,8 +755,8 @@
761755 }
762756
763757 xor_dev->clk = devm_clk_get(&pdev->dev, NULL);
764
- if (IS_ERR(xor_dev->clk) && PTR_ERR(xor_dev->clk) == -EPROBE_DEFER) {
765
- ret = EPROBE_DEFER;
758
+ if (PTR_ERR(xor_dev->clk) == -EPROBE_DEFER) {
759
+ ret = -EPROBE_DEFER;
766760 goto disable_reg_clk;
767761 }
768762 if (!IS_ERR(xor_dev->clk)) {
....@@ -789,8 +783,7 @@
789783 if (ret)
790784 goto free_msi_irqs;
791785
792
- tasklet_init(&xor_dev->irq_tasklet, mv_xor_v2_tasklet,
793
- (unsigned long) xor_dev);
786
+ tasklet_setup(&xor_dev->irq_tasklet, mv_xor_v2_tasklet);
794787
795788 xor_dev->desc_size = mv_xor_v2_set_desc_size(xor_dev);
796789
....@@ -906,6 +899,7 @@
906899 tasklet_kill(&xor_dev->irq_tasklet);
907900
908901 clk_disable_unprepare(xor_dev->clk);
902
+ clk_disable_unprepare(xor_dev->reg_clk);
909903
910904 return 0;
911905 }