18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * This file is part of wl1251
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright (c) 1998-2007 Texas Instruments Incorporated
68c2ecf20Sopenharmony_ci * Copyright (C) 2008 Nokia Corporation
78c2ecf20Sopenharmony_ci */
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#ifndef __WL1251_EVENT_H__
108c2ecf20Sopenharmony_ci#define __WL1251_EVENT_H__
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci/*
138c2ecf20Sopenharmony_ci * Mbox events
148c2ecf20Sopenharmony_ci *
158c2ecf20Sopenharmony_ci * The event mechanism is based on a pair of event buffers (buffers A and
168c2ecf20Sopenharmony_ci * B) at fixed locations in the target's memory. The host processes one
178c2ecf20Sopenharmony_ci * buffer while the other buffer continues to collect events. If the host
188c2ecf20Sopenharmony_ci * is not processing events, an interrupt is issued to signal that a buffer
198c2ecf20Sopenharmony_ci * is ready. Once the host is done with processing events from one buffer,
208c2ecf20Sopenharmony_ci * it signals the target (with an ACK interrupt) that the event buffer is
218c2ecf20Sopenharmony_ci * free.
228c2ecf20Sopenharmony_ci */
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_cienum {
258c2ecf20Sopenharmony_ci	RESERVED1_EVENT_ID                       = BIT(0),
268c2ecf20Sopenharmony_ci	RESERVED2_EVENT_ID                       = BIT(1),
278c2ecf20Sopenharmony_ci	MEASUREMENT_START_EVENT_ID               = BIT(2),
288c2ecf20Sopenharmony_ci	SCAN_COMPLETE_EVENT_ID                   = BIT(3),
298c2ecf20Sopenharmony_ci	CALIBRATION_COMPLETE_EVENT_ID            = BIT(4),
308c2ecf20Sopenharmony_ci	ROAMING_TRIGGER_LOW_RSSI_EVENT_ID        = BIT(5),
318c2ecf20Sopenharmony_ci	PS_REPORT_EVENT_ID                       = BIT(6),
328c2ecf20Sopenharmony_ci	SYNCHRONIZATION_TIMEOUT_EVENT_ID         = BIT(7),
338c2ecf20Sopenharmony_ci	HEALTH_REPORT_EVENT_ID                   = BIT(8),
348c2ecf20Sopenharmony_ci	ACI_DETECTION_EVENT_ID                   = BIT(9),
358c2ecf20Sopenharmony_ci	DEBUG_REPORT_EVENT_ID                    = BIT(10),
368c2ecf20Sopenharmony_ci	MAC_STATUS_EVENT_ID                      = BIT(11),
378c2ecf20Sopenharmony_ci	DISCONNECT_EVENT_COMPLETE_ID             = BIT(12),
388c2ecf20Sopenharmony_ci	JOIN_EVENT_COMPLETE_ID                   = BIT(13),
398c2ecf20Sopenharmony_ci	CHANNEL_SWITCH_COMPLETE_EVENT_ID         = BIT(14),
408c2ecf20Sopenharmony_ci	BSS_LOSE_EVENT_ID                        = BIT(15),
418c2ecf20Sopenharmony_ci	ROAMING_TRIGGER_MAX_TX_RETRY_EVENT_ID    = BIT(16),
428c2ecf20Sopenharmony_ci	MEASUREMENT_COMPLETE_EVENT_ID            = BIT(17),
438c2ecf20Sopenharmony_ci	AP_DISCOVERY_COMPLETE_EVENT_ID           = BIT(18),
448c2ecf20Sopenharmony_ci	SCHEDULED_SCAN_COMPLETE_EVENT_ID         = BIT(19),
458c2ecf20Sopenharmony_ci	PSPOLL_DELIVERY_FAILURE_EVENT_ID 	 = BIT(20),
468c2ecf20Sopenharmony_ci	RESET_BSS_EVENT_ID                       = BIT(21),
478c2ecf20Sopenharmony_ci	REGAINED_BSS_EVENT_ID                    = BIT(22),
488c2ecf20Sopenharmony_ci	ROAMING_TRIGGER_REGAINED_RSSI_EVENT_ID   = BIT(23),
498c2ecf20Sopenharmony_ci	ROAMING_TRIGGER_LOW_SNR_EVENT_ID         = BIT(24),
508c2ecf20Sopenharmony_ci	ROAMING_TRIGGER_REGAINED_SNR_EVENT_ID    = BIT(25),
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci	DBG_EVENT_ID                             = BIT(26),
538c2ecf20Sopenharmony_ci	BT_PTA_SENSE_EVENT_ID                    = BIT(27),
548c2ecf20Sopenharmony_ci	BT_PTA_PREDICTION_EVENT_ID               = BIT(28),
558c2ecf20Sopenharmony_ci	BT_PTA_AVALANCHE_EVENT_ID                = BIT(29),
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci	PLT_RX_CALIBRATION_COMPLETE_EVENT_ID     = BIT(30),
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci	EVENT_MBOX_ALL_EVENT_ID                  = 0x7fffffff,
608c2ecf20Sopenharmony_ci};
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_cistruct event_debug_report {
638c2ecf20Sopenharmony_ci	u8 debug_event_id;
648c2ecf20Sopenharmony_ci	u8 num_params;
658c2ecf20Sopenharmony_ci	u16 pad;
668c2ecf20Sopenharmony_ci	u32 report_1;
678c2ecf20Sopenharmony_ci	u32 report_2;
688c2ecf20Sopenharmony_ci	u32 report_3;
698c2ecf20Sopenharmony_ci} __packed;
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_cistruct event_mailbox {
728c2ecf20Sopenharmony_ci	u32 events_vector;
738c2ecf20Sopenharmony_ci	u32 events_mask;
748c2ecf20Sopenharmony_ci	u32 reserved_1;
758c2ecf20Sopenharmony_ci	u32 reserved_2;
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_ci	char average_rssi_level;
788c2ecf20Sopenharmony_ci	u8 ps_status;
798c2ecf20Sopenharmony_ci	u8 channel_switch_status;
808c2ecf20Sopenharmony_ci	u8 scheduled_scan_status;
818c2ecf20Sopenharmony_ci
828c2ecf20Sopenharmony_ci	/* Channels scanned by the scheduled scan */
838c2ecf20Sopenharmony_ci	u16 scheduled_scan_channels;
848c2ecf20Sopenharmony_ci
858c2ecf20Sopenharmony_ci	/* If bit 0 is set -> target's fatal error */
868c2ecf20Sopenharmony_ci	u16 health_report;
878c2ecf20Sopenharmony_ci	u16 bad_fft_counter;
888c2ecf20Sopenharmony_ci	u8 bt_pta_sense_info;
898c2ecf20Sopenharmony_ci	u8 bt_pta_protective_info;
908c2ecf20Sopenharmony_ci	u32 reserved;
918c2ecf20Sopenharmony_ci	u32 debug_report[2];
928c2ecf20Sopenharmony_ci
938c2ecf20Sopenharmony_ci	/* Number of FCS errors since last event */
948c2ecf20Sopenharmony_ci	u32 fcs_err_counter;
958c2ecf20Sopenharmony_ci
968c2ecf20Sopenharmony_ci	struct event_debug_report report;
978c2ecf20Sopenharmony_ci	u8 average_snr_level;
988c2ecf20Sopenharmony_ci	u8 padding[19];
998c2ecf20Sopenharmony_ci} __packed;
1008c2ecf20Sopenharmony_ci
1018c2ecf20Sopenharmony_cienum {
1028c2ecf20Sopenharmony_ci	EVENT_ENTER_POWER_SAVE_FAIL = 0,
1038c2ecf20Sopenharmony_ci	EVENT_ENTER_POWER_SAVE_SUCCESS,
1048c2ecf20Sopenharmony_ci	EVENT_EXIT_POWER_SAVE_FAIL,
1058c2ecf20Sopenharmony_ci	EVENT_EXIT_POWER_SAVE_SUCCESS,
1068c2ecf20Sopenharmony_ci};
1078c2ecf20Sopenharmony_ci
1088c2ecf20Sopenharmony_ciint wl1251_event_unmask(struct wl1251 *wl);
1098c2ecf20Sopenharmony_civoid wl1251_event_mbox_config(struct wl1251 *wl);
1108c2ecf20Sopenharmony_ciint wl1251_event_handle(struct wl1251 *wl, u8 mbox);
1118c2ecf20Sopenharmony_ciint wl1251_event_wait(struct wl1251 *wl, u32 mask, int timeout_ms);
1128c2ecf20Sopenharmony_ci
1138c2ecf20Sopenharmony_ci#endif
114