1
2
3
4
5
6
7
8#ifndef __BFROM_H__
9#define __BFROM_H__
10
11#include <linux/types.h>
12
13
14#define SYSCTRL_READ 0x00000000
15#define SYSCTRL_WRITE 0x00000001
16#define SYSCTRL_SYSRESET 0x00000002
17#define SYSCTRL_CORERESET 0x00000004
18#define SYSCTRL_SOFTRESET 0x00000006
19#define SYSCTRL_VRCTL 0x00000010
20#define SYSCTRL_EXTVOLTAGE 0x00000020
21#define SYSCTRL_INTVOLTAGE 0x00000000
22#define SYSCTRL_OTPVOLTAGE 0x00000040
23#define SYSCTRL_PLLCTL 0x00000100
24#define SYSCTRL_PLLDIV 0x00000200
25#define SYSCTRL_LOCKCNT 0x00000400
26#define SYSCTRL_PLLSTAT 0x00000800
27
28typedef struct ADI_SYSCTRL_VALUES {
29 uint16_t uwVrCtl;
30 uint16_t uwPllCtl;
31 uint16_t uwPllDiv;
32 uint16_t uwPllLockCnt;
33 uint16_t uwPllStat;
34} ADI_SYSCTRL_VALUES;
35
36static uint32_t (* const bfrom_SysControl)(uint32_t action_flags, ADI_SYSCTRL_VALUES *power_settings, void *reserved) = (void *)0xEF000038;
37
38
39
40
41
42__attribute__((__noreturn__))
43static inline void bfrom_SoftReset(void *new_stack)
44{
45 while (1)
46
47
48
49
50
51 __asm__ __volatile__(
52 "sp = %[stack];"
53 "jump (%[bfrom_syscontrol]);"
54 : : [bfrom_syscontrol] "p"(bfrom_SysControl),
55 "q0"(SYSCTRL_SOFTRESET),
56 "q1"(0),
57 "q2"(NULL),
58 [stack] "p"(new_stack)
59 );
60}
61
62
63static uint32_t (* const bfrom_OtpCommand)(uint32_t command, uint32_t value) = (void *)0xEF000018;
64static uint32_t (* const bfrom_OtpRead)(uint32_t page, uint32_t flags, uint64_t *page_content) = (void *)0xEF00001A;
65static uint32_t (* const bfrom_OtpWrite)(uint32_t page, uint32_t flags, uint64_t *page_content) = (void *)0xEF00001C;
66
67
68#define OTP_INIT 0x00000001
69#define OTP_CLOSE 0x00000002
70
71
72#define OTP_LOWER_HALF 0x00000000
73#define OTP_UPPER_HALF 0x00000001
74#define OTP_NO_ECC 0x00000010
75#define OTP_LOCK 0x00000020
76#define OTP_CHECK_FOR_PREV_WRITE 0x00000080
77
78
79#define OTP_SUCCESS 0x00000000
80#define OTP_MASTER_ERROR 0x001
81#define OTP_WRITE_ERROR 0x003
82#define OTP_READ_ERROR 0x005
83#define OTP_ACC_VIO_ERROR 0x009
84#define OTP_DATA_MULT_ERROR 0x011
85#define OTP_ECC_MULT_ERROR 0x021
86#define OTP_PREV_WR_ERROR 0x041
87#define OTP_DATA_SB_WARN 0x100
88#define OTP_ECC_SB_WARN 0x200
89
90#endif
91