blob: 20205c5da7591b58c6f3e96f531345e064e14c94 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
#ifndef __MACH_IMX_OCOTP_H
#define __MACH_IMX_OCOTP_H
#include <linux/bitfield.h>
#include <linux/types.h>
#define OCOTP_SHADOW_OFFSET 0x400
#define OCOTP_SHADOW_SPACING 0x10
/*
* Trivial shadow register offset -> ocotp register index.
*
* NOTE: Doesn't handle special mapping quirks. See
* imx6q_addr_to_offset and vf610_addr_to_offset for more details. Use
* with care
*/
#define OCOTP_OFFSET_TO_INDEX(o) \
(((o) - OCOTP_SHADOW_OFFSET) / OCOTP_SHADOW_SPACING)
#define OCOTP_WORD_MASK GENMASK( 7, 0)
#define OCOTP_BIT_MASK GENMASK(12, 8)
#define OCOTP_WIDTH_MASK GENMASK(17, 13)
#define OCOTP_WORD(n) FIELD_PREP(OCOTP_WORD_MASK, \
OCOTP_OFFSET_TO_INDEX(n))
#define OCOTP_BIT(n) FIELD_PREP(OCOTP_BIT_MASK, n)
#define OCOTP_WIDTH(n) FIELD_PREP(OCOTP_WIDTH_MASK, (n) - 1)
#define OCOTP_UID_L 0x410
#define OCOTP_UID_H 0x420
int imx_ocotp_read_field(uint32_t field, unsigned *value);
int imx_ocotp_write_field(uint32_t field, unsigned value);
int imx_ocotp_permanent_write(int enable);
bool imx_ocotp_sense_enable(bool enable);
static inline u64 imx_ocotp_read_uid(void __iomem *ocotp)
{
u64 uid;
uid = readl(ocotp + OCOTP_UID_H);
uid <<= 32;
uid |= readl(ocotp + OCOTP_UID_L);
return uid;
}
#endif /* __MACH_IMX_OCOTP_H */
|