cpci_hotplug.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * CompactPCI Hot Plug Core Functions
  4. *
  5. * Copyright (C) 2002 SOMA Networks, Inc.
  6. * Copyright (C) 2001 Greg Kroah-Hartman ([email protected])
  7. * Copyright (C) 2001 IBM Corp.
  8. *
  9. * All rights reserved.
  10. *
  11. * Send feedback to <[email protected]>
  12. */
  13. #ifndef _CPCI_HOTPLUG_H
  14. #define _CPCI_HOTPLUG_H
  15. #include <linux/types.h>
  16. #include <linux/pci.h>
  17. #include <linux/pci_hotplug.h>
  18. /* PICMG 2.1 R2.0 HS CSR bits: */
  19. #define HS_CSR_INS 0x0080
  20. #define HS_CSR_EXT 0x0040
  21. #define HS_CSR_PI 0x0030
  22. #define HS_CSR_LOO 0x0008
  23. #define HS_CSR_PIE 0x0004
  24. #define HS_CSR_EIM 0x0002
  25. #define HS_CSR_DHA 0x0001
  26. struct slot {
  27. u8 number;
  28. unsigned int devfn;
  29. struct pci_bus *bus;
  30. struct pci_dev *dev;
  31. unsigned int latch_status:1;
  32. unsigned int adapter_status:1;
  33. unsigned int extracting;
  34. struct hotplug_slot hotplug_slot;
  35. struct list_head slot_list;
  36. };
  37. struct cpci_hp_controller_ops {
  38. int (*query_enum)(void);
  39. int (*enable_irq)(void);
  40. int (*disable_irq)(void);
  41. int (*check_irq)(void *dev_id);
  42. int (*hardware_test)(struct slot *slot, u32 value);
  43. u8 (*get_power)(struct slot *slot);
  44. int (*set_power)(struct slot *slot, int value);
  45. };
  46. struct cpci_hp_controller {
  47. unsigned int irq;
  48. unsigned long irq_flags;
  49. char *devname;
  50. void *dev_id;
  51. char *name;
  52. struct cpci_hp_controller_ops *ops;
  53. };
  54. static inline const char *slot_name(struct slot *slot)
  55. {
  56. return hotplug_slot_name(&slot->hotplug_slot);
  57. }
  58. static inline struct slot *to_slot(struct hotplug_slot *hotplug_slot)
  59. {
  60. return container_of(hotplug_slot, struct slot, hotplug_slot);
  61. }
  62. int cpci_hp_register_controller(struct cpci_hp_controller *controller);
  63. int cpci_hp_unregister_controller(struct cpci_hp_controller *controller);
  64. int cpci_hp_register_bus(struct pci_bus *bus, u8 first, u8 last);
  65. int cpci_hp_unregister_bus(struct pci_bus *bus);
  66. int cpci_hp_start(void);
  67. int cpci_hp_stop(void);
  68. /* Global variables */
  69. extern int cpci_debug;
  70. /*
  71. * Internal function prototypes, these functions should not be used by
  72. * board/chassis drivers.
  73. */
  74. u8 cpci_get_attention_status(struct slot *slot);
  75. u8 cpci_get_latch_status(struct slot *slot);
  76. u8 cpci_get_adapter_status(struct slot *slot);
  77. u16 cpci_get_hs_csr(struct slot *slot);
  78. int cpci_set_attention_status(struct slot *slot, int status);
  79. int cpci_check_and_clear_ins(struct slot *slot);
  80. int cpci_check_ext(struct slot *slot);
  81. int cpci_clear_ext(struct slot *slot);
  82. int cpci_led_on(struct slot *slot);
  83. int cpci_led_off(struct slot *slot);
  84. int cpci_configure_slot(struct slot *slot);
  85. int cpci_unconfigure_slot(struct slot *slot);
  86. #ifdef CONFIG_HOTPLUG_PCI_CPCI
  87. int cpci_hotplug_init(int debug);
  88. #else
  89. static inline int cpci_hotplug_init(int debug) { return 0; }
  90. #endif
  91. #endif /* _CPCI_HOTPLUG_H */