0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef _PCIEHP_H
0016 #define _PCIEHP_H
0017
0018 #include <linux/types.h>
0019 #include <linux/pci.h>
0020 #include <linux/pci_hotplug.h>
0021 #include <linux/delay.h>
0022 #include <linux/mutex.h>
0023 #include <linux/rwsem.h>
0024 #include <linux/workqueue.h>
0025
0026 #include "../pcie/portdrv.h"
0027
0028 extern bool pciehp_poll_mode;
0029 extern int pciehp_poll_time;
0030
0031
0032
0033
0034
0035 #define ctrl_dbg(ctrl, format, arg...) \
0036 pci_dbg(ctrl->pcie->port, format, ## arg)
0037 #define ctrl_err(ctrl, format, arg...) \
0038 pci_err(ctrl->pcie->port, format, ## arg)
0039 #define ctrl_info(ctrl, format, arg...) \
0040 pci_info(ctrl->pcie->port, format, ## arg)
0041 #define ctrl_warn(ctrl, format, arg...) \
0042 pci_warn(ctrl->pcie->port, format, ## arg)
0043
0044 #define SLOT_NAME_SIZE 10
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088 struct controller {
0089 struct pcie_device *pcie;
0090
0091 u32 slot_cap;
0092 unsigned int inband_presence_disabled:1;
0093
0094 u16 slot_ctrl;
0095 struct mutex ctrl_lock;
0096 unsigned long cmd_started;
0097 unsigned int cmd_busy:1;
0098 wait_queue_head_t queue;
0099
0100 atomic_t pending_events;
0101 unsigned int notification_enabled:1;
0102 unsigned int power_fault_detected;
0103 struct task_struct *poll_thread;
0104
0105 u8 state;
0106 struct mutex state_lock;
0107 struct delayed_work button_work;
0108
0109 struct hotplug_slot hotplug_slot;
0110 struct rw_semaphore reset_lock;
0111 unsigned int depth;
0112 unsigned int ist_running;
0113 int request_result;
0114 wait_queue_head_t requester;
0115 };
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129 #define OFF_STATE 0
0130 #define BLINKINGON_STATE 1
0131 #define BLINKINGOFF_STATE 2
0132 #define POWERON_STATE 3
0133 #define POWEROFF_STATE 4
0134 #define ON_STATE 5
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149 #define DISABLE_SLOT (1 << 16)
0150 #define RERUN_ISR (1 << 17)
0151
0152 #define ATTN_BUTTN(ctrl) ((ctrl)->slot_cap & PCI_EXP_SLTCAP_ABP)
0153 #define POWER_CTRL(ctrl) ((ctrl)->slot_cap & PCI_EXP_SLTCAP_PCP)
0154 #define MRL_SENS(ctrl) ((ctrl)->slot_cap & PCI_EXP_SLTCAP_MRLSP)
0155 #define ATTN_LED(ctrl) ((ctrl)->slot_cap & PCI_EXP_SLTCAP_AIP)
0156 #define PWR_LED(ctrl) ((ctrl)->slot_cap & PCI_EXP_SLTCAP_PIP)
0157 #define NO_CMD_CMPL(ctrl) ((ctrl)->slot_cap & PCI_EXP_SLTCAP_NCCS)
0158 #define PSN(ctrl) (((ctrl)->slot_cap & PCI_EXP_SLTCAP_PSN) >> 19)
0159
0160 void pciehp_request(struct controller *ctrl, int action);
0161 void pciehp_handle_button_press(struct controller *ctrl);
0162 void pciehp_handle_disable_request(struct controller *ctrl);
0163 void pciehp_handle_presence_or_link_change(struct controller *ctrl, u32 events);
0164 int pciehp_configure_device(struct controller *ctrl);
0165 void pciehp_unconfigure_device(struct controller *ctrl, bool presence);
0166 void pciehp_queue_pushbutton_work(struct work_struct *work);
0167 struct controller *pcie_init(struct pcie_device *dev);
0168 int pcie_init_notification(struct controller *ctrl);
0169 void pcie_shutdown_notification(struct controller *ctrl);
0170 void pcie_clear_hotplug_events(struct controller *ctrl);
0171 void pcie_enable_interrupt(struct controller *ctrl);
0172 void pcie_disable_interrupt(struct controller *ctrl);
0173 int pciehp_power_on_slot(struct controller *ctrl);
0174 void pciehp_power_off_slot(struct controller *ctrl);
0175 void pciehp_get_power_status(struct controller *ctrl, u8 *status);
0176
0177 #define INDICATOR_NOOP -1
0178 void pciehp_set_indicators(struct controller *ctrl, int pwr, int attn);
0179
0180 void pciehp_get_latch_status(struct controller *ctrl, u8 *status);
0181 int pciehp_query_power_fault(struct controller *ctrl);
0182 int pciehp_card_present(struct controller *ctrl);
0183 int pciehp_card_present_or_link_active(struct controller *ctrl);
0184 int pciehp_check_link_status(struct controller *ctrl);
0185 int pciehp_check_link_active(struct controller *ctrl);
0186 void pciehp_release_ctrl(struct controller *ctrl);
0187
0188 int pciehp_sysfs_enable_slot(struct hotplug_slot *hotplug_slot);
0189 int pciehp_sysfs_disable_slot(struct hotplug_slot *hotplug_slot);
0190 int pciehp_reset_slot(struct hotplug_slot *hotplug_slot, bool probe);
0191 int pciehp_get_attention_status(struct hotplug_slot *hotplug_slot, u8 *status);
0192 int pciehp_set_raw_indicator_status(struct hotplug_slot *h_slot, u8 status);
0193 int pciehp_get_raw_indicator_status(struct hotplug_slot *h_slot, u8 *status);
0194
0195 int pciehp_slot_reset(struct pcie_device *dev);
0196
0197 static inline const char *slot_name(struct controller *ctrl)
0198 {
0199 return hotplug_slot_name(&ctrl->hotplug_slot);
0200 }
0201
0202 static inline struct controller *to_ctrl(struct hotplug_slot *hotplug_slot)
0203 {
0204 return container_of(hotplug_slot, struct controller, hotplug_slot);
0205 }
0206
0207 #endif