ocotp.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. * Copyright (c) 2011-2012, Freescale Semiconductor, Inc.
  3. * All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without modification,
  6. * are permitted provided that the following conditions are met:
  7. *
  8. * o Redistributions of source code must retain the above copyright notice, this list
  9. * of conditions and the following disclaimer.
  10. *
  11. * o Redistributions in binary form must reproduce the above copyright notice, this
  12. * list of conditions and the following disclaimer in the documentation and/or
  13. * other materials provided with the distribution.
  14. *
  15. * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
  16. * contributors may be used to endorse or promote products derived from this
  17. * software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  20. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  21. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  22. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
  23. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  24. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  25. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  26. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  28. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. */
  30. #ifndef _OCOTP_DRV_H_
  31. #define _OCOTP_DRV_H_
  32. /*!
  33. * @file ocotp.h
  34. * @brief Header file with API for the OCOTP driver.
  35. * @ingroup diag_ocotp
  36. */
  37. #include "sdk.h"
  38. ////////////////////////////////////////////////////////////////////////////////
  39. // Definitions
  40. ////////////////////////////////////////////////////////////////////////////////
  41. #define PITC_ERROR_OTP_RW (-1)
  42. #define ERROR_OTP_PROGRAM_HCLK (PITC_ERROR_OTP_RW)
  43. //! Could not set VDDIO voltage
  44. #define ERROR_OTP_SET_VOLTAGE (PITC_ERROR_OTP_RW-1)
  45. //! OTP Controller is busy
  46. #define ERROR_OTP_CTRL_BUSY (PITC_ERROR_OTP_RW-2)
  47. //! OTP Controller is reporting error
  48. #define ERROR_OTP_CTRL_ERROR (PITC_ERROR_OTP_RW-3)
  49. //! OTP Controller has timeout on write
  50. #define ERROR_OTP_CTRL_TIMEOUT (PITC_ERROR_OTP_RW-4)
  51. //! OTP Controller returns read open
  52. #define ERROR_OTP_RD_BANK_OPEN (PITC_ERROR_OTP_RW-5)
  53. //! invalid OTP register
  54. #define ERROR_OTP_INVALID_REGISTER (PITC_ERROR_OTP_RW-6)
  55. ////////////////////////////////////////////////////////////////////////////////
  56. // API
  57. ////////////////////////////////////////////////////////////////////////////////
  58. #if defined(__cplusplus)
  59. extern "C" {
  60. #endif
  61. /*!
  62. * Read the value of fuses located at bank/row.
  63. *
  64. * @param bank Bank of the fuse.
  65. * @param row Row or word of the fuse.
  66. * @return The value of the fuses at the given bank and row.
  67. */
  68. int32_t ocotp_sense_fuse(uint32_t bank, uint32_t row);
  69. /*!
  70. * Program fuses located at bank/row to value.
  71. *
  72. * @param bank Bank of the fuses.
  73. * @param row Row or word of the fuses.
  74. * @param value Value to program in fuses.
  75. */
  76. void ocotp_fuse_blow_row(uint32_t bank, uint32_t row, uint32_t value);
  77. /*!
  78. * @brief Reload OTP shadow registers.
  79. *
  80. * @retval ERROR_OTP_CTRL_BUSY, if busy
  81. * @retval ERROR_OTP_CTRL_ERROR, if error
  82. * @retval otherwise SUCCESS
  83. */
  84. int ocotp_reload_otp_shadow_registers(void);
  85. #if defined(__cplusplus)
  86. extern "C" {
  87. #endif
  88. #endif //_OCOTP_DRV_H_
  89. ////////////////////////////////////////////////////////////////////////////////
  90. // EOF
  91. ////////////////////////////////////////////////////////////////////////////////