rsi_hal.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. /**
  2. * Copyright (c) 2017 Redpine Signals 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 __RSI_HAL_H__
  17. #define __RSI_HAL_H__
  18. /* Device Operating modes */
  19. #define DEV_OPMODE_WIFI_ALONE 1
  20. #define DEV_OPMODE_BT_ALONE 4
  21. #define DEV_OPMODE_BT_LE_ALONE 8
  22. #define DEV_OPMODE_BT_DUAL 12
  23. #define DEV_OPMODE_STA_BT 5
  24. #define DEV_OPMODE_STA_BT_LE 9
  25. #define DEV_OPMODE_STA_BT_DUAL 13
  26. #define DEV_OPMODE_AP_BT 6
  27. #define DEV_OPMODE_AP_BT_DUAL 14
  28. #define FLASH_WRITE_CHUNK_SIZE (4 * 1024)
  29. #define FLASH_SECTOR_SIZE (4 * 1024)
  30. #define FLASH_SIZE_ADDR 0x04000016
  31. #define PING_BUFFER_ADDRESS 0x19000
  32. #define PONG_BUFFER_ADDRESS 0x1a000
  33. #define SWBL_REGIN 0x41050034
  34. #define SWBL_REGOUT 0x4105003c
  35. #define PING_WRITE 0x1
  36. #define PONG_WRITE 0x2
  37. #define BL_CMD_TIMEOUT 2000
  38. #define BL_BURN_TIMEOUT (50 * 1000)
  39. #define REGIN_VALID 0xA
  40. #define REGIN_INPUT 0xA0
  41. #define REGOUT_VALID 0xAB
  42. #define REGOUT_INVALID (~0xAB)
  43. #define CMD_PASS 0xAA
  44. #define CMD_FAIL 0xCC
  45. #define LOAD_HOSTED_FW 'A'
  46. #define BURN_HOSTED_FW 'B'
  47. #define PING_VALID 'I'
  48. #define PONG_VALID 'O'
  49. #define PING_AVAIL 'I'
  50. #define PONG_AVAIL 'O'
  51. #define EOF_REACHED 'E'
  52. #define CHECK_CRC 'K'
  53. #define POLLING_MODE 'P'
  54. #define CONFIG_AUTO_READ_MODE 'R'
  55. #define JUMP_TO_ZERO_PC 'J'
  56. #define FW_LOADING_SUCCESSFUL 'S'
  57. #define LOADING_INITIATED '1'
  58. #define RSI_ULP_RESET_REG 0x161
  59. #define RSI_WATCH_DOG_TIMER_1 0x16c
  60. #define RSI_WATCH_DOG_TIMER_2 0x16d
  61. #define RSI_WATCH_DOG_DELAY_TIMER_1 0x16e
  62. #define RSI_WATCH_DOG_DELAY_TIMER_2 0x16f
  63. #define RSI_WATCH_DOG_TIMER_ENABLE 0x170
  64. #define RSI_ULP_WRITE_0 00
  65. #define RSI_ULP_WRITE_2 02
  66. #define RSI_ULP_WRITE_50 50
  67. #define RSI_RESTART_WDT BIT(11)
  68. #define RSI_BYPASS_ULP_ON_WDT BIT(1)
  69. #define RSI_ULP_TIMER_ENABLE ((0xaa000) | RSI_RESTART_WDT | \
  70. RSI_BYPASS_ULP_ON_WDT)
  71. #define RSI_RF_SPI_PROG_REG_BASE_ADDR 0x40080000
  72. #define RSI_GSPI_CTRL_REG0 (RSI_RF_SPI_PROG_REG_BASE_ADDR)
  73. #define RSI_GSPI_CTRL_REG1 (RSI_RF_SPI_PROG_REG_BASE_ADDR + 0x2)
  74. #define RSI_GSPI_DATA_REG0 (RSI_RF_SPI_PROG_REG_BASE_ADDR + 0x4)
  75. #define RSI_GSPI_DATA_REG1 (RSI_RF_SPI_PROG_REG_BASE_ADDR + 0x6)
  76. #define RSI_GSPI_DATA_REG2 (RSI_RF_SPI_PROG_REG_BASE_ADDR + 0x8)
  77. #define RSI_GSPI_CTRL_REG0_VALUE 0x340
  78. #define RSI_GSPI_DMA_MODE BIT(13)
  79. #define RSI_GSPI_2_ULP BIT(12)
  80. #define RSI_GSPI_TRIG BIT(7)
  81. #define RSI_GSPI_READ BIT(6)
  82. #define RSI_GSPI_RF_SPI_ACTIVE BIT(8)
  83. /* Boot loader commands */
  84. #define SEND_RPS_FILE '2'
  85. #define FW_IMAGE_MIN_ADDRESS (68 * 1024)
  86. #define MAX_FLASH_FILE_SIZE (400 * 1024) //400K
  87. #define FLASH_START_ADDRESS 16
  88. #define COMMON_HAL_CARD_READY_IND 0x0
  89. #define COMMAN_HAL_WAIT_FOR_CARD_READY 1
  90. #define RSI_DEV_OPMODE_WIFI_ALONE 1
  91. #define RSI_DEV_COEX_MODE_WIFI_ALONE 1
  92. #define BBP_INFO_40MHZ 0x6
  93. #define FW_FLASH_OFFSET 0x820
  94. #define LMAC_VER_OFFSET (FW_FLASH_OFFSET + 0x200)
  95. #define MAX_DWORD_ALIGN_BYTES 64
  96. #define RSI_COMMON_REG_SIZE 2
  97. struct bl_header {
  98. __le32 flags;
  99. __le32 image_no;
  100. __le32 check_sum;
  101. __le32 flash_start_address;
  102. __le32 flash_len;
  103. } __packed;
  104. struct ta_metadata {
  105. char *name;
  106. unsigned int address;
  107. };
  108. struct rsi_mgmt_desc {
  109. __le16 len_qno;
  110. u8 frame_type;
  111. u8 misc_flags;
  112. u8 xtend_desc_size;
  113. u8 header_len;
  114. __le16 frame_info;
  115. __le16 rate_info;
  116. __le16 bbp_info;
  117. __le16 seq_ctrl;
  118. u8 reserved2;
  119. u8 sta_id;
  120. } __packed;
  121. struct rsi_data_desc {
  122. __le16 len_qno;
  123. u8 cfm_frame_type;
  124. u8 misc_flags;
  125. u8 xtend_desc_size;
  126. u8 header_len;
  127. __le16 frame_info;
  128. __le16 rate_info;
  129. __le16 bbp_info;
  130. __le16 mac_flags;
  131. u8 qid_tid;
  132. u8 sta_id;
  133. } __packed;
  134. struct rsi_bt_desc {
  135. __le16 len_qno;
  136. __le16 reserved1;
  137. __le32 reserved2;
  138. __le32 reserved3;
  139. __le16 reserved4;
  140. __le16 bt_pkt_type;
  141. } __packed;
  142. int rsi_hal_device_init(struct rsi_hw *adapter);
  143. int rsi_prepare_mgmt_desc(struct rsi_common *common, struct sk_buff *skb);
  144. int rsi_prepare_data_desc(struct rsi_common *common, struct sk_buff *skb);
  145. int rsi_prepare_beacon(struct rsi_common *common, struct sk_buff *skb);
  146. int rsi_send_pkt_to_bus(struct rsi_common *common, struct sk_buff *skb);
  147. int rsi_send_bt_pkt(struct rsi_common *common, struct sk_buff *skb);
  148. #endif