Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * CompactPCI Hot Plug Core Functions |
| 3 | * |
| 4 | * Copyright (C) 2002 SOMA Networks, Inc. |
| 5 | * Copyright (C) 2001 Greg Kroah-Hartman (greg@kroah.com) |
| 6 | * Copyright (C) 2001 IBM Corp. |
| 7 | * |
| 8 | * All rights reserved. |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU General Public License as published by |
| 12 | * the Free Software Foundation; either version 2 of the License, or (at |
| 13 | * your option) any later version. |
| 14 | * |
| 15 | * This program is distributed in the hope that it will be useful, but |
| 16 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or |
| 18 | * NON INFRINGEMENT. See the GNU General Public License for more |
| 19 | * details. |
| 20 | * |
| 21 | * You should have received a copy of the GNU General Public License |
| 22 | * along with this program; if not, write to the Free Software |
| 23 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 24 | * |
| 25 | * Send feedback to <scottm@somanetworks.com> |
| 26 | */ |
| 27 | |
| 28 | #ifndef _CPCI_HOTPLUG_H |
| 29 | #define _CPCI_HOTPLUG_H |
| 30 | |
| 31 | #include <linux/types.h> |
| 32 | #include <linux/pci.h> |
Alex Chiang | d6c479e | 2008-10-20 17:41:17 -0600 | [diff] [blame] | 33 | #include <linux/pci_hotplug.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | |
Scott Murray | 43b7d7c | 2005-05-09 17:31:50 -0400 | [diff] [blame] | 35 | /* PICMG 2.1 R2.0 HS CSR bits: */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | #define HS_CSR_INS 0x0080 |
| 37 | #define HS_CSR_EXT 0x0040 |
| 38 | #define HS_CSR_PI 0x0030 |
| 39 | #define HS_CSR_LOO 0x0008 |
| 40 | #define HS_CSR_PIE 0x0004 |
| 41 | #define HS_CSR_EIM 0x0002 |
| 42 | #define HS_CSR_DHA 0x0001 |
| 43 | |
| 44 | struct slot { |
| 45 | u8 number; |
| 46 | unsigned int devfn; |
| 47 | struct pci_bus *bus; |
| 48 | struct pci_dev *dev; |
| 49 | unsigned int extracting; |
| 50 | struct hotplug_slot *hotplug_slot; |
| 51 | struct list_head slot_list; |
| 52 | }; |
| 53 | |
| 54 | struct cpci_hp_controller_ops { |
Bogicevic Sasa | ff3ce48 | 2015-12-27 13:21:11 -0800 | [diff] [blame] | 55 | int (*query_enum)(void); |
| 56 | int (*enable_irq)(void); |
| 57 | int (*disable_irq)(void); |
| 58 | int (*check_irq)(void *dev_id); |
| 59 | int (*hardware_test)(struct slot *slot, u32 value); |
| 60 | u8 (*get_power)(struct slot *slot); |
| 61 | int (*set_power)(struct slot *slot, int value); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | }; |
| 63 | |
| 64 | struct cpci_hp_controller { |
| 65 | unsigned int irq; |
| 66 | unsigned long irq_flags; |
| 67 | char *devname; |
| 68 | void *dev_id; |
| 69 | char *name; |
| 70 | struct cpci_hp_controller_ops *ops; |
| 71 | }; |
| 72 | |
Alex Chiang | d6c479e | 2008-10-20 17:41:17 -0600 | [diff] [blame] | 73 | static inline const char *slot_name(struct slot *slot) |
| 74 | { |
| 75 | return hotplug_slot_name(slot->hotplug_slot); |
| 76 | } |
| 77 | |
Bjorn Helgaas | f39d5b7 | 2013-04-12 12:02:59 -0600 | [diff] [blame] | 78 | int cpci_hp_register_controller(struct cpci_hp_controller *controller); |
| 79 | int cpci_hp_unregister_controller(struct cpci_hp_controller *controller); |
| 80 | int cpci_hp_register_bus(struct pci_bus *bus, u8 first, u8 last); |
| 81 | int cpci_hp_unregister_bus(struct pci_bus *bus); |
| 82 | int cpci_hp_start(void); |
| 83 | int cpci_hp_stop(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | |
| 85 | /* |
| 86 | * Internal function prototypes, these functions should not be used by |
| 87 | * board/chassis drivers. |
| 88 | */ |
Bjorn Helgaas | f39d5b7 | 2013-04-12 12:02:59 -0600 | [diff] [blame] | 89 | u8 cpci_get_attention_status(struct slot *slot); |
| 90 | u8 cpci_get_latch_status(struct slot *slot); |
| 91 | u8 cpci_get_adapter_status(struct slot *slot); |
Ryan Desfosses | 3c78bc6 | 2014-04-18 20:13:49 -0400 | [diff] [blame] | 92 | u16 cpci_get_hs_csr(struct slot *slot); |
Bjorn Helgaas | f39d5b7 | 2013-04-12 12:02:59 -0600 | [diff] [blame] | 93 | int cpci_set_attention_status(struct slot *slot, int status); |
Ryan Desfosses | 3c78bc6 | 2014-04-18 20:13:49 -0400 | [diff] [blame] | 94 | int cpci_check_and_clear_ins(struct slot *slot); |
| 95 | int cpci_check_ext(struct slot *slot); |
| 96 | int cpci_clear_ext(struct slot *slot); |
| 97 | int cpci_led_on(struct slot *slot); |
| 98 | int cpci_led_off(struct slot *slot); |
Bjorn Helgaas | f39d5b7 | 2013-04-12 12:02:59 -0600 | [diff] [blame] | 99 | int cpci_configure_slot(struct slot *slot); |
| 100 | int cpci_unconfigure_slot(struct slot *slot); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | |
Bjorn Helgaas | c3139ba | 2013-04-15 10:44:18 -0600 | [diff] [blame] | 102 | #ifdef CONFIG_HOTPLUG_PCI_CPCI |
| 103 | int cpci_hotplug_init(int debug); |
Bjorn Helgaas | c3139ba | 2013-04-15 10:44:18 -0600 | [diff] [blame] | 104 | #else |
| 105 | static inline int cpci_hotplug_init(int debug) { return 0; } |
Bjorn Helgaas | c3139ba | 2013-04-15 10:44:18 -0600 | [diff] [blame] | 106 | #endif |
| 107 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | #endif /* _CPCI_HOTPLUG_H */ |