rt2800soc.c 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. /* Copyright (C) 2009 - 2010 Ivo van Doorn <IvDoorn@gmail.com>
  2. * Copyright (C) 2009 Alban Browaeys <prahal@yahoo.com>
  3. * Copyright (C) 2009 Felix Fietkau <nbd@openwrt.org>
  4. * Copyright (C) 2009 Luis Correia <luis.f.correia@gmail.com>
  5. * Copyright (C) 2009 Mattias Nissler <mattias.nissler@gmx.de>
  6. * Copyright (C) 2009 Mark Asselstine <asselsm@gmail.com>
  7. * Copyright (C) 2009 Xose Vazquez Perez <xose.vazquez@gmail.com>
  8. * Copyright (C) 2009 Bart Zolnierkiewicz <bzolnier@gmail.com>
  9. * <http://rt2x00.serialmonkey.com>
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the
  23. * Free Software Foundation, Inc.,
  24. * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  25. */
  26. /* Module: rt2800soc
  27. * Abstract: rt2800 WiSoC specific routines.
  28. */
  29. #include <linux/etherdevice.h>
  30. #include <linux/init.h>
  31. #include <linux/kernel.h>
  32. #include <linux/module.h>
  33. #include <linux/platform_device.h>
  34. #include "rt2x00.h"
  35. #include "rt2x00mmio.h"
  36. #include "rt2x00soc.h"
  37. #include "rt2800.h"
  38. #include "rt2800lib.h"
  39. #include "rt2800mmio.h"
  40. /* Allow hardware encryption to be disabled. */
  41. static bool modparam_nohwcrypt;
  42. module_param_named(nohwcrypt, modparam_nohwcrypt, bool, S_IRUGO);
  43. MODULE_PARM_DESC(nohwcrypt, "Disable hardware encryption.");
  44. static bool rt2800soc_hwcrypt_disabled(struct rt2x00_dev *rt2x00dev)
  45. {
  46. return modparam_nohwcrypt;
  47. }
  48. static void rt2800soc_disable_radio(struct rt2x00_dev *rt2x00dev)
  49. {
  50. rt2800_disable_radio(rt2x00dev);
  51. rt2x00mmio_register_write(rt2x00dev, PWR_PIN_CFG, 0);
  52. rt2x00mmio_register_write(rt2x00dev, TX_PIN_CFG, 0);
  53. }
  54. static int rt2800soc_set_device_state(struct rt2x00_dev *rt2x00dev,
  55. enum dev_state state)
  56. {
  57. int retval = 0;
  58. switch (state) {
  59. case STATE_RADIO_ON:
  60. retval = rt2800mmio_enable_radio(rt2x00dev);
  61. break;
  62. case STATE_RADIO_OFF:
  63. rt2800soc_disable_radio(rt2x00dev);
  64. break;
  65. case STATE_RADIO_IRQ_ON:
  66. case STATE_RADIO_IRQ_OFF:
  67. rt2800mmio_toggle_irq(rt2x00dev, state);
  68. break;
  69. case STATE_DEEP_SLEEP:
  70. case STATE_SLEEP:
  71. case STATE_STANDBY:
  72. case STATE_AWAKE:
  73. /* These states are not supported, but don't report an error */
  74. retval = 0;
  75. break;
  76. default:
  77. retval = -ENOTSUPP;
  78. break;
  79. }
  80. if (unlikely(retval))
  81. rt2x00_err(rt2x00dev, "Device failed to enter state %d (%d)\n",
  82. state, retval);
  83. return retval;
  84. }
  85. static int rt2800soc_read_eeprom(struct rt2x00_dev *rt2x00dev)
  86. {
  87. void __iomem *base_addr = ioremap(0x1F040000, EEPROM_SIZE);
  88. if (!base_addr)
  89. return -ENOMEM;
  90. memcpy_fromio(rt2x00dev->eeprom, base_addr, EEPROM_SIZE);
  91. iounmap(base_addr);
  92. return 0;
  93. }
  94. /* Firmware functions */
  95. static char *rt2800soc_get_firmware_name(struct rt2x00_dev *rt2x00dev)
  96. {
  97. WARN_ON_ONCE(1);
  98. return NULL;
  99. }
  100. static int rt2800soc_load_firmware(struct rt2x00_dev *rt2x00dev,
  101. const u8 *data, const size_t len)
  102. {
  103. WARN_ON_ONCE(1);
  104. return 0;
  105. }
  106. static int rt2800soc_check_firmware(struct rt2x00_dev *rt2x00dev,
  107. const u8 *data, const size_t len)
  108. {
  109. WARN_ON_ONCE(1);
  110. return 0;
  111. }
  112. static int rt2800soc_write_firmware(struct rt2x00_dev *rt2x00dev,
  113. const u8 *data, const size_t len)
  114. {
  115. WARN_ON_ONCE(1);
  116. return 0;
  117. }
  118. static const struct ieee80211_ops rt2800soc_mac80211_ops = {
  119. .tx = rt2x00mac_tx,
  120. .start = rt2x00mac_start,
  121. .stop = rt2x00mac_stop,
  122. .add_interface = rt2x00mac_add_interface,
  123. .remove_interface = rt2x00mac_remove_interface,
  124. .config = rt2x00mac_config,
  125. .configure_filter = rt2x00mac_configure_filter,
  126. .set_key = rt2x00mac_set_key,
  127. .sw_scan_start = rt2x00mac_sw_scan_start,
  128. .sw_scan_complete = rt2x00mac_sw_scan_complete,
  129. .get_stats = rt2x00mac_get_stats,
  130. .get_tkip_seq = rt2800_get_tkip_seq,
  131. .set_rts_threshold = rt2800_set_rts_threshold,
  132. .sta_add = rt2x00mac_sta_add,
  133. .sta_remove = rt2x00mac_sta_remove,
  134. .bss_info_changed = rt2x00mac_bss_info_changed,
  135. .conf_tx = rt2800_conf_tx,
  136. .get_tsf = rt2800_get_tsf,
  137. .rfkill_poll = rt2x00mac_rfkill_poll,
  138. .ampdu_action = rt2800_ampdu_action,
  139. .flush = rt2x00mac_flush,
  140. .get_survey = rt2800_get_survey,
  141. .get_ringparam = rt2x00mac_get_ringparam,
  142. .tx_frames_pending = rt2x00mac_tx_frames_pending,
  143. };
  144. static const struct rt2800_ops rt2800soc_rt2800_ops = {
  145. .register_read = rt2x00mmio_register_read,
  146. .register_read_lock = rt2x00mmio_register_read, /* same for SoCs */
  147. .register_write = rt2x00mmio_register_write,
  148. .register_write_lock = rt2x00mmio_register_write, /* same for SoCs */
  149. .register_multiread = rt2x00mmio_register_multiread,
  150. .register_multiwrite = rt2x00mmio_register_multiwrite,
  151. .regbusy_read = rt2x00mmio_regbusy_read,
  152. .read_eeprom = rt2800soc_read_eeprom,
  153. .hwcrypt_disabled = rt2800soc_hwcrypt_disabled,
  154. .drv_write_firmware = rt2800soc_write_firmware,
  155. .drv_init_registers = rt2800mmio_init_registers,
  156. .drv_get_txwi = rt2800mmio_get_txwi,
  157. };
  158. static const struct rt2x00lib_ops rt2800soc_rt2x00_ops = {
  159. .irq_handler = rt2800mmio_interrupt,
  160. .txstatus_tasklet = rt2800mmio_txstatus_tasklet,
  161. .pretbtt_tasklet = rt2800mmio_pretbtt_tasklet,
  162. .tbtt_tasklet = rt2800mmio_tbtt_tasklet,
  163. .rxdone_tasklet = rt2800mmio_rxdone_tasklet,
  164. .autowake_tasklet = rt2800mmio_autowake_tasklet,
  165. .probe_hw = rt2800_probe_hw,
  166. .get_firmware_name = rt2800soc_get_firmware_name,
  167. .check_firmware = rt2800soc_check_firmware,
  168. .load_firmware = rt2800soc_load_firmware,
  169. .initialize = rt2x00mmio_initialize,
  170. .uninitialize = rt2x00mmio_uninitialize,
  171. .get_entry_state = rt2800mmio_get_entry_state,
  172. .clear_entry = rt2800mmio_clear_entry,
  173. .set_device_state = rt2800soc_set_device_state,
  174. .rfkill_poll = rt2800_rfkill_poll,
  175. .link_stats = rt2800_link_stats,
  176. .reset_tuner = rt2800_reset_tuner,
  177. .link_tuner = rt2800_link_tuner,
  178. .gain_calibration = rt2800_gain_calibration,
  179. .vco_calibration = rt2800_vco_calibration,
  180. .start_queue = rt2800mmio_start_queue,
  181. .kick_queue = rt2800mmio_kick_queue,
  182. .stop_queue = rt2800mmio_stop_queue,
  183. .flush_queue = rt2x00mmio_flush_queue,
  184. .write_tx_desc = rt2800mmio_write_tx_desc,
  185. .write_tx_data = rt2800_write_tx_data,
  186. .write_beacon = rt2800_write_beacon,
  187. .clear_beacon = rt2800_clear_beacon,
  188. .fill_rxdone = rt2800mmio_fill_rxdone,
  189. .config_shared_key = rt2800_config_shared_key,
  190. .config_pairwise_key = rt2800_config_pairwise_key,
  191. .config_filter = rt2800_config_filter,
  192. .config_intf = rt2800_config_intf,
  193. .config_erp = rt2800_config_erp,
  194. .config_ant = rt2800_config_ant,
  195. .config = rt2800_config,
  196. .sta_add = rt2800_sta_add,
  197. .sta_remove = rt2800_sta_remove,
  198. };
  199. static const struct rt2x00_ops rt2800soc_ops = {
  200. .name = KBUILD_MODNAME,
  201. .drv_data_size = sizeof(struct rt2800_drv_data),
  202. .max_ap_intf = 8,
  203. .eeprom_size = EEPROM_SIZE,
  204. .rf_size = RF_SIZE,
  205. .tx_queues = NUM_TX_QUEUES,
  206. .queue_init = rt2800mmio_queue_init,
  207. .lib = &rt2800soc_rt2x00_ops,
  208. .drv = &rt2800soc_rt2800_ops,
  209. .hw = &rt2800soc_mac80211_ops,
  210. #ifdef CONFIG_RT2X00_LIB_DEBUGFS
  211. .debugfs = &rt2800_rt2x00debug,
  212. #endif /* CONFIG_RT2X00_LIB_DEBUGFS */
  213. };
  214. static int rt2800soc_probe(struct platform_device *pdev)
  215. {
  216. return rt2x00soc_probe(pdev, &rt2800soc_ops);
  217. }
  218. static struct platform_driver rt2800soc_driver = {
  219. .driver = {
  220. .name = "rt2800_wmac",
  221. .owner = THIS_MODULE,
  222. .mod_name = KBUILD_MODNAME,
  223. },
  224. .probe = rt2800soc_probe,
  225. .remove = rt2x00soc_remove,
  226. .suspend = rt2x00soc_suspend,
  227. .resume = rt2x00soc_resume,
  228. };
  229. module_platform_driver(rt2800soc_driver);
  230. MODULE_AUTHOR(DRV_PROJECT);
  231. MODULE_VERSION(DRV_VERSION);
  232. MODULE_DESCRIPTION("Ralink WiSoC Wireless LAN driver.");
  233. MODULE_LICENSE("GPL");