blob: 59f6b722cf12033a27530f8201ae089748eea179 [file] [log] [blame]
Siva Durga Prasad Paladuguf1b97b52019-04-10 12:38:10 +05301/* SPDX-License-Identifier: GPL-2.0+ */
2/*
3 * (C) Copyright 2019 Xilinx, Inc.
4 * Siva Durga Prasad Paladugu <siva.durga.paladugu@xilinx.com>
5 */
6
7#ifndef __FRU_H
8#define __FRU_H
Ashok Reddy Soma7a036b62022-02-23 15:00:59 +01009#include <net.h>
Siva Durga Prasad Paladuguf1b97b52019-04-10 12:38:10 +053010
11struct fru_common_hdr {
12 u8 version;
13 u8 off_internal;
14 u8 off_chassis;
15 u8 off_board;
16 u8 off_product;
17 u8 off_multirec;
18 u8 pad;
19 u8 crc;
20};
21
22#define FRU_BOARD_MAX_LEN 32
Ashok Reddy Soma7a036b62022-02-23 15:00:59 +010023#define FRU_MAX_NO_OF_MAC_ADDR 4
Siva Durga Prasad Paladuguf1b97b52019-04-10 12:38:10 +053024
Michal Simek4489e0a2019-04-15 13:54:09 +020025struct __packed fru_board_info_header {
26 u8 ver;
27 u8 len;
28 u8 lang_code;
29 u8 time[3];
30};
31
32struct __packed fru_board_info_member {
33 u8 type_len;
34 u8 *name;
35};
36
Siva Durga Prasad Paladuguf1b97b52019-04-10 12:38:10 +053037struct fru_board_data {
38 u8 ver;
39 u8 len;
40 u8 lang_code;
41 u8 time[3];
42 u8 manufacturer_type_len;
43 u8 manufacturer_name[FRU_BOARD_MAX_LEN];
44 u8 product_name_type_len;
45 u8 product_name[FRU_BOARD_MAX_LEN];
46 u8 serial_number_type_len;
47 u8 serial_number[FRU_BOARD_MAX_LEN];
48 u8 part_number_type_len;
49 u8 part_number[FRU_BOARD_MAX_LEN];
50 u8 file_id_type_len;
51 u8 file_id[FRU_BOARD_MAX_LEN];
Michal Simek4489e0a2019-04-15 13:54:09 +020052 /* Xilinx custom fields */
53 u8 rev_type_len;
54 u8 rev[FRU_BOARD_MAX_LEN];
Michal Simekcd40b822020-11-06 13:58:01 +010055 u8 pcie_type_len;
56 u8 pcie[FRU_BOARD_MAX_LEN];
57 u8 uuid_type_len;
58 u8 uuid[FRU_BOARD_MAX_LEN];
Siva Durga Prasad Paladuguf1b97b52019-04-10 12:38:10 +053059};
60
Ashok Reddy Soma7a036b62022-02-23 15:00:59 +010061struct fru_multirec_hdr {
62 u8 rec_type;
63 u8 type;
64 u8 len;
65 u8 csum;
66 u8 hdr_csum;
67};
68
69struct fru_multirec_mac {
70 u8 xlnx_iana_id[3];
71 u8 ver;
72 u8 macid[FRU_MAX_NO_OF_MAC_ADDR][ETH_ALEN];
73};
74
Siva Durga Prasad Paladuguf1b97b52019-04-10 12:38:10 +053075struct fru_table {
Siva Durga Prasad Paladuguf1b97b52019-04-10 12:38:10 +053076 struct fru_common_hdr hdr;
77 struct fru_board_data brd;
Ashok Reddy Soma7a036b62022-02-23 15:00:59 +010078 struct fru_multirec_mac mac;
Michal Simek5fb093f2020-11-06 13:53:01 +010079 bool captured;
Siva Durga Prasad Paladuguf1b97b52019-04-10 12:38:10 +053080};
81
82#define FRU_TYPELEN_CODE_MASK 0xC0
83#define FRU_TYPELEN_LEN_MASK 0x3F
84#define FRU_COMMON_HDR_VER_MASK 0xF
85#define FRU_COMMON_HDR_LEN_MULTIPLIER 8
86#define FRU_LANG_CODE_ENGLISH 0
87#define FRU_LANG_CODE_ENGLISH_1 25
88#define FRU_TYPELEN_EOF 0xC1
Ashok Reddy Soma7a036b62022-02-23 15:00:59 +010089#define FRU_MULTIREC_TYPE_OEM 0xD2
90#define FRU_MULTIREC_MAC_OFFSET 4
91#define FRU_LAST_REC BIT(7)
92#define FRU_DUT_MACID 0x31
Siva Durga Prasad Paladuguf1b97b52019-04-10 12:38:10 +053093
94/* This should be minimum of fields */
95#define FRU_BOARD_AREA_TOTAL_FIELDS 5
96#define FRU_TYPELEN_TYPE_SHIFT 6
97#define FRU_TYPELEN_TYPE_BINARY 0
98#define FRU_TYPELEN_TYPE_ASCII8 3
99
100int fru_display(int verbose);
101int fru_capture(unsigned long addr);
Michal Simek4489e0a2019-04-15 13:54:09 +0200102int fru_generate(unsigned long addr, char *manufacturer, char *board_name,
103 char *serial_no, char *part_no, char *revision);
Siva Durga Prasad Paladuguf1b97b52019-04-10 12:38:10 +0530104u8 fru_checksum(u8 *addr, u8 len);
105
106extern struct fru_table fru_data;
107
108#endif /* FRU_H */