statisticsMemoryDefinition.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /*
  2. * linux/arch/arm/mach-omap1/clock.c
  3. *
  4. * Copyright (C) 2004 - 2005, 2009-2010 Nokia Corporation
  5. * Written by Tuukka Tikkanen <tuukka.tikkanen@elektrobit.com>
  6. *
  7. * Modified to use omap shared clock framework by
  8. * Tony Lindgren <tony@atomide.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/export.h>
  16. #include <linux/list.h>
  17. #include <linux/errno.h>
  18. #include <linux/err.h>
  19. #include <linux/io.h>
  20. #include <linux/clk.h>
  21. #include <linux/clkdev.h>
  22. #include <asm/mach-types.h>
  23. #include <mach/hardware.h>
  24. #include "soc.h"
  25. #include "iomap.h"
  26. #include "clock.h"
  27. #include "opp.h"
  28. #include "sram.h"
  29. __u32 arm_idlect1_mask;
  30. struct clk *api_ck_p, *ck_dpll1_p, *ck_ref_p;
  31. static LIST_HEAD(clocks);
  32. static DEFINE_MUTEX(clocks_mutex);
  33. static DEFINE_SPINLOCK(clockfw_lock);
  34. /*
  35. * Omap1 specific clock functions
  36. */
  37. unsigned long omap1_uart_recalc(struct clk *clk)
  38. {
  39. unsigned int val = __raw_readl(clk->enable_reg);
  40. return val & clk->enable_bit ? 48000000 : 12000000;
  41. }
  42. unsigned long omap1_sossi_recalc(struct clk *clk)
  43. {
  44. u32 div = omap_readl(MOD_CONF_CTRL_1);
  45. div = (div >> 17) & 0x7;
  46. div++;
  47. return clk->parent->rate / div;
  48. }
  49. static void omap1_clk_allow_idle(struct clk *clk)
  50. {
  51. struct arm_idlect1_clk * iclk = (struct arm_idlect1_clk *)clk;
  52. if (!(clk->flags & CLOCK_IDLE_CONTROL))
  53. return;
  54. if (iclk->no_idle_count > 0 && !(--iclk->no_idle_count))
  55. arm_idlect1_mask |= 1 << iclk->idlect_shift;
  56. }
  57. static void omap1_clk_deny_idle(struct clk *clk)
  58. {
  59. struct arm_idlect1_clk * iclk = (struct arm_idlect1_clk *)clk;
  60. if (!(clk->flags & CLOCK_IDLE_CONTROL))
  61. return;
  62. if (iclk->no_idle_count++ == 0)
  63. arm_idlect1_mask &= ~(1 << iclk->idlect_shift);
  64. }
  65. static __u16 verify_ckctl_value(__u16 newval)
  66. {
  67. /* This function checks for following limitations set
  68. * by the hardware (all conditions must be true):
  69. * DSPMMU_CK == DSP_CK or DSPMMU_CK == DSP_CK/2
  70. * ARM_CK >= TC_CK
  71. * DSP_CK >= TC_CK
  72. * DSPMMU_CK >= TC_CK
  73. *
  74. * In addition following rules are enforced:
  75. * LCD_CK <= TC_CK
  76. * ARMPER_CK <= TC_CK
  77. *
  78. * However, maximum frequencies are not checked for!
  79. */
  80. __u8 per_exp;
  81. __u8 lcd_exp;
  82. __u8 arm_exp;
  83. __u8 dsp_exp;
  84. __u8 tc_exp;
  85. __u8 dspmmu_exp;
  86. per_exp = (newval >> CKCTL_PERDIV_OFFSET) & 3;
  87. lcd_exp = (newval >> CKCTL_LCDDIV_OFFSET) & 3;
  88. arm_exp = (newval >> CKCTL_ARMDIV_OFFSET) & 3;
  89. dsp_exp = (newval >> CKCTL_DSPDIV_OFFSET) & 3;
  90. tc_exp = (newval >> CKCTL_TCDIV_OFFSET) & 3;
  91. dspmmu_exp = (newval >> CKCTL_DSPMMUDIV_OFFSET) & 3;
  92. if (dspmmu_exp < dsp_exp)
  93. dspmmu_exp = dsp_exp;
  94. if (dspmmu_exp > dsp_exp+1)
  95. dspmmu_exp = dsp_exp+1;
  96. if (tc_exp < arm_exp)
  97. tc_exp = arm_exp;
  98. if (tc_exp < dspmmu_exp)
  99. tc_exp = dspmmu_exp;
  100. if (tc_exp > lcd_exp)
  101. lcd_exp = tc_exp;
  102. if (tc_exp > per_exp)
  103. per_exp = tc_exp;
  104. newval &= 0xf000;
  105. newval |= per_exp << CKCTL_PERDIV_OFFSET;
  106. newval |= lcd_exp << CKCTL_LCDDIV_OFFSET;
  107. newval |= arm_exp << CKCTL_ARMDIV_OFFSET;
  108. newval |= dsp_exp << CKCTL_DSPDIV_OFFSET;
  109. newval |= tc_exp << CKCTL_TCDIV_OFFSET;
  110. newval |= dspmmu_exp << CKCTL_DSPMMUDIV_OFFSET;
  111. return newval;