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