wil_platform.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * Copyright (c) 2014-2017 Qualcomm Atheros, Inc.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #ifndef __WIL_PLATFORM_H__
  17. #define __WIL_PLATFORM_H__
  18. struct device;
  19. enum wil_platform_event {
  20. WIL_PLATFORM_EVT_FW_CRASH = 0,
  21. WIL_PLATFORM_EVT_PRE_RESET = 1,
  22. WIL_PLATFORM_EVT_FW_RDY = 2,
  23. WIL_PLATFORM_EVT_PRE_SUSPEND = 3,
  24. WIL_PLATFORM_EVT_POST_SUSPEND = 4,
  25. };
  26. enum wil_platform_features {
  27. WIL_PLATFORM_FEATURE_FW_EXT_CLK_CONTROL = 0,
  28. WIL_PLATFORM_FEATURE_TRIPLE_MSI = 1,
  29. WIL_PLATFORM_FEATURE_MAX,
  30. };
  31. enum wil_platform_capa {
  32. WIL_PLATFORM_CAPA_RADIO_ON_IN_SUSPEND = 0,
  33. WIL_PLATFORM_CAPA_T_PWR_ON_0 = 1,
  34. WIL_PLATFORM_CAPA_EXT_CLK = 2,
  35. WIL_PLATFORM_CAPA_MAX,
  36. };
  37. /**
  38. * struct wil_platform_ops - wil platform module calls from this
  39. * driver to platform driver
  40. */
  41. struct wil_platform_ops {
  42. int (*bus_request)(void *handle, uint32_t kbps /* KBytes/Sec */);
  43. int (*suspend)(void *handle, bool keep_device_power);
  44. int (*resume)(void *handle, bool device_powered_on);
  45. void (*uninit)(void *handle);
  46. int (*notify)(void *handle, enum wil_platform_event evt);
  47. int (*get_capa)(void *handle);
  48. void (*set_features)(void *handle, int features);
  49. };
  50. /**
  51. * struct wil_platform_rops - wil platform module callbacks from
  52. * platform driver to this driver
  53. * @ramdump: store a ramdump from the wil firmware. The platform
  54. * driver may add additional data to the ramdump to
  55. * generate the final crash dump.
  56. * @fw_recovery: start a firmware recovery process. Called as
  57. * part of a crash recovery process which may include other
  58. * related platform subsystems.
  59. */
  60. struct wil_platform_rops {
  61. int (*ramdump)(void *wil_handle, void *buf, uint32_t size);
  62. int (*fw_recovery)(void *wil_handle);
  63. };
  64. /**
  65. * wil_platform_init - initialize the platform driver
  66. *
  67. * @dev - pointer to the wil6210 device
  68. * @ops - structure with platform driver operations. Platform
  69. * driver will fill this structure with function pointers.
  70. * @rops - structure with callbacks from platform driver to
  71. * this driver. The platform driver copies the structure to
  72. * its own storage. Can be NULL if this driver does not
  73. * support crash recovery.
  74. * @wil_handle - context for this driver that will be passed
  75. * when platform driver invokes one of the callbacks in
  76. * rops. May be NULL if rops is NULL.
  77. */
  78. void *wil_platform_init(struct device *dev, struct wil_platform_ops *ops,
  79. const struct wil_platform_rops *rops, void *wil_handle);
  80. int __init wil_platform_modinit(void);
  81. void wil_platform_modexit(void);
  82. #endif /* __WIL_PLATFORM_H__ */