atheros driver (3/8)
Subsystems (3)
drivers/net/wireless/atheros/atheros5212/beacons.c +235 -0
@@ -0,0 +1,235 @@ +/* +* All the work was created by reverse engineering and porting +* for interoperability. The creator is Mateusz Berezecki, +* unless explicitly marked ( some parts are derived +* from GPL'ed parts of madwifi project located at http://madwifi.sf.net) +* +* derived or copied parts of code licensed under +* dual GPL/BSD license +* Copyright (c) 2002-2005 Sam Leffler, Errno Consulting +* All rights reserved. +* +* rest of the code has been reversed by me and is under copyright too +* Copyright (C) 2005 Mateusz Berezecki +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +*/ + +#include <linux/config.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/version.h> +#include <linux/init.h> +#include <linux/delay.h> +#include <linux/pci.h> +#include <linux/netdevice.h> + +#include <net/ieee80211.h> + +#include <linux/wireless.h> +#include <net/iw_handler.h> + +#include "atheros_id.h" +#include "atheros_dev.h" +#include "atheros_defs.h" +//#include "atheros_devops.h" +//#include "atheros_regops.h" +#include "atheros_registers.h" +#include "atheros.h" + + + + +void ath_beacon_init (struct net_device *netdev,unsigned int nextbtt, +unsigned int intval) +{ +struct atheros_priv *pdata =ieee80211_priv (netdev); +struct ieee80211_device *dev =netdev_priv (netdev); +unsigned int val; + +ath_reg_write (netdev,AR5212_TIMER0 , nextbtt); + +switch (dev->iw_mode) { +case IW_MODE_MONITOR : +case IW_MODE_INFRA : +ath_reg_write (netdev, +AR5212_TIMER1 , +0xffff ); +ath_reg_write (netdev, +AR5212_TIMER2 , +0x7ffff ); +break ; + +case IW_MODE_ADHOC : +ath_reg_write (netdev, +AR5212_TIMER1 , + (nextbtt -2 ) <<3 ); +ath_reg_write (netdev, +AR5212_TIMER2 , + (nextbtt -10 ) <<3 ); +break ; + +default : +break ; + } + +ath_reg_write (netdev,AR5212_TIMER3 , nextbtt + + (pdata->atim_win ? pdata->atim_win :1 )); + + val = intval & + (AR5212_BEACON_PERIOD | +AR5212_BEACON_RESET_TSF | +AR5212_BEACON_ENABLE ); + +if (val &AR5212_BEACON_RESET_TSF ) +ath_reg_write (netdev,AR5212_BEACON , +AR5212_BEACON_RESET_TSF ); + +ath_reg_write (netdev,AR5212_BEACON , val); +} + +void ath_reset_station_btimers (struct net_device *netdev) +{ +int tmp; + +ath_reg_write (netdev,AR5212_TIMER0 ,0 ); + tmp = (ath_reg_read (netdev,AR5212_STA_ID1 ) + |AR5212_STA_ID1_PWR_SV ) & + ~(AR5212_STA_ID1_DEFAULT_ANTENNA | +AR5212_STA_ID1_PCF ); + + +ath_reg_write (netdev,AR5212_BEACON ,0xffff ); +return ; +} + +void ath_set_station_btimers (struct net_device *netdev, +struct beacon_state *state,unsigned int tsf, +unsigned int dtcx,unsigned int cfpcx) +{ +unsigned int tmp, dtimp, nextt; +unsigned int bintval; + +if (state->bs_cfpperiod) { + tmp =ath_reg_read (netdev,AR5212_STA_ID1 ); + tmp |=AR5212_STA_ID1_PCF ; + +ath_reg_write (netdev,AR5212_STA_ID1 , tmp); + +ath_reg_write (netdev,AR5212_CFP_PERIOD , + state->bs_cfpperiod * + state->bs_dtimperiod * + state->bs_intval); + +ath_reg_write (netdev,AR5212_CFP_DUR , + state->bs_cfpmaxduration); + +ath_reg_write (netdev,AR5212_TIMER2 , + ((tsf + + ((cfpcx * state->bs_dtimperiod + dtcx) * + state->bs_intval))) <<3 ); + }else +ath_reg_disable (netdev, +AR5212_STA_ID1 , +AR5212_STA_ID1_PCF ); + + + bintval = state->bs_intval; + +ath_reg_write (netdev,AR5212_TIMER0 , state->bs_nexttbtt); + + tmp =ath_reg_read (netdev,AR5212_BEACON ) &0xff800000 ; + tmp |= state->bs_intval &0xffff ; + +if (state->bs_timoffset) { + tmp |= ((state->bs_timoffset +4 ) <<16 ) &0x7f0000 ; + }else { + tmp |= (4 <<16 ) &0x7f0000 ; + } + +ath_reg_write (netdev,AR5212_BEACON , tmp); + + +if (state->bs_bmissthreshold <= (0xff00 >>8 )) { +BUG (); +return ; + } + + tmp =ath_reg_read (netdev,AR5212_RSSI_THR ) & (~0xff00 ); + tmp |= (state->bs_bmissthreshold <<8 ) &0xff00 ; +ath_reg_write (netdev,AR5212_RSSI_THR , tmp); + + + bintval = state->bs_intval; +if (bintval < state->bs_sleepduration) + bintval = state->bs_sleepduration; + + + dtimp = state->bs_dtimperiod; +if (state->bs_sleepduration > dtimp) + dtimp = state->bs_sleepduration; + +if (bintval == dtimp) + nextt = state->bs_nextdtim; +else + nextt = state->bs_nexttbtt; + +ath_reg_write (netdev,AR5212_SLEEP0 , + ((state->bs_nextdtim -3 ) &0x7ffff ) | + ((10 <<24 ) &0xff000000 ) | +0x00080000 |0x00100000 ); + +ath_reg_write (netdev,AR5212_SLEEP1 , + ( ( (nextt -3 ) <<3 ) &0x7ffff ) | + ((10 <<24 ) &0xff000000 )); + +ath_reg_write (netdev,AR5212_SLEEP2 , + (bintval &0x0000ffff ) | + ((dtimp <<16 ) &0xffff0000 )); +} + + +unsigned int ath_wait_for_beacon_done (struct net_device *netdev) +{ +unsigned int i; + +for (i =0 ; i <1000 ; i++) { +/* XXX remove this comment +* if ( !ath_num_tx_pending(netdev, 2) ) +break; +*/ +udelay (10 ); + } + +if (i <1000 ) +return 1 ; + +return 0 ; +} + + +unsigned int ath_beacon_queue_setup (struct net_device *netdev) +{ +struct tx_queue_info qi; +memset (&qi,0 ,sizeof (qi)); + + qi.tqi_aifs =0xffffffff ; + qi.tqi_cwmin =0xffffffff ; + qi.tqi_cwmax =0xffffffff ; + qi.tqi_qflags =0x00000002 ; + +return ath_setup_tx_queue (netdev,2 , &qi); +} +
drivers/net/wireless/atheros/atheros5212/caps.c +176 -0
176 lines not on this page · raw message
drivers/net/wireless/atheros/atheros5212/caps.h +61 -0
61 lines not on this page · raw message
drivers/net/wireless/atheros/atheros5212/chans.c +213 -0
213 lines not on this page · raw message
drivers/net/wireless/atheros/atheros5212/chans.h +110 -0
110 lines not on this page · raw message
_______________________________________________
Kernel-mentors mailing list
[email protected]
http://selenic.com/mailman/listinfo/kernel-mentors