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