Corey Minyard | 243ac21 | 2018-02-20 07:30:22 -0600 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Corey Minyard | 1e89a49 | 2017-09-12 13:52:13 -0500 | [diff] [blame] | 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 | |
Corey Minyard | 104fb25 | 2019-07-31 19:18:25 -0500 | [diff] [blame] | 9 | #ifndef __IPMI_SI_H__ |
| 10 | #define __IPMI_SI_H__ |
| 11 | |
| 12 | #include <linux/ipmi.h> |
Corey Minyard | 4f3e819 | 2017-09-12 15:10:22 -0500 | [diff] [blame] | 13 | #include <linux/interrupt.h> |
Corey Minyard | 3cd83ba | 2019-02-21 14:21:17 -0600 | [diff] [blame] | 14 | #include <linux/platform_device.h> |
Corey Minyard | 104fb25 | 2019-07-31 19:18:25 -0500 | [diff] [blame] | 15 | |
| 16 | #define SI_DEVICE_NAME "ipmi_si" |
Corey Minyard | 1e89a49 | 2017-09-12 13:52:13 -0500 | [diff] [blame] | 17 | |
Corey Minyard | 1e89a49 | 2017-09-12 13:52:13 -0500 | [diff] [blame] | 18 | #define DEFAULT_REGSPACING 1 |
| 19 | #define DEFAULT_REGSIZE 1 |
| 20 | |
Andy Shevchenko | 59cdb2e7 | 2021-04-02 20:43:30 +0300 | [diff] [blame] | 21 | /* Numbers in this enumerator should be mapped to si_to_str[] */ |
Corey Minyard | 104fb25 | 2019-07-31 19:18:25 -0500 | [diff] [blame] | 22 | enum si_type { |
Andy Shevchenko | 59cdb2e7 | 2021-04-02 20:43:30 +0300 | [diff] [blame] | 23 | SI_TYPE_INVALID, SI_KCS, SI_SMIC, SI_BT, SI_TYPE_MAX |
Corey Minyard | 104fb25 | 2019-07-31 19:18:25 -0500 | [diff] [blame] | 24 | }; |
| 25 | |
Andy Shevchenko | 59cdb2e7 | 2021-04-02 20:43:30 +0300 | [diff] [blame] | 26 | /* Array is defined in the ipmi_si_intf.c */ |
| 27 | extern const char *const si_to_str[]; |
| 28 | |
Corey Minyard | 104fb25 | 2019-07-31 19:18:25 -0500 | [diff] [blame] | 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. */ |
Corey Minyard | 104fb25 | 2019-07-31 19:18:25 -0500 | [diff] [blame] | 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 | }; |
Corey Minyard | 9d70029 | 2017-09-12 22:55:57 -0500 | [diff] [blame] | 70 | |
Corey Minyard | bb398a4 | 2017-09-12 21:37:02 -0500 | [diff] [blame] | 71 | int ipmi_si_add_smi(struct si_sm_io *io); |
Corey Minyard | 4f3e819 | 2017-09-12 15:10:22 -0500 | [diff] [blame] | 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); |
Corey Minyard | bb398a4 | 2017-09-12 21:37:02 -0500 | [diff] [blame] | 76 | int ipmi_si_remove_by_dev(struct device *dev); |
Corey Minyard | bdb57b7 | 2019-02-21 17:21:50 -0600 | [diff] [blame] | 77 | struct device *ipmi_si_remove_by_data(int addr_space, enum si_type si_type, |
| 78 | unsigned long addr); |
Corey Minyard | 41b766d | 2019-02-21 12:10:07 -0600 | [diff] [blame] | 79 | void ipmi_hardcode_init(void); |
| 80 | void ipmi_si_hardcode_exit(void); |
Corey Minyard | bdb57b7 | 2019-02-21 17:21:50 -0600 | [diff] [blame] | 81 | void ipmi_si_hotmod_exit(void); |
Corey Minyard | f6296bd | 2019-02-21 12:53:00 -0600 | [diff] [blame] | 82 | int ipmi_si_hardcode_match(int addr_space, unsigned long addr); |
Corey Minyard | 9d70029 | 2017-09-12 22:55:57 -0500 | [diff] [blame] | 83 | void ipmi_si_platform_init(void); |
| 84 | void ipmi_si_platform_shutdown(void); |
Corey Minyard | e17c657 | 2019-02-21 17:41:47 -0600 | [diff] [blame] | 85 | void ipmi_remove_platform_device_by_name(char *name); |
Corey Minyard | 9d70029 | 2017-09-12 22:55:57 -0500 | [diff] [blame] | 86 | |
| 87 | extern struct platform_driver ipmi_platform_driver; |
Corey Minyard | 13d0b35 | 2017-09-12 23:04:35 -0500 | [diff] [blame] | 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 |
Corey Minyard | c6f85a7 | 2017-09-12 23:10:18 -0500 | [diff] [blame] | 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 |
Corey Minyard | 58e2763 | 2017-09-12 23:24:30 -0500 | [diff] [blame] | 103 | |
| 104 | int ipmi_si_port_setup(struct si_sm_io *io); |
| 105 | int ipmi_si_mem_setup(struct si_sm_io *io); |
Corey Minyard | 104fb25 | 2019-07-31 19:18:25 -0500 | [diff] [blame] | 106 | |
| 107 | #endif /* __IPMI_SI_H__ */ |