diff options
author | Kalle Valo <kalle.valo@nokia.com> | 2009-04-29 16:33:31 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-05-06 15:14:54 -0400 |
commit | 2f01a1f58889fbfeb68b1bc1b52e4197f3333490 (patch) | |
tree | 949cf33c4e3dcdf7abcf95c9bda4d8372da04f97 /drivers/net/wireless/wl12xx/event.c | |
parent | d53d9e67b55f6a9fc3f836c5c392eb41ce5676f4 (diff) |
wl12xx: add driver
wl12xx is a driver for TI wl1251 802.11 chipset designed for embedded
devices, supporting both SDIO and SPI busses. Currently the driver
supports only SPI. Adding support 1253 (the 5 GHz version) should be
relatively easy. More information here:
http://focus.ti.com/general/docs/wtbu/wtbuproductcontent.tsp?contentId=4711&navigationId=12494&templateId=6123
(Collapsed original sequence of pre-merge patches into single commit for
initial merge. -- JWL)
Signed-off-by: Kalle Valo <kalle.valo@nokia.com>
Signed-off-by: Bob Copeland <me@bobcopeland.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/wl12xx/event.c')
-rw-r--r-- | drivers/net/wireless/wl12xx/event.c | 127 |
1 files changed, 127 insertions, 0 deletions
diff --git a/drivers/net/wireless/wl12xx/event.c b/drivers/net/wireless/wl12xx/event.c new file mode 100644 index 000000000000..99529ca89a7e --- /dev/null +++ b/drivers/net/wireless/wl12xx/event.c | |||
@@ -0,0 +1,127 @@ | |||
1 | /* | ||
2 | * This file is part of wl12xx | ||
3 | * | ||
4 | * Copyright (c) 1998-2007 Texas Instruments Incorporated | ||
5 | * Copyright (C) 2008 Nokia Corporation | ||
6 | * | ||
7 | * Contact: Kalle Valo <kalle.valo@nokia.com> | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or | ||
10 | * modify it under the terms of the GNU General Public License | ||
11 | * version 2 as published by the Free Software Foundation. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, but | ||
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
16 | * General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program; if not, write to the Free Software | ||
20 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
21 | * 02110-1301 USA | ||
22 | * | ||
23 | */ | ||
24 | |||
25 | #include "wl12xx.h" | ||
26 | #include "reg.h" | ||
27 | #include "spi.h" | ||
28 | #include "event.h" | ||
29 | #include "ps.h" | ||
30 | |||
31 | static int wl12xx_event_scan_complete(struct wl12xx *wl, | ||
32 | struct event_mailbox *mbox) | ||
33 | { | ||
34 | wl12xx_debug(DEBUG_EVENT, "status: 0x%x, channels: %d", | ||
35 | mbox->scheduled_scan_status, | ||
36 | mbox->scheduled_scan_channels); | ||
37 | |||
38 | if (wl->scanning) { | ||
39 | mutex_unlock(&wl->mutex); | ||
40 | ieee80211_scan_completed(wl->hw, false); | ||
41 | mutex_lock(&wl->mutex); | ||
42 | wl->scanning = false; | ||
43 | } | ||
44 | |||
45 | return 0; | ||
46 | } | ||
47 | |||
48 | static void wl12xx_event_mbox_dump(struct event_mailbox *mbox) | ||
49 | { | ||
50 | wl12xx_debug(DEBUG_EVENT, "MBOX DUMP:"); | ||
51 | wl12xx_debug(DEBUG_EVENT, "\tvector: 0x%x", mbox->events_vector); | ||
52 | wl12xx_debug(DEBUG_EVENT, "\tmask: 0x%x", mbox->events_mask); | ||
53 | } | ||
54 | |||
55 | static int wl12xx_event_process(struct wl12xx *wl, struct event_mailbox *mbox) | ||
56 | { | ||
57 | int ret; | ||
58 | u32 vector; | ||
59 | |||
60 | wl12xx_event_mbox_dump(mbox); | ||
61 | |||
62 | vector = mbox->events_vector & ~(mbox->events_mask); | ||
63 | wl12xx_debug(DEBUG_EVENT, "vector: 0x%x", vector); | ||
64 | |||
65 | if (vector & SCAN_COMPLETE_EVENT_ID) { | ||
66 | ret = wl12xx_event_scan_complete(wl, mbox); | ||
67 | if (ret < 0) | ||
68 | return ret; | ||
69 | } | ||
70 | |||
71 | if (vector & BSS_LOSE_EVENT_ID) { | ||
72 | wl12xx_debug(DEBUG_EVENT, "BSS_LOSE_EVENT"); | ||
73 | |||
74 | if (wl->psm_requested && wl->psm) { | ||
75 | ret = wl12xx_ps_set_mode(wl, STATION_ACTIVE_MODE); | ||
76 | if (ret < 0) | ||
77 | return ret; | ||
78 | } | ||
79 | } | ||
80 | |||
81 | return 0; | ||
82 | } | ||
83 | |||
84 | int wl12xx_event_unmask(struct wl12xx *wl) | ||
85 | { | ||
86 | int ret; | ||
87 | |||
88 | ret = wl12xx_acx_event_mbox_mask(wl, ~(wl->event_mask)); | ||
89 | if (ret < 0) | ||
90 | return ret; | ||
91 | |||
92 | return 0; | ||
93 | } | ||
94 | |||
95 | void wl12xx_event_mbox_config(struct wl12xx *wl) | ||
96 | { | ||
97 | wl->mbox_ptr[0] = wl12xx_reg_read32(wl, REG_EVENT_MAILBOX_PTR); | ||
98 | wl->mbox_ptr[1] = wl->mbox_ptr[0] + sizeof(struct event_mailbox); | ||
99 | |||
100 | wl12xx_debug(DEBUG_EVENT, "MBOX ptrs: 0x%x 0x%x", | ||
101 | wl->mbox_ptr[0], wl->mbox_ptr[1]); | ||
102 | } | ||
103 | |||
104 | int wl12xx_event_handle(struct wl12xx *wl, u8 mbox_num) | ||
105 | { | ||
106 | struct event_mailbox mbox; | ||
107 | int ret; | ||
108 | |||
109 | wl12xx_debug(DEBUG_EVENT, "EVENT on mbox %d", mbox_num); | ||
110 | |||
111 | if (mbox_num > 1) | ||
112 | return -EINVAL; | ||
113 | |||
114 | /* first we read the mbox descriptor */ | ||
115 | wl12xx_spi_mem_read(wl, wl->mbox_ptr[mbox_num], &mbox, | ||
116 | sizeof(struct event_mailbox)); | ||
117 | |||
118 | /* process the descriptor */ | ||
119 | ret = wl12xx_event_process(wl, &mbox); | ||
120 | if (ret < 0) | ||
121 | return ret; | ||
122 | |||
123 | /* then we let the firmware know it can go on...*/ | ||
124 | wl12xx_reg_write32(wl, ACX_REG_INTERRUPT_TRIG, INTR_TRIG_EVENT_ACK); | ||
125 | |||
126 | return 0; | ||
127 | } | ||