dimmtemp.c 18 KB

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