clocks.c 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. *
  3. * Clock initialization for OMAP5
  4. *
  5. * (C) Copyright 2010
  6. * Texas Instruments, <www.ti.com>
  7. *
  8. * Aneesh V <aneesh@ti.com>
  9. * Sricharan R <r.sricharan@ti.com>
  10. *
  11. * Based on previous work by:
  12. * Santosh Shilimkar <santosh.shilimkar@ti.com>
  13. * Rajendra Nayak <rnayak@ti.com>
  14. *
  15. * See file CREDITS for list of people who contributed to this
  16. * project.
  17. *
  18. * This program is free software; you can redistribute it and/or
  19. * modify it under the terms of the GNU General Public License as
  20. * published by the Free Software Foundation; either version 2 of
  21. * the License, or (at your option) any later version.
  22. *
  23. * This program is distributed in the hope that it will be useful,
  24. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  25. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  26. * GNU General Public License for more details.
  27. *
  28. * You should have received a copy of the GNU General Public License
  29. * along with this program; if not, write to the Free Software
  30. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  31. * MA 02111-1307 USA
  32. */
  33. #include <common.h>
  34. #include <asm/omap_common.h>
  35. #include <asm/arch/clocks.h>
  36. #include <asm/arch/sys_proto.h>
  37. #include <asm/utils.h>
  38. #include <asm/omap_gpio.h>
  39. #include <asm/emif.h>
  40. #ifndef CONFIG_SPL_BUILD
  41. /*
  42. * printing to console doesn't work unless
  43. * this code is executed from SPL
  44. */
  45. #define printf(fmt, args...)
  46. #define puts(s)
  47. #endif
  48. /*
  49. * Setup the voltages for vdd_mpu, vdd_core, and vdd_iva
  50. * We set the maximum voltages allowed here because Smart-Reflex is not
  51. * enabled in bootloader. Voltage initialization in the kernel will set
  52. * these to the nominal values after enabling Smart-Reflex
  53. */
  54. void scale_vcores(void)
  55. {
  56. u32 volt_core, volt_mpu, volt_mm;
  57. omap_vc_init(PRM_VC_I2C_CHANNEL_FREQ_KHZ);
  58. /* Palmas settings */
  59. if (omap_revision() != OMAP5432_ES1_0) {
  60. volt_core = VDD_CORE;
  61. volt_mpu = VDD_MPU;
  62. volt_mm = VDD_MM;
  63. } else {
  64. volt_core = VDD_CORE_5432;
  65. volt_mpu = VDD_MPU_5432;
  66. volt_mm = VDD_MM_5432;
  67. }
  68. do_scale_vcore(SMPS_REG_ADDR_8_CORE, volt_core);
  69. do_scale_vcore(SMPS_REG_ADDR_12_MPU, volt_mpu);
  70. do_scale_vcore(SMPS_REG_ADDR_45_IVA, volt_mm);
  71. if (emif_sdram_type() == EMIF_SDRAM_TYPE_DDR3) {
  72. /* Configure LDO SRAM "magic" bits */
  73. writel(2, (*prcm)->prm_sldo_core_setup);
  74. writel(2, (*prcm)->prm_sldo_mpu_setup);
  75. writel(2, (*prcm)->prm_sldo_mm_setup);
  76. }
  77. }
  78. u32 get_offset_code(u32 volt_offset)
  79. {
  80. u32 offset_code, step = 10000; /* 10 mV represented in uV */
  81. volt_offset -= PALMAS_SMPS_BASE_VOLT_UV;
  82. offset_code = (volt_offset + step - 1) / step;
  83. /*
  84. * Offset codes 1-6 all give the base voltage in Palmas
  85. * Offset code 0 switches OFF the SMPS
  86. */
  87. return offset_code + 6;
  88. }