1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun
3*4882a593Smuzhiyun /*
4*4882a593Smuzhiyun * edac_module.h
5*4882a593Smuzhiyun *
6*4882a593Smuzhiyun * For defining functions/data for within the EDAC_CORE module only
7*4882a593Smuzhiyun *
8*4882a593Smuzhiyun * written by doug thompson <norsk5@xmission.h>
9*4882a593Smuzhiyun */
10*4882a593Smuzhiyun
11*4882a593Smuzhiyun #ifndef __EDAC_MODULE_H__
12*4882a593Smuzhiyun #define __EDAC_MODULE_H__
13*4882a593Smuzhiyun
14*4882a593Smuzhiyun #include "edac_mc.h"
15*4882a593Smuzhiyun #include "edac_pci.h"
16*4882a593Smuzhiyun #include "edac_device.h"
17*4882a593Smuzhiyun
18*4882a593Smuzhiyun /*
19*4882a593Smuzhiyun * INTERNAL EDAC MODULE:
20*4882a593Smuzhiyun * EDAC memory controller sysfs create/remove functions
21*4882a593Smuzhiyun * and setup/teardown functions
22*4882a593Smuzhiyun *
23*4882a593Smuzhiyun * edac_mc objects
24*4882a593Smuzhiyun */
25*4882a593Smuzhiyun /* on edac_mc_sysfs.c */
26*4882a593Smuzhiyun int edac_mc_sysfs_init(void);
27*4882a593Smuzhiyun void edac_mc_sysfs_exit(void);
28*4882a593Smuzhiyun extern int edac_create_sysfs_mci_device(struct mem_ctl_info *mci,
29*4882a593Smuzhiyun const struct attribute_group **groups);
30*4882a593Smuzhiyun extern void edac_remove_sysfs_mci_device(struct mem_ctl_info *mci);
31*4882a593Smuzhiyun extern int edac_get_log_ue(void);
32*4882a593Smuzhiyun extern int edac_get_log_ce(void);
33*4882a593Smuzhiyun extern int edac_get_panic_on_ue(void);
34*4882a593Smuzhiyun extern int edac_mc_get_log_ue(void);
35*4882a593Smuzhiyun extern int edac_mc_get_log_ce(void);
36*4882a593Smuzhiyun extern int edac_mc_get_panic_on_ue(void);
37*4882a593Smuzhiyun extern int edac_get_poll_msec(void);
38*4882a593Smuzhiyun extern unsigned int edac_mc_get_poll_msec(void);
39*4882a593Smuzhiyun
40*4882a593Smuzhiyun unsigned edac_dimm_info_location(struct dimm_info *dimm, char *buf,
41*4882a593Smuzhiyun unsigned len);
42*4882a593Smuzhiyun
43*4882a593Smuzhiyun /* on edac_device.c */
44*4882a593Smuzhiyun extern int edac_device_register_sysfs_main_kobj(
45*4882a593Smuzhiyun struct edac_device_ctl_info *edac_dev);
46*4882a593Smuzhiyun extern void edac_device_unregister_sysfs_main_kobj(
47*4882a593Smuzhiyun struct edac_device_ctl_info *edac_dev);
48*4882a593Smuzhiyun extern int edac_device_create_sysfs(struct edac_device_ctl_info *edac_dev);
49*4882a593Smuzhiyun extern void edac_device_remove_sysfs(struct edac_device_ctl_info *edac_dev);
50*4882a593Smuzhiyun
51*4882a593Smuzhiyun /* edac core workqueue: single CPU mode */
52*4882a593Smuzhiyun int edac_workqueue_setup(void);
53*4882a593Smuzhiyun void edac_workqueue_teardown(void);
54*4882a593Smuzhiyun bool edac_queue_work(struct delayed_work *work, unsigned long delay);
55*4882a593Smuzhiyun bool edac_stop_work(struct delayed_work *work);
56*4882a593Smuzhiyun bool edac_mod_work(struct delayed_work *work, unsigned long delay);
57*4882a593Smuzhiyun
58*4882a593Smuzhiyun extern void edac_device_reset_delay_period(struct edac_device_ctl_info
59*4882a593Smuzhiyun *edac_dev, unsigned long value);
60*4882a593Smuzhiyun extern void edac_mc_reset_delay_period(unsigned long value);
61*4882a593Smuzhiyun
62*4882a593Smuzhiyun extern void *edac_align_ptr(void **p, unsigned size, int n_elems);
63*4882a593Smuzhiyun
64*4882a593Smuzhiyun /*
65*4882a593Smuzhiyun * EDAC debugfs functions
66*4882a593Smuzhiyun */
67*4882a593Smuzhiyun
68*4882a593Smuzhiyun #define edac_debugfs_remove_recursive debugfs_remove_recursive
69*4882a593Smuzhiyun #define edac_debugfs_remove debugfs_remove
70*4882a593Smuzhiyun #ifdef CONFIG_EDAC_DEBUG
71*4882a593Smuzhiyun void edac_debugfs_init(void);
72*4882a593Smuzhiyun void edac_debugfs_exit(void);
73*4882a593Smuzhiyun void edac_create_debugfs_nodes(struct mem_ctl_info *mci);
74*4882a593Smuzhiyun struct dentry *edac_debugfs_create_dir(const char *dirname);
75*4882a593Smuzhiyun struct dentry *
76*4882a593Smuzhiyun edac_debugfs_create_dir_at(const char *dirname, struct dentry *parent);
77*4882a593Smuzhiyun struct dentry *
78*4882a593Smuzhiyun edac_debugfs_create_file(const char *name, umode_t mode, struct dentry *parent,
79*4882a593Smuzhiyun void *data, const struct file_operations *fops);
80*4882a593Smuzhiyun void edac_debugfs_create_x8(const char *name, umode_t mode,
81*4882a593Smuzhiyun struct dentry *parent, u8 *value);
82*4882a593Smuzhiyun void edac_debugfs_create_x16(const char *name, umode_t mode,
83*4882a593Smuzhiyun struct dentry *parent, u16 *value);
84*4882a593Smuzhiyun void edac_debugfs_create_x32(const char *name, umode_t mode,
85*4882a593Smuzhiyun struct dentry *parent, u32 *value);
86*4882a593Smuzhiyun #else
edac_debugfs_init(void)87*4882a593Smuzhiyun static inline void edac_debugfs_init(void) { }
edac_debugfs_exit(void)88*4882a593Smuzhiyun static inline void edac_debugfs_exit(void) { }
edac_create_debugfs_nodes(struct mem_ctl_info * mci)89*4882a593Smuzhiyun static inline void edac_create_debugfs_nodes(struct mem_ctl_info *mci) { }
edac_debugfs_create_dir(const char * dirname)90*4882a593Smuzhiyun static inline struct dentry *edac_debugfs_create_dir(const char *dirname) { return NULL; }
91*4882a593Smuzhiyun static inline struct dentry *
edac_debugfs_create_dir_at(const char * dirname,struct dentry * parent)92*4882a593Smuzhiyun edac_debugfs_create_dir_at(const char *dirname, struct dentry *parent) { return NULL; }
93*4882a593Smuzhiyun static inline struct dentry *
edac_debugfs_create_file(const char * name,umode_t mode,struct dentry * parent,void * data,const struct file_operations * fops)94*4882a593Smuzhiyun edac_debugfs_create_file(const char *name, umode_t mode, struct dentry *parent,
95*4882a593Smuzhiyun void *data, const struct file_operations *fops) { return NULL; }
edac_debugfs_create_x8(const char * name,umode_t mode,struct dentry * parent,u8 * value)96*4882a593Smuzhiyun static inline void edac_debugfs_create_x8(const char *name, umode_t mode,
97*4882a593Smuzhiyun struct dentry *parent, u8 *value) { }
edac_debugfs_create_x16(const char * name,umode_t mode,struct dentry * parent,u16 * value)98*4882a593Smuzhiyun static inline void edac_debugfs_create_x16(const char *name, umode_t mode,
99*4882a593Smuzhiyun struct dentry *parent, u16 *value) { }
edac_debugfs_create_x32(const char * name,umode_t mode,struct dentry * parent,u32 * value)100*4882a593Smuzhiyun static inline void edac_debugfs_create_x32(const char *name, umode_t mode,
101*4882a593Smuzhiyun struct dentry *parent, u32 *value) { }
102*4882a593Smuzhiyun #endif
103*4882a593Smuzhiyun
104*4882a593Smuzhiyun /*
105*4882a593Smuzhiyun * EDAC PCI functions
106*4882a593Smuzhiyun */
107*4882a593Smuzhiyun #ifdef CONFIG_PCI
108*4882a593Smuzhiyun extern void edac_pci_do_parity_check(void);
109*4882a593Smuzhiyun extern void edac_pci_clear_parity_errors(void);
110*4882a593Smuzhiyun extern int edac_sysfs_pci_setup(void);
111*4882a593Smuzhiyun extern void edac_sysfs_pci_teardown(void);
112*4882a593Smuzhiyun extern int edac_pci_get_check_errors(void);
113*4882a593Smuzhiyun extern int edac_pci_get_poll_msec(void);
114*4882a593Smuzhiyun extern void edac_pci_remove_sysfs(struct edac_pci_ctl_info *pci);
115*4882a593Smuzhiyun extern void edac_pci_handle_pe(struct edac_pci_ctl_info *pci, const char *msg);
116*4882a593Smuzhiyun extern void edac_pci_handle_npe(struct edac_pci_ctl_info *pci,
117*4882a593Smuzhiyun const char *msg);
118*4882a593Smuzhiyun #else /* CONFIG_PCI */
119*4882a593Smuzhiyun /* pre-process these away */
120*4882a593Smuzhiyun #define edac_pci_do_parity_check()
121*4882a593Smuzhiyun #define edac_pci_clear_parity_errors()
122*4882a593Smuzhiyun #define edac_sysfs_pci_setup() (0)
123*4882a593Smuzhiyun #define edac_sysfs_pci_teardown()
124*4882a593Smuzhiyun #define edac_pci_get_check_errors()
125*4882a593Smuzhiyun #define edac_pci_get_poll_msec()
126*4882a593Smuzhiyun #define edac_pci_handle_pe()
127*4882a593Smuzhiyun #define edac_pci_handle_npe()
128*4882a593Smuzhiyun #endif /* CONFIG_PCI */
129*4882a593Smuzhiyun
130*4882a593Smuzhiyun #endif /* __EDAC_MODULE_H__ */
131