b17995a772ea6557b7bf53e866c1661b1cda845d
[openwrt/staging/florian.git] / package / bcm43xx-mac80211 / src / bcm43xx / bcm43xx_power.c
1 /*
2
3 Broadcom BCM43xx wireless driver
4
5 Copyright (c) 2005 Martin Langer <martin-langer@gmx.de>,
6 Stefano Brivio <st3@riseup.net>
7 Michael Buesch <mb@bu3sch.de>
8 Danny van Dyk <kugelfang@gentoo.org>
9 Andreas Jaggi <andreas.jaggi@waterwave.ch>
10
11 Some parts of the code in this file are derived from the ipw2200
12 driver Copyright(c) 2003 - 2004 Intel Corporation.
13
14 This program is free software; you can redistribute it and/or modify
15 it under the terms of the GNU General Public License as published by
16 the Free Software Foundation; either version 2 of the License, or
17 (at your option) any later version.
18
19 This program is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 GNU General Public License for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with this program; see the file COPYING. If not, write to
26 the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
27 Boston, MA 02110-1301, USA.
28
29 */
30
31 #include <linux/delay.h>
32
33 #include "bcm43xx.h"
34 #include "bcm43xx_power.h"
35 #include "bcm43xx_main.h"
36
37
38 //TODO Kill this file.
39
40 /* Set the PowerSavingControlBits.
41 * Bitvalues:
42 * 0 => unset the bit
43 * 1 => set the bit
44 * -1 => calculate the bit
45 */
46 void bcm43xx_power_saving_ctl_bits(struct bcm43xx_wldev *dev,
47 int bit25, int bit26)
48 {
49 int i;
50 u32 status;
51
52 //FIXME: Force 25 to off and 26 to on for now:
53 bit25 = 0;
54 bit26 = 1;
55
56 if (bit25 == -1) {
57 //TODO: If powersave is not off and FIXME is not set and we are not in adhoc
58 // and thus is not an AP and we are associated, set bit 25
59 }
60 if (bit26 == -1) {
61 //TODO: If the device is awake or this is an AP, or we are scanning, or FIXME,
62 // or we are associated, or FIXME, or the latest PS-Poll packet sent was
63 // successful, set bit26
64 }
65 status = bcm43xx_read32(dev, BCM43xx_MMIO_STATUS_BITFIELD);
66 if (bit25)
67 status |= BCM43xx_SBF_PS1;
68 else
69 status &= ~BCM43xx_SBF_PS1;
70 if (bit26)
71 status |= BCM43xx_SBF_PS2;
72 else
73 status &= ~BCM43xx_SBF_PS2;
74 bcm43xx_write32(dev, BCM43xx_MMIO_STATUS_BITFIELD, status);
75 if (bit26 && dev->dev->id.revision >= 5) {
76 for (i = 0; i < 100; i++) {
77 if (bcm43xx_shm_read32(dev, BCM43xx_SHM_SHARED, 0x0040) != 4)
78 break;
79 udelay(10);
80 }
81 }
82 }