190921014SLuciano Coelho /* 290921014SLuciano Coelho * This file is part of wl1251 390921014SLuciano Coelho * 490921014SLuciano Coelho * Copyright (c) 1998-2007 Texas Instruments Incorporated 590921014SLuciano Coelho * Copyright (C) 2008 Nokia Corporation 690921014SLuciano Coelho * 790921014SLuciano Coelho * This program is free software; you can redistribute it and/or 890921014SLuciano Coelho * modify it under the terms of the GNU General Public License 990921014SLuciano Coelho * version 2 as published by the Free Software Foundation. 1090921014SLuciano Coelho * 1190921014SLuciano Coelho * This program is distributed in the hope that it will be useful, but 1290921014SLuciano Coelho * WITHOUT ANY WARRANTY; without even the implied warranty of 1390921014SLuciano Coelho * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 1490921014SLuciano Coelho * General Public License for more details. 1590921014SLuciano Coelho * 1690921014SLuciano Coelho * You should have received a copy of the GNU General Public License 1790921014SLuciano Coelho * along with this program; if not, write to the Free Software 1890921014SLuciano Coelho * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 1990921014SLuciano Coelho * 02110-1301 USA 2090921014SLuciano Coelho * 2190921014SLuciano Coelho */ 2290921014SLuciano Coelho 2390921014SLuciano Coelho #ifndef __WL1251_EVENT_H__ 2490921014SLuciano Coelho #define __WL1251_EVENT_H__ 2590921014SLuciano Coelho 2690921014SLuciano Coelho /* 2790921014SLuciano Coelho * Mbox events 2890921014SLuciano Coelho * 2990921014SLuciano Coelho * The event mechanism is based on a pair of event buffers (buffers A and 3090921014SLuciano Coelho * B) at fixed locations in the target's memory. The host processes one 3190921014SLuciano Coelho * buffer while the other buffer continues to collect events. If the host 3290921014SLuciano Coelho * is not processing events, an interrupt is issued to signal that a buffer 3390921014SLuciano Coelho * is ready. Once the host is done with processing events from one buffer, 3490921014SLuciano Coelho * it signals the target (with an ACK interrupt) that the event buffer is 3590921014SLuciano Coelho * free. 3690921014SLuciano Coelho */ 3790921014SLuciano Coelho 3890921014SLuciano Coelho enum { 3990921014SLuciano Coelho RESERVED1_EVENT_ID = BIT(0), 4090921014SLuciano Coelho RESERVED2_EVENT_ID = BIT(1), 4190921014SLuciano Coelho MEASUREMENT_START_EVENT_ID = BIT(2), 4290921014SLuciano Coelho SCAN_COMPLETE_EVENT_ID = BIT(3), 4390921014SLuciano Coelho CALIBRATION_COMPLETE_EVENT_ID = BIT(4), 4490921014SLuciano Coelho ROAMING_TRIGGER_LOW_RSSI_EVENT_ID = BIT(5), 4590921014SLuciano Coelho PS_REPORT_EVENT_ID = BIT(6), 4690921014SLuciano Coelho SYNCHRONIZATION_TIMEOUT_EVENT_ID = BIT(7), 4790921014SLuciano Coelho HEALTH_REPORT_EVENT_ID = BIT(8), 4890921014SLuciano Coelho ACI_DETECTION_EVENT_ID = BIT(9), 4990921014SLuciano Coelho DEBUG_REPORT_EVENT_ID = BIT(10), 5090921014SLuciano Coelho MAC_STATUS_EVENT_ID = BIT(11), 5190921014SLuciano Coelho DISCONNECT_EVENT_COMPLETE_ID = BIT(12), 5290921014SLuciano Coelho JOIN_EVENT_COMPLETE_ID = BIT(13), 5390921014SLuciano Coelho CHANNEL_SWITCH_COMPLETE_EVENT_ID = BIT(14), 5490921014SLuciano Coelho BSS_LOSE_EVENT_ID = BIT(15), 5590921014SLuciano Coelho ROAMING_TRIGGER_MAX_TX_RETRY_EVENT_ID = BIT(16), 5690921014SLuciano Coelho MEASUREMENT_COMPLETE_EVENT_ID = BIT(17), 5790921014SLuciano Coelho AP_DISCOVERY_COMPLETE_EVENT_ID = BIT(18), 5890921014SLuciano Coelho SCHEDULED_SCAN_COMPLETE_EVENT_ID = BIT(19), 5990921014SLuciano Coelho PSPOLL_DELIVERY_FAILURE_EVENT_ID = BIT(20), 6090921014SLuciano Coelho RESET_BSS_EVENT_ID = BIT(21), 6190921014SLuciano Coelho REGAINED_BSS_EVENT_ID = BIT(22), 6290921014SLuciano Coelho ROAMING_TRIGGER_REGAINED_RSSI_EVENT_ID = BIT(23), 6390921014SLuciano Coelho ROAMING_TRIGGER_LOW_SNR_EVENT_ID = BIT(24), 6490921014SLuciano Coelho ROAMING_TRIGGER_REGAINED_SNR_EVENT_ID = BIT(25), 6590921014SLuciano Coelho 6690921014SLuciano Coelho DBG_EVENT_ID = BIT(26), 6790921014SLuciano Coelho BT_PTA_SENSE_EVENT_ID = BIT(27), 6890921014SLuciano Coelho BT_PTA_PREDICTION_EVENT_ID = BIT(28), 6990921014SLuciano Coelho BT_PTA_AVALANCHE_EVENT_ID = BIT(29), 7090921014SLuciano Coelho 7190921014SLuciano Coelho PLT_RX_CALIBRATION_COMPLETE_EVENT_ID = BIT(30), 7290921014SLuciano Coelho 7390921014SLuciano Coelho EVENT_MBOX_ALL_EVENT_ID = 0x7fffffff, 7490921014SLuciano Coelho }; 7590921014SLuciano Coelho 7690921014SLuciano Coelho struct event_debug_report { 7790921014SLuciano Coelho u8 debug_event_id; 7890921014SLuciano Coelho u8 num_params; 7990921014SLuciano Coelho u16 pad; 8090921014SLuciano Coelho u32 report_1; 8190921014SLuciano Coelho u32 report_2; 8290921014SLuciano Coelho u32 report_3; 8390921014SLuciano Coelho } __packed; 8490921014SLuciano Coelho 8590921014SLuciano Coelho struct event_mailbox { 8690921014SLuciano Coelho u32 events_vector; 8790921014SLuciano Coelho u32 events_mask; 8890921014SLuciano Coelho u32 reserved_1; 8990921014SLuciano Coelho u32 reserved_2; 9090921014SLuciano Coelho 9190921014SLuciano Coelho char average_rssi_level; 9290921014SLuciano Coelho u8 ps_status; 9390921014SLuciano Coelho u8 channel_switch_status; 9490921014SLuciano Coelho u8 scheduled_scan_status; 9590921014SLuciano Coelho 9690921014SLuciano Coelho /* Channels scanned by the scheduled scan */ 9790921014SLuciano Coelho u16 scheduled_scan_channels; 9890921014SLuciano Coelho 9990921014SLuciano Coelho /* If bit 0 is set -> target's fatal error */ 10090921014SLuciano Coelho u16 health_report; 10190921014SLuciano Coelho u16 bad_fft_counter; 10290921014SLuciano Coelho u8 bt_pta_sense_info; 10390921014SLuciano Coelho u8 bt_pta_protective_info; 10490921014SLuciano Coelho u32 reserved; 10590921014SLuciano Coelho u32 debug_report[2]; 10690921014SLuciano Coelho 10790921014SLuciano Coelho /* Number of FCS errors since last event */ 10890921014SLuciano Coelho u32 fcs_err_counter; 10990921014SLuciano Coelho 11090921014SLuciano Coelho struct event_debug_report report; 11190921014SLuciano Coelho u8 average_snr_level; 11290921014SLuciano Coelho u8 padding[19]; 11390921014SLuciano Coelho } __packed; 11490921014SLuciano Coelho 115*f7ad1eedSDavid Gnedt enum { 116*f7ad1eedSDavid Gnedt EVENT_ENTER_POWER_SAVE_FAIL = 0, 117*f7ad1eedSDavid Gnedt EVENT_ENTER_POWER_SAVE_SUCCESS, 118*f7ad1eedSDavid Gnedt EVENT_EXIT_POWER_SAVE_FAIL, 119*f7ad1eedSDavid Gnedt EVENT_EXIT_POWER_SAVE_SUCCESS, 120*f7ad1eedSDavid Gnedt }; 121*f7ad1eedSDavid Gnedt 12290921014SLuciano Coelho int wl1251_event_unmask(struct wl1251 *wl); 12390921014SLuciano Coelho void wl1251_event_mbox_config(struct wl1251 *wl); 12490921014SLuciano Coelho int wl1251_event_handle(struct wl1251 *wl, u8 mbox); 12590921014SLuciano Coelho int wl1251_event_wait(struct wl1251 *wl, u32 mask, int timeout_ms); 12690921014SLuciano Coelho 12790921014SLuciano Coelho #endif 128