aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/hotplug/shpchp.h
diff options
context:
space:
mode:
authorKenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>2006-12-16 18:25:57 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2006-12-20 13:54:44 -0500
commit8352e04eb427db0ca8ebb9a8547971d433627cad (patch)
tree07c9a8a0f7c9e04449dd43247b91c3b360eb48aa /drivers/pci/hotplug/shpchp.h
parent6f39be2e05cc6e66481f1395264297f06bef1e21 (diff)
shpchp: cleanup shpchp.h
This patch cleans up shpchp.h. Signed-off-by: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com> Signed-off-by: Kristen Carlson Accardi <kristen.c.accardi@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/pci/hotplug/shpchp.h')
-rw-r--r--drivers/pci/hotplug/shpchp.h190
1 files changed, 60 insertions, 130 deletions
diff --git a/drivers/pci/hotplug/shpchp.h b/drivers/pci/hotplug/shpchp.h
index e21714982476..3ca6a4f574b3 100644
--- a/drivers/pci/hotplug/shpchp.h
+++ b/drivers/pci/hotplug/shpchp.h
@@ -47,11 +47,17 @@ extern int shpchp_poll_time;
47extern int shpchp_debug; 47extern int shpchp_debug;
48extern struct workqueue_struct *shpchp_wq; 48extern struct workqueue_struct *shpchp_wq;
49 49
50/*#define dbg(format, arg...) do { if (shpchp_debug) printk(KERN_DEBUG "%s: " format, MY_NAME , ## arg); } while (0)*/ 50#define dbg(format, arg...) \
51#define dbg(format, arg...) do { if (shpchp_debug) printk("%s: " format, MY_NAME , ## arg); } while (0) 51 do { \
52#define err(format, arg...) printk(KERN_ERR "%s: " format, MY_NAME , ## arg) 52 if (shpchp_debug) \
53#define info(format, arg...) printk(KERN_INFO "%s: " format, MY_NAME , ## arg) 53 printk("%s: " format, MY_NAME , ## arg); \
54#define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME , ## arg) 54 } while (0)
55#define err(format, arg...) \
56 printk(KERN_ERR "%s: " format, MY_NAME , ## arg)
57#define info(format, arg...) \
58 printk(KERN_INFO "%s: " format, MY_NAME , ## arg)
59#define warn(format, arg...) \
60 printk(KERN_WARNING "%s: " format, MY_NAME , ## arg)
55 61
56#define SLOT_NAME_SIZE 10 62#define SLOT_NAME_SIZE 10
57struct slot { 63struct slot {
@@ -99,13 +105,11 @@ struct controller {
99 struct timer_list poll_timer; 105 struct timer_list poll_timer;
100}; 106};
101 107
102
103/* Define AMD SHPC ID */ 108/* Define AMD SHPC ID */
104#define PCI_DEVICE_ID_AMD_GOLAM_7450 0x7450 109#define PCI_DEVICE_ID_AMD_GOLAM_7450 0x7450
105#define PCI_DEVICE_ID_AMD_POGO_7458 0x7458 110#define PCI_DEVICE_ID_AMD_POGO_7458 0x7458
106 111
107/* AMD PCIX bridge registers */ 112/* AMD PCIX bridge registers */
108
109#define PCIX_MEM_BASE_LIMIT_OFFSET 0x1C 113#define PCIX_MEM_BASE_LIMIT_OFFSET 0x1C
110#define PCIX_MISCII_OFFSET 0x48 114#define PCIX_MISCII_OFFSET 0x48
111#define PCIX_MISC_BRIDGE_ERRORS_OFFSET 0x80 115#define PCIX_MISC_BRIDGE_ERRORS_OFFSET 0x80
@@ -140,8 +144,6 @@ struct controller {
140#define POWERON_STATE 3 144#define POWERON_STATE 3
141#define POWEROFF_STATE 4 145#define POWEROFF_STATE 4
142 146
143#define PCI_TO_PCI_BRIDGE_CLASS 0x00060400
144
145/* Error messages */ 147/* Error messages */
146#define INTERLOCK_OPEN 0x00000002 148#define INTERLOCK_OPEN 0x00000002
147#define ADD_NOT_SUPPORTED 0x00000003 149#define ADD_NOT_SUPPORTED 0x00000003
@@ -153,50 +155,32 @@ struct controller {
153#define WRONG_BUS_FREQUENCY 0x0000000D 155#define WRONG_BUS_FREQUENCY 0x0000000D
154#define POWER_FAILURE 0x0000000E 156#define POWER_FAILURE 0x0000000E
155 157
156#define REMOVE_NOT_SUPPORTED 0x00000003
157
158#define DISABLE_CARD 1
159
160/*
161 * error Messages
162 */
163#define msg_initialization_err "Initialization failure, error=%d\n"
164#define msg_button_on "PCI slot #%s - powering on due to button press.\n"
165#define msg_button_off "PCI slot #%s - powering off due to button press.\n"
166#define msg_button_cancel "PCI slot #%s - action canceled due to button press.\n"
167
168/* sysfs functions for the hotplug controller info */
169extern int __must_check shpchp_create_ctrl_files(struct controller *ctrl); 158extern int __must_check shpchp_create_ctrl_files(struct controller *ctrl);
170 159extern void shpchp_remove_ctrl_files(struct controller *ctrl);
171extern int shpchp_sysfs_enable_slot(struct slot *slot); 160extern int shpchp_sysfs_enable_slot(struct slot *slot);
172extern int shpchp_sysfs_disable_slot(struct slot *slot); 161extern int shpchp_sysfs_disable_slot(struct slot *slot);
173
174extern u8 shpchp_handle_attention_button(u8 hp_slot, struct controller *ctrl); 162extern u8 shpchp_handle_attention_button(u8 hp_slot, struct controller *ctrl);
175extern u8 shpchp_handle_switch_change(u8 hp_slot, struct controller *ctrl); 163extern u8 shpchp_handle_switch_change(u8 hp_slot, struct controller *ctrl);
176extern u8 shpchp_handle_presence_change(u8 hp_slot, struct controller *ctrl); 164extern u8 shpchp_handle_presence_change(u8 hp_slot, struct controller *ctrl);
177extern u8 shpchp_handle_power_fault(u8 hp_slot, struct controller *ctrl); 165extern u8 shpchp_handle_power_fault(u8 hp_slot, struct controller *ctrl);
178 166extern int shpchp_configure_device(struct slot *p_slot);
179/* pci functions */ 167extern int shpchp_unconfigure_device(struct slot *p_slot);
180extern int shpchp_save_config(struct controller *ctrl, int busnumber, int num_ctlr_slots, int first_device_num); 168extern void cleanup_slots(struct controller *ctrl);
181extern int shpchp_configure_device(struct slot *p_slot); 169extern void queue_pushbutton_work(struct work_struct *work);
182extern int shpchp_unconfigure_device(struct slot *p_slot); 170extern int shpc_init( struct controller *ctrl, struct pci_dev *pdev);
183extern void shpchp_remove_ctrl_files(struct controller *ctrl);
184extern void cleanup_slots(struct controller *ctrl);
185extern void queue_pushbutton_work(struct work_struct *work);
186
187 171
188#ifdef CONFIG_ACPI 172#ifdef CONFIG_ACPI
189static inline int get_hp_params_from_firmware(struct pci_dev *dev, 173static inline int get_hp_params_from_firmware(struct pci_dev *dev,
190 struct hotplug_params *hpp) 174 struct hotplug_params *hpp)
191{ 175{
192 if (ACPI_FAILURE(acpi_get_hp_params_from_firmware(dev->bus, hpp))) 176 if (ACPI_FAILURE(acpi_get_hp_params_from_firmware(dev->bus, hpp)))
193 return -ENODEV; 177 return -ENODEV;
194 return 0; 178 return 0;
195} 179}
196#define get_hp_hw_control_from_firmware(pdev) \ 180#define get_hp_hw_control_from_firmware(pdev) \
197 do { \ 181 do { \
198 if (DEVICE_ACPI_HANDLE(&(pdev->dev))) \ 182 if (DEVICE_ACPI_HANDLE(&(pdev->dev))) \
199 acpi_run_oshp(DEVICE_ACPI_HANDLE(&(pdev->dev))); \ 183 acpi_run_oshp(DEVICE_ACPI_HANDLE(&(pdev->dev)));\
200 } while (0) 184 } while (0)
201#else 185#else
202#define get_hp_params_from_firmware(dev, hpp) (-ENODEV) 186#define get_hp_params_from_firmware(dev, hpp) (-ENODEV)
@@ -217,90 +201,40 @@ struct ctrl_reg {
217 volatile u32 serr_loc; 201 volatile u32 serr_loc;
218 volatile u32 serr_intr_enable; 202 volatile u32 serr_intr_enable;
219 volatile u32 slot1; 203 volatile u32 slot1;
220 volatile u32 slot2;
221 volatile u32 slot3;
222 volatile u32 slot4;
223 volatile u32 slot5;
224 volatile u32 slot6;
225 volatile u32 slot7;
226 volatile u32 slot8;
227 volatile u32 slot9;
228 volatile u32 slot10;
229 volatile u32 slot11;
230 volatile u32 slot12;
231} __attribute__ ((packed)); 204} __attribute__ ((packed));
232 205
233/* offsets to the controller registers based on the above structure layout */ 206/* offsets to the controller registers based on the above structure layout */
234enum ctrl_offsets { 207enum ctrl_offsets {
235 BASE_OFFSET = offsetof(struct ctrl_reg, base_offset), 208 BASE_OFFSET = offsetof(struct ctrl_reg, base_offset),
236 SLOT_AVAIL1 = offsetof(struct ctrl_reg, slot_avail1), 209 SLOT_AVAIL1 = offsetof(struct ctrl_reg, slot_avail1),
237 SLOT_AVAIL2 = offsetof(struct ctrl_reg, slot_avail2), 210 SLOT_AVAIL2 = offsetof(struct ctrl_reg, slot_avail2),
238 SLOT_CONFIG = offsetof(struct ctrl_reg, slot_config), 211 SLOT_CONFIG = offsetof(struct ctrl_reg, slot_config),
239 SEC_BUS_CONFIG = offsetof(struct ctrl_reg, sec_bus_config), 212 SEC_BUS_CONFIG = offsetof(struct ctrl_reg, sec_bus_config),
240 MSI_CTRL = offsetof(struct ctrl_reg, msi_ctrl), 213 MSI_CTRL = offsetof(struct ctrl_reg, msi_ctrl),
241 PROG_INTERFACE = offsetof(struct ctrl_reg, prog_interface), 214 PROG_INTERFACE = offsetof(struct ctrl_reg, prog_interface),
242 CMD = offsetof(struct ctrl_reg, cmd), 215 CMD = offsetof(struct ctrl_reg, cmd),
243 CMD_STATUS = offsetof(struct ctrl_reg, cmd_status), 216 CMD_STATUS = offsetof(struct ctrl_reg, cmd_status),
244 INTR_LOC = offsetof(struct ctrl_reg, intr_loc), 217 INTR_LOC = offsetof(struct ctrl_reg, intr_loc),
245 SERR_LOC = offsetof(struct ctrl_reg, serr_loc), 218 SERR_LOC = offsetof(struct ctrl_reg, serr_loc),
246 SERR_INTR_ENABLE = offsetof(struct ctrl_reg, serr_intr_enable), 219 SERR_INTR_ENABLE = offsetof(struct ctrl_reg, serr_intr_enable),
247 SLOT1 = offsetof(struct ctrl_reg, slot1), 220 SLOT1 = offsetof(struct ctrl_reg, slot1),
248 SLOT2 = offsetof(struct ctrl_reg, slot2),
249 SLOT3 = offsetof(struct ctrl_reg, slot3),
250 SLOT4 = offsetof(struct ctrl_reg, slot4),
251 SLOT5 = offsetof(struct ctrl_reg, slot5),
252 SLOT6 = offsetof(struct ctrl_reg, slot6),
253 SLOT7 = offsetof(struct ctrl_reg, slot7),
254 SLOT8 = offsetof(struct ctrl_reg, slot8),
255 SLOT9 = offsetof(struct ctrl_reg, slot9),
256 SLOT10 = offsetof(struct ctrl_reg, slot10),
257 SLOT11 = offsetof(struct ctrl_reg, slot11),
258 SLOT12 = offsetof(struct ctrl_reg, slot12),
259}; 221};
260 222
261/* Inline functions to check the sanity of a pointer that is passed to us */ 223static inline struct slot *get_slot(struct hotplug_slot *hotplug_slot)
262static inline int slot_paranoia_check (struct slot *slot, const char *function)
263{
264 if (!slot) {
265 dbg("%s - slot == NULL", function);
266 return -1;
267 }
268 if (!slot->hotplug_slot) {
269 dbg("%s - slot->hotplug_slot == NULL!", function);
270 return -1;
271 }
272 return 0;
273}
274
275static inline struct slot *get_slot (struct hotplug_slot *hotplug_slot, const char *function)
276{ 224{
277 struct slot *slot; 225 return hotplug_slot->private;
278
279 if (!hotplug_slot) {
280 dbg("%s - hotplug_slot == NULL\n", function);
281 return NULL;
282 }
283
284 slot = (struct slot *)hotplug_slot->private;
285 if (slot_paranoia_check (slot, function))
286 return NULL;
287 return slot;
288} 226}
289 227
290static inline struct slot *shpchp_find_slot (struct controller *ctrl, u8 device) 228static inline struct slot *shpchp_find_slot(struct controller *ctrl, u8 device)
291{ 229{
292 struct slot *slot; 230 struct slot *slot;
293 231
294 if (!ctrl)
295 return NULL;
296
297 list_for_each_entry(slot, &ctrl->slot_list, slot_list) { 232 list_for_each_entry(slot, &ctrl->slot_list, slot_list) {
298 if (slot->device == device) 233 if (slot->device == device)
299 return slot; 234 return slot;
300 } 235 }
301 236
302 err("%s: slot (device=0x%x) not found\n", __FUNCTION__, device); 237 err("%s: slot (device=0x%x) not found\n", __FUNCTION__, device);
303
304 return NULL; 238 return NULL;
305} 239}
306 240
@@ -377,31 +311,27 @@ static inline void amd_pogo_errata_restore_misc_reg(struct slot *p_slot)
377 pci_write_config_dword(p_slot->ctrl->pci_dev, PCIX_MISCII_OFFSET, pcix_misc2_temp); 311 pci_write_config_dword(p_slot->ctrl->pci_dev, PCIX_MISCII_OFFSET, pcix_misc2_temp);
378} 312}
379 313
380int shpc_init( struct controller *ctrl, struct pci_dev *pdev);
381
382struct hpc_ops { 314struct hpc_ops {
383 int (*power_on_slot ) (struct slot *slot); 315 int (*power_on_slot)(struct slot *slot);
384 int (*slot_enable ) (struct slot *slot); 316 int (*slot_enable)(struct slot *slot);
385 int (*slot_disable ) (struct slot *slot); 317 int (*slot_disable)(struct slot *slot);
386 int (*set_bus_speed_mode) (struct slot *slot, enum pci_bus_speed speed); 318 int (*set_bus_speed_mode)(struct slot *slot, enum pci_bus_speed speed);
387 int (*get_power_status) (struct slot *slot, u8 *status); 319 int (*get_power_status)(struct slot *slot, u8 *status);
388 int (*get_attention_status) (struct slot *slot, u8 *status); 320 int (*get_attention_status)(struct slot *slot, u8 *status);
389 int (*set_attention_status) (struct slot *slot, u8 status); 321 int (*set_attention_status)(struct slot *slot, u8 status);
390 int (*get_latch_status) (struct slot *slot, u8 *status); 322 int (*get_latch_status)(struct slot *slot, u8 *status);
391 int (*get_adapter_status) (struct slot *slot, u8 *status); 323 int (*get_adapter_status)(struct slot *slot, u8 *status);
392 324 int (*get_max_bus_speed)(struct slot *slot, enum pci_bus_speed *speed);
393 int (*get_max_bus_speed) (struct slot *slot, enum pci_bus_speed *speed); 325 int (*get_cur_bus_speed)(struct slot *slot, enum pci_bus_speed *speed);
394 int (*get_cur_bus_speed) (struct slot *slot, enum pci_bus_speed *speed); 326 int (*get_adapter_speed)(struct slot *slot, enum pci_bus_speed *speed);
395 int (*get_adapter_speed) (struct slot *slot, enum pci_bus_speed *speed); 327 int (*get_mode1_ECC_cap)(struct slot *slot, u8 *mode);
396 int (*get_mode1_ECC_cap) (struct slot *slot, u8 *mode); 328 int (*get_prog_int)(struct slot *slot, u8 *prog_int);
397 int (*get_prog_int) (struct slot *slot, u8 *prog_int); 329 int (*query_power_fault)(struct slot *slot);
398 330 void (*green_led_on)(struct slot *slot);
399 int (*query_power_fault) (struct slot *slot); 331 void (*green_led_off)(struct slot *slot);
400 void (*green_led_on) (struct slot *slot); 332 void (*green_led_blink)(struct slot *slot);
401 void (*green_led_off) (struct slot *slot); 333 void (*release_ctlr)(struct controller *ctrl);
402 void (*green_led_blink) (struct slot *slot); 334 int (*check_cmd_status)(struct controller *ctrl);
403 void (*release_ctlr) (struct controller *ctrl);
404 int (*check_cmd_status) (struct controller *ctrl);
405}; 335};
406 336
407#endif /* _SHPCHP_H */ 337#endif /* _SHPCHP_H */