sdio_chip.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. /*
  2. * Copyright (c) 2011 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 _BRCMFMAC_SDIO_CHIP_H_
  17. #define _BRCMFMAC_SDIO_CHIP_H_
  18. /*
  19. * Core reg address translation.
  20. * Both macro's returns a 32 bits byte address on the backplane bus.
  21. */
  22. #define CORE_CC_REG(base, field) \
  23. (base + offsetof(struct chipcregs, field))
  24. #define CORE_BUS_REG(base, field) \
  25. (base + offsetof(struct sdpcmd_regs, field))
  26. #define CORE_SB(base, field) \
  27. (base + SBCONFIGOFF + offsetof(struct sbconfig, field))
  28. /* SDIO function 1 register CHIPCLKCSR */
  29. /* Force ALP request to backplane */
  30. #define SBSDIO_FORCE_ALP 0x01
  31. /* Force HT request to backplane */
  32. #define SBSDIO_FORCE_HT 0x02
  33. /* Force ILP request to backplane */
  34. #define SBSDIO_FORCE_ILP 0x04
  35. /* Make ALP ready (power up xtal) */
  36. #define SBSDIO_ALP_AVAIL_REQ 0x08
  37. /* Make HT ready (power up PLL) */
  38. #define SBSDIO_HT_AVAIL_REQ 0x10
  39. /* Squelch clock requests from HW */
  40. #define SBSDIO_FORCE_HW_CLKREQ_OFF 0x20
  41. /* Status: ALP is ready */
  42. #define SBSDIO_ALP_AVAIL 0x40
  43. /* Status: HT is ready */
  44. #define SBSDIO_HT_AVAIL 0x80
  45. #define SBSDIO_AVBITS (SBSDIO_HT_AVAIL | SBSDIO_ALP_AVAIL)
  46. #define SBSDIO_ALPAV(regval) ((regval) & SBSDIO_AVBITS)
  47. #define SBSDIO_HTAV(regval) (((regval) & SBSDIO_AVBITS) == SBSDIO_AVBITS)
  48. #define SBSDIO_ALPONLY(regval) (SBSDIO_ALPAV(regval) && !SBSDIO_HTAV(regval))
  49. #define SBSDIO_CLKAV(regval, alponly) \
  50. (SBSDIO_ALPAV(regval) && (alponly ? 1 : SBSDIO_HTAV(regval)))
  51. #define BRCMF_MAX_CORENUM 6
  52. struct brcmf_core {
  53. u16 id;
  54. u16 rev;
  55. u32 base;
  56. u32 wrapbase;
  57. u32 caps;
  58. u32 cib;
  59. };
  60. struct brcmf_chip {
  61. u32 chip;
  62. u32 chiprev;
  63. /* core info */
  64. /* always put chipcommon core at 0, bus core at 1 */
  65. struct brcmf_core c_inf[BRCMF_MAX_CORENUM];
  66. u32 pmurev;
  67. u32 pmucaps;
  68. u32 ramsize;
  69. u32 rambase;
  70. u32 rst_vec; /* reset vertor for ARM CR4 core */
  71. bool (*iscoreup)(struct brcmf_sdio_dev *sdiodev, struct brcmf_chip *ci,
  72. u16 coreid);
  73. u32 (*corerev)(struct brcmf_sdio_dev *sdiodev, struct brcmf_chip *ci,
  74. u16 coreid);
  75. void (*coredisable)(struct brcmf_sdio_dev *sdiodev,
  76. struct brcmf_chip *ci, u16 coreid, u32 pre_resetbits,
  77. u32 in_resetbits);
  78. void (*resetcore)(struct brcmf_sdio_dev *sdiodev,
  79. struct brcmf_chip *ci, u16 coreid, u32 pre_resetbits,
  80. u32 in_resetbits, u32 post_resetbits);
  81. };
  82. struct sbconfig {
  83. u32 PAD[2];
  84. u32 sbipsflag; /* initiator port ocp slave flag */
  85. u32 PAD[3];
  86. u32 sbtpsflag; /* target port ocp slave flag */
  87. u32 PAD[11];
  88. u32 sbtmerrloga; /* (sonics >= 2.3) */
  89. u32 PAD;
  90. u32 sbtmerrlog; /* (sonics >= 2.3) */
  91. u32 PAD[3];
  92. u32 sbadmatch3; /* address match3 */
  93. u32 PAD;
  94. u32 sbadmatch2; /* address match2 */
  95. u32 PAD;
  96. u32 sbadmatch1; /* address match1 */
  97. u32 PAD[7];
  98. u32 sbimstate; /* initiator agent state */
  99. u32 sbintvec; /* interrupt mask */
  100. u32 sbtmstatelow; /* target state */
  101. u32 sbtmstatehigh; /* target state */
  102. u32 sbbwa0; /* bandwidth allocation table0 */
  103. u32 PAD;
  104. u32 sbimconfiglow; /* initiator configuration */
  105. u32 sbimconfighigh; /* initiator configuration */
  106. u32 sbadmatch0; /* address match0 */
  107. u32 PAD;
  108. u32 sbtmconfiglow; /* target configuration */
  109. u32 sbtmconfighigh; /* target configuration */
  110. u32 sbbconfig; /* broadcast configuration */
  111. u32 PAD;
  112. u32 sbbstate; /* broadcast state */
  113. u32 PAD[3];
  114. u32 sbactcnfg; /* activate configuration */
  115. u32 PAD[3];
  116. u32 sbflagst; /* current sbflags */
  117. u32 PAD[3];
  118. u32 sbidlow; /* identification */
  119. u32 sbidhigh; /* identification */
  120. };
  121. /* sdio core registers */
  122. struct sdpcmd_regs {
  123. u32 corecontrol; /* 0x00, rev8 */
  124. u32 corestatus; /* rev8 */
  125. u32 PAD[1];
  126. u32 biststatus; /* rev8 */
  127. /* PCMCIA access */
  128. u16 pcmciamesportaladdr; /* 0x010, rev8 */
  129. u16 PAD[1];
  130. u16 pcmciamesportalmask; /* rev8 */
  131. u16 PAD[1];
  132. u16 pcmciawrframebc; /* rev8 */
  133. u16 PAD[1];
  134. u16 pcmciaunderflowtimer; /* rev8 */
  135. u16 PAD[1];
  136. /* interrupt */
  137. u32 intstatus; /* 0x020, rev8 */
  138. u32 hostintmask; /* rev8 */
  139. u32 intmask; /* rev8 */
  140. u32 sbintstatus; /* rev8 */
  141. u32 sbintmask; /* rev8 */
  142. u32 funcintmask; /* rev4 */
  143. u32 PAD[2];
  144. u32 tosbmailbox; /* 0x040, rev8 */
  145. u32 tohostmailbox; /* rev8 */
  146. u32 tosbmailboxdata; /* rev8 */
  147. u32 tohostmailboxdata; /* rev8 */
  148. /* synchronized access to registers in SDIO clock domain */
  149. u32 sdioaccess; /* 0x050, rev8 */
  150. u32 PAD[3];
  151. /* PCMCIA frame control */
  152. u8 pcmciaframectrl; /* 0x060, rev8 */
  153. u8 PAD[3];
  154. u8 pcmciawatermark; /* rev8 */
  155. u8 PAD[155];
  156. /* interrupt batching control */
  157. u32 intrcvlazy; /* 0x100, rev8 */
  158. u32 PAD[3];
  159. /* counters */
  160. u32 cmd52rd; /* 0x110, rev8 */
  161. u32 cmd52wr; /* rev8 */
  162. u32 cmd53rd; /* rev8 */
  163. u32 cmd53wr; /* rev8 */
  164. u32 abort; /* rev8 */
  165. u32 datacrcerror; /* rev8 */
  166. u32 rdoutofsync; /* rev8 */
  167. u32 wroutofsync; /* rev8 */
  168. u32 writebusy; /* rev8 */
  169. u32 readwait; /* rev8 */
  170. u32 readterm; /* rev8 */
  171. u32 writeterm; /* rev8 */
  172. u32 PAD[40];
  173. u32 clockctlstatus; /* rev8 */
  174. u32 PAD[7];
  175. u32 PAD[128]; /* DMA engines */
  176. /* SDIO/PCMCIA CIS region */
  177. char cis[512]; /* 0x400-0x5ff, rev6 */
  178. /* PCMCIA function control registers */
  179. char pcmciafcr[256]; /* 0x600-6ff, rev6 */
  180. u16 PAD[55];
  181. /* PCMCIA backplane access */
  182. u16 backplanecsr; /* 0x76E, rev6 */
  183. u16 backplaneaddr0; /* rev6 */
  184. u16 backplaneaddr1; /* rev6 */
  185. u16 backplaneaddr2; /* rev6 */
  186. u16 backplaneaddr3; /* rev6 */
  187. u16 backplanedata0; /* rev6 */
  188. u16 backplanedata1; /* rev6 */
  189. u16 backplanedata2; /* rev6 */
  190. u16 backplanedata3; /* rev6 */
  191. u16 PAD[31];
  192. /* sprom "size" & "blank" info */
  193. u16 spromstatus; /* 0x7BE, rev2 */
  194. u32 PAD[464];
  195. u16 PAD[0x80];
  196. };
  197. int brcmf_sdio_chip_attach(struct brcmf_sdio_dev *sdiodev,
  198. struct brcmf_chip **ci_ptr);
  199. void brcmf_sdio_chip_detach(struct brcmf_chip **ci_ptr);
  200. void brcmf_sdio_chip_drivestrengthinit(struct brcmf_sdio_dev *sdiodev,
  201. struct brcmf_chip *ci,
  202. u32 drivestrength);
  203. u8 brcmf_sdio_chip_getinfidx(struct brcmf_chip *ci, u16 coreid);
  204. void brcmf_sdio_chip_enter_download(struct brcmf_sdio_dev *sdiodev,
  205. struct brcmf_chip *ci);
  206. bool brcmf_sdio_chip_exit_download(struct brcmf_sdio_dev *sdiodev,
  207. struct brcmf_chip *ci, u32 rstvec);
  208. #endif /* _BRCMFMAC_SDIO_CHIP_H_ */