aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/hotplug/pciehp.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pci/hotplug/pciehp.h')
-rw-r--r--drivers/pci/hotplug/pciehp.h107
1 files changed, 29 insertions, 78 deletions
diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h
index 36faa9a8e18f..3070f77eb56a 100644
--- a/drivers/pci/hotplug/pciehp.h
+++ b/drivers/pci/hotplug/pciehp.h
@@ -72,15 +72,9 @@ do { \
72 72
73#define SLOT_NAME_SIZE 10 73#define SLOT_NAME_SIZE 10
74struct slot { 74struct slot {
75 u8 bus;
76 u8 device;
77 u8 state; 75 u8 state;
78 u8 hp_slot;
79 u32 number;
80 struct controller *ctrl; 76 struct controller *ctrl;
81 struct hpc_ops *hpc_ops;
82 struct hotplug_slot *hotplug_slot; 77 struct hotplug_slot *hotplug_slot;
83 struct list_head slot_list;
84 struct delayed_work work; /* work for button event */ 78 struct delayed_work work; /* work for button event */
85 struct mutex lock; 79 struct mutex lock;
86}; 80};
@@ -92,18 +86,10 @@ struct event_info {
92}; 86};
93 87
94struct controller { 88struct controller {
95 struct mutex crit_sect; /* critical section mutex */
96 struct mutex ctrl_lock; /* controller lock */ 89 struct mutex ctrl_lock; /* controller lock */
97 int num_slots; /* Number of slots on ctlr */
98 int slot_num_inc; /* 1 or -1 */
99 struct pci_dev *pci_dev;
100 struct pcie_device *pcie; /* PCI Express port service */ 90 struct pcie_device *pcie; /* PCI Express port service */
101 struct list_head slot_list; 91 struct slot *slot;
102 struct hpc_ops *hpc_ops;
103 wait_queue_head_t queue; /* sleep & wake process */ 92 wait_queue_head_t queue; /* sleep & wake process */
104 u8 slot_device_offset;
105 u32 first_slot; /* First physical slot number */ /* PCIE only has 1 slot */
106 u8 slot_bus; /* Bus where the slots handled by this controller sit */
107 u32 slot_cap; 93 u32 slot_cap;
108 u8 cap_base; 94 u8 cap_base;
109 struct timer_list poll_timer; 95 struct timer_list poll_timer;
@@ -131,40 +117,20 @@ struct controller {
131#define POWERON_STATE 3 117#define POWERON_STATE 3
132#define POWEROFF_STATE 4 118#define POWEROFF_STATE 4
133 119
134/* Error messages */ 120#define ATTN_BUTTN(ctrl) ((ctrl)->slot_cap & PCI_EXP_SLTCAP_ABP)
135#define INTERLOCK_OPEN 0x00000002 121#define POWER_CTRL(ctrl) ((ctrl)->slot_cap & PCI_EXP_SLTCAP_PCP)
136#define ADD_NOT_SUPPORTED 0x00000003 122#define MRL_SENS(ctrl) ((ctrl)->slot_cap & PCI_EXP_SLTCAP_MRLSP)
137#define CARD_FUNCTIONING 0x00000005 123#define ATTN_LED(ctrl) ((ctrl)->slot_cap & PCI_EXP_SLTCAP_AIP)
138#define ADAPTER_NOT_SAME 0x00000006 124#define PWR_LED(ctrl) ((ctrl)->slot_cap & PCI_EXP_SLTCAP_PIP)
139#define NO_ADAPTER_PRESENT 0x00000009 125#define HP_SUPR_RM(ctrl) ((ctrl)->slot_cap & PCI_EXP_SLTCAP_HPS)
140#define NOT_ENOUGH_RESOURCES 0x0000000B 126#define EMI(ctrl) ((ctrl)->slot_cap & PCI_EXP_SLTCAP_EIP)
141#define DEVICE_TYPE_NOT_SUPPORTED 0x0000000C 127#define NO_CMD_CMPL(ctrl) ((ctrl)->slot_cap & PCI_EXP_SLTCAP_NCCS)
142#define WRONG_BUS_FREQUENCY 0x0000000D 128#define PSN(ctrl) ((ctrl)->slot_cap >> 19)
143#define POWER_FAILURE 0x0000000E
144
145/* Field definitions in Slot Capabilities Register */
146#define ATTN_BUTTN_PRSN 0x00000001
147#define PWR_CTRL_PRSN 0x00000002
148#define MRL_SENS_PRSN 0x00000004
149#define ATTN_LED_PRSN 0x00000008
150#define PWR_LED_PRSN 0x00000010
151#define HP_SUPR_RM_SUP 0x00000020
152#define EMI_PRSN 0x00020000
153#define NO_CMD_CMPL_SUP 0x00040000
154
155#define ATTN_BUTTN(ctrl) ((ctrl)->slot_cap & ATTN_BUTTN_PRSN)
156#define POWER_CTRL(ctrl) ((ctrl)->slot_cap & PWR_CTRL_PRSN)
157#define MRL_SENS(ctrl) ((ctrl)->slot_cap & MRL_SENS_PRSN)
158#define ATTN_LED(ctrl) ((ctrl)->slot_cap & ATTN_LED_PRSN)
159#define PWR_LED(ctrl) ((ctrl)->slot_cap & PWR_LED_PRSN)
160#define HP_SUPR_RM(ctrl) ((ctrl)->slot_cap & HP_SUPR_RM_SUP)
161#define EMI(ctrl) ((ctrl)->slot_cap & EMI_PRSN)
162#define NO_CMD_CMPL(ctrl) ((ctrl)->slot_cap & NO_CMD_CMPL_SUP)
163 129
164extern int pciehp_sysfs_enable_slot(struct slot *slot); 130extern int pciehp_sysfs_enable_slot(struct slot *slot);
165extern int pciehp_sysfs_disable_slot(struct slot *slot); 131extern int pciehp_sysfs_disable_slot(struct slot *slot);
166extern u8 pciehp_handle_attention_button(struct slot *p_slot); 132extern u8 pciehp_handle_attention_button(struct slot *p_slot);
167 extern u8 pciehp_handle_switch_change(struct slot *p_slot); 133extern u8 pciehp_handle_switch_change(struct slot *p_slot);
168extern u8 pciehp_handle_presence_change(struct slot *p_slot); 134extern u8 pciehp_handle_presence_change(struct slot *p_slot);
169extern u8 pciehp_handle_power_fault(struct slot *p_slot); 135extern u8 pciehp_handle_power_fault(struct slot *p_slot);
170extern int pciehp_configure_device(struct slot *p_slot); 136extern int pciehp_configure_device(struct slot *p_slot);
@@ -175,45 +141,30 @@ int pcie_init_notification(struct controller *ctrl);
175int pciehp_enable_slot(struct slot *p_slot); 141int pciehp_enable_slot(struct slot *p_slot);
176int pciehp_disable_slot(struct slot *p_slot); 142int pciehp_disable_slot(struct slot *p_slot);
177int pcie_enable_notification(struct controller *ctrl); 143int pcie_enable_notification(struct controller *ctrl);
144int pciehp_power_on_slot(struct slot *slot);
145int pciehp_power_off_slot(struct slot *slot);
146int pciehp_get_power_status(struct slot *slot, u8 *status);
147int pciehp_get_attention_status(struct slot *slot, u8 *status);
148
149int pciehp_set_attention_status(struct slot *slot, u8 status);
150int pciehp_get_latch_status(struct slot *slot, u8 *status);
151int pciehp_get_adapter_status(struct slot *slot, u8 *status);
152int pciehp_get_max_link_speed(struct slot *slot, enum pci_bus_speed *speed);
153int pciehp_get_max_link_width(struct slot *slot, enum pcie_link_width *val);
154int pciehp_get_cur_link_speed(struct slot *slot, enum pci_bus_speed *speed);
155int pciehp_get_cur_link_width(struct slot *slot, enum pcie_link_width *val);
156int pciehp_query_power_fault(struct slot *slot);
157void pciehp_green_led_on(struct slot *slot);
158void pciehp_green_led_off(struct slot *slot);
159void pciehp_green_led_blink(struct slot *slot);
160int pciehp_check_link_status(struct controller *ctrl);
161void pciehp_release_ctrl(struct controller *ctrl);
178 162
179static inline const char *slot_name(struct slot *slot) 163static inline const char *slot_name(struct slot *slot)
180{ 164{
181 return hotplug_slot_name(slot->hotplug_slot); 165 return hotplug_slot_name(slot->hotplug_slot);
182} 166}
183 167
184static inline struct slot *pciehp_find_slot(struct controller *ctrl, u8 device)
185{
186 struct slot *slot;
187
188 list_for_each_entry(slot, &ctrl->slot_list, slot_list) {
189 if (slot->device == device)
190 return slot;
191 }
192
193 ctrl_err(ctrl, "Slot (device=0x%02x) not found\n", device);
194 return NULL;
195}
196
197struct hpc_ops {
198 int (*power_on_slot)(struct slot *slot);
199 int (*power_off_slot)(struct slot *slot);
200 int (*get_power_status)(struct slot *slot, u8 *status);
201 int (*get_attention_status)(struct slot *slot, u8 *status);
202 int (*set_attention_status)(struct slot *slot, u8 status);
203 int (*get_latch_status)(struct slot *slot, u8 *status);
204 int (*get_adapter_status)(struct slot *slot, u8 *status);
205 int (*get_max_bus_speed)(struct slot *slot, enum pci_bus_speed *speed);
206 int (*get_cur_bus_speed)(struct slot *slot, enum pci_bus_speed *speed);
207 int (*get_max_lnk_width)(struct slot *slot, enum pcie_link_width *val);
208 int (*get_cur_lnk_width)(struct slot *slot, enum pcie_link_width *val);
209 int (*query_power_fault)(struct slot *slot);
210 void (*green_led_on)(struct slot *slot);
211 void (*green_led_off)(struct slot *slot);
212 void (*green_led_blink)(struct slot *slot);
213 void (*release_ctlr)(struct controller *ctrl);
214 int (*check_lnk_status)(struct controller *ctrl);
215};
216
217#ifdef CONFIG_ACPI 168#ifdef CONFIG_ACPI
218#include <acpi/acpi.h> 169#include <acpi/acpi.h>
219#include <acpi/acpi_bus.h> 170#include <acpi/acpi_bus.h>