]>
Commit | Line | Data |
---|---|---|
83d290c5 | 1 | // SPDX-License-Identifier: GPL-2.0+ |
6ce8b10b PF |
2 | /* |
3 | * Copyright 2017 NXP | |
4 | * | |
5 | * Peng Fan <[email protected]> | |
6ce8b10b PF |
6 | */ |
7 | ||
6ce8b10b PF |
8 | #include <asm/arch/imx-regs.h> |
9 | #include <asm/io.h> | |
10 | #include <asm/arch/sys_proto.h> | |
11 | #include <errno.h> | |
12 | ||
13 | struct imx_mac_fuse { | |
14 | u32 mac_addr0; | |
15 | u32 rsvd0[3]; | |
16 | u32 mac_addr1; | |
17 | u32 rsvd1[3]; | |
18 | u32 mac_addr2; | |
19 | u32 rsvd2[7]; | |
20 | }; | |
21 | ||
22 | #define MAC_FUSE_MX6_OFFSET 0x620 | |
23 | #define MAC_FUSE_MX7_OFFSET 0x640 | |
24 | ||
25 | void imx_get_mac_from_fuse(int dev_id, unsigned char *mac) | |
26 | { | |
27 | struct imx_mac_fuse *fuse; | |
28 | u32 offset; | |
29 | bool has_second_mac; | |
30 | ||
31 | offset = is_mx6() ? MAC_FUSE_MX6_OFFSET : MAC_FUSE_MX7_OFFSET; | |
32 | fuse = (struct imx_mac_fuse *)(ulong)(OCOTP_BASE_ADDR + offset); | |
6daa6a97 | 33 | has_second_mac = is_mx7() || is_mx6sx() || is_mx6ul() || is_mx6ull() || is_imx8mp(); |
6ce8b10b PF |
34 | |
35 | if (has_second_mac && dev_id == 1) { | |
36 | u32 value = readl(&fuse->mac_addr2); | |
37 | ||
38 | mac[0] = value >> 24; | |
39 | mac[1] = value >> 16; | |
40 | mac[2] = value >> 8; | |
41 | mac[3] = value; | |
42 | ||
43 | value = readl(&fuse->mac_addr1); | |
44 | mac[4] = value >> 24; | |
45 | mac[5] = value >> 16; | |
46 | ||
47 | } else { | |
48 | u32 value = readl(&fuse->mac_addr1); | |
49 | ||
50 | mac[0] = value >> 8; | |
51 | mac[1] = value; | |
52 | ||
53 | value = readl(&fuse->mac_addr0); | |
54 | mac[2] = value >> 24; | |
55 | mac[3] = value >> 16; | |
56 | mac[4] = value >> 8; | |
57 | mac[5] = value; | |
58 | } | |
59 | } |