wifi: wilc1000: make sdio deinit function really deinit the sdio card

In order to be able to read raw registers (eg the nv mac address) in
wilc1000 during probe before the firmware is loaded and running, we need to
run the basic sdio functions initialization, but then we also need to
properly deinitialize those right after, to preserve the current driver
behavior (keeping the chip idle/unconfigured until the corresponding
interface is brought up). Calling wilc_sdio_deinit in its current form is
not enough because it merely resets an internal flag.

Implement a deinit sequence which symmetrically reset all steps performed
in wilc_sdio_init (only for parts activating/deactivating features, for the
sake of simplicity, let's ignore blocks size configuration reset)

Signed-off-by: Alexis Lothoré <alexis.lothore@bootlin.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://msgid.link/20240514-mac_addr_at_probe-v2-5-afef09f1cd10@bootlin.com
This commit is contained in:
Alexis Lothoré
2024-05-14 17:51:23 +02:00
committed by Kalle Valo
parent 59cf9277c1
commit a5d6b1d453

View File

@@ -627,7 +627,52 @@ static int wilc_sdio_read(struct wilc *wilc, u32 addr, u8 *buf, u32 size)
static int wilc_sdio_deinit(struct wilc *wilc)
{
struct sdio_func *func = dev_to_sdio_func(wilc->dev);
struct wilc_sdio *sdio_priv = wilc->bus_data;
struct sdio_cmd52 cmd;
int ret;
cmd.read_write = 1;
cmd.function = 0;
cmd.raw = 1;
/* Disable all functions interrupts */
cmd.address = SDIO_CCCR_IENx;
cmd.data = 0;
ret = wilc_sdio_cmd52(wilc, &cmd);
if (ret) {
dev_err(&func->dev, "Failed to disable functions interrupts\n");
return ret;
}
/* Disable all functions */
cmd.address = SDIO_CCCR_IOEx;
cmd.data = 0;
ret = wilc_sdio_cmd52(wilc, &cmd);
if (ret) {
dev_err(&func->dev,
"Failed to reset all functions\n");
return ret;
}
/* Disable CSA */
cmd.read_write = 0;
cmd.address = SDIO_FBR_BASE(1);
ret = wilc_sdio_cmd52(wilc, &cmd);
if (ret) {
dev_err(&func->dev,
"Failed to read CSA for function 1\n");
return ret;
}
cmd.read_write = 1;
cmd.address = SDIO_FBR_BASE(1);
cmd.data &= ~SDIO_FBR_ENABLE_CSA;
ret = wilc_sdio_cmd52(wilc, &cmd);
if (ret) {
dev_err(&func->dev,
"Failed to disable CSA for function 1\n");
return ret;
}
sdio_priv->isinit = false;
return 0;