22b799f5a2
When the LMAC active monitor detects 'link break between lmac and host'
(the hw_buf_used==pending watchdog in bes2600_bh_lmac_active_monitor),
bes2600_chrdev_wifi_force_close(hw_priv, true) is invoked to tear the
device down and prepare for a fresh probe. On the wifi_force_close_work
side this calls bes2600_chrdev_do_system_close() which dispatches
sbus_ops->power_switch(0).
On PineTab2 (RK3566 + BES2600WM over SDIO) this recovery path is a
no-op:
* bes2600_sdio_power_down() writes a SYSTEM_CLOSE host-int message,
clears MMC_CAP_NONREMOVABLE, and schedules sdio_scan_work, which is
the literal one-line stub bes_warn("...this function does
nothing\n").
* bes2600_sdio_on() (the eventual power_switch(1) counterpart)
toggles pdata->powerup, which is NULL on PineTab2 because the
wifi-reset GPIO is owned by sdio_pwrseq, not the bes2600 device
tree node (see arch/arm64/boot/dts/rockchip/rk3566-pinetab2.dtsi:
'The reset pin is claimed by sdio_mmcseq, It is better to move it
to U-Boot so the OS can use it.').
Net result: the chip is never reset. The function drivers are not
removed (the SDIO core has no signal that the card is gone), the
firmware stays wedged, and a subsequent rmmod bes2600 leaves the SDIO
function in a half-torn-down state. modprobe bes2600 then fails with
'probe with driver bes2600_wlan failed with error -123' (-ENOMEDIUM)
on both functions (:1 wifi, :2 BT-companion) until a full system
reboot.
Observed on PineTab2 (linux-pinetab2 6.19.10-danctnix1-1) after ~150
minutes of background-scan rejects (wsm_generic_confirm 0x0007,
[SCAN] Scan failed (-22)) accumulating until the LMAC stopped
acknowledging TX buffers (hw_buf_used:24 pending:24). Reproducible
under sustained scan pressure.
Add a sbus operation bus_reset() that the recovery path can call when
power_switch() has no effective chip-reset signal of its own. Provide
an SDIO implementation that calls mmc_hw_reset(self->func->card),
which on a multi-function SDIO card (PineTab2 binds func 1 for WLAN
and func 2 for the BT-companion path) takes the remove-and-rescan
path: mmc_sdio_hw_reset() marks the card removed and schedules
mmc_rescan, which tears down the bound function drivers and re-detects
the card on the next sweep, in turn reinvoking bes2600_sdio_probe().
With a single function probed it instead invokes mmc_power_cycle()
directly, which on PineTab2 toggles the wifi-reset GPIO via
sdio_pwrseq.
Add bes2600_chrdev_do_bus_reset() as the chrdev-side helper. It
invokes the bus op and then waits on probe_done_wq for the SDIO
remove() callback to clear sbus_priv, mirroring the wait pattern
already used by bes2600_chrdev_do_system_close() so that a subsequent
bes2600_switch_wifi(true) sees a clean state and can wait on the
fresh probe.
Wire it into bes2600_chrdev_wifi_force_close_work(): when halt_dev is
set (the hard-exception path used by both
bes2600_bh_lmac_active_monitor and bes2600_bh_mcu_active_monitor) and
the underlying bus implements bus_reset, take the new recovery path;
otherwise fall back to the legacy power_switch(0) sequence so this
patch is a no-op on USB or any other future bus that does not provide
bus_reset.
mmc_hw_reset() is exported by the MMC core and is the canonical
recovery primitive; calling it without holding the SDIO host claim is
correct because the multi-func remove-and-rescan path acquires the
host claim via the mmc workqueue, and the single-func mmc_power_cycle
path does not require the host claim.
No DT change is required: this works against the existing PineTab2
DTS, where the wifi-reset GPIO and the optional sdio_pwrkey GPIO (on
v2.0 boards) are both already configured as MMC pwrseq resets.
Signed-off-by: Markus Fritsche <fritsche.markus@gmail.com>
97 lines
2.9 KiB
C
97 lines
2.9 KiB
C
/*
|
|
* Mac80211 driver for BES2600 device
|
|
*
|
|
* Copyright (c) 2022, Bestechnic
|
|
* Author:
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
* published by the Free Software Foundation.
|
|
*/
|
|
#ifndef __BES_CHARDEV_H__
|
|
#define __BES_CHARDEV_H__
|
|
|
|
#define BES2600_FW_TYPE_WIFI_SIGNAL 0
|
|
#define BES2600_FW_TYPE_WIFI_NO_SIGNAL 1
|
|
#define BES2600_FW_TYPE_BT 2
|
|
#define BES2600_FW_TYPE_MAX_NUM 3
|
|
|
|
#define DPD_VERSION_OFFSET 0x3AF4
|
|
#define DPD_BIN_SIZE 0x3B14
|
|
#define DPD_BIN_FILE_SIZE 0x4000
|
|
#define DPD_CUR_VERSION 7
|
|
|
|
enum pend_read_op {
|
|
BES_CDEV_READ_WAKEUP_STATE = 0,
|
|
/* add new here */
|
|
|
|
BES_CDEV_READ_NUM_MAX,
|
|
};
|
|
|
|
enum wifi_wakeup_reason_code {
|
|
WAKEUP_REASON_WIFI_DEAUTH_DISASSOC = 0x1000,
|
|
WAKEUP_REASON_WIFI_BSSLOST,
|
|
/* add new here */
|
|
};
|
|
|
|
enum bt_wakeup_reason_code {
|
|
WAKEUP_REASON_BT_PLAY = 0x0100,
|
|
/* add new here */
|
|
};
|
|
|
|
enum wakeup_event {
|
|
WAKEUP_EVENT_NONE = 0,
|
|
WAKEUP_EVENT_SETTING,
|
|
WAKEUP_EVENT_WSME,
|
|
WAKEUP_EVENT_PEER_DETACH,
|
|
/* add new here */
|
|
};
|
|
|
|
/* dpd management */
|
|
u8* bes2600_chrdev_get_dpd_buffer(u32 size);
|
|
int bes2600_chrdev_update_dpd_data(void);
|
|
const u8* bes2600_chrdev_get_dpd_data(u32 *len);
|
|
void bes2600_chrdev_free_dpd_data(void);
|
|
|
|
/* get/set subs_priv instance from/to bes_chrdev module */
|
|
void bes2600_chrdev_set_sbus_priv_data(struct sbus_priv *priv, bool error);
|
|
struct sbus_priv *bes2600_chrdev_get_sbus_priv_data(void);
|
|
|
|
/* used to control device power down */
|
|
int bes2600_chrdev_check_system_close(void);
|
|
int bes2600_chrdev_do_system_close(const struct sbus_ops *sbus_ops, struct sbus_priv *priv);
|
|
int bes2600_chrdev_do_bus_reset(const struct sbus_ops *sbus_ops, struct sbus_priv *priv);
|
|
void bes2600_chrdev_wakeup_bt(void);
|
|
void bes2600_chrdev_wifi_force_close(struct bes2600_common *hw_priv, bool halt_dev);
|
|
void bes2600_chrdev_usb_remove(struct bes2600_common *hw_priv);
|
|
int bes2600_chrdev_switch_subsys_glb(int wifi, int bt);
|
|
|
|
/* get and set internal state */
|
|
bool bes2600_chrdev_is_wifi_opened(void);
|
|
bool bes2600_chrdev_is_bt_opened(void);
|
|
int bes2600_chrdev_get_fw_type(void);
|
|
bool bes2600_chrdev_is_signal_mode(void);
|
|
void bes2600_chrdev_update_signal_mode(void);
|
|
bool bes2600_chrdev_is_bus_error(void);
|
|
|
|
/* bus probe check */
|
|
void bes2600_chrdev_start_bus_probe(void);
|
|
void bes2600_chrdev_bus_probe_notify(void);
|
|
|
|
/* set wifi wakeup state */
|
|
void bes2600_chrdev_wifi_update_wakeup_reason(u16 reason, u16 port);
|
|
void bes2600_chrdev_wakeup_by_event_set(enum wakeup_event wakeup_event);
|
|
int bes2600_chrdev_wakeup_by_event_get(void);
|
|
|
|
/* init and deinit module */
|
|
int bes2600_chrdev_init(struct sbus_ops *ops);
|
|
void bes2600_chrdev_free(void);
|
|
|
|
#ifdef BES2600_DUMP_FW_DPD_LOG
|
|
void bes2600_free_dpd_log_buffer(void);
|
|
u8* bes2600_alloc_dpd_log_buffer(u16 len);
|
|
void bes2600_get_dpd_log(char **data, size_t *len);
|
|
#endif
|
|
|
|
#endif /* __BES_CHARDEV_H__ */
|