common.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * linux/arch/arm/plat-omap/common.c
  3. *
  4. * Code common to all OMAP machines.
  5. * The file is created by Tony Lindgren <tony@atomide.com>
  6. *
  7. * Copyright (C) 2009 Texas Instruments
  8. * Added OMAP4 support - Santosh Shilimkar <santosh.shilimkar@ti.com>
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License version 2 as
  12. * published by the Free Software Foundation.
  13. */
  14. #include <linux/kernel.h>
  15. #include <linux/init.h>
  16. #include <linux/io.h>
  17. #include <linux/dma-mapping.h>
  18. #include <plat/common.h>
  19. #include <plat/board.h>
  20. #include <plat/vram.h>
  21. #include <plat/dsp.h>
  22. #include <plat/dma.h>
  23. #include <plat/omap-secure.h>
  24. #define NO_LENGTH_CHECK 0xffffffff
  25. struct omap_board_config_kernel *omap_board_config __initdata;
  26. int omap_board_config_size;
  27. static const void *__init get_config(u16 tag, size_t len,
  28. int skip, size_t *len_out)
  29. {
  30. struct omap_board_config_kernel *kinfo = NULL;
  31. int i;
  32. /* Try to find the config from the board-specific structures
  33. * in the kernel. */
  34. for (i = 0; i < omap_board_config_size; i++) {
  35. if (omap_board_config[i].tag == tag) {
  36. if (skip == 0) {
  37. kinfo = &omap_board_config[i];
  38. break;
  39. } else {
  40. skip--;
  41. }
  42. }
  43. }
  44. if (kinfo == NULL)
  45. return NULL;
  46. return kinfo->data;
  47. }
  48. const void *__init __omap_get_config(u16 tag, size_t len, int nr)
  49. {
  50. return get_config(tag, len, nr, NULL);
  51. }
  52. const void *__init omap_get_var_config(u16 tag, size_t *len)
  53. {
  54. return get_config(tag, NO_LENGTH_CHECK, 0, len);
  55. }
  56. void __init omap_reserve(void)
  57. {
  58. omap_vram_reserve_sdram_memblock();
  59. omap_dsp_reserve_sdram_memblock();
  60. omap_secure_ram_reserve_memblock();
  61. omap_barrier_reserve_memblock();
  62. }
  63. void __init omap_init_consistent_dma_size(void)
  64. {
  65. #ifdef CONFIG_FB_OMAP_CONSISTENT_DMA_SIZE
  66. init_consistent_dma_size(CONFIG_FB_OMAP_CONSISTENT_DMA_SIZE << 20);
  67. #endif
  68. }
  69. /*
  70. * Stub function for OMAP2 so that common files
  71. * continue to build when custom builds are used
  72. */
  73. int __weak omap_secure_ram_reserve_memblock(void)
  74. {
  75. return 0;
  76. }