sram-init.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * OMAP SRAM detection and management
  3. *
  4. * Copyright (C) 2005 Nokia Corporation
  5. * Written by Tony Lindgren <tony@atomide.com>
  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/module.h>
  12. #include <linux/kernel.h>
  13. #include <linux/init.h>
  14. #include <linux/io.h>
  15. #include <asm/fncpy.h>
  16. #include <asm/tlb.h>
  17. #include <asm/cacheflush.h>
  18. #include <asm/mach/map.h>
  19. #include "soc.h"
  20. #include "sram.h"
  21. #define OMAP1_SRAM_PA 0x20000000
  22. #define SRAM_BOOTLOADER_SZ 0x80
  23. /*
  24. * The amount of SRAM depends on the core type.
  25. * Note that we cannot try to test for SRAM here because writes
  26. * to secure SRAM will hang the system. Also the SRAM is not
  27. * yet mapped at this point.
  28. */
  29. static void __init omap_detect_and_map_sram(void)
  30. {
  31. unsigned long omap_sram_skip = SRAM_BOOTLOADER_SZ;
  32. unsigned long omap_sram_start = OMAP1_SRAM_PA;
  33. unsigned long omap_sram_size;
  34. if (cpu_is_omap7xx())
  35. omap_sram_size = 0x32000; /* 200K */
  36. else if (cpu_is_omap15xx())
  37. omap_sram_size = 0x30000; /* 192K */
  38. else if (cpu_is_omap1610() || cpu_is_omap1611() ||
  39. cpu_is_omap1621() || cpu_is_omap1710())
  40. omap_sram_size = 0x4000; /* 16K */
  41. else {
  42. pr_err("Could not detect SRAM size\n");
  43. omap_sram_size = 0x4000;
  44. }
  45. omap_map_sram(omap_sram_start, omap_sram_size,
  46. omap_sram_skip, 1);
  47. }
  48. static void (*_omap_sram_reprogram_clock)(u32 dpllctl, u32 ckctl);
  49. void omap_sram_reprogram_clock(u32 dpllctl, u32 ckctl)
  50. {
  51. BUG_ON(!_omap_sram_reprogram_clock);
  52. /* On 730, bit 13 must always be 1 */
  53. if (cpu_is_omap7xx())
  54. ckctl |= 0x2000;
  55. _omap_sram_reprogram_clock(dpllctl, ckctl);
  56. }
  57. int __init omap_sram_init(void)
  58. {
  59. omap_detect_and_map_sram();
  60. _omap_sram_reprogram_clock =
  61. omap_sram_push(omap1_sram_reprogram_clock,
  62. omap1_sram_reprogram_clock_sz);
  63. return 0;
  64. }