dev-mfc.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /* linux/arch/arm/plat-s5p/dev-mfc.c
  2. *
  3. * Copyright (C) 2010-2011 Samsung Electronics Co.Ltd
  4. *
  5. * Base S5P MFC resource and device definitions
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. */
  11. #include <linux/kernel.h>
  12. #include <linux/interrupt.h>
  13. #include <linux/platform_device.h>
  14. #include <linux/dma-mapping.h>
  15. #include <linux/memblock.h>
  16. #include <linux/ioport.h>
  17. #include <mach/map.h>
  18. #include <plat/devs.h>
  19. #include <plat/irqs.h>
  20. #include <plat/mfc.h>
  21. static struct resource s5p_mfc_resource[] = {
  22. [0] = {
  23. .start = S5P_PA_MFC,
  24. .end = S5P_PA_MFC + SZ_64K - 1,
  25. .flags = IORESOURCE_MEM,
  26. },
  27. [1] = {
  28. .start = IRQ_MFC,
  29. .end = IRQ_MFC,
  30. .flags = IORESOURCE_IRQ,
  31. }
  32. };
  33. struct platform_device s5p_device_mfc = {
  34. .name = "s5p-mfc",
  35. .id = -1,
  36. .num_resources = ARRAY_SIZE(s5p_mfc_resource),
  37. .resource = s5p_mfc_resource,
  38. };
  39. /*
  40. * MFC hardware has 2 memory interfaces which are modelled as two separate
  41. * platform devices to let dma-mapping distinguish between them.
  42. *
  43. * MFC parent device (s5p_device_mfc) must be registered before memory
  44. * interface specific devices (s5p_device_mfc_l and s5p_device_mfc_r).
  45. */
  46. static u64 s5p_mfc_dma_mask = DMA_BIT_MASK(32);
  47. struct platform_device s5p_device_mfc_l = {
  48. .name = "s5p-mfc-l",
  49. .id = -1,
  50. .dev = {
  51. .parent = &s5p_device_mfc.dev,
  52. .dma_mask = &s5p_mfc_dma_mask,
  53. .coherent_dma_mask = DMA_BIT_MASK(32),
  54. },
  55. };
  56. struct platform_device s5p_device_mfc_r = {
  57. .name = "s5p-mfc-r",
  58. .id = -1,
  59. .dev = {
  60. .parent = &s5p_device_mfc.dev,
  61. .dma_mask = &s5p_mfc_dma_mask,
  62. .coherent_dma_mask = DMA_BIT_MASK(32),
  63. },
  64. };
  65. struct s5p_mfc_reserved_mem {
  66. phys_addr_t base;
  67. unsigned long size;
  68. struct device *dev;
  69. };
  70. static struct s5p_mfc_reserved_mem s5p_mfc_mem[2] __initdata;
  71. void __init s5p_mfc_reserve_mem(phys_addr_t rbase, unsigned int rsize,
  72. phys_addr_t lbase, unsigned int lsize)
  73. {
  74. int i;
  75. s5p_mfc_mem[0].dev = &s5p_device_mfc_r.dev;
  76. s5p_mfc_mem[0].base = rbase;
  77. s5p_mfc_mem[0].size = rsize;
  78. s5p_mfc_mem[1].dev = &s5p_device_mfc_l.dev;
  79. s5p_mfc_mem[1].base = lbase;
  80. s5p_mfc_mem[1].size = lsize;
  81. for (i = 0; i < ARRAY_SIZE(s5p_mfc_mem); i++) {
  82. struct s5p_mfc_reserved_mem *area = &s5p_mfc_mem[i];
  83. if (memblock_remove(area->base, area->size)) {
  84. printk(KERN_ERR "Failed to reserve memory for MFC device (%ld bytes at 0x%08lx)\n",
  85. area->size, (unsigned long) area->base);
  86. area->base = 0;
  87. }
  88. }
  89. }
  90. static int __init s5p_mfc_memory_init(void)
  91. {
  92. int i;
  93. for (i = 0; i < ARRAY_SIZE(s5p_mfc_mem); i++) {
  94. struct s5p_mfc_reserved_mem *area = &s5p_mfc_mem[i];
  95. if (!area->base)
  96. continue;
  97. if (dma_declare_coherent_memory(area->dev, area->base,
  98. area->base, area->size,
  99. DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE) == 0)
  100. printk(KERN_ERR "Failed to declare coherent memory for MFC device (%ld bytes at 0x%08lx)\n",
  101. area->size, (unsigned long) area->base);
  102. }
  103. return 0;
  104. }
  105. device_initcall(s5p_mfc_memory_init);