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 enum si_type { 22 SI_TYPE_INVALID, SI_KCS, SI_SMIC, SI_BT 23 }; 24 25 enum ipmi_addr_space { 26 IPMI_IO_ADDR_SPACE, IPMI_MEM_ADDR_SPACE 27 }; 28 29 /* 30 * The structure for doing I/O in the state machine. The state 31 * machine doesn't have the actual I/O routines, they are done through 32 * this interface. 33 */ 34 struct si_sm_io { 35 unsigned char (*inputb)(const struct si_sm_io *io, unsigned int offset); 36 void (*outputb)(const struct si_sm_io *io, 37 unsigned int offset, 38 unsigned char b); 39 40 /* 41 * Generic info used by the actual handling routines, the 42 * state machine shouldn't touch these. 43 */ 44 void __iomem *addr; 45 unsigned int regspacing; 46 unsigned int regsize; 47 unsigned int regshift; 48 enum ipmi_addr_space addr_space; 49 unsigned long addr_data; 50 enum ipmi_addr_src addr_source; /* ACPI, PCI, SMBIOS, hardcode, etc. */ 51 void (*addr_source_cleanup)(struct si_sm_io *io); 52 void *addr_source_data; 53 union ipmi_smi_info_union addr_info; 54 55 int (*io_setup)(struct si_sm_io *info); 56 void (*io_cleanup)(struct si_sm_io *info); 57 unsigned int io_size; 58 59 int irq; 60 int (*irq_setup)(struct si_sm_io *io); 61 void *irq_handler_data; 62 void (*irq_cleanup)(struct si_sm_io *io); 63 64 u8 slave_addr; 65 enum si_type si_type; 66 struct device *dev; 67 }; 68 69 int ipmi_si_add_smi(struct si_sm_io *io); 70 irqreturn_t ipmi_si_irq_handler(int irq, void *data); 71 void ipmi_irq_start_cleanup(struct si_sm_io *io); 72 int ipmi_std_irq_setup(struct si_sm_io *io); 73 void ipmi_irq_finish_setup(struct si_sm_io *io); 74 int ipmi_si_remove_by_dev(struct device *dev); 75 struct device *ipmi_si_remove_by_data(int addr_space, enum si_type si_type, 76 unsigned long addr); 77 void ipmi_hardcode_init(void); 78 void ipmi_si_hardcode_exit(void); 79 void ipmi_si_hotmod_exit(void); 80 int ipmi_si_hardcode_match(int addr_space, unsigned long addr); 81 void ipmi_si_platform_init(void); 82 void ipmi_si_platform_shutdown(void); 83 void ipmi_remove_platform_device_by_name(char *name); 84 85 extern struct platform_driver ipmi_platform_driver; 86 87 #ifdef CONFIG_PCI 88 void ipmi_si_pci_init(void); 89 void ipmi_si_pci_shutdown(void); 90 #else 91 static inline void ipmi_si_pci_init(void) { } 92 static inline void ipmi_si_pci_shutdown(void) { } 93 #endif 94 #ifdef CONFIG_PARISC 95 void ipmi_si_parisc_init(void); 96 void ipmi_si_parisc_shutdown(void); 97 #else 98 static inline void ipmi_si_parisc_init(void) { } 99 static inline void ipmi_si_parisc_shutdown(void) { } 100 #endif 101 102 int ipmi_si_port_setup(struct si_sm_io *io); 103 int ipmi_si_mem_setup(struct si_sm_io *io); 104 105 #endif /* __IPMI_SI_H__ */ 106