xref: /openbmc/linux/drivers/char/ipmi/ipmi_si.h (revision 36de991e)
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * ipmi_si.h
4  *
5  * Interface from the device-specific interfaces (OF, DMI, ACPI, PCI,
6  * etc) to the base ipmi system interface code.
7  */
8 
9 #ifndef __IPMI_SI_H__
10 #define __IPMI_SI_H__
11 
12 #include <linux/ipmi.h>
13 #include <linux/interrupt.h>
14 #include <linux/platform_device.h>
15 
16 #define SI_DEVICE_NAME "ipmi_si"
17 
18 #define DEFAULT_REGSPACING	1
19 #define DEFAULT_REGSIZE		1
20 
21 /* Numbers in this enumerator should be mapped to si_to_str[] */
22 enum si_type {
23 	SI_TYPE_INVALID, SI_KCS, SI_SMIC, SI_BT, SI_TYPE_MAX
24 };
25 
26 /* Array is defined in the ipmi_si_intf.c */
27 extern const char *const si_to_str[];
28 
29 enum ipmi_addr_space {
30 	IPMI_IO_ADDR_SPACE, IPMI_MEM_ADDR_SPACE
31 };
32 
33 /*
34  * The structure for doing I/O in the state machine.  The state
35  * machine doesn't have the actual I/O routines, they are done through
36  * this interface.
37  */
38 struct si_sm_io {
39 	unsigned char (*inputb)(const struct si_sm_io *io, unsigned int offset);
40 	void (*outputb)(const struct si_sm_io *io,
41 			unsigned int  offset,
42 			unsigned char b);
43 
44 	/*
45 	 * Generic info used by the actual handling routines, the
46 	 * state machine shouldn't touch these.
47 	 */
48 	void __iomem *addr;
49 	unsigned int regspacing;
50 	unsigned int regsize;
51 	unsigned int regshift;
52 	enum ipmi_addr_space addr_space;
53 	unsigned long addr_data;
54 	enum ipmi_addr_src addr_source; /* ACPI, PCI, SMBIOS, hardcode, etc. */
55 	union ipmi_smi_info_union addr_info;
56 
57 	int (*io_setup)(struct si_sm_io *info);
58 	void (*io_cleanup)(struct si_sm_io *info);
59 	unsigned int io_size;
60 
61 	int irq;
62 	int (*irq_setup)(struct si_sm_io *io);
63 	void *irq_handler_data;
64 	void (*irq_cleanup)(struct si_sm_io *io);
65 
66 	u8 slave_addr;
67 	enum si_type si_type;
68 	struct device *dev;
69 };
70 
71 int ipmi_si_add_smi(struct si_sm_io *io);
72 irqreturn_t ipmi_si_irq_handler(int irq, void *data);
73 void ipmi_irq_start_cleanup(struct si_sm_io *io);
74 int ipmi_std_irq_setup(struct si_sm_io *io);
75 void ipmi_irq_finish_setup(struct si_sm_io *io);
76 void ipmi_si_remove_by_dev(struct device *dev);
77 struct device *ipmi_si_remove_by_data(int addr_space, enum si_type si_type,
78 				      unsigned long addr);
79 void ipmi_hardcode_init(void);
80 void ipmi_si_hardcode_exit(void);
81 void ipmi_si_hotmod_exit(void);
82 int ipmi_si_hardcode_match(int addr_space, unsigned long addr);
83 void ipmi_si_platform_init(void);
84 void ipmi_si_platform_shutdown(void);
85 void ipmi_remove_platform_device_by_name(char *name);
86 
87 extern struct platform_driver ipmi_platform_driver;
88 
89 #ifdef CONFIG_PCI
90 void ipmi_si_pci_init(void);
91 void ipmi_si_pci_shutdown(void);
92 #else
93 static inline void ipmi_si_pci_init(void) { }
94 static inline void ipmi_si_pci_shutdown(void) { }
95 #endif
96 #ifdef CONFIG_PARISC
97 void ipmi_si_parisc_init(void);
98 void ipmi_si_parisc_shutdown(void);
99 #else
100 static inline void ipmi_si_parisc_init(void) { }
101 static inline void ipmi_si_parisc_shutdown(void) { }
102 #endif
103 
104 int ipmi_si_port_setup(struct si_sm_io *io);
105 int ipmi_si_mem_setup(struct si_sm_io *io);
106 
107 #endif /* __IPMI_SI_H__ */
108