root/drivers/net/wireless/ralink/rt2x00/rt2800soc.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. rt2800soc_hwcrypt_disabled
  2. rt2800soc_disable_radio
  3. rt2800soc_set_device_state
  4. rt2800soc_read_eeprom
  5. rt2800soc_get_firmware_name
  6. rt2800soc_load_firmware
  7. rt2800soc_check_firmware
  8. rt2800soc_write_firmware
  9. rt2800soc_probe

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

/* [<][>][^][v][top][bottom][index][help] */