s5p-dev-mfc.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Copyright (C) 2010-2011 Samsung Electronics Co.Ltd
  3. *
  4. * Base S5P MFC resource and device definitions
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #include <linux/kernel.h>
  11. #include <linux/interrupt.h>
  12. #include <linux/platform_device.h>
  13. #include <linux/dma-mapping.h>
  14. #include <linux/memblock.h>
  15. #include <linux/ioport.h>
  16. #include <mach/map.h>
  17. #include <plat/devs.h>
  18. #include <plat/irqs.h>
  19. #include <plat/mfc.h>
  20. struct s5p_mfc_reserved_mem {
  21. phys_addr_t base;
  22. unsigned long size;
  23. struct device *dev;
  24. };
  25. static struct s5p_mfc_reserved_mem s5p_mfc_mem[2] __initdata;
  26. void __init s5p_mfc_reserve_mem(phys_addr_t rbase, unsigned int rsize,
  27. phys_addr_t lbase, unsigned int lsize)
  28. {
  29. int i;
  30. s5p_mfc_mem[0].dev = &s5p_device_mfc_r.dev;
  31. s5p_mfc_mem[0].base = rbase;
  32. s5p_mfc_mem[0].size = rsize;
  33. s5p_mfc_mem[1].dev = &s5p_device_mfc_l.dev;
  34. s5p_mfc_mem[1].base = lbase;
  35. s5p_mfc_mem[1].size = lsize;
  36. for (i = 0; i < ARRAY_SIZE(s5p_mfc_mem); i++) {
  37. struct s5p_mfc_reserved_mem *area = &s5p_mfc_mem[i];
  38. if (memblock_remove(area->base, area->size)) {
  39. printk(KERN_ERR "Failed to reserve memory for MFC device (%ld bytes at 0x%08lx)\n",
  40. area->size, (unsigned long) area->base);
  41. area->base = 0;
  42. }
  43. }
  44. }
  45. static int __init s5p_mfc_memory_init(void)
  46. {
  47. int i;
  48. for (i = 0; i < ARRAY_SIZE(s5p_mfc_mem); i++) {
  49. struct s5p_mfc_reserved_mem *area = &s5p_mfc_mem[i];
  50. if (!area->base)
  51. continue;
  52. if (dma_declare_coherent_memory(area->dev, area->base,
  53. area->base, area->size,
  54. DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE) == 0)
  55. printk(KERN_ERR "Failed to declare coherent memory for MFC device (%ld bytes at 0x%08lx)\n",
  56. area->size, (unsigned long) area->base);
  57. }
  58. return 0;
  59. }
  60. device_initcall(s5p_mfc_memory_init);