omap-iommu.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. struct iommu_device {
  15. resource_size_t base;
  16. int irq;
  17. struct iommu_platform_data pdata;
  18. struct resource res[2];
  19. };
  20. #ifdef CONFIG_ARCH_OMAP3
  21. static struct iommu_device devices[] = {
  22. {
  23. .base = 0x480bd400,
  24. .irq = 24,
  25. .pdata = {
  26. .name = "isp",
  27. .nr_tlb_entries = 8,
  28. .clk_name = "cam_ick",
  29. },
  30. },
  31. #if defined(CONFIG_MPU_BRIDGE_IOMMU)
  32. {
  33. .base = 0x5d000000,
  34. .irq = 28,
  35. .pdata = {
  36. .name = "iva2",
  37. .nr_tlb_entries = 32,
  38. .clk_name = "iva2_ck",
  39. },
  40. },
  41. #endif
  42. };
  43. #endif
  44. #define NR_IOMMU_DEVICES ARRAY_SIZE(devices)
  45. static struct platform_device *omap_iommu_pdev[NR_IOMMU_DEVICES];
  46. static int __init omap_iommu_init(void)
  47. {
  48. int i, err;
  49. struct resource res[] = {
  50. { .flags = IORESOURCE_MEM },
  51. { .flags = IORESOURCE_IRQ },
  52. };
  53. for (i = 0; i < NR_IOMMU_DEVICES; i++) {
  54. struct platform_device *pdev;
  55. const struct iommu_device *d = &devices[i];
  56. pdev = platform_device_alloc("omap-iommu", i);
  57. if (!pdev) {
  58. err = -ENOMEM;
  59. goto err_out;
  60. }
  61. res[0].start = d->base;
  62. res[0].end = d->base + MMU_REG_SIZE - 1;
  63. res[1].start = res[1].end = d->irq;
  64. err = platform_device_add_resources(pdev, res,
  65. ARRAY_SIZE(res));
  66. if (err)
  67. goto err_out;
  68. err = platform_device_add_data(pdev, &d->pdata,
  69. sizeof(d->pdata));
  70. if (err)
  71. goto err_out;
  72. err = platform_device_add(pdev);
  73. if (err)
  74. goto err_out;
  75. omap_iommu_pdev[i] = pdev;
  76. }
  77. return 0;
  78. err_out:
  79. while (i--)
  80. platform_device_put(omap_iommu_pdev[i]);
  81. return err;
  82. }
  83. module_init(omap_iommu_init);
  84. static void __exit omap_iommu_exit(void)
  85. {
  86. int i;
  87. for (i = 0; i < NR_IOMMU_DEVICES; i++)
  88. platform_device_unregister(omap_iommu_pdev[i]);
  89. }
  90. module_exit(omap_iommu_exit);
  91. MODULE_AUTHOR("Hiroshi DOYU");
  92. MODULE_DESCRIPTION("omap iommu: omap device registration");
  93. MODULE_LICENSE("GPL v2");