Bjorn Helgaas | 736759e | 2018-01-26 14:22:04 -0600 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /* |
| 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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | * 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 Chiang | d6c479e | 2008-10-20 17:41:17 -0600 | [diff] [blame] | 19 | #include <linux/pci_hotplug.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | |
Scott Murray | 43b7d7c | 2005-05-09 17:31:50 -0400 | [diff] [blame] | 21 | /* PICMG 2.1 R2.0 HS CSR bits: */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | #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 | |
| 30 | struct slot { |
| 31 | u8 number; |
| 32 | unsigned int devfn; |
| 33 | struct pci_bus *bus; |
| 34 | struct pci_dev *dev; |
Lukas Wunner | a7da216 | 2018-09-08 09:59:01 +0200 | [diff] [blame] | 35 | unsigned int latch_status:1; |
| 36 | unsigned int adapter_status:1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | unsigned int extracting; |
Lukas Wunner | 125450f | 2018-09-08 09:59:01 +0200 | [diff] [blame] | 38 | struct hotplug_slot hotplug_slot; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | struct list_head slot_list; |
| 40 | }; |
| 41 | |
| 42 | struct cpci_hp_controller_ops { |
Bogicevic Sasa | ff3ce48 | 2015-12-27 13:21:11 -0800 | [diff] [blame] | 43 | 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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | }; |
| 51 | |
| 52 | struct 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 Chiang | d6c479e | 2008-10-20 17:41:17 -0600 | [diff] [blame] | 61 | static inline const char *slot_name(struct slot *slot) |
| 62 | { |
Lukas Wunner | 125450f | 2018-09-08 09:59:01 +0200 | [diff] [blame] | 63 | return hotplug_slot_name(&slot->hotplug_slot); |
| 64 | } |
| 65 | |
| 66 | static inline struct slot *to_slot(struct hotplug_slot *hotplug_slot) |
| 67 | { |
| 68 | return container_of(hotplug_slot, struct slot, hotplug_slot); |
Alex Chiang | d6c479e | 2008-10-20 17:41:17 -0600 | [diff] [blame] | 69 | } |
| 70 | |
Bjorn Helgaas | f39d5b7 | 2013-04-12 12:02:59 -0600 | [diff] [blame] | 71 | int cpci_hp_register_controller(struct cpci_hp_controller *controller); |
| 72 | int cpci_hp_unregister_controller(struct cpci_hp_controller *controller); |
| 73 | int cpci_hp_register_bus(struct pci_bus *bus, u8 first, u8 last); |
| 74 | int cpci_hp_unregister_bus(struct pci_bus *bus); |
| 75 | int cpci_hp_start(void); |
| 76 | int cpci_hp_stop(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | |
Krzysztof WilczyĆski | 6d71cc4 | 2021-07-01 18:43:06 +0000 | [diff] [blame] | 78 | /* Global variables */ |
| 79 | extern int cpci_debug; |
| 80 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | /* |
| 82 | * Internal function prototypes, these functions should not be used by |
| 83 | * board/chassis drivers. |
| 84 | */ |
Bjorn Helgaas | f39d5b7 | 2013-04-12 12:02:59 -0600 | [diff] [blame] | 85 | u8 cpci_get_attention_status(struct slot *slot); |
| 86 | u8 cpci_get_latch_status(struct slot *slot); |
| 87 | u8 cpci_get_adapter_status(struct slot *slot); |
Ryan Desfosses | 3c78bc6 | 2014-04-18 20:13:49 -0400 | [diff] [blame] | 88 | u16 cpci_get_hs_csr(struct slot *slot); |
Bjorn Helgaas | f39d5b7 | 2013-04-12 12:02:59 -0600 | [diff] [blame] | 89 | int cpci_set_attention_status(struct slot *slot, int status); |
Ryan Desfosses | 3c78bc6 | 2014-04-18 20:13:49 -0400 | [diff] [blame] | 90 | int cpci_check_and_clear_ins(struct slot *slot); |
| 91 | int cpci_check_ext(struct slot *slot); |
| 92 | int cpci_clear_ext(struct slot *slot); |
| 93 | int cpci_led_on(struct slot *slot); |
| 94 | int cpci_led_off(struct slot *slot); |
Bjorn Helgaas | f39d5b7 | 2013-04-12 12:02:59 -0600 | [diff] [blame] | 95 | int cpci_configure_slot(struct slot *slot); |
| 96 | int cpci_unconfigure_slot(struct slot *slot); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | |
Bjorn Helgaas | c3139ba | 2013-04-15 10:44:18 -0600 | [diff] [blame] | 98 | #ifdef CONFIG_HOTPLUG_PCI_CPCI |
| 99 | int cpci_hotplug_init(int debug); |
Bjorn Helgaas | c3139ba | 2013-04-15 10:44:18 -0600 | [diff] [blame] | 100 | #else |
| 101 | static inline int cpci_hotplug_init(int debug) { return 0; } |
Bjorn Helgaas | c3139ba | 2013-04-15 10:44:18 -0600 | [diff] [blame] | 102 | #endif |
| 103 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | #endif /* _CPCI_HOTPLUG_H */ |