brcmfmac-sdio.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*
  2. * Copyright (c) 2013 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. /*
  19. * Platform specific driver functions and data. Through the platform specific
  20. * device data functions can be provided to help the brcmfmac driver to
  21. * operate with the device in combination with the used platform.
  22. *
  23. * Use the platform data in the following (similar) way:
  24. *
  25. *
  26. #include <brcmfmac_platform.h>
  27. static void brcmfmac_power_on(void)
  28. {
  29. }
  30. static void brcmfmac_power_off(void)
  31. {
  32. }
  33. static void brcmfmac_reset(void)
  34. {
  35. }
  36. static struct brcmfmac_sdio_platform_data brcmfmac_sdio_pdata = {
  37. .power_on = brcmfmac_power_on,
  38. .power_off = brcmfmac_power_off,
  39. .reset = brcmfmac_reset
  40. };
  41. static struct platform_device brcmfmac_device = {
  42. .name = BRCMFMAC_SDIO_PDATA_NAME,
  43. .id = PLATFORM_DEVID_NONE,
  44. .dev.platform_data = &brcmfmac_sdio_pdata
  45. };
  46. void __init brcmfmac_init_pdata(void)
  47. {
  48. brcmfmac_sdio_pdata.oob_irq_supported = true;
  49. brcmfmac_sdio_pdata.oob_irq_nr = gpio_to_irq(GPIO_BRCMF_SDIO_OOB);
  50. brcmfmac_sdio_pdata.oob_irq_flags = IORESOURCE_IRQ |
  51. IORESOURCE_IRQ_HIGHLEVEL;
  52. platform_device_register(&brcmfmac_device);
  53. }
  54. *
  55. *
  56. * Note: the brcmfmac can be loaded as module or be statically built-in into
  57. * the kernel. If built-in then do note that it uses module_init (and
  58. * module_exit) routines which equal device_initcall. So if you intend to
  59. * create a module with the platform specific data for the brcmfmac and have
  60. * it built-in to the kernel then use a higher initcall then device_initcall
  61. * (see init.h). If this is not done then brcmfmac will load without problems
  62. * but will not pickup the platform data.
  63. *
  64. * When the driver does not "detect" platform driver data then it will continue
  65. * without reporting anything and just assume there is no data needed. Which is
  66. * probably true for most platforms.
  67. *
  68. * Explanation of the platform_data fields:
  69. *
  70. * drive_strength: is the preferred drive_strength to be used for the SDIO
  71. * pins. If 0 then a default value will be used. This is the target drive
  72. * strength, the exact drive strength which will be used depends on the
  73. * capabilities of the device.
  74. *
  75. * oob_irq_supported: does the board have support for OOB interrupts. SDIO
  76. * in-band interrupts are relatively slow and for having less overhead on
  77. * interrupt processing an out of band interrupt can be used. If the HW
  78. * supports this then enable this by setting this field to true and configure
  79. * the oob related fields.
  80. *
  81. * oob_irq_nr, oob_irq_flags: the OOB interrupt information. The values are
  82. * used for registering the irq using request_irq function.
  83. *
  84. * broken_sg_support: flag for broken sg list support of SDIO host controller.
  85. * Set this to true if the SDIO host controller has higher align requirement
  86. * than 32 bytes for each scatterlist item.
  87. *
  88. * sd_head_align: alignment requirement for start of data buffer
  89. *
  90. * sd_sgentry_align: length alignment requirement for each sg entry
  91. *
  92. * power_on: This function is called by the brcmfmac when the module gets
  93. * loaded. This can be particularly useful for low power devices. The platform
  94. * spcific routine may for example decide to power up the complete device.
  95. * If there is no use-case for this function then provide NULL.
  96. *
  97. * power_off: This function is called by the brcmfmac when the module gets
  98. * unloaded. At this point the device can be powered down or otherwise be reset.
  99. * So if an actual power_off is not supported but reset is then reset the device
  100. * when this function gets called. This can be particularly useful for low power
  101. * devices. If there is no use-case for this function (either power-down or
  102. * reset) then provide NULL.
  103. *
  104. * reset: This function can get called if the device communication broke down.
  105. * This functionality is particularly useful in case of SDIO type devices. It is
  106. * possible to reset a dongle via sdio data interface, but it requires that
  107. * this is fully functional. This function is chip/module specific and this
  108. * function should return only after the complete reset has completed.
  109. */
  110. #define BRCMFMAC_SDIO_PDATA_NAME "brcmfmac_sdio"
  111. struct brcmfmac_sdio_platform_data {
  112. unsigned int drive_strength;
  113. bool oob_irq_supported;
  114. unsigned int oob_irq_nr;
  115. unsigned long oob_irq_flags;
  116. bool broken_sg_support;
  117. unsigned short sd_head_align;
  118. unsigned short sd_sgentry_align;
  119. void (*power_on)(void);
  120. void (*power_off)(void);
  121. void (*reset)(void);
  122. };
  123. #endif /* _LINUX_BRCMFMAC_PLATFORM_H */