xref: /linux/drivers/hwmon/peci/dimmtemp.c (revision f16d85cd3de9d0c761b74155b4cbe2f20d3dcf80)
1 // SPDX-License-Identifier: GPL-2.0-only
2 // Copyright (c) 2018-2021 Intel Corporation
3 
4 #include <linux/auxiliary_bus.h>
5 #include <linux/bitfield.h>
6 #include <linux/bitops.h>
7 #include <linux/hwmon.h>
8 #include <linux/jiffies.h>
9 #include <linux/module.h>
10 #include <linux/peci.h>
11 #include <linux/peci-cpu.h>
12 #include <linux/units.h>
13 #include <linux/workqueue.h>
14 
15 #include "common.h"
16 
17 #define DIMM_MASK_CHECK_DELAY_JIFFIES	msecs_to_jiffies(5000)
18 
19 /* Max number of channel ranks and DIMM index per channel */
20 #define CHAN_RANK_MAX_ON_HSX	8
21 #define DIMM_IDX_MAX_ON_HSX	3
22 #define CHAN_RANK_MAX_ON_BDX	4
23 #define DIMM_IDX_MAX_ON_BDX	3
24 #define CHAN_RANK_MAX_ON_BDXD	2
25 #define DIMM_IDX_MAX_ON_BDXD	2
26 #define CHAN_RANK_MAX_ON_SKX	6
27 #define DIMM_IDX_MAX_ON_SKX	2
28 #define CHAN_RANK_MAX_ON_ICX	8
29 #define DIMM_IDX_MAX_ON_ICX	2
30 #define CHAN_RANK_MAX_ON_ICXD	4
31 #define DIMM_IDX_MAX_ON_ICXD	2
32 #define CHAN_RANK_MAX_ON_SPR	8
33 #define DIMM_IDX_MAX_ON_SPR	2
34 #define CHAN_RANK_MAX_ON_EMR	8
35 #define DIMM_IDX_MAX_ON_EMR	2
36 
37 #define CHAN_RANK_MAX		CHAN_RANK_MAX_ON_HSX
38 #define DIMM_IDX_MAX		DIMM_IDX_MAX_ON_HSX
39 #define DIMM_NUMS_MAX		(CHAN_RANK_MAX * DIMM_IDX_MAX)
40 
41 #define CPU_SEG_MASK		GENMASK(23, 16)
42 #define GET_CPU_SEG(x)		(((x) & CPU_SEG_MASK) >> 16)
43 #define CPU_BUS_MASK		GENMASK(7, 0)
44 #define GET_CPU_BUS(x)		((x) & CPU_BUS_MASK)
45 
46 #define DIMM_TEMP_MAX		GENMASK(15, 8)
47 #define DIMM_TEMP_CRIT		GENMASK(23, 16)
48 #define GET_TEMP_MAX(x)		(((x) & DIMM_TEMP_MAX) >> 8)
49 #define GET_TEMP_CRIT(x)	(((x) & DIMM_TEMP_CRIT) >> 16)
50 
51 #define NO_DIMM_RETRY_COUNT_MAX	120
52 
53 struct peci_dimmtemp;
54 
55 struct dimm_info {
56 	int chan_rank_max;
57 	int dimm_idx_max;
58 	u8 min_peci_revision;
59 	int (*read_thresholds)(struct peci_dimmtemp *priv, int dimm_order,
60 			       int chan_rank, u32 *data);
61 };
62 
63 struct peci_dimm_thresholds {
64 	long temp_max;
65 	long temp_crit;
66 	struct peci_sensor_state state;
67 };
68 
69 enum peci_dimm_threshold_type {
70 	temp_max_type,
71 	temp_crit_type,
72 };
73 
74 struct peci_dimmtemp {
75 	struct peci_device *peci_dev;
76 	struct device *dev;
77 	const char *name;
78 	const struct dimm_info *gen_info;
79 	struct delayed_work detect_work;
80 	struct {
81 		struct peci_sensor_data temp;
82 		struct peci_dimm_thresholds thresholds;
83 	} dimm[DIMM_NUMS_MAX];
84 	char **dimmtemp_label;
85 	DECLARE_BITMAP(dimm_mask, DIMM_NUMS_MAX);
86 	u8 no_dimm_retry_count;
87 };
88 
89 static u8 __dimm_temp(u32 reg, int dimm_order)
90 {
91 	return (reg >> (dimm_order * 8)) & 0xff;
92 }
93 
94 static int get_dimm_temp(struct peci_dimmtemp *priv, int dimm_no, long *val)
95 {
96 	int dimm_order = dimm_no % priv->gen_info->dimm_idx_max;
97 	int chan_rank = dimm_no / priv->gen_info->dimm_idx_max;
98 	u32 data;
99 	int ret;
100 
101 	if (!peci_sensor_need_update(&priv->dimm[dimm_no].temp.state))
102 		goto skip_update;
103 
104 	ret = peci_pcs_read(priv->peci_dev, PECI_PCS_DDR_DIMM_TEMP, chan_rank, &data);
105 	if (ret)
106 		return ret;
107 
108 	priv->dimm[dimm_no].temp.value = __dimm_temp(data, dimm_order) * MILLIDEGREE_PER_DEGREE;
109 
110 	peci_sensor_mark_updated(&priv->dimm[dimm_no].temp.state);
111 
112 skip_update:
113 	*val = priv->dimm[dimm_no].temp.value;
114 	return 0;
115 }
116 
117 static int update_thresholds(struct peci_dimmtemp *priv, int dimm_no)
118 {
119 	int dimm_order = dimm_no % priv->gen_info->dimm_idx_max;
120 	int chan_rank = dimm_no / priv->gen_info->dimm_idx_max;
121 	u32 data;
122 	int ret;
123 
124 	if (!peci_sensor_need_update(&priv->dimm[dimm_no].thresholds.state))
125 		return 0;
126 
127 	ret = priv->gen_info->read_thresholds(priv, dimm_order, chan_rank, &data);
128 	if (ret)
129 		return ret;
130 
131 	priv->dimm[dimm_no].thresholds.temp_max = GET_TEMP_MAX(data) * MILLIDEGREE_PER_DEGREE;
132 	priv->dimm[dimm_no].thresholds.temp_crit = GET_TEMP_CRIT(data) * MILLIDEGREE_PER_DEGREE;
133 
134 	peci_sensor_mark_updated(&priv->dimm[dimm_no].thresholds.state);
135 
136 	return 0;
137 }
138 
139 static int get_dimm_thresholds(struct peci_dimmtemp *priv, enum peci_dimm_threshold_type type,
140 			       int dimm_no, long *val)
141 {
142 	int ret;
143 
144 	ret = update_thresholds(priv, dimm_no);
145 	if (ret)
146 		return ret;
147 
148 	switch (type) {
149 	case temp_max_type:
150 		*val = priv->dimm[dimm_no].thresholds.temp_max;
151 		break;
152 	case temp_crit_type:
153 		*val = priv->dimm[dimm_no].thresholds.temp_crit;
154 		break;
155 	default:
156 		ret = -EOPNOTSUPP;
157 		break;
158 	}
159 	return ret;
160 }
161 
162 static int dimmtemp_read_string(struct device *dev,
163 				enum hwmon_sensor_types type,
164 				u32 attr, int channel, const char **str)
165 {
166 	struct peci_dimmtemp *priv = dev_get_drvdata(dev);
167 
168 	if (attr != hwmon_temp_label)
169 		return -EOPNOTSUPP;
170 
171 	*str = (const char *)priv->dimmtemp_label[channel];
172 
173 	return 0;
174 }
175 
176 static int dimmtemp_read(struct device *dev, enum hwmon_sensor_types type,
177 			 u32 attr, int channel, long *val)
178 {
179 	struct peci_dimmtemp *priv = dev_get_drvdata(dev);
180 
181 	switch (attr) {
182 	case hwmon_temp_input:
183 		return get_dimm_temp(priv, channel, val);
184 	case hwmon_temp_max:
185 		return get_dimm_thresholds(priv, temp_max_type, channel, val);
186 	case hwmon_temp_crit:
187 		return get_dimm_thresholds(priv, temp_crit_type, channel, val);
188 	default:
189 		break;
190 	}
191 
192 	return -EOPNOTSUPP;
193 }
194 
195 static umode_t dimmtemp_is_visible(const void *data, enum hwmon_sensor_types type,
196 				   u32 attr, int channel)
197 {
198 	const struct peci_dimmtemp *priv = data;
199 
200 	if (test_bit(channel, priv->dimm_mask))
201 		return 0444;
202 
203 	return 0;
204 }
205 
206 static const struct hwmon_ops peci_dimmtemp_ops = {
207 	.is_visible = dimmtemp_is_visible,
208 	.read_string = dimmtemp_read_string,
209 	.read = dimmtemp_read,
210 };
211 
212 static int check_populated_dimms(struct peci_dimmtemp *priv)
213 {
214 	int chan_rank_max = priv->gen_info->chan_rank_max;
215 	int dimm_idx_max = priv->gen_info->dimm_idx_max;
216 	DECLARE_BITMAP(dimm_mask, DIMM_NUMS_MAX);
217 	DECLARE_BITMAP(chan_rank_empty, CHAN_RANK_MAX);
218 
219 	int chan_rank, dimm_idx, ret, i;
220 	u32 pcs;
221 
222 	if (chan_rank_max * dimm_idx_max > DIMM_NUMS_MAX) {
223 		WARN_ONCE(1, "Unsupported number of DIMMs - chan_rank_max: %d, dimm_idx_max: %d",
224 			  chan_rank_max, dimm_idx_max);
225 		return -EINVAL;
226 	}
227 
228 	bitmap_zero(dimm_mask, DIMM_NUMS_MAX);
229 	bitmap_zero(chan_rank_empty, CHAN_RANK_MAX);
230 
231 	for (chan_rank = 0; chan_rank < chan_rank_max; chan_rank++) {
232 		ret = peci_pcs_read(priv->peci_dev, PECI_PCS_DDR_DIMM_TEMP, chan_rank, &pcs);
233 		if (ret) {
234 			/*
235 			 * Overall, we expect either success or -EINVAL in
236 			 * order to determine whether DIMM is populated or not.
237 			 * For anything else we fall back to deferring the
238 			 * detection to be performed at a later point in time.
239 			 */
240 			if (ret == -EINVAL) {
241 				bitmap_set(chan_rank_empty, chan_rank, 1);
242 				continue;
243 			}
244 
245 			return -EAGAIN;
246 		}
247 
248 		for (dimm_idx = 0; dimm_idx < dimm_idx_max; dimm_idx++)
249 			if (__dimm_temp(pcs, dimm_idx))
250 				bitmap_set(dimm_mask, chan_rank * dimm_idx_max + dimm_idx, 1);
251 	}
252 
253 	/*
254 	 * If we got all -EINVALs, it means that the CPU doesn't have any
255 	 * DIMMs. Unfortunately, it may also happen at the very start of
256 	 * host platform boot. Retrying a couple of times lets us make sure
257 	 * that the state is persistent.
258 	 */
259 	if (bitmap_full(chan_rank_empty, chan_rank_max)) {
260 		if (priv->no_dimm_retry_count < NO_DIMM_RETRY_COUNT_MAX) {
261 			priv->no_dimm_retry_count++;
262 
263 			return -EAGAIN;
264 		}
265 
266 		return -ENODEV;
267 	}
268 
269 	/*
270 	 * It's possible that memory training is not done yet. In this case we
271 	 * defer the detection to be performed at a later point in time.
272 	 */
273 	if (bitmap_empty(dimm_mask, DIMM_NUMS_MAX)) {
274 		priv->no_dimm_retry_count = 0;
275 		return -EAGAIN;
276 	}
277 
278 	for_each_set_bit(i, dimm_mask, DIMM_NUMS_MAX) {
279 		dev_dbg(priv->dev, "Found DIMM%#x\n", i);
280 	}
281 
282 	bitmap_copy(priv->dimm_mask, dimm_mask, DIMM_NUMS_MAX);
283 
284 	return 0;
285 }
286 
287 static int create_dimm_temp_label(struct peci_dimmtemp *priv, int chan)
288 {
289 	int rank = chan / priv->gen_info->dimm_idx_max;
290 	int idx = chan % priv->gen_info->dimm_idx_max;
291 
292 	priv->dimmtemp_label[chan] = devm_kasprintf(priv->dev, GFP_KERNEL,
293 						    "DIMM %c%d", 'A' + rank,
294 						    idx + 1);
295 	if (!priv->dimmtemp_label[chan])
296 		return -ENOMEM;
297 
298 	return 0;
299 }
300 
301 static const struct hwmon_channel_info * const peci_dimmtemp_temp_info[] = {
302 	HWMON_CHANNEL_INFO(temp,
303 			   [0 ... DIMM_NUMS_MAX - 1] = HWMON_T_LABEL |
304 				HWMON_T_INPUT | HWMON_T_MAX | HWMON_T_CRIT),
305 	NULL
306 };
307 
308 static const struct hwmon_chip_info peci_dimmtemp_chip_info = {
309 	.ops = &peci_dimmtemp_ops,
310 	.info = peci_dimmtemp_temp_info,
311 };
312 
313 static int create_dimm_temp_info(struct peci_dimmtemp *priv)
314 {
315 	int ret, i, channels;
316 	struct device *dev;
317 
318 	/*
319 	 * We expect to either find populated DIMMs and carry on with creating
320 	 * sensors, or find out that there are no DIMMs populated.
321 	 * All other states mean that the platform never reached the state that
322 	 * allows to check DIMM state - causing us to retry later on.
323 	 */
324 	ret = check_populated_dimms(priv);
325 	if (ret == -ENODEV) {
326 		dev_dbg(priv->dev, "No DIMMs found\n");
327 		return 0;
328 	}
329 	if (ret == -EAGAIN) {
330 		schedule_delayed_work(&priv->detect_work, DIMM_MASK_CHECK_DELAY_JIFFIES);
331 		dev_dbg(priv->dev, "Deferred populating DIMM temp info\n");
332 	}
333 	if (ret)
334 		return ret;
335 
336 	channels = priv->gen_info->chan_rank_max * priv->gen_info->dimm_idx_max;
337 
338 	priv->dimmtemp_label = devm_kzalloc(priv->dev, channels * sizeof(char *), GFP_KERNEL);
339 	if (!priv->dimmtemp_label)
340 		return -ENOMEM;
341 
342 	for_each_set_bit(i, priv->dimm_mask, DIMM_NUMS_MAX) {
343 		ret = create_dimm_temp_label(priv, i);
344 		if (ret)
345 			return ret;
346 	}
347 
348 	dev = devm_hwmon_device_register_with_info(priv->dev, priv->name, priv,
349 						   &peci_dimmtemp_chip_info, NULL);
350 	if (IS_ERR(dev)) {
351 		dev_err(priv->dev, "Failed to register hwmon device\n");
352 		return PTR_ERR(dev);
353 	}
354 
355 	dev_dbg(priv->dev, "%s: sensor '%s'\n", dev_name(dev), priv->name);
356 
357 	return 0;
358 }
359 
360 static void create_dimm_temp_info_delayed(struct work_struct *work)
361 {
362 	struct peci_dimmtemp *priv = container_of(to_delayed_work(work),
363 						  struct peci_dimmtemp,
364 						  detect_work);
365 	int ret;
366 
367 	ret = create_dimm_temp_info(priv);
368 	if (ret && ret != -EAGAIN)
369 		dev_err(priv->dev, "Failed to populate DIMM temp info\n");
370 }
371 
372 static int peci_dimmtemp_probe(struct auxiliary_device *adev, const struct auxiliary_device_id *id)
373 {
374 	struct device *dev = &adev->dev;
375 	struct peci_device *peci_dev = to_peci_device(dev->parent);
376 	struct peci_dimmtemp *priv;
377 	int ret;
378 
379 	priv = devm_kzalloc_obj(dev, *priv);
380 	if (!priv)
381 		return -ENOMEM;
382 
383 	priv->name = devm_kasprintf(dev, GFP_KERNEL, "peci_dimmtemp.cpu%d",
384 				    peci_dev->info.socket_id);
385 	if (!priv->name)
386 		return -ENOMEM;
387 
388 	priv->dev = dev;
389 	priv->peci_dev = peci_dev;
390 	priv->gen_info = (const struct dimm_info *)id->driver_data;
391 
392 	/*
393 	 * This is just a sanity check. Since we're using commands that are
394 	 * guaranteed to be supported on a given platform, we should never see
395 	 * revision lower than expected.
396 	 */
397 	if (peci_dev->info.peci_revision < priv->gen_info->min_peci_revision)
398 		dev_warn(priv->dev,
399 			 "Unexpected PECI revision %#x, some features may be unavailable\n",
400 			 peci_dev->info.peci_revision);
401 
402 	auxiliary_set_drvdata(adev, priv);
403 	INIT_DELAYED_WORK(&priv->detect_work, create_dimm_temp_info_delayed);
404 
405 	ret = create_dimm_temp_info(priv);
406 	if (ret && ret != -EAGAIN) {
407 		dev_err(dev, "Failed to populate DIMM temp info\n");
408 		return ret;
409 	}
410 
411 	return 0;
412 }
413 
414 static void peci_dimmtemp_remove(struct auxiliary_device *adev)
415 {
416 	struct peci_dimmtemp *priv = auxiliary_get_drvdata(adev);
417 
418 	cancel_delayed_work_sync(&priv->detect_work);
419 }
420 
421 static int
422 read_thresholds_hsx(struct peci_dimmtemp *priv, int dimm_order, int chan_rank, u32 *data)
423 {
424 	u8 dev, func;
425 	u16 reg;
426 	int ret;
427 
428 	/*
429 	 * Device 20, Function 0: IMC 0 channel 0 -> rank 0
430 	 * Device 20, Function 1: IMC 0 channel 1 -> rank 1
431 	 * Device 21, Function 0: IMC 0 channel 2 -> rank 2
432 	 * Device 21, Function 1: IMC 0 channel 3 -> rank 3
433 	 * Device 23, Function 0: IMC 1 channel 0 -> rank 4
434 	 * Device 23, Function 1: IMC 1 channel 1 -> rank 5
435 	 * Device 24, Function 0: IMC 1 channel 2 -> rank 6
436 	 * Device 24, Function 1: IMC 1 channel 3 -> rank 7
437 	 */
438 	dev = 20 + chan_rank / 2 + chan_rank / 4;
439 	func = chan_rank % 2;
440 	reg = 0x120 + dimm_order * 4;
441 
442 	ret = peci_pci_local_read(priv->peci_dev, 1, dev, func, reg, data);
443 	if (ret)
444 		return ret;
445 
446 	return 0;
447 }
448 
449 static int
450 read_thresholds_bdxd(struct peci_dimmtemp *priv, int dimm_order, int chan_rank, u32 *data)
451 {
452 	u8 dev, func;
453 	u16 reg;
454 	int ret;
455 
456 	/*
457 	 * Device 10, Function 2: IMC 0 channel 0 -> rank 0
458 	 * Device 10, Function 6: IMC 0 channel 1 -> rank 1
459 	 * Device 12, Function 2: IMC 1 channel 0 -> rank 2
460 	 * Device 12, Function 6: IMC 1 channel 1 -> rank 3
461 	 */
462 	dev = 10 + chan_rank / 2 * 2;
463 	func = (chan_rank % 2) ? 6 : 2;
464 	reg = 0x120 + dimm_order * 4;
465 
466 	ret = peci_pci_local_read(priv->peci_dev, 2, dev, func, reg, data);
467 	if (ret)
468 		return ret;
469 
470 	return 0;
471 }
472 
473 static int
474 read_thresholds_skx(struct peci_dimmtemp *priv, int dimm_order, int chan_rank, u32 *data)
475 {
476 	u8 dev, func;
477 	u16 reg;
478 	int ret;
479 
480 	/*
481 	 * Device 10, Function 2: IMC 0 channel 0 -> rank 0
482 	 * Device 10, Function 6: IMC 0 channel 1 -> rank 1
483 	 * Device 11, Function 2: IMC 0 channel 2 -> rank 2
484 	 * Device 12, Function 2: IMC 1 channel 0 -> rank 3
485 	 * Device 12, Function 6: IMC 1 channel 1 -> rank 4
486 	 * Device 13, Function 2: IMC 1 channel 2 -> rank 5
487 	 */
488 	dev = 10 + chan_rank / 3 * 2 + (chan_rank % 3 == 2 ? 1 : 0);
489 	func = chan_rank % 3 == 1 ? 6 : 2;
490 	reg = 0x120 + dimm_order * 4;
491 
492 	ret = peci_pci_local_read(priv->peci_dev, 2, dev, func, reg, data);
493 	if (ret)
494 		return ret;
495 
496 	return 0;
497 }
498 
499 static int
500 read_thresholds_icx(struct peci_dimmtemp *priv, int dimm_order, int chan_rank, u32 *data)
501 {
502 	u32 reg_val;
503 	u64 offset;
504 	int ret;
505 	u8 dev;
506 
507 	ret = peci_ep_pci_local_read(priv->peci_dev, 0, 13, 0, 2, 0xd4, &reg_val);
508 	if (ret || !(reg_val & BIT(31)))
509 		return -ENODATA;
510 
511 	ret = peci_ep_pci_local_read(priv->peci_dev, 0, 13, 0, 2, 0xd0, &reg_val);
512 	if (ret)
513 		return -ENODATA;
514 
515 	/*
516 	 * Device 26, Offset 224e0: IMC 0 channel 0 -> rank 0
517 	 * Device 26, Offset 264e0: IMC 0 channel 1 -> rank 1
518 	 * Device 27, Offset 224e0: IMC 1 channel 0 -> rank 2
519 	 * Device 27, Offset 264e0: IMC 1 channel 1 -> rank 3
520 	 * Device 28, Offset 224e0: IMC 2 channel 0 -> rank 4
521 	 * Device 28, Offset 264e0: IMC 2 channel 1 -> rank 5
522 	 * Device 29, Offset 224e0: IMC 3 channel 0 -> rank 6
523 	 * Device 29, Offset 264e0: IMC 3 channel 1 -> rank 7
524 	 */
525 	dev = 26 + chan_rank / 2;
526 	offset = 0x224e0 + dimm_order * 4 + (chan_rank % 2) * 0x4000;
527 
528 	ret = peci_mmio_read(priv->peci_dev, 0, GET_CPU_SEG(reg_val), GET_CPU_BUS(reg_val),
529 			     dev, 0, offset, data);
530 	if (ret)
531 		return ret;
532 
533 	return 0;
534 }
535 
536 static int
537 read_thresholds_spr(struct peci_dimmtemp *priv, int dimm_order, int chan_rank, u32 *data)
538 {
539 	u32 reg_val;
540 	u64 offset;
541 	int ret;
542 	u8 dev;
543 
544 	ret = peci_ep_pci_local_read(priv->peci_dev, 0, 30, 0, 2, 0xd4, &reg_val);
545 	if (ret || !(reg_val & BIT(31)))
546 		return -ENODATA;
547 
548 	ret = peci_ep_pci_local_read(priv->peci_dev, 0, 30, 0, 2, 0xd0, &reg_val);
549 	if (ret)
550 		return -ENODATA;
551 
552 	/*
553 	 * Device 26, Offset 219a8: IMC 0 channel 0 -> rank 0
554 	 * Device 26, Offset 299a8: IMC 0 channel 1 -> rank 1
555 	 * Device 27, Offset 219a8: IMC 1 channel 0 -> rank 2
556 	 * Device 27, Offset 299a8: IMC 1 channel 1 -> rank 3
557 	 * Device 28, Offset 219a8: IMC 2 channel 0 -> rank 4
558 	 * Device 28, Offset 299a8: IMC 2 channel 1 -> rank 5
559 	 * Device 29, Offset 219a8: IMC 3 channel 0 -> rank 6
560 	 * Device 29, Offset 299a8: IMC 3 channel 1 -> rank 7
561 	 */
562 	dev = 26 + chan_rank / 2;
563 	offset = 0x219a8 + dimm_order * 4 + (chan_rank % 2) * 0x8000;
564 
565 	ret = peci_mmio_read(priv->peci_dev, 0, GET_CPU_SEG(reg_val), GET_CPU_BUS(reg_val),
566 			     dev, 0, offset, data);
567 	if (ret)
568 		return ret;
569 
570 	return 0;
571 }
572 
573 static int read_thresholds_emr(struct peci_dimmtemp *priv, int dimm_order,
574 			       int chan_rank, u32 *data)
575 {
576 	return read_thresholds_spr(priv, dimm_order, chan_rank, data);
577 }
578 
579 static const struct dimm_info dimm_hsx = {
580 	.chan_rank_max	= CHAN_RANK_MAX_ON_HSX,
581 	.dimm_idx_max	= DIMM_IDX_MAX_ON_HSX,
582 	.min_peci_revision = 0x33,
583 	.read_thresholds = &read_thresholds_hsx,
584 };
585 
586 static const struct dimm_info dimm_bdx = {
587 	.chan_rank_max	= CHAN_RANK_MAX_ON_BDX,
588 	.dimm_idx_max	= DIMM_IDX_MAX_ON_BDX,
589 	.min_peci_revision = 0x33,
590 	.read_thresholds = &read_thresholds_hsx,
591 };
592 
593 static const struct dimm_info dimm_bdxd = {
594 	.chan_rank_max	= CHAN_RANK_MAX_ON_BDXD,
595 	.dimm_idx_max	= DIMM_IDX_MAX_ON_BDXD,
596 	.min_peci_revision = 0x33,
597 	.read_thresholds = &read_thresholds_bdxd,
598 };
599 
600 static const struct dimm_info dimm_skx = {
601 	.chan_rank_max	= CHAN_RANK_MAX_ON_SKX,
602 	.dimm_idx_max	= DIMM_IDX_MAX_ON_SKX,
603 	.min_peci_revision = 0x33,
604 	.read_thresholds = &read_thresholds_skx,
605 };
606 
607 static const struct dimm_info dimm_icx = {
608 	.chan_rank_max	= CHAN_RANK_MAX_ON_ICX,
609 	.dimm_idx_max	= DIMM_IDX_MAX_ON_ICX,
610 	.min_peci_revision = 0x40,
611 	.read_thresholds = &read_thresholds_icx,
612 };
613 
614 static const struct dimm_info dimm_icxd = {
615 	.chan_rank_max	= CHAN_RANK_MAX_ON_ICXD,
616 	.dimm_idx_max	= DIMM_IDX_MAX_ON_ICXD,
617 	.min_peci_revision = 0x40,
618 	.read_thresholds = &read_thresholds_icx,
619 };
620 
621 static const struct dimm_info dimm_spr = {
622 	.chan_rank_max	= CHAN_RANK_MAX_ON_SPR,
623 	.dimm_idx_max	= DIMM_IDX_MAX_ON_SPR,
624 	.min_peci_revision = 0x40,
625 	.read_thresholds = &read_thresholds_spr,
626 };
627 
628 static const struct dimm_info dimm_emr = {
629 	.chan_rank_max  = CHAN_RANK_MAX_ON_EMR,
630 	.dimm_idx_max  = DIMM_IDX_MAX_ON_EMR,
631 	.min_peci_revision = 0x40,
632 	.read_thresholds = &read_thresholds_emr,
633 };
634 
635 static const struct auxiliary_device_id peci_dimmtemp_ids[] = {
636 	{
637 		.name = "peci_cpu.dimmtemp.hsx",
638 		.driver_data = (kernel_ulong_t)&dimm_hsx,
639 	},
640 	{
641 		.name = "peci_cpu.dimmtemp.bdx",
642 		.driver_data = (kernel_ulong_t)&dimm_bdx,
643 	},
644 	{
645 		.name = "peci_cpu.dimmtemp.bdxd",
646 		.driver_data = (kernel_ulong_t)&dimm_bdxd,
647 	},
648 	{
649 		.name = "peci_cpu.dimmtemp.skx",
650 		.driver_data = (kernel_ulong_t)&dimm_skx,
651 	},
652 	{
653 		.name = "peci_cpu.dimmtemp.icx",
654 		.driver_data = (kernel_ulong_t)&dimm_icx,
655 	},
656 	{
657 		.name = "peci_cpu.dimmtemp.icxd",
658 		.driver_data = (kernel_ulong_t)&dimm_icxd,
659 	},
660 	{
661 		.name = "peci_cpu.dimmtemp.spr",
662 		.driver_data = (kernel_ulong_t)&dimm_spr,
663 	},
664 	{
665 		.name = "peci_cpu.dimmtemp.emr",
666 		.driver_data = (kernel_ulong_t)&dimm_emr,
667 	},
668 	{ }
669 };
670 MODULE_DEVICE_TABLE(auxiliary, peci_dimmtemp_ids);
671 
672 static struct auxiliary_driver peci_dimmtemp_driver = {
673 	.probe		= peci_dimmtemp_probe,
674 	.remove		= peci_dimmtemp_remove,
675 	.id_table	= peci_dimmtemp_ids,
676 };
677 
678 module_auxiliary_driver(peci_dimmtemp_driver);
679 
680 MODULE_AUTHOR("Jae Hyun Yoo <jae.hyun.yoo@linux.intel.com>");
681 MODULE_AUTHOR("Iwona Winiarska <iwona.winiarska@intel.com>");
682 MODULE_DESCRIPTION("PECI dimmtemp driver");
683 MODULE_LICENSE("GPL");
684 MODULE_IMPORT_NS("PECI_CPU");
685