brcmfmac.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. /*
  2. * Copyright (c) 201 Broadcom Corporation
  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 ANY
  11. * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  13. * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  14. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #ifndef _LINUX_BRCMFMAC_PLATFORM_H
  17. #define _LINUX_BRCMFMAC_PLATFORM_H
  18. #define BRCMFMAC_PDATA_NAME "brcmfmac"
  19. #define BRCMFMAC_COUNTRY_BUF_SZ 4
  20. /*
  21. * Platform specific driver functions and data. Through the platform specific
  22. * device data functions and data can be provided to help the brcmfmac driver to
  23. * operate with the device in combination with the used platform.
  24. */
  25. /**
  26. * Note: the brcmfmac can be loaded as module or be statically built-in into
  27. * the kernel. If built-in then do note that it uses module_init (and
  28. * module_exit) routines which equal device_initcall. So if you intend to
  29. * create a module with the platform specific data for the brcmfmac and have
  30. * it built-in to the kernel then use a higher initcall then device_initcall
  31. * (see init.h). If this is not done then brcmfmac will load without problems
  32. * but will not pickup the platform data.
  33. *
  34. * When the driver does not "detect" platform driver data then it will continue
  35. * without reporting anything and just assume there is no data needed. Which is
  36. * probably true for most platforms.
  37. */
  38. /**
  39. * enum brcmf_bus_type - Bus type identifier. Currently SDIO, USB and PCIE are
  40. * supported.
  41. */
  42. enum brcmf_bus_type {
  43. BRCMF_BUSTYPE_SDIO,
  44. BRCMF_BUSTYPE_USB,
  45. BRCMF_BUSTYPE_PCIE
  46. };
  47. /**
  48. * struct brcmfmac_sdio_pd - SDIO Device specific platform data.
  49. *
  50. * @txglomsz: SDIO txglom size. Use 0 if default of driver is to be
  51. * used.
  52. * @drive_strength: is the preferred drive_strength to be used for the SDIO
  53. * pins. If 0 then a default value will be used. This is
  54. * the target drive strength, the exact drive strength
  55. * which will be used depends on the capabilities of the
  56. * device.
  57. * @oob_irq_supported: does the board have support for OOB interrupts. SDIO
  58. * in-band interrupts are relatively slow and for having
  59. * less overhead on interrupt processing an out of band
  60. * interrupt can be used. If the HW supports this then
  61. * enable this by setting this field to true and configure
  62. * the oob related fields.
  63. * @oob_irq_nr,
  64. * @oob_irq_flags: the OOB interrupt information. The values are used for
  65. * registering the irq using request_irq function.
  66. * @broken_sg_support: flag for broken sg list support of SDIO host controller.
  67. * Set this to true if the SDIO host controller has higher
  68. * align requirement than 32 bytes for each scatterlist
  69. * item.
  70. * @sd_head_align: alignment requirement for start of data buffer.
  71. * @sd_sgentry_align: length alignment requirement for each sg entry.
  72. * @reset: This function can get called if the device communication
  73. * broke down. This functionality is particularly useful in
  74. * case of SDIO type devices. It is possible to reset a
  75. * dongle via sdio data interface, but it requires that
  76. * this is fully functional. This function is chip/module
  77. * specific and this function should return only after the
  78. * complete reset has completed.
  79. */
  80. struct brcmfmac_sdio_pd {
  81. int txglomsz;
  82. unsigned int drive_strength;
  83. bool oob_irq_supported;
  84. unsigned int oob_irq_nr;
  85. unsigned long oob_irq_flags;
  86. bool broken_sg_support;
  87. unsigned short sd_head_align;
  88. unsigned short sd_sgentry_align;
  89. void (*reset)(void);
  90. };
  91. /**
  92. * struct brcmfmac_pd_cc_entry - Struct for translating user space country code
  93. * (iso3166) to firmware country code and
  94. * revision.
  95. *
  96. * @iso3166: iso3166 alpha 2 country code string.
  97. * @cc: firmware country code string.
  98. * @rev: firmware country code revision.
  99. */
  100. struct brcmfmac_pd_cc_entry {
  101. char iso3166[BRCMFMAC_COUNTRY_BUF_SZ];
  102. char cc[BRCMFMAC_COUNTRY_BUF_SZ];
  103. s32 rev;
  104. };
  105. /**
  106. * struct brcmfmac_pd_cc - Struct for translating country codes as set by user
  107. * space to a country code and rev which can be used by
  108. * firmware.
  109. *
  110. * @table_size: number of entries in table (> 0)
  111. * @table: array of 1 or more elements with translation information.
  112. */
  113. struct brcmfmac_pd_cc {
  114. int table_size;
  115. struct brcmfmac_pd_cc_entry table[];
  116. };
  117. /**
  118. * struct brcmfmac_pd_device - Device specific platform data. (id/rev/bus_type)
  119. * is the unique identifier of the device.
  120. *
  121. * @id: ID of the device for which this data is. In case of SDIO
  122. * or PCIE this is the chipid as identified by chip.c In
  123. * case of USB this is the chipid as identified by the
  124. * device query.
  125. * @rev: chip revision, see id.
  126. * @bus_type: The type of bus. Some chipid/rev exist for different bus
  127. * types. Each bus type has its own set of settings.
  128. * @feature_disable: Bitmask of features to disable (override), See feature.c
  129. * in brcmfmac for details.
  130. * @country_codes: If available, pointer to struct for translating country
  131. * codes.
  132. * @bus: Bus specific (union) device settings. Currently only
  133. * SDIO.
  134. */
  135. struct brcmfmac_pd_device {
  136. unsigned int id;
  137. unsigned int rev;
  138. enum brcmf_bus_type bus_type;
  139. unsigned int feature_disable;
  140. struct brcmfmac_pd_cc *country_codes;
  141. union {
  142. struct brcmfmac_sdio_pd sdio;
  143. } bus;
  144. };
  145. /**
  146. * struct brcmfmac_platform_data - BRCMFMAC specific platform data.
  147. *
  148. * @power_on: This function is called by the brcmfmac driver when the module
  149. * gets loaded. This can be particularly useful for low power
  150. * devices. The platform spcific routine may for example decide to
  151. * power up the complete device. If there is no use-case for this
  152. * function then provide NULL.
  153. * @power_off: This function is called by the brcmfmac when the module gets
  154. * unloaded. At this point the devices can be powered down or
  155. * otherwise be reset. So if an actual power_off is not supported
  156. * but reset is supported by the devices then reset the devices
  157. * when this function gets called. This can be particularly useful
  158. * for low power devices. If there is no use-case for this
  159. * function then provide NULL.
  160. */
  161. struct brcmfmac_platform_data {
  162. void (*power_on)(void);
  163. void (*power_off)(void);
  164. char *fw_alternative_path;
  165. int device_count;
  166. struct brcmfmac_pd_device devices[];
  167. };
  168. #endif /* _LINUX_BRCMFMAC_PLATFORM_H */