xref: /OK3568_Linux_fs/kernel/drivers/pci/hotplug/cpci_hotplug.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0+ */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * CompactPCI Hot Plug Core Functions
4*4882a593Smuzhiyun  *
5*4882a593Smuzhiyun  * Copyright (C) 2002 SOMA Networks, Inc.
6*4882a593Smuzhiyun  * Copyright (C) 2001 Greg Kroah-Hartman (greg@kroah.com)
7*4882a593Smuzhiyun  * Copyright (C) 2001 IBM Corp.
8*4882a593Smuzhiyun  *
9*4882a593Smuzhiyun  * All rights reserved.
10*4882a593Smuzhiyun  *
11*4882a593Smuzhiyun  * Send feedback to <scottm@somanetworks.com>
12*4882a593Smuzhiyun  */
13*4882a593Smuzhiyun 
14*4882a593Smuzhiyun #ifndef _CPCI_HOTPLUG_H
15*4882a593Smuzhiyun #define _CPCI_HOTPLUG_H
16*4882a593Smuzhiyun 
17*4882a593Smuzhiyun #include <linux/types.h>
18*4882a593Smuzhiyun #include <linux/pci.h>
19*4882a593Smuzhiyun #include <linux/pci_hotplug.h>
20*4882a593Smuzhiyun 
21*4882a593Smuzhiyun /* PICMG 2.1 R2.0 HS CSR bits: */
22*4882a593Smuzhiyun #define HS_CSR_INS	0x0080
23*4882a593Smuzhiyun #define HS_CSR_EXT	0x0040
24*4882a593Smuzhiyun #define HS_CSR_PI	0x0030
25*4882a593Smuzhiyun #define HS_CSR_LOO	0x0008
26*4882a593Smuzhiyun #define HS_CSR_PIE	0x0004
27*4882a593Smuzhiyun #define HS_CSR_EIM	0x0002
28*4882a593Smuzhiyun #define HS_CSR_DHA	0x0001
29*4882a593Smuzhiyun 
30*4882a593Smuzhiyun struct slot {
31*4882a593Smuzhiyun 	u8 number;
32*4882a593Smuzhiyun 	unsigned int devfn;
33*4882a593Smuzhiyun 	struct pci_bus *bus;
34*4882a593Smuzhiyun 	struct pci_dev *dev;
35*4882a593Smuzhiyun 	unsigned int latch_status:1;
36*4882a593Smuzhiyun 	unsigned int adapter_status:1;
37*4882a593Smuzhiyun 	unsigned int extracting;
38*4882a593Smuzhiyun 	struct hotplug_slot hotplug_slot;
39*4882a593Smuzhiyun 	struct list_head slot_list;
40*4882a593Smuzhiyun };
41*4882a593Smuzhiyun 
42*4882a593Smuzhiyun struct cpci_hp_controller_ops {
43*4882a593Smuzhiyun 	int (*query_enum)(void);
44*4882a593Smuzhiyun 	int (*enable_irq)(void);
45*4882a593Smuzhiyun 	int (*disable_irq)(void);
46*4882a593Smuzhiyun 	int (*check_irq)(void *dev_id);
47*4882a593Smuzhiyun 	int (*hardware_test)(struct slot *slot, u32 value);
48*4882a593Smuzhiyun 	u8  (*get_power)(struct slot *slot);
49*4882a593Smuzhiyun 	int (*set_power)(struct slot *slot, int value);
50*4882a593Smuzhiyun };
51*4882a593Smuzhiyun 
52*4882a593Smuzhiyun struct cpci_hp_controller {
53*4882a593Smuzhiyun 	unsigned int irq;
54*4882a593Smuzhiyun 	unsigned long irq_flags;
55*4882a593Smuzhiyun 	char *devname;
56*4882a593Smuzhiyun 	void *dev_id;
57*4882a593Smuzhiyun 	char *name;
58*4882a593Smuzhiyun 	struct cpci_hp_controller_ops *ops;
59*4882a593Smuzhiyun };
60*4882a593Smuzhiyun 
slot_name(struct slot * slot)61*4882a593Smuzhiyun static inline const char *slot_name(struct slot *slot)
62*4882a593Smuzhiyun {
63*4882a593Smuzhiyun 	return hotplug_slot_name(&slot->hotplug_slot);
64*4882a593Smuzhiyun }
65*4882a593Smuzhiyun 
to_slot(struct hotplug_slot * hotplug_slot)66*4882a593Smuzhiyun static inline struct slot *to_slot(struct hotplug_slot *hotplug_slot)
67*4882a593Smuzhiyun {
68*4882a593Smuzhiyun 	return container_of(hotplug_slot, struct slot, hotplug_slot);
69*4882a593Smuzhiyun }
70*4882a593Smuzhiyun 
71*4882a593Smuzhiyun int cpci_hp_register_controller(struct cpci_hp_controller *controller);
72*4882a593Smuzhiyun int cpci_hp_unregister_controller(struct cpci_hp_controller *controller);
73*4882a593Smuzhiyun int cpci_hp_register_bus(struct pci_bus *bus, u8 first, u8 last);
74*4882a593Smuzhiyun int cpci_hp_unregister_bus(struct pci_bus *bus);
75*4882a593Smuzhiyun int cpci_hp_start(void);
76*4882a593Smuzhiyun int cpci_hp_stop(void);
77*4882a593Smuzhiyun 
78*4882a593Smuzhiyun /*
79*4882a593Smuzhiyun  * Internal function prototypes, these functions should not be used by
80*4882a593Smuzhiyun  * board/chassis drivers.
81*4882a593Smuzhiyun  */
82*4882a593Smuzhiyun u8 cpci_get_attention_status(struct slot *slot);
83*4882a593Smuzhiyun u8 cpci_get_latch_status(struct slot *slot);
84*4882a593Smuzhiyun u8 cpci_get_adapter_status(struct slot *slot);
85*4882a593Smuzhiyun u16 cpci_get_hs_csr(struct slot *slot);
86*4882a593Smuzhiyun int cpci_set_attention_status(struct slot *slot, int status);
87*4882a593Smuzhiyun int cpci_check_and_clear_ins(struct slot *slot);
88*4882a593Smuzhiyun int cpci_check_ext(struct slot *slot);
89*4882a593Smuzhiyun int cpci_clear_ext(struct slot *slot);
90*4882a593Smuzhiyun int cpci_led_on(struct slot *slot);
91*4882a593Smuzhiyun int cpci_led_off(struct slot *slot);
92*4882a593Smuzhiyun int cpci_configure_slot(struct slot *slot);
93*4882a593Smuzhiyun int cpci_unconfigure_slot(struct slot *slot);
94*4882a593Smuzhiyun 
95*4882a593Smuzhiyun #ifdef CONFIG_HOTPLUG_PCI_CPCI
96*4882a593Smuzhiyun int cpci_hotplug_init(int debug);
97*4882a593Smuzhiyun #else
cpci_hotplug_init(int debug)98*4882a593Smuzhiyun static inline int cpci_hotplug_init(int debug) { return 0; }
99*4882a593Smuzhiyun #endif
100*4882a593Smuzhiyun 
101*4882a593Smuzhiyun #endif	/* _CPCI_HOTPLUG_H */
102