xref: /linux/drivers/pci/hotplug/cpci_hotplug.h (revision a1c613ae4c322ddd58d5a8539dbfba2a0380a8c0)
1736759efSBjorn Helgaas /* SPDX-License-Identifier: GPL-2.0+ */
21da177e4SLinus Torvalds /*
31da177e4SLinus Torvalds  * CompactPCI Hot Plug Core Functions
41da177e4SLinus Torvalds  *
51da177e4SLinus Torvalds  * Copyright (C) 2002 SOMA Networks, Inc.
61da177e4SLinus Torvalds  * Copyright (C) 2001 Greg Kroah-Hartman (greg@kroah.com)
71da177e4SLinus Torvalds  * Copyright (C) 2001 IBM Corp.
81da177e4SLinus Torvalds  *
91da177e4SLinus Torvalds  * All rights reserved.
101da177e4SLinus Torvalds  *
111da177e4SLinus Torvalds  * Send feedback to <scottm@somanetworks.com>
121da177e4SLinus Torvalds  */
131da177e4SLinus Torvalds 
141da177e4SLinus Torvalds #ifndef _CPCI_HOTPLUG_H
151da177e4SLinus Torvalds #define _CPCI_HOTPLUG_H
161da177e4SLinus Torvalds 
171da177e4SLinus Torvalds #include <linux/types.h>
181da177e4SLinus Torvalds #include <linux/pci.h>
19d6c479e0SAlex Chiang #include <linux/pci_hotplug.h>
201da177e4SLinus Torvalds 
2143b7d7cfSScott Murray /* PICMG 2.1 R2.0 HS CSR bits: */
221da177e4SLinus Torvalds #define HS_CSR_INS	0x0080
231da177e4SLinus Torvalds #define HS_CSR_EXT	0x0040
241da177e4SLinus Torvalds #define HS_CSR_PI	0x0030
251da177e4SLinus Torvalds #define HS_CSR_LOO	0x0008
261da177e4SLinus Torvalds #define HS_CSR_PIE	0x0004
271da177e4SLinus Torvalds #define HS_CSR_EIM	0x0002
281da177e4SLinus Torvalds #define HS_CSR_DHA	0x0001
291da177e4SLinus Torvalds 
301da177e4SLinus Torvalds struct slot {
311da177e4SLinus Torvalds 	u8 number;
321da177e4SLinus Torvalds 	unsigned int devfn;
331da177e4SLinus Torvalds 	struct pci_bus *bus;
341da177e4SLinus Torvalds 	struct pci_dev *dev;
35a7da2161SLukas Wunner 	unsigned int latch_status:1;
36a7da2161SLukas Wunner 	unsigned int adapter_status:1;
371da177e4SLinus Torvalds 	unsigned int extracting;
38125450f8SLukas Wunner 	struct hotplug_slot hotplug_slot;
391da177e4SLinus Torvalds 	struct list_head slot_list;
401da177e4SLinus Torvalds };
411da177e4SLinus Torvalds 
421da177e4SLinus Torvalds struct cpci_hp_controller_ops {
431da177e4SLinus Torvalds 	int (*query_enum)(void);
441da177e4SLinus Torvalds 	int (*enable_irq)(void);
451da177e4SLinus Torvalds 	int (*disable_irq)(void);
461da177e4SLinus Torvalds 	int (*check_irq)(void *dev_id);
471da177e4SLinus Torvalds 	int (*hardware_test)(struct slot *slot, u32 value);
481da177e4SLinus Torvalds 	u8  (*get_power)(struct slot *slot);
491da177e4SLinus Torvalds 	int (*set_power)(struct slot *slot, int value);
501da177e4SLinus Torvalds };
511da177e4SLinus Torvalds 
521da177e4SLinus Torvalds struct cpci_hp_controller {
531da177e4SLinus Torvalds 	unsigned int irq;
541da177e4SLinus Torvalds 	unsigned long irq_flags;
551da177e4SLinus Torvalds 	char *devname;
561da177e4SLinus Torvalds 	void *dev_id;
571da177e4SLinus Torvalds 	char *name;
581da177e4SLinus Torvalds 	struct cpci_hp_controller_ops *ops;
591da177e4SLinus Torvalds };
601da177e4SLinus Torvalds 
slot_name(struct slot * slot)61d6c479e0SAlex Chiang static inline const char *slot_name(struct slot *slot)
62d6c479e0SAlex Chiang {
63125450f8SLukas Wunner 	return hotplug_slot_name(&slot->hotplug_slot);
64125450f8SLukas Wunner }
65125450f8SLukas Wunner 
to_slot(struct hotplug_slot * hotplug_slot)66125450f8SLukas Wunner static inline struct slot *to_slot(struct hotplug_slot *hotplug_slot)
67125450f8SLukas Wunner {
68125450f8SLukas Wunner 	return container_of(hotplug_slot, struct slot, hotplug_slot);
69d6c479e0SAlex Chiang }
70d6c479e0SAlex Chiang 
71f39d5b72SBjorn Helgaas int cpci_hp_register_controller(struct cpci_hp_controller *controller);
72f39d5b72SBjorn Helgaas int cpci_hp_unregister_controller(struct cpci_hp_controller *controller);
73f39d5b72SBjorn Helgaas int cpci_hp_register_bus(struct pci_bus *bus, u8 first, u8 last);
74f39d5b72SBjorn Helgaas int cpci_hp_unregister_bus(struct pci_bus *bus);
75f39d5b72SBjorn Helgaas int cpci_hp_start(void);
76f39d5b72SBjorn Helgaas int cpci_hp_stop(void);
771da177e4SLinus Torvalds 
78*6d71cc4cSKrzysztof Wilczyński /* Global variables */
79*6d71cc4cSKrzysztof Wilczyński extern int cpci_debug;
80*6d71cc4cSKrzysztof Wilczyński 
811da177e4SLinus Torvalds /*
821da177e4SLinus Torvalds  * Internal function prototypes, these functions should not be used by
831da177e4SLinus Torvalds  * board/chassis drivers.
841da177e4SLinus Torvalds  */
85f39d5b72SBjorn Helgaas u8 cpci_get_attention_status(struct slot *slot);
86f39d5b72SBjorn Helgaas u16 cpci_get_hs_csr(struct slot *slot);
87f39d5b72SBjorn Helgaas int cpci_set_attention_status(struct slot *slot, int status);
88f39d5b72SBjorn Helgaas int cpci_check_and_clear_ins(struct slot *slot);
89f39d5b72SBjorn Helgaas int cpci_check_ext(struct slot *slot);
90f39d5b72SBjorn Helgaas int cpci_clear_ext(struct slot *slot);
91f39d5b72SBjorn Helgaas int cpci_led_on(struct slot *slot);
92f39d5b72SBjorn Helgaas int cpci_led_off(struct slot *slot);
93f39d5b72SBjorn Helgaas int cpci_configure_slot(struct slot *slot);
94f39d5b72SBjorn Helgaas int cpci_unconfigure_slot(struct slot *slot);
951da177e4SLinus Torvalds 
96c3139ba2SBjorn Helgaas #ifdef CONFIG_HOTPLUG_PCI_CPCI
97c3139ba2SBjorn Helgaas int cpci_hotplug_init(int debug);
98c3139ba2SBjorn Helgaas #else
cpci_hotplug_init(int debug)99c3139ba2SBjorn Helgaas static inline int cpci_hotplug_init(int debug) { return 0; }
100c3139ba2SBjorn Helgaas #endif
101c3139ba2SBjorn Helgaas 
1021da177e4SLinus Torvalds #endif	/* _CPCI_HOTPLUG_H */
103