xref: /illumos-gate/usr/src/lib/libjedec/common/libjedec_temp.c (revision 9164a50bf932130cbb5097a16f6986873ce0e6e5)
1 /*
2  * This file and its contents are supplied under the terms of the
3  * Common Development and Distribution License ("CDDL"), version 1.0.
4  * You may only use this file in accordance with the terms of version
5  * 1.0 of the CDDL.
6  *
7  * A full copy of the text of the CDDL should have accompanied this
8  * source.  A copy of the CDDL is also available via the Internet at
9  * http://www.illumos.org/license/CDDL.
10  */
11 
12 /*
13  * Copyright 2023 Oxide Computer Company
14  */
15 
16 /*
17  * JESD402-1A Temperature Ranges
18  */
19 
20 #include <libjedec.h>
21 #include <sys/sysmacros.h>
22 
23 typedef struct {
24 	libjedec_temp_range_t	ltm_temp;
25 	int32_t			ltm_min;
26 	int32_t			ltm_max;
27 } libjedec_temp_map_t;
28 
29 static const libjedec_temp_map_t libjedec_temp_map[] = {
30 	{ JEDEC_TEMP_CASE_A1T, -40, 125 },
31 	{ JEDEC_TEMP_CASE_A2T, -40, 105 },
32 	{ JEDEC_TEMP_CASE_A3T, -40, 85 },
33 	{ JEDEC_TEMP_CASE_IT, -40, 95 },
34 	{ JEDEC_TEMP_CASE_ET, -25, 105 },
35 	{ JEDEC_TEMP_CASE_ST, -25, 85 },
36 	{ JEDEC_TEMP_CASE_XT, 0, 95 },
37 	{ JEDEC_TEMP_CASE_NT, 0, 85 },
38 	{ JEDEC_TEMP_CASE_RT, 0, 45 },
39 	{ JEDEC_TEMP_AMB_CT, 0, 70 },
40 	{ JEDEC_TEMP_AMB_IOT, -40, 85 },
41 	{ JEDEC_TEMP_AMB_IPT, -40, 105 },
42 	{ JEDEC_TEMP_AMB_IXT, -40, 125 },
43 	{ JEDEC_TEMP_AMB_AO3T, -40, 85 },
44 	{ JEDEC_TEMP_AMB_AO2T, -40, 105 },
45 	{ JEDEC_TEMP_AMB_AO1T, -40, 125 },
46 	{ JEDEC_TEMP_STOR_2, -55, 125 },
47 	{ JEDEC_TEMP_STOR_1B, -55, 100 },
48 	{ JEDEC_TEMP_STOR_1A, -40, 105 },
49 	{ JEDEC_TEMP_STOR_ST, -40, 85 }
50 };
51 
52 boolean_t
53 libjedec_temp_range(libjedec_temp_range_t temp, int32_t *min, int32_t *max)
54 {
55 	for (size_t i = 0; i < ARRAY_SIZE(libjedec_temp_map); i++) {
56 		if (temp == libjedec_temp_map[i].ltm_temp) {
57 			*min = libjedec_temp_map[i].ltm_min;
58 			*max = libjedec_temp_map[i].ltm_max;
59 			return (B_TRUE);
60 		}
61 	}
62 
63 	return (B_FALSE);
64 }
65