|
3 | 3 |
|
4 | 4 | #define dev_fmt(fmt) "tegra241_cmdqv: " fmt |
5 | 5 |
|
6 | | -#include <linux/acpi.h> |
7 | 6 | #include <linux/debugfs.h> |
8 | 7 | #include <linux/dma-mapping.h> |
9 | 8 | #include <linux/interrupt.h> |
10 | 9 | #include <linux/iommu.h> |
11 | 10 | #include <linux/iommufd.h> |
12 | 11 | #include <linux/iopoll.h> |
| 12 | +#include <linux/platform_device.h> |
13 | 13 | #include <uapi/linux/iommufd.h> |
14 | 14 |
|
15 | | -#include <acpi/acpixf.h> |
16 | | - |
17 | 15 | #include "arm-smmu-v3.h" |
18 | 16 |
|
19 | 17 | /* CMDQV register page base and size defines */ |
@@ -854,69 +852,6 @@ static struct arm_smmu_impl_ops tegra241_cmdqv_impl_ops = { |
854 | 852 |
|
855 | 853 | /* Probe Functions */ |
856 | 854 |
|
857 | | -static int tegra241_cmdqv_acpi_is_memory(struct acpi_resource *res, void *data) |
858 | | -{ |
859 | | - struct resource_win win; |
860 | | - |
861 | | - return !acpi_dev_resource_address_space(res, &win); |
862 | | -} |
863 | | - |
864 | | -static int tegra241_cmdqv_acpi_get_irqs(struct acpi_resource *ares, void *data) |
865 | | -{ |
866 | | - struct resource r; |
867 | | - int *irq = data; |
868 | | - |
869 | | - if (*irq <= 0 && acpi_dev_resource_interrupt(ares, 0, &r)) |
870 | | - *irq = r.start; |
871 | | - return 1; /* No need to add resource to the list */ |
872 | | -} |
873 | | - |
874 | | -static struct resource * |
875 | | -tegra241_cmdqv_find_acpi_resource(struct device *dev, int *irq) |
876 | | -{ |
877 | | - struct acpi_device *adev = to_acpi_device(dev); |
878 | | - struct list_head resource_list; |
879 | | - struct resource_entry *rentry; |
880 | | - struct resource *res = NULL; |
881 | | - int ret; |
882 | | - |
883 | | - INIT_LIST_HEAD(&resource_list); |
884 | | - ret = acpi_dev_get_resources(adev, &resource_list, |
885 | | - tegra241_cmdqv_acpi_is_memory, NULL); |
886 | | - if (ret < 0) { |
887 | | - dev_err(dev, "failed to get memory resource: %d\n", ret); |
888 | | - return NULL; |
889 | | - } |
890 | | - |
891 | | - rentry = list_first_entry_or_null(&resource_list, |
892 | | - struct resource_entry, node); |
893 | | - if (!rentry) { |
894 | | - dev_err(dev, "failed to get memory resource entry\n"); |
895 | | - goto free_list; |
896 | | - } |
897 | | - |
898 | | - /* Caller must free the res */ |
899 | | - res = kzalloc(sizeof(*res), GFP_KERNEL); |
900 | | - if (!res) |
901 | | - goto free_list; |
902 | | - |
903 | | - *res = *rentry->res; |
904 | | - |
905 | | - acpi_dev_free_resource_list(&resource_list); |
906 | | - |
907 | | - INIT_LIST_HEAD(&resource_list); |
908 | | - |
909 | | - if (irq) |
910 | | - ret = acpi_dev_get_resources(adev, &resource_list, |
911 | | - tegra241_cmdqv_acpi_get_irqs, irq); |
912 | | - if (ret < 0 || !irq || *irq <= 0) |
913 | | - dev_warn(dev, "no interrupt. errors will not be reported\n"); |
914 | | - |
915 | | -free_list: |
916 | | - acpi_dev_free_resource_list(&resource_list); |
917 | | - return res; |
918 | | -} |
919 | | - |
920 | 855 | static int tegra241_cmdqv_init_structures(struct arm_smmu_device *smmu) |
921 | 856 | { |
922 | 857 | struct tegra241_cmdqv *cmdqv = |
@@ -1042,18 +977,23 @@ __tegra241_cmdqv_probe(struct arm_smmu_device *smmu, struct resource *res, |
1042 | 977 |
|
1043 | 978 | struct arm_smmu_device *tegra241_cmdqv_probe(struct arm_smmu_device *smmu) |
1044 | 979 | { |
| 980 | + struct platform_device *pdev = to_platform_device(smmu->impl_dev); |
1045 | 981 | struct arm_smmu_device *new_smmu; |
1046 | | - struct resource *res = NULL; |
| 982 | + struct resource *res; |
1047 | 983 | int irq; |
1048 | 984 |
|
1049 | | - if (!smmu->dev->of_node) |
1050 | | - res = tegra241_cmdqv_find_acpi_resource(smmu->impl_dev, &irq); |
1051 | | - if (!res) |
| 985 | + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 986 | + if (!res) { |
| 987 | + dev_err(&pdev->dev, "no memory resource found for CMDQV\n"); |
1052 | 988 | goto out_fallback; |
| 989 | + } |
1053 | 990 |
|
1054 | | - new_smmu = __tegra241_cmdqv_probe(smmu, res, irq); |
1055 | | - kfree(res); |
| 991 | + irq = platform_get_irq_optional(pdev, 0); |
| 992 | + if (irq <= 0) |
| 993 | + dev_warn(&pdev->dev, |
| 994 | + "no interrupt. errors will not be reported\n"); |
1056 | 995 |
|
| 996 | + new_smmu = __tegra241_cmdqv_probe(smmu, res, irq); |
1057 | 997 | if (new_smmu) |
1058 | 998 | return new_smmu; |
1059 | 999 |
|
|
0 commit comments