blob: 0a4c69539f24660a9a3fed2641ec98c00e70c805 [file] [log] [blame]
Corey Minyard243ac212018-02-20 07:30:22 -06001/* SPDX-License-Identifier: GPL-2.0+ */
Corey Minyard1e89a492017-09-12 13:52:13 -05002/*
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 Minyard104fb252019-07-31 19:18:25 -05009#ifndef __IPMI_SI_H__
10#define __IPMI_SI_H__
11
12#include <linux/ipmi.h>
Corey Minyard4f3e8192017-09-12 15:10:22 -050013#include <linux/interrupt.h>
Corey Minyard3cd83ba2019-02-21 14:21:17 -060014#include <linux/platform_device.h>
Corey Minyard104fb252019-07-31 19:18:25 -050015
16#define SI_DEVICE_NAME "ipmi_si"
Corey Minyard1e89a492017-09-12 13:52:13 -050017
Corey Minyard1e89a492017-09-12 13:52:13 -050018#define DEFAULT_REGSPACING 1
19#define DEFAULT_REGSIZE 1
20
Andy Shevchenko59cdb2e72021-04-02 20:43:30 +030021/* Numbers in this enumerator should be mapped to si_to_str[] */
Corey Minyard104fb252019-07-31 19:18:25 -050022enum si_type {
Andy Shevchenko59cdb2e72021-04-02 20:43:30 +030023 SI_TYPE_INVALID, SI_KCS, SI_SMIC, SI_BT, SI_TYPE_MAX
Corey Minyard104fb252019-07-31 19:18:25 -050024};
25
Andy Shevchenko59cdb2e72021-04-02 20:43:30 +030026/* Array is defined in the ipmi_si_intf.c */
27extern const char *const si_to_str[];
28
Corey Minyard104fb252019-07-31 19:18:25 -050029enum 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 */
38struct 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 Minyard104fb252019-07-31 19:18:25 -050055 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 Minyard9d700292017-09-12 22:55:57 -050070
Corey Minyardbb398a42017-09-12 21:37:02 -050071int ipmi_si_add_smi(struct si_sm_io *io);
Corey Minyard4f3e8192017-09-12 15:10:22 -050072irqreturn_t ipmi_si_irq_handler(int irq, void *data);
73void ipmi_irq_start_cleanup(struct si_sm_io *io);
74int ipmi_std_irq_setup(struct si_sm_io *io);
75void ipmi_irq_finish_setup(struct si_sm_io *io);
Corey Minyardbb398a42017-09-12 21:37:02 -050076int ipmi_si_remove_by_dev(struct device *dev);
Corey Minyardbdb57b72019-02-21 17:21:50 -060077struct device *ipmi_si_remove_by_data(int addr_space, enum si_type si_type,
78 unsigned long addr);
Corey Minyard41b766d2019-02-21 12:10:07 -060079void ipmi_hardcode_init(void);
80void ipmi_si_hardcode_exit(void);
Corey Minyardbdb57b72019-02-21 17:21:50 -060081void ipmi_si_hotmod_exit(void);
Corey Minyardf6296bd2019-02-21 12:53:00 -060082int ipmi_si_hardcode_match(int addr_space, unsigned long addr);
Corey Minyard9d700292017-09-12 22:55:57 -050083void ipmi_si_platform_init(void);
84void ipmi_si_platform_shutdown(void);
Corey Minyarde17c6572019-02-21 17:41:47 -060085void ipmi_remove_platform_device_by_name(char *name);
Corey Minyard9d700292017-09-12 22:55:57 -050086
87extern struct platform_driver ipmi_platform_driver;
Corey Minyard13d0b352017-09-12 23:04:35 -050088
89#ifdef CONFIG_PCI
90void ipmi_si_pci_init(void);
91void ipmi_si_pci_shutdown(void);
92#else
93static inline void ipmi_si_pci_init(void) { }
94static inline void ipmi_si_pci_shutdown(void) { }
95#endif
Corey Minyardc6f85a72017-09-12 23:10:18 -050096#ifdef CONFIG_PARISC
97void ipmi_si_parisc_init(void);
98void ipmi_si_parisc_shutdown(void);
99#else
100static inline void ipmi_si_parisc_init(void) { }
101static inline void ipmi_si_parisc_shutdown(void) { }
102#endif
Corey Minyard58e27632017-09-12 23:24:30 -0500103
104int ipmi_si_port_setup(struct si_sm_io *io);
105int ipmi_si_mem_setup(struct si_sm_io *io);
Corey Minyard104fb252019-07-31 19:18:25 -0500106
107#endif /* __IPMI_SI_H__ */