1 //*****************************************************************************
2 //
3 //  am_hal_otp.h
4 //! @file
5 //!
6 //! @brief Functions for handling the OTP interface.
7 //
8 //*****************************************************************************
9 
10 //*****************************************************************************
11 //
12 // Copyright (c) 2017, Ambiq Micro
13 // All rights reserved.
14 //
15 // Redistribution and use in source and binary forms, with or without
16 // modification, are permitted provided that the following conditions are met:
17 //
18 // 1. Redistributions of source code must retain the above copyright notice,
19 // this list of conditions and the following disclaimer.
20 //
21 // 2. Redistributions in binary form must reproduce the above copyright
22 // notice, this list of conditions and the following disclaimer in the
23 // documentation and/or other materials provided with the distribution.
24 //
25 // 3. Neither the name of the copyright holder nor the names of its
26 // contributors may be used to endorse or promote products derived from this
27 // software without specific prior written permission.
28 //
29 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
30 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
31 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
32 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
33 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
34 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
35 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
36 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
37 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
38 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
39 // POSSIBILITY OF SUCH DAMAGE.
40 //
41 // This is part of revision 1.2.11 of the AmbiqSuite Development Package.
42 //
43 //*****************************************************************************
44 #ifndef AM_HAL_OTP_H
45 #define AM_HAL_OTP_H
46 
47 //*****************************************************************************
48 //
49 // Define some OTP values and macros.
50 //
51 //*****************************************************************************
52 #define AM_HAL_OTP_SIG0             0x00
53 #define AM_HAL_OTP_SIG1             0x04
54 #define AM_HAL_OTP_SIG2             0x08
55 #define AM_HAL_OTP_SIG3             0x0C
56 
57 #define AM_HAL_OTP_DBGR_O           0x10
58 #define AM_HAL_OTP_WRITPROT0_O      0x20
59 #define AM_HAL_OTP_WRITPROT1_O      0x24
60 #define AM_HAL_OTP_COPYPROT0_O      0x30
61 #define AM_HAL_OTP_COPYPROT1_O      0x34
62 
63 #define AM_HAL_OTP_ADDR             0x50020000
64 #define AM_HAL_OTP_DBGRPROT_ADDR    (AM_HAL_OTP_ADDR + AM_HAL_OTP_DBGR_O)
65 #define AM_HAL_OTP_WRITPROT_ADDR    (AM_HAL_OTP_ADDR + AM_HAL_OTP_WRITPROT0_O)
66 #define AM_HAL_OTP_COPYPROT_ADDR    (AM_HAL_OTP_ADDR + AM_HAL_OTP_COPYPROT0_O)
67 
68 #define AM_HAL_OTP_CHUNKSIZE        (16*1024)
69 
70 //
71 // Debugger port lockout macros.
72 //
73 #define AM_OTP_DBGR_LOCKOUT_S       (0)
74 #define AM_OTP_DBGR_LOCKOUT_M       (0x1 << AM_OTP_DBGR_LOCKOUT_S)
75 #define AM_OTP_STRM_LOCKOUT_S       (1)
76 #define AM_OTP_STRM_LOCKOUT_M       (0x1 << AM_OTP_STRM_LOCKOUT_S)
77 #define AM_OTP_SRAM_LOCKOUT_S       (2)
78 #define AM_OTP_SRAM_LOCKOUT_M       (0x1 << AM_OTP_SRAM_LOCKOUT_S)
79 
80 #ifdef __cplusplus
81 extern "C"
82 {
83 #endif
84 
85 //*****************************************************************************
86 //
87 // Function prototypes
88 //
89 //*****************************************************************************
90 extern int am_hal_otp_is_debugger_lockedout(void);
91 extern int am_hal_otp_debugger_lockout(void);
92 extern int am_hal_otp_sram_lockout(void);
93 extern int am_hal_otp_set_copy_protection(uint32_t u32BegAddr, uint32_t u32EndAddr);
94 extern int am_hal_otp_set_write_protection(uint32_t u32BegAddr, uint32_t u32EndAddr);
95 
96 #ifdef __cplusplus
97 }
98 #endif
99 
100 #endif // AM_HAL_OTP_H
101 
102 //*****************************************************************************
103 //
104 // End Doxygen group.
105 //! @}
106 //
107 //*****************************************************************************
108 
109