1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Common codes for both the skx_edac driver and Intel 10nm server EDAC driver.
4 * Originally split out from the skx_edac driver.
6 * Copyright (c) 2018, Intel Corporation.
9 #ifndef _SKX_COMM_EDAC_H
10 #define _SKX_COMM_EDAC_H
17 #define skx_printk(level, fmt, arg...) \
18 edac_printk(level, "skx", fmt, ##arg)
20 #define skx_mc_printk(mci, level, fmt, arg...) \
21 edac_mc_chipset_printk(mci, level, "skx", fmt, ##arg)
24 * Get a bit field at register value <v>, from bit <lo> to bit <hi>
26 #define GET_BITFIELD(v, lo, hi) \
27 (((v) & GENMASK_ULL((hi), (lo))) >> (lo))
29 #define SKX_NUM_IMC 2 /* Memory controllers per socket */
30 #define SKX_NUM_CHANNELS 3 /* Channels per memory controller */
31 #define SKX_NUM_DIMMS 2 /* Max DIMMS per channel */
33 #define I10NM_NUM_IMC 4
34 #define I10NM_NUM_CHANNELS 2
35 #define I10NM_NUM_DIMMS 2
37 #define MAX(a, b) ((a) > (b) ? (a) : (b))
38 #define NUM_IMC MAX(SKX_NUM_IMC, I10NM_NUM_IMC)
39 #define NUM_CHANNELS MAX(SKX_NUM_CHANNELS, I10NM_NUM_CHANNELS)
40 #define NUM_DIMMS MAX(SKX_NUM_DIMMS, I10NM_NUM_DIMMS)
42 #define IS_DIMM_PRESENT(r) GET_BITFIELD(r, 15, 15)
43 #define IS_NVDIMM_PRESENT(r, i) GET_BITFIELD(r, i, i)
46 * Each cpu socket contains some pci devices that provide global
47 * information, and also some that are local to each of the two
48 * memory controllers on the die.
51 struct list_head list;
54 struct pci_dev *sad_all;
55 struct pci_dev *util_all;
56 struct pci_dev *uracu; /* for i10nm CPU */
59 struct mem_ctl_info *mci;
60 struct pci_dev *mdev; /* for i10nm CPU */
61 void __iomem *mbase; /* for i10nm CPU */
62 u8 mc; /* system wide mc# */
63 u8 lmc; /* socket relative mc# */
114 typedef int (*get_dimm_config_f)(struct mem_ctl_info *mci);
115 typedef bool (*skx_decode_f)(struct decoded_addr *res);
117 int __init skx_adxl_get(void);
118 void __exit skx_adxl_put(void);
119 void skx_set_decode(skx_decode_f decode);
121 int skx_get_src_id(struct skx_dev *d, int off, u8 *id);
122 int skx_get_node_id(struct skx_dev *d, u8 *id);
124 int skx_get_all_bus_mappings(unsigned int did, int off, enum type,
125 struct list_head **list);
127 int skx_get_hi_lo(unsigned int did, int off[], u64 *tolm, u64 *tohm);
129 int skx_get_dimm_info(u32 mtr, u32 amap, struct dimm_info *dimm,
130 struct skx_imc *imc, int chan, int dimmno);
132 int skx_get_nvdimm_info(struct dimm_info *dimm, struct skx_imc *imc,
133 int chan, int dimmno, const char *mod_str);
135 int skx_register_mci(struct skx_imc *imc, struct pci_dev *pdev,
136 const char *ctl_name, const char *mod_str,
137 get_dimm_config_f get_dimm_config);
139 int skx_mce_check_error(struct notifier_block *nb, unsigned long val,
142 void skx_remove(void);
144 #endif /* _SKX_COMM_EDAC_H */