Path: blob/master/arch/arm/mach-msm/devices-iommu.c
10817 views
/* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved.1*2* This program is free software; you can redistribute it and/or modify3* it under the terms of the GNU General Public License version 2 and4* only version 2 as published by the Free Software Foundation.5*6* This program is distributed in the hope that it will be useful,7* but WITHOUT ANY WARRANTY; without even the implied warranty of8* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9* GNU General Public License for more details.10*11* You should have received a copy of the GNU General Public License12* along with this program; if not, write to the Free Software13* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA14* 02110-1301, USA.15*/1617#include <linux/kernel.h>18#include <linux/platform_device.h>19#include <linux/bootmem.h>20#include <mach/irqs.h>21#include <mach/iommu.h>2223static struct resource msm_iommu_jpegd_resources[] = {24{25.start = 0x07300000,26.end = 0x07300000 + SZ_1M - 1,27.name = "physbase",28.flags = IORESOURCE_MEM,29},30{31.name = "nonsecure_irq",32.start = SMMU_JPEGD_CB_SC_NON_SECURE_IRQ,33.end = SMMU_JPEGD_CB_SC_NON_SECURE_IRQ,34.flags = IORESOURCE_IRQ,35},36{37.name = "secure_irq",38.start = SMMU_JPEGD_CB_SC_SECURE_IRQ,39.end = SMMU_JPEGD_CB_SC_SECURE_IRQ,40.flags = IORESOURCE_IRQ,41},42};4344static struct resource msm_iommu_vpe_resources[] = {45{46.start = 0x07400000,47.end = 0x07400000 + SZ_1M - 1,48.name = "physbase",49.flags = IORESOURCE_MEM,50},51{52.name = "nonsecure_irq",53.start = SMMU_VPE_CB_SC_NON_SECURE_IRQ,54.end = SMMU_VPE_CB_SC_NON_SECURE_IRQ,55.flags = IORESOURCE_IRQ,56},57{58.name = "secure_irq",59.start = SMMU_VPE_CB_SC_SECURE_IRQ,60.end = SMMU_VPE_CB_SC_SECURE_IRQ,61.flags = IORESOURCE_IRQ,62},63};6465static struct resource msm_iommu_mdp0_resources[] = {66{67.start = 0x07500000,68.end = 0x07500000 + SZ_1M - 1,69.name = "physbase",70.flags = IORESOURCE_MEM,71},72{73.name = "nonsecure_irq",74.start = SMMU_MDP0_CB_SC_NON_SECURE_IRQ,75.end = SMMU_MDP0_CB_SC_NON_SECURE_IRQ,76.flags = IORESOURCE_IRQ,77},78{79.name = "secure_irq",80.start = SMMU_MDP0_CB_SC_SECURE_IRQ,81.end = SMMU_MDP0_CB_SC_SECURE_IRQ,82.flags = IORESOURCE_IRQ,83},84};8586static struct resource msm_iommu_mdp1_resources[] = {87{88.start = 0x07600000,89.end = 0x07600000 + SZ_1M - 1,90.name = "physbase",91.flags = IORESOURCE_MEM,92},93{94.name = "nonsecure_irq",95.start = SMMU_MDP1_CB_SC_NON_SECURE_IRQ,96.end = SMMU_MDP1_CB_SC_NON_SECURE_IRQ,97.flags = IORESOURCE_IRQ,98},99{100.name = "secure_irq",101.start = SMMU_MDP1_CB_SC_SECURE_IRQ,102.end = SMMU_MDP1_CB_SC_SECURE_IRQ,103.flags = IORESOURCE_IRQ,104},105};106107static struct resource msm_iommu_rot_resources[] = {108{109.start = 0x07700000,110.end = 0x07700000 + SZ_1M - 1,111.name = "physbase",112.flags = IORESOURCE_MEM,113},114{115.name = "nonsecure_irq",116.start = SMMU_ROT_CB_SC_NON_SECURE_IRQ,117.end = SMMU_ROT_CB_SC_NON_SECURE_IRQ,118.flags = IORESOURCE_IRQ,119},120{121.name = "secure_irq",122.start = SMMU_ROT_CB_SC_SECURE_IRQ,123.end = SMMU_ROT_CB_SC_SECURE_IRQ,124.flags = IORESOURCE_IRQ,125},126};127128static struct resource msm_iommu_ijpeg_resources[] = {129{130.start = 0x07800000,131.end = 0x07800000 + SZ_1M - 1,132.name = "physbase",133.flags = IORESOURCE_MEM,134},135{136.name = "nonsecure_irq",137.start = SMMU_IJPEG_CB_SC_NON_SECURE_IRQ,138.end = SMMU_IJPEG_CB_SC_NON_SECURE_IRQ,139.flags = IORESOURCE_IRQ,140},141{142.name = "secure_irq",143.start = SMMU_IJPEG_CB_SC_SECURE_IRQ,144.end = SMMU_IJPEG_CB_SC_SECURE_IRQ,145.flags = IORESOURCE_IRQ,146},147};148149static struct resource msm_iommu_vfe_resources[] = {150{151.start = 0x07900000,152.end = 0x07900000 + SZ_1M - 1,153.name = "physbase",154.flags = IORESOURCE_MEM,155},156{157.name = "nonsecure_irq",158.start = SMMU_VFE_CB_SC_NON_SECURE_IRQ,159.end = SMMU_VFE_CB_SC_NON_SECURE_IRQ,160.flags = IORESOURCE_IRQ,161},162{163.name = "secure_irq",164.start = SMMU_VFE_CB_SC_SECURE_IRQ,165.end = SMMU_VFE_CB_SC_SECURE_IRQ,166.flags = IORESOURCE_IRQ,167},168};169170static struct resource msm_iommu_vcodec_a_resources[] = {171{172.start = 0x07A00000,173.end = 0x07A00000 + SZ_1M - 1,174.name = "physbase",175.flags = IORESOURCE_MEM,176},177{178.name = "nonsecure_irq",179.start = SMMU_VCODEC_A_CB_SC_NON_SECURE_IRQ,180.end = SMMU_VCODEC_A_CB_SC_NON_SECURE_IRQ,181.flags = IORESOURCE_IRQ,182},183{184.name = "secure_irq",185.start = SMMU_VCODEC_A_CB_SC_SECURE_IRQ,186.end = SMMU_VCODEC_A_CB_SC_SECURE_IRQ,187.flags = IORESOURCE_IRQ,188},189};190191static struct resource msm_iommu_vcodec_b_resources[] = {192{193.start = 0x07B00000,194.end = 0x07B00000 + SZ_1M - 1,195.name = "physbase",196.flags = IORESOURCE_MEM,197},198{199.name = "nonsecure_irq",200.start = SMMU_VCODEC_B_CB_SC_NON_SECURE_IRQ,201.end = SMMU_VCODEC_B_CB_SC_NON_SECURE_IRQ,202.flags = IORESOURCE_IRQ,203},204{205.name = "secure_irq",206.start = SMMU_VCODEC_B_CB_SC_SECURE_IRQ,207.end = SMMU_VCODEC_B_CB_SC_SECURE_IRQ,208.flags = IORESOURCE_IRQ,209},210};211212static struct resource msm_iommu_gfx3d_resources[] = {213{214.start = 0x07C00000,215.end = 0x07C00000 + SZ_1M - 1,216.name = "physbase",217.flags = IORESOURCE_MEM,218},219{220.name = "nonsecure_irq",221.start = SMMU_GFX3D_CB_SC_NON_SECURE_IRQ,222.end = SMMU_GFX3D_CB_SC_NON_SECURE_IRQ,223.flags = IORESOURCE_IRQ,224},225{226.name = "secure_irq",227.start = SMMU_GFX3D_CB_SC_SECURE_IRQ,228.end = SMMU_GFX3D_CB_SC_SECURE_IRQ,229.flags = IORESOURCE_IRQ,230},231};232233static struct resource msm_iommu_gfx2d0_resources[] = {234{235.start = 0x07D00000,236.end = 0x07D00000 + SZ_1M - 1,237.name = "physbase",238.flags = IORESOURCE_MEM,239},240{241.name = "nonsecure_irq",242.start = SMMU_GFX2D0_CB_SC_NON_SECURE_IRQ,243.end = SMMU_GFX2D0_CB_SC_NON_SECURE_IRQ,244.flags = IORESOURCE_IRQ,245},246{247.name = "secure_irq",248.start = SMMU_GFX2D0_CB_SC_SECURE_IRQ,249.end = SMMU_GFX2D0_CB_SC_SECURE_IRQ,250.flags = IORESOURCE_IRQ,251},252};253254static struct resource msm_iommu_gfx2d1_resources[] = {255{256.start = 0x07E00000,257.end = 0x07E00000 + SZ_1M - 1,258.name = "physbase",259.flags = IORESOURCE_MEM,260},261{262.name = "nonsecure_irq",263.start = SMMU_GFX2D1_CB_SC_NON_SECURE_IRQ,264.end = SMMU_GFX2D1_CB_SC_NON_SECURE_IRQ,265.flags = IORESOURCE_IRQ,266},267{268.name = "secure_irq",269.start = SMMU_GFX2D1_CB_SC_SECURE_IRQ,270.end = SMMU_GFX2D1_CB_SC_SECURE_IRQ,271.flags = IORESOURCE_IRQ,272},273};274275static struct platform_device msm_root_iommu_dev = {276.name = "msm_iommu",277.id = -1,278};279280static struct msm_iommu_dev jpegd_iommu = {281.name = "jpegd",282.ncb = 2,283};284285static struct msm_iommu_dev vpe_iommu = {286.name = "vpe",287.ncb = 2,288};289290static struct msm_iommu_dev mdp0_iommu = {291.name = "mdp0",292.ncb = 2,293};294295static struct msm_iommu_dev mdp1_iommu = {296.name = "mdp1",297.ncb = 2,298};299300static struct msm_iommu_dev rot_iommu = {301.name = "rot",302.ncb = 2,303};304305static struct msm_iommu_dev ijpeg_iommu = {306.name = "ijpeg",307.ncb = 2,308};309310static struct msm_iommu_dev vfe_iommu = {311.name = "vfe",312.ncb = 2,313};314315static struct msm_iommu_dev vcodec_a_iommu = {316.name = "vcodec_a",317.ncb = 2,318};319320static struct msm_iommu_dev vcodec_b_iommu = {321.name = "vcodec_b",322.ncb = 2,323};324325static struct msm_iommu_dev gfx3d_iommu = {326.name = "gfx3d",327.ncb = 3,328};329330static struct msm_iommu_dev gfx2d0_iommu = {331.name = "gfx2d0",332.ncb = 2,333};334335static struct msm_iommu_dev gfx2d1_iommu = {336.name = "gfx2d1",337.ncb = 2,338};339340static struct platform_device msm_device_iommu_jpegd = {341.name = "msm_iommu",342.id = 0,343.dev = {344.parent = &msm_root_iommu_dev.dev,345},346.num_resources = ARRAY_SIZE(msm_iommu_jpegd_resources),347.resource = msm_iommu_jpegd_resources,348};349350static struct platform_device msm_device_iommu_vpe = {351.name = "msm_iommu",352.id = 1,353.dev = {354.parent = &msm_root_iommu_dev.dev,355},356.num_resources = ARRAY_SIZE(msm_iommu_vpe_resources),357.resource = msm_iommu_vpe_resources,358};359360static struct platform_device msm_device_iommu_mdp0 = {361.name = "msm_iommu",362.id = 2,363.dev = {364.parent = &msm_root_iommu_dev.dev,365},366.num_resources = ARRAY_SIZE(msm_iommu_mdp0_resources),367.resource = msm_iommu_mdp0_resources,368};369370static struct platform_device msm_device_iommu_mdp1 = {371.name = "msm_iommu",372.id = 3,373.dev = {374.parent = &msm_root_iommu_dev.dev,375},376.num_resources = ARRAY_SIZE(msm_iommu_mdp1_resources),377.resource = msm_iommu_mdp1_resources,378};379380static struct platform_device msm_device_iommu_rot = {381.name = "msm_iommu",382.id = 4,383.dev = {384.parent = &msm_root_iommu_dev.dev,385},386.num_resources = ARRAY_SIZE(msm_iommu_rot_resources),387.resource = msm_iommu_rot_resources,388};389390static struct platform_device msm_device_iommu_ijpeg = {391.name = "msm_iommu",392.id = 5,393.dev = {394.parent = &msm_root_iommu_dev.dev,395},396.num_resources = ARRAY_SIZE(msm_iommu_ijpeg_resources),397.resource = msm_iommu_ijpeg_resources,398};399400static struct platform_device msm_device_iommu_vfe = {401.name = "msm_iommu",402.id = 6,403.dev = {404.parent = &msm_root_iommu_dev.dev,405},406.num_resources = ARRAY_SIZE(msm_iommu_vfe_resources),407.resource = msm_iommu_vfe_resources,408};409410static struct platform_device msm_device_iommu_vcodec_a = {411.name = "msm_iommu",412.id = 7,413.dev = {414.parent = &msm_root_iommu_dev.dev,415},416.num_resources = ARRAY_SIZE(msm_iommu_vcodec_a_resources),417.resource = msm_iommu_vcodec_a_resources,418};419420static struct platform_device msm_device_iommu_vcodec_b = {421.name = "msm_iommu",422.id = 8,423.dev = {424.parent = &msm_root_iommu_dev.dev,425},426.num_resources = ARRAY_SIZE(msm_iommu_vcodec_b_resources),427.resource = msm_iommu_vcodec_b_resources,428};429430static struct platform_device msm_device_iommu_gfx3d = {431.name = "msm_iommu",432.id = 9,433.dev = {434.parent = &msm_root_iommu_dev.dev,435},436.num_resources = ARRAY_SIZE(msm_iommu_gfx3d_resources),437.resource = msm_iommu_gfx3d_resources,438};439440static struct platform_device msm_device_iommu_gfx2d0 = {441.name = "msm_iommu",442.id = 10,443.dev = {444.parent = &msm_root_iommu_dev.dev,445},446.num_resources = ARRAY_SIZE(msm_iommu_gfx2d0_resources),447.resource = msm_iommu_gfx2d0_resources,448};449450struct platform_device msm_device_iommu_gfx2d1 = {451.name = "msm_iommu",452.id = 11,453.dev = {454.parent = &msm_root_iommu_dev.dev,455},456.num_resources = ARRAY_SIZE(msm_iommu_gfx2d1_resources),457.resource = msm_iommu_gfx2d1_resources,458};459460static struct msm_iommu_ctx_dev jpegd_src_ctx = {461.name = "jpegd_src",462.num = 0,463.mids = {0, -1}464};465466static struct msm_iommu_ctx_dev jpegd_dst_ctx = {467.name = "jpegd_dst",468.num = 1,469.mids = {1, -1}470};471472static struct msm_iommu_ctx_dev vpe_src_ctx = {473.name = "vpe_src",474.num = 0,475.mids = {0, -1}476};477478static struct msm_iommu_ctx_dev vpe_dst_ctx = {479.name = "vpe_dst",480.num = 1,481.mids = {1, -1}482};483484static struct msm_iommu_ctx_dev mdp_vg1_ctx = {485.name = "mdp_vg1",486.num = 0,487.mids = {0, 2, -1}488};489490static struct msm_iommu_ctx_dev mdp_rgb1_ctx = {491.name = "mdp_rgb1",492.num = 1,493.mids = {1, 3, 4, 5, 6, 7, 8, 9, 10, -1}494};495496static struct msm_iommu_ctx_dev mdp_vg2_ctx = {497.name = "mdp_vg2",498.num = 0,499.mids = {0, 2, -1}500};501502static struct msm_iommu_ctx_dev mdp_rgb2_ctx = {503.name = "mdp_rgb2",504.num = 1,505.mids = {1, 3, 4, 5, 6, 7, 8, 9, 10, -1}506};507508static struct msm_iommu_ctx_dev rot_src_ctx = {509.name = "rot_src",510.num = 0,511.mids = {0, -1}512};513514static struct msm_iommu_ctx_dev rot_dst_ctx = {515.name = "rot_dst",516.num = 1,517.mids = {1, -1}518};519520static struct msm_iommu_ctx_dev ijpeg_src_ctx = {521.name = "ijpeg_src",522.num = 0,523.mids = {0, -1}524};525526static struct msm_iommu_ctx_dev ijpeg_dst_ctx = {527.name = "ijpeg_dst",528.num = 1,529.mids = {1, -1}530};531532static struct msm_iommu_ctx_dev vfe_imgwr_ctx = {533.name = "vfe_imgwr",534.num = 0,535.mids = {2, 3, 4, 5, 6, 7, 8, -1}536};537538static struct msm_iommu_ctx_dev vfe_misc_ctx = {539.name = "vfe_misc",540.num = 1,541.mids = {0, 1, 9, -1}542};543544static struct msm_iommu_ctx_dev vcodec_a_stream_ctx = {545.name = "vcodec_a_stream",546.num = 0,547.mids = {2, 5, -1}548};549550static struct msm_iommu_ctx_dev vcodec_a_mm1_ctx = {551.name = "vcodec_a_mm1",552.num = 1,553.mids = {0, 1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -1}554};555556static struct msm_iommu_ctx_dev vcodec_b_mm2_ctx = {557.name = "vcodec_b_mm2",558.num = 0,559.mids = {0, 1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -1}560};561562static struct msm_iommu_ctx_dev gfx3d_user_ctx = {563.name = "gfx3d_user",564.num = 0,565.mids = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -1}566};567568static struct msm_iommu_ctx_dev gfx3d_priv_ctx = {569.name = "gfx3d_priv",570.num = 1,571.mids = {16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,57231, -1}573};574575static struct msm_iommu_ctx_dev gfx2d0_2d0_ctx = {576.name = "gfx2d0_2d0",577.num = 0,578.mids = {0, 1, 2, 3, 4, 5, 6, 7, -1}579};580581static struct msm_iommu_ctx_dev gfx2d1_2d1_ctx = {582.name = "gfx2d1_2d1",583.num = 0,584.mids = {0, 1, 2, 3, 4, 5, 6, 7, -1}585};586587static struct platform_device msm_device_jpegd_src_ctx = {588.name = "msm_iommu_ctx",589.id = 0,590.dev = {591.parent = &msm_device_iommu_jpegd.dev,592},593};594595static struct platform_device msm_device_jpegd_dst_ctx = {596.name = "msm_iommu_ctx",597.id = 1,598.dev = {599.parent = &msm_device_iommu_jpegd.dev,600},601};602603static struct platform_device msm_device_vpe_src_ctx = {604.name = "msm_iommu_ctx",605.id = 2,606.dev = {607.parent = &msm_device_iommu_vpe.dev,608},609};610611static struct platform_device msm_device_vpe_dst_ctx = {612.name = "msm_iommu_ctx",613.id = 3,614.dev = {615.parent = &msm_device_iommu_vpe.dev,616},617};618619static struct platform_device msm_device_mdp_vg1_ctx = {620.name = "msm_iommu_ctx",621.id = 4,622.dev = {623.parent = &msm_device_iommu_mdp0.dev,624},625};626627static struct platform_device msm_device_mdp_rgb1_ctx = {628.name = "msm_iommu_ctx",629.id = 5,630.dev = {631.parent = &msm_device_iommu_mdp0.dev,632},633};634635static struct platform_device msm_device_mdp_vg2_ctx = {636.name = "msm_iommu_ctx",637.id = 6,638.dev = {639.parent = &msm_device_iommu_mdp1.dev,640},641};642643static struct platform_device msm_device_mdp_rgb2_ctx = {644.name = "msm_iommu_ctx",645.id = 7,646.dev = {647.parent = &msm_device_iommu_mdp1.dev,648},649};650651static struct platform_device msm_device_rot_src_ctx = {652.name = "msm_iommu_ctx",653.id = 8,654.dev = {655.parent = &msm_device_iommu_rot.dev,656},657};658659static struct platform_device msm_device_rot_dst_ctx = {660.name = "msm_iommu_ctx",661.id = 9,662.dev = {663.parent = &msm_device_iommu_rot.dev,664},665};666667static struct platform_device msm_device_ijpeg_src_ctx = {668.name = "msm_iommu_ctx",669.id = 10,670.dev = {671.parent = &msm_device_iommu_ijpeg.dev,672},673};674675static struct platform_device msm_device_ijpeg_dst_ctx = {676.name = "msm_iommu_ctx",677.id = 11,678.dev = {679.parent = &msm_device_iommu_ijpeg.dev,680},681};682683static struct platform_device msm_device_vfe_imgwr_ctx = {684.name = "msm_iommu_ctx",685.id = 12,686.dev = {687.parent = &msm_device_iommu_vfe.dev,688},689};690691static struct platform_device msm_device_vfe_misc_ctx = {692.name = "msm_iommu_ctx",693.id = 13,694.dev = {695.parent = &msm_device_iommu_vfe.dev,696},697};698699static struct platform_device msm_device_vcodec_a_stream_ctx = {700.name = "msm_iommu_ctx",701.id = 14,702.dev = {703.parent = &msm_device_iommu_vcodec_a.dev,704},705};706707static struct platform_device msm_device_vcodec_a_mm1_ctx = {708.name = "msm_iommu_ctx",709.id = 15,710.dev = {711.parent = &msm_device_iommu_vcodec_a.dev,712},713};714715static struct platform_device msm_device_vcodec_b_mm2_ctx = {716.name = "msm_iommu_ctx",717.id = 16,718.dev = {719.parent = &msm_device_iommu_vcodec_b.dev,720},721};722723static struct platform_device msm_device_gfx3d_user_ctx = {724.name = "msm_iommu_ctx",725.id = 17,726.dev = {727.parent = &msm_device_iommu_gfx3d.dev,728},729};730731static struct platform_device msm_device_gfx3d_priv_ctx = {732.name = "msm_iommu_ctx",733.id = 18,734.dev = {735.parent = &msm_device_iommu_gfx3d.dev,736},737};738739static struct platform_device msm_device_gfx2d0_2d0_ctx = {740.name = "msm_iommu_ctx",741.id = 19,742.dev = {743.parent = &msm_device_iommu_gfx2d0.dev,744},745};746747static struct platform_device msm_device_gfx2d1_2d1_ctx = {748.name = "msm_iommu_ctx",749.id = 20,750.dev = {751.parent = &msm_device_iommu_gfx2d1.dev,752},753};754755static struct platform_device *msm_iommu_devs[] = {756&msm_device_iommu_jpegd,757&msm_device_iommu_vpe,758&msm_device_iommu_mdp0,759&msm_device_iommu_mdp1,760&msm_device_iommu_rot,761&msm_device_iommu_ijpeg,762&msm_device_iommu_vfe,763&msm_device_iommu_vcodec_a,764&msm_device_iommu_vcodec_b,765&msm_device_iommu_gfx3d,766&msm_device_iommu_gfx2d0,767&msm_device_iommu_gfx2d1,768};769770static struct msm_iommu_dev *msm_iommu_data[] = {771&jpegd_iommu,772&vpe_iommu,773&mdp0_iommu,774&mdp1_iommu,775&rot_iommu,776&ijpeg_iommu,777&vfe_iommu,778&vcodec_a_iommu,779&vcodec_b_iommu,780&gfx3d_iommu,781&gfx2d0_iommu,782&gfx2d1_iommu,783};784785static struct platform_device *msm_iommu_ctx_devs[] = {786&msm_device_jpegd_src_ctx,787&msm_device_jpegd_dst_ctx,788&msm_device_vpe_src_ctx,789&msm_device_vpe_dst_ctx,790&msm_device_mdp_vg1_ctx,791&msm_device_mdp_rgb1_ctx,792&msm_device_mdp_vg2_ctx,793&msm_device_mdp_rgb2_ctx,794&msm_device_rot_src_ctx,795&msm_device_rot_dst_ctx,796&msm_device_ijpeg_src_ctx,797&msm_device_ijpeg_dst_ctx,798&msm_device_vfe_imgwr_ctx,799&msm_device_vfe_misc_ctx,800&msm_device_vcodec_a_stream_ctx,801&msm_device_vcodec_a_mm1_ctx,802&msm_device_vcodec_b_mm2_ctx,803&msm_device_gfx3d_user_ctx,804&msm_device_gfx3d_priv_ctx,805&msm_device_gfx2d0_2d0_ctx,806&msm_device_gfx2d1_2d1_ctx,807};808809static struct msm_iommu_ctx_dev *msm_iommu_ctx_data[] = {810&jpegd_src_ctx,811&jpegd_dst_ctx,812&vpe_src_ctx,813&vpe_dst_ctx,814&mdp_vg1_ctx,815&mdp_rgb1_ctx,816&mdp_vg2_ctx,817&mdp_rgb2_ctx,818&rot_src_ctx,819&rot_dst_ctx,820&ijpeg_src_ctx,821&ijpeg_dst_ctx,822&vfe_imgwr_ctx,823&vfe_misc_ctx,824&vcodec_a_stream_ctx,825&vcodec_a_mm1_ctx,826&vcodec_b_mm2_ctx,827&gfx3d_user_ctx,828&gfx3d_priv_ctx,829&gfx2d0_2d0_ctx,830&gfx2d1_2d1_ctx,831};832833static int __init msm8x60_iommu_init(void)834{835int ret, i;836837ret = platform_device_register(&msm_root_iommu_dev);838if (ret != 0) {839pr_err("Failed to register root IOMMU device!\n");840goto failure;841}842843for (i = 0; i < ARRAY_SIZE(msm_iommu_devs); i++) {844ret = platform_device_add_data(msm_iommu_devs[i],845msm_iommu_data[i],846sizeof(struct msm_iommu_dev));847if (ret != 0) {848pr_err("platform_device_add_data failed, "849"i = %d\n", i);850goto failure_unwind;851}852853ret = platform_device_register(msm_iommu_devs[i]);854855if (ret != 0) {856pr_err("platform_device_register iommu failed, "857"i = %d\n", i);858goto failure_unwind;859}860}861862for (i = 0; i < ARRAY_SIZE(msm_iommu_ctx_devs); i++) {863ret = platform_device_add_data(msm_iommu_ctx_devs[i],864msm_iommu_ctx_data[i],865sizeof(*msm_iommu_ctx_devs[i]));866if (ret != 0) {867pr_err("platform_device_add_data iommu failed, "868"i = %d\n", i);869goto failure_unwind2;870}871872ret = platform_device_register(msm_iommu_ctx_devs[i]);873if (ret != 0) {874pr_err("platform_device_register ctx failed, "875"i = %d\n", i);876goto failure_unwind2;877}878}879return 0;880881failure_unwind2:882while (--i >= 0)883platform_device_unregister(msm_iommu_ctx_devs[i]);884failure_unwind:885while (--i >= 0)886platform_device_unregister(msm_iommu_devs[i]);887888platform_device_unregister(&msm_root_iommu_dev);889failure:890return ret;891}892893static void __exit msm8x60_iommu_exit(void)894{895int i;896897for (i = 0; i < ARRAY_SIZE(msm_iommu_ctx_devs); i++)898platform_device_unregister(msm_iommu_ctx_devs[i]);899900for (i = 0; i < ARRAY_SIZE(msm_iommu_devs); ++i)901platform_device_unregister(msm_iommu_devs[i]);902903platform_device_unregister(&msm_root_iommu_dev);904}905906subsys_initcall(msm8x60_iommu_init);907module_exit(msm8x60_iommu_exit);908909MODULE_LICENSE("GPL v2");910MODULE_AUTHOR("Stepan Moskovchenko <[email protected]>");911912913