mt_ildo.c 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * Copyright (c) 2015, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions are met:
  6. *
  7. * Redistributions of source code must retain the above copyright notice, this
  8. * list of conditions and the following disclaimer.
  9. *
  10. * Redistributions in binary form must reproduce the above copyright notice,
  11. * this list of conditions and the following disclaimer in the documentation
  12. * and/or other materials provided with the distribution.
  13. *
  14. * Neither the name of ARM nor the names of its contributors may be used
  15. * to endorse or promote products derived from this software without specific
  16. * prior written permission.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  19. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  20. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  21. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
  22. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  23. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  24. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  25. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  26. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  27. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  28. * POSSIBILITY OF SUCH DAMAGE.
  29. */
  30. #include <reg.h>
  31. #include <debug.h>
  32. #include <platform/mt_typedefs.h>
  33. #include <platform/sec_devinfo.h>
  34. #include <platform/mt_ildo.h>
  35. #include "mtk_secure_api.h"
  36. #define mmio_write_32(addr, val) DRV_WriteReg32(addr, val)
  37. #define mmio_read_32(addr) DRV_Reg32(addr)
  38. #ifdef CONFIG_ARM64
  39. #define MTK_SIP_LK_ILDO_READ_EFUSE 0xC20003D0
  40. #else
  41. #define MTK_SIP_LK_ILDO_READ_EFUSE 0x820003D0
  42. #endif
  43. /* fixme: correct efuse idx & number of efuse reg*/
  44. #define DEVINFO_IDX_0 50 /* 0x580 */
  45. #define DEVINFO_IDX_1 51 /* 0x580 */
  46. #define DEVINFO_IDX_2 52 /* 0x580 */
  47. #define DEVINFO_IDX_3 53 /* 0x580 */
  48. #define ILDO_EFUSE_CNT 4
  49. static const unsigned int ildo_efuse_idx[ILDO_EFUSE_CNT] = {
  50. DEVINFO_IDX_0,
  51. DEVINFO_IDX_1,
  52. DEVINFO_IDX_2,
  53. DEVINFO_IDX_3
  54. };
  55. static unsigned int ildo_efuse[ILDO_EFUSE_CNT];
  56. //extern unsigned long mt_secure_call(unsigned long, unsigned long, unsigned long, unsigned long);
  57. int ildo_init(void)
  58. {
  59. int ret;
  60. dprintf(CRITICAL, "ildo_init() in lk\n");
  61. #if ILDO_FUNC_ENABLE
  62. /* fixme: DCM bug workaround */
  63. /* FCM stall dcm bypass control (use QACTIVE instead of stalldcm active signal) */
  64. ildo_write_field(0x0C53C89C, 20:13, 0xC0);
  65. /* bigCPU local stall dcm disable */
  66. ildo_write_field(0x0C533230, 0:0, 0);
  67. /* bigCPU local stall dcm disable */
  68. ildo_write_field(0x0C533A30, 0:0, 0);
  69. /* set mux for CPU 7 to use ARMPLL_BB */
  70. DRV_WriteReg32(0x0C53AD00, 0x1);
  71. #endif
  72. for (int i = 0; i < ILDO_EFUSE_CNT; i++) {
  73. /* fixme: correct efuse idx & number of efuse reg*/
  74. /* ildo_efuse[i] = get_devinfo_with_index(ildo_efuse_idx[i]); */
  75. ildo_efuse[i] = 0;
  76. dprintf(INFO, "ildo_efuse[%d] = 0x%08X\n", i, ildo_efuse[i]);
  77. ret = mt_secure_call(MTK_SIP_LK_ILDO_READ_EFUSE, i, ildo_efuse[i], 0, 0);
  78. if (ret != 0)
  79. dprintf(CRITICAL, "LK smc call MTK_SIP_LK_ILDO_READ_EFUSE error: id = %d\n", i);
  80. }
  81. return 0;
  82. }