msm: iommu: Clean up IOMMU platform data
Statically assign the IOMMU platform data to the IOMMU
platform devices rather than adding it at probe time, to
make the code easier to maintain.
Change-Id: I59ceec62d5b07acf97f021934f38ce00e79baeb4
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
diff --git a/arch/arm/mach-msm/devices-iommu.c b/arch/arm/mach-msm/devices-iommu.c
index 3d2d2e7..6b9c8e6 100644
--- a/arch/arm/mach-msm/devices-iommu.c
+++ b/arch/arm/mach-msm/devices-iommu.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved.
+/* Copyright (c) 2010-2012, Code Aurora Forum. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -391,6 +391,7 @@
.id = 0,
.dev = {
.parent = &msm_root_iommu_dev.dev,
+ .platform_data = &jpegd_iommu,
},
.num_resources = ARRAY_SIZE(msm_iommu_jpegd_resources),
.resource = msm_iommu_jpegd_resources,
@@ -401,6 +402,7 @@
.id = 1,
.dev = {
.parent = &msm_root_iommu_dev.dev,
+ .platform_data = &vpe_iommu,
},
.num_resources = ARRAY_SIZE(msm_iommu_vpe_resources),
.resource = msm_iommu_vpe_resources,
@@ -411,6 +413,7 @@
.id = 2,
.dev = {
.parent = &msm_root_iommu_dev.dev,
+ .platform_data = &mdp0_iommu,
},
.num_resources = ARRAY_SIZE(msm_iommu_mdp0_resources),
.resource = msm_iommu_mdp0_resources,
@@ -421,6 +424,7 @@
.id = 3,
.dev = {
.parent = &msm_root_iommu_dev.dev,
+ .platform_data = &mdp1_iommu,
},
.num_resources = ARRAY_SIZE(msm_iommu_mdp1_resources),
.resource = msm_iommu_mdp1_resources,
@@ -431,6 +435,7 @@
.id = 4,
.dev = {
.parent = &msm_root_iommu_dev.dev,
+ .platform_data = &rot_iommu,
},
.num_resources = ARRAY_SIZE(msm_iommu_rot_resources),
.resource = msm_iommu_rot_resources,
@@ -441,6 +446,7 @@
.id = 5,
.dev = {
.parent = &msm_root_iommu_dev.dev,
+ .platform_data = &ijpeg_iommu,
},
.num_resources = ARRAY_SIZE(msm_iommu_ijpeg_resources),
.resource = msm_iommu_ijpeg_resources,
@@ -451,6 +457,7 @@
.id = 6,
.dev = {
.parent = &msm_root_iommu_dev.dev,
+ .platform_data = &vfe_iommu,
},
.num_resources = ARRAY_SIZE(msm_iommu_vfe_resources),
.resource = msm_iommu_vfe_resources,
@@ -461,6 +468,7 @@
.id = 7,
.dev = {
.parent = &msm_root_iommu_dev.dev,
+ .platform_data = &vcodec_a_iommu,
},
.num_resources = ARRAY_SIZE(msm_iommu_vcodec_a_resources),
.resource = msm_iommu_vcodec_a_resources,
@@ -471,6 +479,7 @@
.id = 8,
.dev = {
.parent = &msm_root_iommu_dev.dev,
+ .platform_data = &vcodec_b_iommu,
},
.num_resources = ARRAY_SIZE(msm_iommu_vcodec_b_resources),
.resource = msm_iommu_vcodec_b_resources,
@@ -481,6 +490,7 @@
.id = 9,
.dev = {
.parent = &msm_root_iommu_dev.dev,
+ .platform_data = &gfx3d_iommu,
},
.num_resources = ARRAY_SIZE(msm_iommu_gfx3d_resources),
.resource = msm_iommu_gfx3d_resources,
@@ -491,6 +501,7 @@
.id = 10,
.dev = {
.parent = &msm_root_iommu_dev.dev,
+ .platform_data = &gfx3d1_iommu,
},
.num_resources = ARRAY_SIZE(msm_iommu_gfx3d1_resources),
.resource = msm_iommu_gfx3d1_resources,
@@ -501,6 +512,7 @@
.id = 10,
.dev = {
.parent = &msm_root_iommu_dev.dev,
+ .platform_data = &gfx2d0_iommu,
},
.num_resources = ARRAY_SIZE(msm_iommu_gfx2d0_resources),
.resource = msm_iommu_gfx2d0_resources,
@@ -511,6 +523,7 @@
.id = 11,
.dev = {
.parent = &msm_root_iommu_dev.dev,
+ .platform_data = &gfx2d1_iommu,
},
.num_resources = ARRAY_SIZE(msm_iommu_gfx2d1_resources),
.resource = msm_iommu_gfx2d1_resources,
@@ -521,6 +534,7 @@
.id = 11,
.dev = {
.parent = &msm_root_iommu_dev.dev,
+ .platform_data = &vcap_iommu,
},
.num_resources = ARRAY_SIZE(msm_iommu_vcap_resources),
.resource = msm_iommu_vcap_resources,
@@ -683,6 +697,7 @@
.id = 0,
.dev = {
.parent = &msm_device_iommu_jpegd.dev,
+ .platform_data = &jpegd_src_ctx,
},
};
@@ -691,6 +706,7 @@
.id = 1,
.dev = {
.parent = &msm_device_iommu_jpegd.dev,
+ .platform_data = &jpegd_dst_ctx,
},
};
@@ -699,6 +715,7 @@
.id = 2,
.dev = {
.parent = &msm_device_iommu_vpe.dev,
+ .platform_data = &vpe_src_ctx,
},
};
@@ -707,6 +724,7 @@
.id = 3,
.dev = {
.parent = &msm_device_iommu_vpe.dev,
+ .platform_data = &vpe_dst_ctx,
},
};
@@ -715,6 +733,7 @@
.id = 4,
.dev = {
.parent = &msm_device_iommu_mdp0.dev,
+ .platform_data = &mdp_vg1_ctx,
},
};
@@ -723,6 +742,7 @@
.id = 5,
.dev = {
.parent = &msm_device_iommu_mdp0.dev,
+ .platform_data = &mdp_rgb1_ctx,
},
};
@@ -731,6 +751,7 @@
.id = 6,
.dev = {
.parent = &msm_device_iommu_mdp1.dev,
+ .platform_data = &mdp_vg2_ctx,
},
};
@@ -739,6 +760,7 @@
.id = 7,
.dev = {
.parent = &msm_device_iommu_mdp1.dev,
+ .platform_data = &mdp_rgb2_ctx,
},
};
@@ -747,6 +769,7 @@
.id = 8,
.dev = {
.parent = &msm_device_iommu_rot.dev,
+ .platform_data = &rot_src_ctx,
},
};
@@ -755,6 +778,7 @@
.id = 9,
.dev = {
.parent = &msm_device_iommu_rot.dev,
+ .platform_data = &rot_dst_ctx,
},
};
@@ -763,6 +787,7 @@
.id = 10,
.dev = {
.parent = &msm_device_iommu_ijpeg.dev,
+ .platform_data = &ijpeg_src_ctx,
},
};
@@ -771,6 +796,7 @@
.id = 11,
.dev = {
.parent = &msm_device_iommu_ijpeg.dev,
+ .platform_data = &ijpeg_dst_ctx,
},
};
@@ -779,6 +805,7 @@
.id = 12,
.dev = {
.parent = &msm_device_iommu_vfe.dev,
+ .platform_data = &vfe_imgwr_ctx,
},
};
@@ -787,6 +814,7 @@
.id = 13,
.dev = {
.parent = &msm_device_iommu_vfe.dev,
+ .platform_data = &vfe_misc_ctx,
},
};
@@ -795,6 +823,7 @@
.id = 14,
.dev = {
.parent = &msm_device_iommu_vcodec_a.dev,
+ .platform_data = &vcodec_a_stream_ctx,
},
};
@@ -803,6 +832,7 @@
.id = 15,
.dev = {
.parent = &msm_device_iommu_vcodec_a.dev,
+ .platform_data = &vcodec_a_mm1_ctx,
},
};
@@ -811,6 +841,7 @@
.id = 16,
.dev = {
.parent = &msm_device_iommu_vcodec_b.dev,
+ .platform_data = &vcodec_b_mm2_ctx,
},
};
@@ -819,6 +850,7 @@
.id = 17,
.dev = {
.parent = &msm_device_iommu_gfx3d.dev,
+ .platform_data = &gfx3d_user_ctx,
},
};
@@ -827,6 +859,7 @@
.id = 18,
.dev = {
.parent = &msm_device_iommu_gfx3d.dev,
+ .platform_data = &gfx3d_priv_ctx,
},
};
@@ -835,6 +868,7 @@
.id = 19,
.dev = {
.parent = &msm_device_iommu_gfx3d1.dev,
+ .platform_data = &gfx3d1_user_ctx,
},
};
@@ -843,6 +877,7 @@
.id = 20,
.dev = {
.parent = &msm_device_iommu_gfx3d1.dev,
+ .platform_data = &gfx3d1_priv_ctx,
},
};
@@ -851,6 +886,7 @@
.id = 19,
.dev = {
.parent = &msm_device_iommu_gfx2d0.dev,
+ .platform_data = &gfx2d0_2d0_ctx,
},
};
@@ -859,6 +895,7 @@
.id = 20,
.dev = {
.parent = &msm_device_iommu_gfx2d1.dev,
+ .platform_data = &gfx2d1_2d1_ctx,
},
};
@@ -867,6 +904,7 @@
.id = 21,
.dev = {
.parent = &msm_device_iommu_vcap.dev,
+ .platform_data = &vcap_vc_ctx,
},
};
@@ -875,6 +913,7 @@
.id = 22,
.dev = {
.parent = &msm_device_iommu_vcap.dev,
+ .platform_data = &vcap_vp_ctx,
},
};
@@ -901,29 +940,6 @@
&msm_device_iommu_vcap,
};
-static struct msm_iommu_dev *msm_iommu_common_data[] = {
- &jpegd_iommu,
- &vpe_iommu,
- &mdp0_iommu,
- &mdp1_iommu,
- &rot_iommu,
- &ijpeg_iommu,
- &vfe_iommu,
- &vcodec_a_iommu,
- &vcodec_b_iommu,
- &gfx3d_iommu,
-};
-
-static struct msm_iommu_dev *msm_iommu_gfx2d_data[] = {
- &gfx2d0_iommu,
- &gfx2d1_iommu,
-};
-
-static struct msm_iommu_dev *msm_iommu_8064_data[] = {
- &gfx3d1_iommu,
- &vcap_iommu,
-};
-
static struct platform_device *msm_iommu_common_ctx_devs[] = {
&msm_device_jpegd_src_ctx,
&msm_device_jpegd_dst_ctx,
@@ -958,54 +974,11 @@
&msm_device_vcap_vp_ctx,
};
-static struct msm_iommu_ctx_dev *msm_iommu_common_ctx_data[] = {
- &jpegd_src_ctx,
- &jpegd_dst_ctx,
- &vpe_src_ctx,
- &vpe_dst_ctx,
- &mdp_vg1_ctx,
- &mdp_rgb1_ctx,
- &mdp_vg2_ctx,
- &mdp_rgb2_ctx,
- &rot_src_ctx,
- &rot_dst_ctx,
- &ijpeg_src_ctx,
- &ijpeg_dst_ctx,
- &vfe_imgwr_ctx,
- &vfe_misc_ctx,
- &vcodec_a_stream_ctx,
- &vcodec_a_mm1_ctx,
- &vcodec_b_mm2_ctx,
- &gfx3d_user_ctx,
- &gfx3d_priv_ctx,
-};
-
-static struct msm_iommu_ctx_dev *msm_iommu_gfx2d_ctx_data[] = {
- &gfx2d0_2d0_ctx,
- &gfx2d1_2d1_ctx,
-};
-
-static struct msm_iommu_ctx_dev *msm_iommu_8064_ctx_data[] = {
- &gfx3d1_user_ctx,
- &gfx3d1_priv_ctx,
- &vcap_vc_ctx,
- &vcap_vp_ctx,
-};
-
-static int iommu_init_devs(struct platform_device *devs[],
- struct msm_iommu_dev *data[], int size)
+static int iommu_init_devs(struct platform_device *devs[], int size)
{
int ret, i;
for (i = 0; i < size; i++) {
- ret = platform_device_add_data(devs[i],
- data[i], sizeof(struct msm_iommu_dev));
- if (ret != 0) {
- pr_err("platform_device_add_data failed, "
- "i = %d\n", i);
- goto failure_unwind;
- }
-
ret = platform_device_register(devs[i]);
if (ret != 0) {
@@ -1024,20 +997,11 @@
}
-static int iommu_init_ctx_devs(struct platform_device *ctx_devs[],
- struct msm_iommu_ctx_dev *ctx_data[], int size)
+static int iommu_init_ctx_devs(struct platform_device *ctx_devs[], int size)
{
int ret, i;
for (i = 0; i < size; i++) {
- ret = platform_device_add_data(ctx_devs[i],
- ctx_data[i], sizeof(struct msm_iommu_ctx_dev));
- if (ret != 0) {
- pr_err("platform_device_add_data iommu failed, "
- "i = %d\n", i);
- goto failure_unwind;
- }
-
ret = platform_device_register(ctx_devs[i]);
if (ret != 0) {
pr_err("platform_device_register ctx failed, "
@@ -1070,7 +1034,6 @@
/* Initialize common devs */
ret = iommu_init_devs(msm_iommu_common_devs,
- msm_iommu_common_data,
ARRAY_SIZE(msm_iommu_common_devs));
if (ret != 0)
goto failure2;
@@ -1078,19 +1041,16 @@
/* Initialize soc-specific devs */
if (cpu_is_apq8064()) {
ret = iommu_init_devs(msm_iommu_8064_devs,
- msm_iommu_8064_data,
ARRAY_SIZE(msm_iommu_8064_devs));
} else {
ret = iommu_init_devs(msm_iommu_gfx2d_devs,
- msm_iommu_gfx2d_data,
- ARRAY_SIZE(msm_iommu_gfx2d_devs));
+ ARRAY_SIZE(msm_iommu_gfx2d_devs));
}
if (ret != 0)
goto failure2;
/* Initialize common ctx_devs */
ret = iommu_init_ctx_devs(msm_iommu_common_ctx_devs,
- msm_iommu_common_ctx_data,
ARRAY_SIZE(msm_iommu_common_ctx_devs));
if (ret != 0)
goto failure2;
@@ -1098,11 +1058,9 @@
/* Initialize soc-specific ctx_devs */
if (cpu_is_apq8064()) {
ret = iommu_init_ctx_devs(msm_iommu_8064_ctx_devs,
- msm_iommu_8064_ctx_data,
ARRAY_SIZE(msm_iommu_8064_ctx_devs));
} else {
ret = iommu_init_ctx_devs(msm_iommu_gfx2d_ctx_devs,
- msm_iommu_gfx2d_ctx_data,
ARRAY_SIZE(msm_iommu_gfx2d_ctx_devs));
}
if (ret != 0)