dev-mfc.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. struct s5p_mfc_reserved_mem {
  22. phys_addr_t base;
  23. unsigned long size;
  24. struct device *dev;
  25. };
  26. static struct s5p_mfc_reserved_mem s5p_mfc_mem[2] __initdata;
  27. void __init s5p_mfc_reserve_mem(phys_addr_t rbase, unsigned int rsize,
  28. phys_addr_t lbase, unsigned int lsize)
  29. {
  30. int i;
  31. s5p_mfc_mem[0].dev = &s5p_device_mfc_r.dev;
  32. s5p_mfc_mem[0].base = rbase;
  33. s5p_mfc_mem[0].size = rsize;
  34. s5p_mfc_mem[1].dev = &s5p_device_mfc_l.dev;
  35. s5p_mfc_mem[1].base = lbase;
  36. s5p_mfc_mem[1].size = lsize;
  37. for (i = 0; i < ARRAY_SIZE(s5p_mfc_mem); i++) {
  38. struct s5p_mfc_reserved_mem *area = &s5p_mfc_mem[i];
  39. if (memblock_remove(area->base, area->size)) {
  40. printk(KERN_ERR "Failed to reserve memory for MFC device (%ld bytes at 0x%08lx)\n",
  41. area->size, (unsigned long) area->base);
  42. area->base = 0;
  43. }
  44. }
  45. }
  46. static int __init s5p_mfc_memory_init(void)
  47. {
  48. int i;
  49. for (i = 0; i < ARRAY_SIZE(s5p_mfc_mem); i++) {
  50. struct s5p_mfc_reserved_mem *area = &s5p_mfc_mem[i];
  51. if (!area->base)
  52. continue;
  53. if (dma_declare_coherent_memory(area->dev, area->base,
  54. area->base, area->size,
  55. DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE) == 0)
  56. printk(KERN_ERR "Failed to declare coherent memory for MFC device (%ld bytes at 0x%08lx)\n",
  57. area->size, (unsigned long) area->base);
  58. }
  59. return 0;
  60. }
  61. device_initcall(s5p_mfc_memory_init);