d1: add new target
[openwrt/staging/mans0n.git] / target / linux / d1 / patches-6.1 / 0050-iommu-sun50i-Support-variants-without-an-external-re.patch
1 From 15a0487680cf506bb4b9bfee2c41b2c3176d4efa Mon Sep 17 00:00:00 2001
2 From: Samuel Holland <samuel@sholland.org>
3 Date: Wed, 27 Apr 2022 19:01:57 -0500
4 Subject: [PATCH 050/117] iommu/sun50i: Support variants without an external
5 reset
6
7 The IOMMU in the Allwinner D1 SoC does not have an external reset line.
8
9 Only attempt to get the reset on hardware variants which should have one
10 according to the binding. And switch from the deprecated function to the
11 explicit "exclusive" variant.
12
13 Signed-off-by: Samuel Holland <samuel@sholland.org>
14 ---
15 drivers/iommu/sun50i-iommu.c | 18 ++++++++++++++++--
16 1 file changed, 16 insertions(+), 2 deletions(-)
17
18 --- a/drivers/iommu/sun50i-iommu.c
19 +++ b/drivers/iommu/sun50i-iommu.c
20 @@ -95,6 +95,10 @@
21
22 #define SPAGE_SIZE 4096
23
24 +struct sun50i_iommu_variant {
25 + bool has_reset;
26 +};
27 +
28 struct sun50i_iommu {
29 struct iommu_device iommu;
30
31 @@ -979,9 +983,14 @@ static irqreturn_t sun50i_iommu_irq(int
32
33 static int sun50i_iommu_probe(struct platform_device *pdev)
34 {
35 + const struct sun50i_iommu_variant *variant;
36 struct sun50i_iommu *iommu;
37 int ret, irq;
38
39 + variant = of_device_get_match_data(&pdev->dev);
40 + if (!variant)
41 + return -EINVAL;
42 +
43 iommu = devm_kzalloc(&pdev->dev, sizeof(*iommu), GFP_KERNEL);
44 if (!iommu)
45 return -ENOMEM;
46 @@ -1021,7 +1030,8 @@ static int sun50i_iommu_probe(struct pla
47 goto err_free_group;
48 }
49
50 - iommu->reset = devm_reset_control_get(&pdev->dev, NULL);
51 + if (variant->has_reset)
52 + iommu->reset = devm_reset_control_get_exclusive(&pdev->dev, NULL);
53 if (IS_ERR(iommu->reset)) {
54 dev_err(&pdev->dev, "Couldn't get our reset line.\n");
55 ret = PTR_ERR(iommu->reset);
56 @@ -1059,8 +1069,12 @@ err_free_cache:
57 return ret;
58 }
59
60 +static const struct sun50i_iommu_variant sun50i_h6_iommu = {
61 + .has_reset = true,
62 +};
63 +
64 static const struct of_device_id sun50i_iommu_dt[] = {
65 - { .compatible = "allwinner,sun50i-h6-iommu", },
66 + { .compatible = "allwinner,sun50i-h6-iommu", .data = &sun50i_h6_iommu },
67 { /* sentinel */ },
68 };
69 MODULE_DEVICE_TABLE(of, sun50i_iommu_dt);