omap-iommu.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. /*
  2. * omap iommu: omap device registration
  3. *
  4. * Copyright (C) 2008-2009 Nokia Corporation
  5. *
  6. * Written by Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. */
  12. #include <linux/platform_device.h>
  13. #include <plat/iommu.h>
  14. #include <plat/irqs.h>
  15. struct iommu_device {
  16. resource_size_t base;
  17. int irq;
  18. struct iommu_platform_data pdata;
  19. struct resource res[2];
  20. };
  21. static struct iommu_device *devices;
  22. static int num_iommu_devices;
  23. #ifdef CONFIG_ARCH_OMAP3
  24. static struct iommu_device omap3_devices[] = {
  25. {
  26. .base = 0x480bd400,
  27. .irq = 24,
  28. .pdata = {
  29. .name = "isp",
  30. .nr_tlb_entries = 8,
  31. .clk_name = "cam_ick",
  32. .da_start = 0x0,
  33. .da_end = 0xFFFFF000,
  34. },
  35. },
  36. #if defined(CONFIG_OMAP_IOMMU_IVA2)
  37. {
  38. .base = 0x5d000000,
  39. .irq = 28,
  40. .pdata = {
  41. .name = "iva2",
  42. .nr_tlb_entries = 32,
  43. .clk_name = "iva2_ck",
  44. .da_start = 0x11000000,
  45. .da_end = 0xFFFFF000,
  46. },
  47. },
  48. #endif
  49. };
  50. #define NR_OMAP3_IOMMU_DEVICES ARRAY_SIZE(omap3_devices)
  51. static struct platform_device *omap3_iommu_pdev[NR_OMAP3_IOMMU_DEVICES];
  52. #else
  53. #define omap3_devices NULL
  54. #define NR_OMAP3_IOMMU_DEVICES 0
  55. #define omap3_iommu_pdev NULL
  56. #endif
  57. #ifdef CONFIG_ARCH_OMAP4
  58. static struct iommu_device omap4_devices[] = {
  59. {
  60. .base = OMAP4_MMU1_BASE,
  61. .irq = OMAP44XX_IRQ_DUCATI_MMU,
  62. .pdata = {
  63. .name = "ducati",
  64. .nr_tlb_entries = 32,
  65. .clk_name = "ipu_fck",
  66. .da_start = 0x0,
  67. .da_end = 0xFFFFF000,
  68. },
  69. },
  70. #if defined(CONFIG_MPU_TESLA_IOMMU)
  71. {
  72. .base = OMAP4_MMU2_BASE,
  73. .irq = INT_44XX_DSP_MMU,
  74. .pdata = {
  75. .name = "tesla",
  76. .nr_tlb_entries = 32,
  77. .clk_name = "tesla_ick",
  78. .da_start = 0x0,
  79. .da_end = 0xFFFFF000,
  80. },
  81. },
  82. #endif
  83. };
  84. #define NR_OMAP4_IOMMU_DEVICES ARRAY_SIZE(omap4_devices)
  85. static struct platform_device *omap4_iommu_pdev[NR_OMAP4_IOMMU_DEVICES];
  86. #else
  87. #define omap4_devices NULL
  88. #define NR_OMAP4_IOMMU_DEVICES 0
  89. #define omap4_iommu_pdev NULL
  90. #endif
  91. static struct platform_device **omap_iommu_pdev;
  92. static int __init omap_iommu_init(void)
  93. {
  94. int i, err;
  95. struct resource res[] = {
  96. { .flags = IORESOURCE_MEM },
  97. { .flags = IORESOURCE_IRQ },
  98. };
  99. if (cpu_is_omap34xx()) {
  100. devices = omap3_devices;
  101. omap_iommu_pdev = omap3_iommu_pdev;
  102. num_iommu_devices = NR_OMAP3_IOMMU_DEVICES;
  103. } else if (cpu_is_omap44xx()) {
  104. devices = omap4_devices;
  105. omap_iommu_pdev = omap4_iommu_pdev;
  106. num_iommu_devices = NR_OMAP4_IOMMU_DEVICES;
  107. } else
  108. return -ENODEV;
  109. for (i = 0; i < num_iommu_devices; i++) {
  110. struct platform_device *pdev;
  111. const struct iommu_device *d = &devices[i];
  112. pdev = platform_device_alloc("omap-iommu", i);
  113. if (!pdev) {
  114. err = -ENOMEM;
  115. goto err_out;
  116. }
  117. res[0].start = d->base;
  118. res[0].end = d->base + MMU_REG_SIZE - 1;
  119. res[1].start = res[1].end = d->irq;
  120. err = platform_device_add_resources(pdev, res,
  121. ARRAY_SIZE(res));
  122. if (err)
  123. goto err_out;
  124. err = platform_device_add_data(pdev, &d->pdata,
  125. sizeof(d->pdata));
  126. if (err)
  127. goto err_out;
  128. err = platform_device_add(pdev);
  129. if (err)
  130. goto err_out;
  131. omap_iommu_pdev[i] = pdev;
  132. }
  133. return 0;
  134. err_out:
  135. while (i--)
  136. platform_device_put(omap_iommu_pdev[i]);
  137. return err;
  138. }
  139. module_init(omap_iommu_init);
  140. static void __exit omap_iommu_exit(void)
  141. {
  142. int i;
  143. for (i = 0; i < num_iommu_devices; i++)
  144. platform_device_unregister(omap_iommu_pdev[i]);
  145. }
  146. module_exit(omap_iommu_exit);
  147. MODULE_AUTHOR("Hiroshi DOYU");
  148. MODULE_DESCRIPTION("omap iommu: omap device registration");
  149. MODULE_LICENSE("GPL v2");