omap3-iommu.c 2.1 KB

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