blob: f33ff2bca414f00e5e1479973abeb5c7e58b1d6c [file] [log] [blame]
Bjorn Helgaas736759e2018-01-26 14:22:04 -06001/* SPDX-License-Identifier: GPL-2.0+ */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
3 * CompactPCI Hot Plug Core Functions
4 *
5 * Copyright (C) 2002 SOMA Networks, Inc.
6 * Copyright (C) 2001 Greg Kroah-Hartman (greg@kroah.com)
7 * Copyright (C) 2001 IBM Corp.
8 *
9 * All rights reserved.
10 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070011 * Send feedback to <scottm@somanetworks.com>
12 */
13
14#ifndef _CPCI_HOTPLUG_H
15#define _CPCI_HOTPLUG_H
16
17#include <linux/types.h>
18#include <linux/pci.h>
Alex Chiangd6c479e2008-10-20 17:41:17 -060019#include <linux/pci_hotplug.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070020
Scott Murray43b7d7c2005-05-09 17:31:50 -040021/* PICMG 2.1 R2.0 HS CSR bits: */
Linus Torvalds1da177e2005-04-16 15:20:36 -070022#define HS_CSR_INS 0x0080
23#define HS_CSR_EXT 0x0040
24#define HS_CSR_PI 0x0030
25#define HS_CSR_LOO 0x0008
26#define HS_CSR_PIE 0x0004
27#define HS_CSR_EIM 0x0002
28#define HS_CSR_DHA 0x0001
29
30struct slot {
31 u8 number;
32 unsigned int devfn;
33 struct pci_bus *bus;
34 struct pci_dev *dev;
Lukas Wunnera7da2162018-09-08 09:59:01 +020035 unsigned int latch_status:1;
36 unsigned int adapter_status:1;
Linus Torvalds1da177e2005-04-16 15:20:36 -070037 unsigned int extracting;
Lukas Wunner125450f2018-09-08 09:59:01 +020038 struct hotplug_slot hotplug_slot;
Linus Torvalds1da177e2005-04-16 15:20:36 -070039 struct list_head slot_list;
40};
41
42struct cpci_hp_controller_ops {
Bogicevic Sasaff3ce482015-12-27 13:21:11 -080043 int (*query_enum)(void);
44 int (*enable_irq)(void);
45 int (*disable_irq)(void);
46 int (*check_irq)(void *dev_id);
47 int (*hardware_test)(struct slot *slot, u32 value);
48 u8 (*get_power)(struct slot *slot);
49 int (*set_power)(struct slot *slot, int value);
Linus Torvalds1da177e2005-04-16 15:20:36 -070050};
51
52struct cpci_hp_controller {
53 unsigned int irq;
54 unsigned long irq_flags;
55 char *devname;
56 void *dev_id;
57 char *name;
58 struct cpci_hp_controller_ops *ops;
59};
60
Alex Chiangd6c479e2008-10-20 17:41:17 -060061static inline const char *slot_name(struct slot *slot)
62{
Lukas Wunner125450f2018-09-08 09:59:01 +020063 return hotplug_slot_name(&slot->hotplug_slot);
64}
65
66static inline struct slot *to_slot(struct hotplug_slot *hotplug_slot)
67{
68 return container_of(hotplug_slot, struct slot, hotplug_slot);
Alex Chiangd6c479e2008-10-20 17:41:17 -060069}
70
Bjorn Helgaasf39d5b72013-04-12 12:02:59 -060071int cpci_hp_register_controller(struct cpci_hp_controller *controller);
72int cpci_hp_unregister_controller(struct cpci_hp_controller *controller);
73int cpci_hp_register_bus(struct pci_bus *bus, u8 first, u8 last);
74int cpci_hp_unregister_bus(struct pci_bus *bus);
75int cpci_hp_start(void);
76int cpci_hp_stop(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070077
78/*
79 * Internal function prototypes, these functions should not be used by
80 * board/chassis drivers.
81 */
Bjorn Helgaasf39d5b72013-04-12 12:02:59 -060082u8 cpci_get_attention_status(struct slot *slot);
83u8 cpci_get_latch_status(struct slot *slot);
84u8 cpci_get_adapter_status(struct slot *slot);
Ryan Desfosses3c78bc62014-04-18 20:13:49 -040085u16 cpci_get_hs_csr(struct slot *slot);
Bjorn Helgaasf39d5b72013-04-12 12:02:59 -060086int cpci_set_attention_status(struct slot *slot, int status);
Ryan Desfosses3c78bc62014-04-18 20:13:49 -040087int cpci_check_and_clear_ins(struct slot *slot);
88int cpci_check_ext(struct slot *slot);
89int cpci_clear_ext(struct slot *slot);
90int cpci_led_on(struct slot *slot);
91int cpci_led_off(struct slot *slot);
Bjorn Helgaasf39d5b72013-04-12 12:02:59 -060092int cpci_configure_slot(struct slot *slot);
93int cpci_unconfigure_slot(struct slot *slot);
Linus Torvalds1da177e2005-04-16 15:20:36 -070094
Bjorn Helgaasc3139ba2013-04-15 10:44:18 -060095#ifdef CONFIG_HOTPLUG_PCI_CPCI
96int cpci_hotplug_init(int debug);
Bjorn Helgaasc3139ba2013-04-15 10:44:18 -060097#else
98static inline int cpci_hotplug_init(int debug) { return 0; }
Bjorn Helgaasc3139ba2013-04-15 10:44:18 -060099#endif
100
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101#endif /* _CPCI_HOTPLUG_H */