aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/dma/mv_xor.c40
-rw-r--r--drivers/dma/mv_xor.h1
2 files changed, 29 insertions, 12 deletions
diff --git a/drivers/dma/mv_xor.c b/drivers/dma/mv_xor.c
index a6ec82776cbc..6d012a56b97b 100644
--- a/drivers/dma/mv_xor.c
+++ b/drivers/dma/mv_xor.c
@@ -31,6 +31,11 @@
31#include "dmaengine.h" 31#include "dmaengine.h"
32#include "mv_xor.h" 32#include "mv_xor.h"
33 33
34enum mv_xor_type {
35 XOR_ORION,
36 XOR_ARMADA_38X,
37};
38
34enum mv_xor_mode { 39enum mv_xor_mode {
35 XOR_MODE_IN_REG, 40 XOR_MODE_IN_REG,
36 XOR_MODE_IN_DESC, 41 XOR_MODE_IN_DESC,
@@ -933,7 +938,7 @@ static int mv_xor_channel_remove(struct mv_xor_chan *mv_chan)
933static struct mv_xor_chan * 938static struct mv_xor_chan *
934mv_xor_channel_add(struct mv_xor_device *xordev, 939mv_xor_channel_add(struct mv_xor_device *xordev,
935 struct platform_device *pdev, 940 struct platform_device *pdev,
936 int idx, dma_cap_mask_t cap_mask, int irq, int op_in_desc) 941 int idx, dma_cap_mask_t cap_mask, int irq)
937{ 942{
938 int ret = 0; 943 int ret = 0;
939 struct mv_xor_chan *mv_chan; 944 struct mv_xor_chan *mv_chan;
@@ -945,7 +950,10 @@ mv_xor_channel_add(struct mv_xor_device *xordev,
945 950
946 mv_chan->idx = idx; 951 mv_chan->idx = idx;
947 mv_chan->irq = irq; 952 mv_chan->irq = irq;
948 mv_chan->op_in_desc = op_in_desc; 953 if (xordev->xor_type == XOR_ORION)
954 mv_chan->op_in_desc = XOR_MODE_IN_REG;
955 else
956 mv_chan->op_in_desc = XOR_MODE_IN_DESC;
949 957
950 dma_dev = &mv_chan->dmadev; 958 dma_dev = &mv_chan->dmadev;
951 959
@@ -1137,8 +1145,8 @@ static int mv_xor_resume(struct platform_device *dev)
1137} 1145}
1138 1146
1139static const struct of_device_id mv_xor_dt_ids[] = { 1147static const struct of_device_id mv_xor_dt_ids[] = {
1140 { .compatible = "marvell,orion-xor", .data = (void *)XOR_MODE_IN_REG }, 1148 { .compatible = "marvell,orion-xor", .data = (void *)XOR_ORION },
1141 { .compatible = "marvell,armada-380-xor", .data = (void *)XOR_MODE_IN_DESC }, 1149 { .compatible = "marvell,armada-380-xor", .data = (void *)XOR_ARMADA_38X },
1142 {}, 1150 {},
1143}; 1151};
1144 1152
@@ -1152,7 +1160,6 @@ static int mv_xor_probe(struct platform_device *pdev)
1152 struct resource *res; 1160 struct resource *res;
1153 unsigned int max_engines, max_channels; 1161 unsigned int max_engines, max_channels;
1154 int i, ret; 1162 int i, ret;
1155 int op_in_desc;
1156 1163
1157 dev_notice(&pdev->dev, "Marvell shared XOR driver\n"); 1164 dev_notice(&pdev->dev, "Marvell shared XOR driver\n");
1158 1165
@@ -1180,6 +1187,20 @@ static int mv_xor_probe(struct platform_device *pdev)
1180 1187
1181 platform_set_drvdata(pdev, xordev); 1188 platform_set_drvdata(pdev, xordev);
1182 1189
1190
1191 /*
1192 * We need to know which type of XOR device we use before
1193 * setting up. In non-dt case it can only be the legacy one.
1194 */
1195 xordev->xor_type = XOR_ORION;
1196 if (pdev->dev.of_node) {
1197 const struct of_device_id *of_id =
1198 of_match_device(mv_xor_dt_ids,
1199 &pdev->dev);
1200
1201 xordev->xor_type = (uintptr_t)of_id->data;
1202 }
1203
1183 /* 1204 /*
1184 * (Re-)program MBUS remapping windows if we are asked to. 1205 * (Re-)program MBUS remapping windows if we are asked to.
1185 */ 1206 */
@@ -1212,15 +1233,11 @@ static int mv_xor_probe(struct platform_device *pdev)
1212 if (pdev->dev.of_node) { 1233 if (pdev->dev.of_node) {
1213 struct device_node *np; 1234 struct device_node *np;
1214 int i = 0; 1235 int i = 0;
1215 const struct of_device_id *of_id =
1216 of_match_device(mv_xor_dt_ids,
1217 &pdev->dev);
1218 1236
1219 for_each_child_of_node(pdev->dev.of_node, np) { 1237 for_each_child_of_node(pdev->dev.of_node, np) {
1220 struct mv_xor_chan *chan; 1238 struct mv_xor_chan *chan;
1221 dma_cap_mask_t cap_mask; 1239 dma_cap_mask_t cap_mask;
1222 int irq; 1240 int irq;
1223 op_in_desc = (uintptr_t)of_id->data;
1224 1241
1225 if (i >= max_channels) 1242 if (i >= max_channels)
1226 continue; 1243 continue;
@@ -1237,7 +1254,7 @@ static int mv_xor_probe(struct platform_device *pdev)
1237 } 1254 }
1238 1255
1239 chan = mv_xor_channel_add(xordev, pdev, i, 1256 chan = mv_xor_channel_add(xordev, pdev, i,
1240 cap_mask, irq, op_in_desc); 1257 cap_mask, irq);
1241 if (IS_ERR(chan)) { 1258 if (IS_ERR(chan)) {
1242 ret = PTR_ERR(chan); 1259 ret = PTR_ERR(chan);
1243 irq_dispose_mapping(irq); 1260 irq_dispose_mapping(irq);
@@ -1266,8 +1283,7 @@ static int mv_xor_probe(struct platform_device *pdev)
1266 } 1283 }
1267 1284
1268 chan = mv_xor_channel_add(xordev, pdev, i, 1285 chan = mv_xor_channel_add(xordev, pdev, i,
1269 cd->cap_mask, irq, 1286 cd->cap_mask, irq);
1270 XOR_MODE_IN_REG);
1271 if (IS_ERR(chan)) { 1287 if (IS_ERR(chan)) {
1272 ret = PTR_ERR(chan); 1288 ret = PTR_ERR(chan);
1273 goto err_channel_add; 1289 goto err_channel_add;
diff --git a/drivers/dma/mv_xor.h b/drivers/dma/mv_xor.h
index c19fe30e5ae9..bf56e082e7cd 100644
--- a/drivers/dma/mv_xor.h
+++ b/drivers/dma/mv_xor.h
@@ -85,6 +85,7 @@ struct mv_xor_device {
85 void __iomem *xor_high_base; 85 void __iomem *xor_high_base;
86 struct clk *clk; 86 struct clk *clk;
87 struct mv_xor_chan *channels[MV_XOR_MAX_CHANNELS]; 87 struct mv_xor_chan *channels[MV_XOR_MAX_CHANNELS];
88 int xor_type;
88}; 89};
89 90
90/** 91/**