omap-iommu.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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/module.h>
  13. #include <linux/platform_device.h>
  14. #include <plat/iommu.h>
  15. #include "soc.h"
  16. #include "common.h"
  17. struct iommu_device {
  18. resource_size_t base;
  19. int irq;
  20. struct iommu_platform_data pdata;
  21. struct resource res[2];
  22. };
  23. static struct iommu_device *devices;
  24. static int num_iommu_devices;
  25. #ifdef CONFIG_ARCH_OMAP3
  26. static struct iommu_device omap3_devices[] = {
  27. {
  28. .base = 0x480bd400,
  29. .irq = 24 + OMAP_INTC_START,
  30. .pdata = {
  31. .name = "isp",
  32. .nr_tlb_entries = 8,
  33. .clk_name = "cam_ick",
  34. .da_start = 0x0,
  35. .da_end = 0xFFFFF000,
  36. },
  37. },
  38. #if defined(CONFIG_OMAP_IOMMU_IVA2)
  39. {
  40. .base = 0x5d000000,
  41. .irq = 28 + OMAP_INTC_START,
  42. .pdata = {
  43. .name = "iva2",
  44. .nr_tlb_entries = 32,
  45. .clk_name = "iva2_ck",
  46. .da_start = 0x11000000,
  47. .da_end = 0xFFFFF000,
  48. },
  49. },
  50. #endif
  51. };
  52. #define NR_OMAP3_IOMMU_DEVICES ARRAY_SIZE(omap3_devices)
  53. static struct platform_device *omap3_iommu_pdev[NR_OMAP3_IOMMU_DEVICES];
  54. #else
  55. #define omap3_devices NULL
  56. #define NR_OMAP3_IOMMU_DEVICES 0
  57. #define omap3_iommu_pdev NULL
  58. #endif
  59. #ifdef CONFIG_ARCH_OMAP4
  60. static struct iommu_device omap4_devices[] = {
  61. {
  62. .base = OMAP4_MMU1_BASE,
  63. .irq = 100 + OMAP44XX_IRQ_GIC_START,
  64. .pdata = {
  65. .name = "ducati",
  66. .nr_tlb_entries = 32,
  67. .clk_name = "ipu_fck",
  68. .da_start = 0x0,
  69. .da_end = 0xFFFFF000,
  70. },
  71. },
  72. {
  73. .base = OMAP4_MMU2_BASE,
  74. .irq = 28 + OMAP44XX_IRQ_GIC_START,
  75. .pdata = {
  76. .name = "tesla",
  77. .nr_tlb_entries = 32,
  78. .clk_name = "dsp_fck",
  79. .da_start = 0x0,
  80. .da_end = 0xFFFFF000,
  81. },
  82. },
  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. /* must be ready before omap3isp is probed */
  140. subsys_initcall(omap_iommu_init);
  141. static void __exit omap_iommu_exit(void)
  142. {
  143. int i;
  144. for (i = 0; i < num_iommu_devices; i++)
  145. platform_device_unregister(omap_iommu_pdev[i]);
  146. }
  147. module_exit(omap_iommu_exit);
  148. MODULE_AUTHOR("Hiroshi DOYU");
  149. MODULE_DESCRIPTION("omap iommu: omap device registration");
  150. MODULE_LICENSE("GPL v2");