1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * Copyright (c) 2016-2020 Toradex
4  */
5 
6 #ifndef _TDX_CFG_BLOCK_H
7 #define _TDX_CFG_BLOCK_H
8 
9 #include "tdx-common.h"
10 
11 struct toradex_hw {
12 	u16 ver_major;
13 	u16 ver_minor;
14 	u16 ver_assembly;
15 	u16 prodid;
16 };
17 
18 struct toradex_eth_addr {
19 	u32 oui:24;
20 	u32 nic:24;
21 } __attribute__((__packed__));
22 
23 struct toradex_som {
24 	const char *name;
25 	int is_enabled;
26 };
27 
28 enum {
29 	COLIBRI_PXA270_V1_312MHZ = 1,
30 	COLIBRI_PXA270_V1_520MHZ,
31 	COLIBRI_PXA320,
32 	COLIBRI_PXA300,
33 	COLIBRI_PXA310, /* 5 */
34 	COLIBRI_PXA320_IT,
35 	COLIBRI_PXA300_XT,
36 	COLIBRI_PXA270_312MHZ,
37 	COLIBRI_PXA270_520MHZ,
38 	COLIBRI_VF50, /* 10 */
39 	COLIBRI_VF61,
40 	COLIBRI_VF61_IT,
41 	COLIBRI_VF50_IT,
42 	COLIBRI_IMX6S,
43 	COLIBRI_IMX6DL, /* 15 */
44 	COLIBRI_IMX6S_IT,
45 	COLIBRI_IMX6DL_IT,
46 	/* 18 */
47 	/* 19 */
48 	COLIBRI_T20_256MB = 20,
49 	COLIBRI_T20_512MB,
50 	COLIBRI_T20_512MB_IT,
51 	COLIBRI_T30,
52 	COLIBRI_T20_256MB_IT,
53 	APALIS_T30_2GB, /* 25 */
54 	APALIS_T30_1GB,
55 	APALIS_IMX6Q,
56 	APALIS_IMX6Q_IT,
57 	APALIS_IMX6D,
58 	COLIBRI_T30_IT, /* 30 */
59 	APALIS_T30_IT,
60 	COLIBRI_IMX7S,
61 	COLIBRI_IMX7D,
62 	APALIS_TK1_2GB,
63 	APALIS_IMX6D_IT, /* 35 */
64 	COLIBRI_IMX6ULL,
65 	APALIS_IMX8QM_WIFI_BT_IT,
66 	COLIBRI_IMX8QXP_WIFI_BT_IT,
67 	COLIBRI_IMX7D_EMMC,
68 	COLIBRI_IMX6ULL_WIFI_BT_IT, /* 40 */
69 	COLIBRI_IMX7D_EPDC,
70 	APALIS_TK1_4GB,
71 	COLIBRI_T20_512MB_IT_SETEK,
72 	COLIBRI_IMX6ULL_IT,
73 	COLIBRI_IMX6ULL_WIFI_BT, /* 45 */
74 	APALIS_IMX8QXP_WIFI_BT_IT,
75 	APALIS_IMX8QM_IT,
76 	APALIS_IMX8QP_WIFI_BT,
77 	APALIS_IMX8QP,
78 	COLIBRI_IMX8QXP_IT, /* 50 */
79 	COLIBRI_IMX8DX_WIFI_BT,
80 	COLIBRI_IMX8DX,
81 	APALIS_IMX8QXP,
82 	APALIS_IMX8DXP,
83 	VERDIN_IMX8MMQ_WIFI_BT_IT, /* 55 */
84 	VERDIN_IMX8MNQ_WIFI_BT,
85 	VERDIN_IMX8MMDL,
86 	VERDIN_IMX8MPQ_WIFI_BT_IT,
87 	VERDIN_IMX8MMQ_IT,
88 	VERDIN_IMX8MMDL_WIFI_BT_IT, /* 60 */
89 	VERDIN_IMX8MPQ,
90 	COLIBRI_IMX6ULL_IT_EMMC,
91 	VERDIN_IMX8MPQ_IT,
92 	VERDIN_IMX8MPQ_2GB_WIFI_BT_IT,
93 	VERDIN_IMX8MPQL_IT, /* 65 */
94 	VERDIN_IMX8MPQ_8GB_WIFI_BT,
95 	APALIS_IMX8QM_8GB_WIFI_BT_IT,
96 	VERDIN_IMX8MMQ_WIFI_BT_IT_NO_CAN,
97 };
98 
99 enum {
100 	DAHLIA = 155,
101 	VERDIN_DEVELOPMENT_BOARD = 156,
102 };
103 
104 enum {
105 	VERDIN_DSI_TO_HDMI_ADAPTER = 157,
106 	VERDIN_DSI_TO_LVDS_ADAPTER = 159,
107 };
108 
109 extern const struct toradex_som toradex_modules[];
110 extern const char * const toradex_carrier_boards[];
111 extern bool valid_cfgblock;
112 extern struct toradex_hw tdx_hw_tag;
113 extern struct toradex_hw tdx_car_hw_tag;
114 extern struct toradex_eth_addr tdx_eth_addr;
115 extern u32 tdx_serial;
116 extern u32 tdx_car_serial;
117 
118 int read_tdx_cfg_block(void);
119 int read_tdx_cfg_block_carrier(void);
120 
121 int try_migrate_tdx_cfg_block_carrier(void);
122 
123 void get_mac_from_serial(u32 tdx_serial, struct toradex_eth_addr *eth_addr);
124 
125 #endif /* _TDX_CFG_BLOCK_H */
126