Skip to content

Commit a1be646

Browse files
Krishna Tcarlescufi
authored andcommitted
drivers: wifi: Fix QSPI frequency configuration for RPU wakeup
With the init/uninit changes for every transaction configuring lowest clock for RPU wakup is broken, 24MHz (DTS) clock is used to wakeup RPU, though it works, fix this by directly modifying the global QSPI configuration and let init take care of configuring IFCONFIG1 register. Signed-off-by: Krishna T <[email protected]>
1 parent 0e648ee commit a1be646

File tree

1 file changed

+16
-14
lines changed
  • drivers/wifi/nrf700x/zephyr/src/qspi/src

1 file changed

+16
-14
lines changed

drivers/wifi/nrf700x/zephyr/src/qspi/src/qspi_if.c

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -101,17 +101,25 @@ struct qspi_nor_data {
101101
#endif /* CONFIG_MULTITHREADING */
102102
};
103103

104-
static inline int qspi_freq_to_sckfreq(int freq)
104+
static inline int qspi_freq_mhz_to_sckfreq(int freq_m)
105105
{
106+
if (freq_m > (NRF_QSPI_BASE_CLOCK_FREQ / MHZ(1))) {
107+
return NRF_QSPI_FREQ_DIV1;
108+
}
106109
#if defined(CONFIG_SOC_SERIES_NRF53X)
107110
/* QSPIM (6-96MHz) : 192MHz / (2*(SCKFREQ + 1)) */
108-
return ((192 / freq) / 2) - 1;
111+
return ((192 / freq_m) / 2) - 1;
109112
#else
110113
/* QSPIM (2-32MHz): 32 MHz / (SCKFREQ + 1) */
111-
return (32 / freq) - 1;
114+
return (32 / freq_m) - 1;
112115
#endif
113116
}
114117

118+
static inline int qspi_dts_freq_to_sckfreq(void)
119+
{
120+
/* DTS frequency is in HZ */
121+
return qspi_freq_mhz_to_sckfreq(INST_0_SCK_FREQUENCY / MHZ(1));
122+
}
115123

116124
static inline int qspi_get_mode(bool cpol, bool cpha)
117125
{
@@ -566,9 +574,7 @@ static inline void qspi_fill_init_struct(nrfx_qspi_config_t *initstruct)
566574
initstruct->prot_if.dpmconfig = false;
567575

568576
/* Configure physical interface */
569-
initstruct->phy_if.sck_freq = (INST_0_SCK_FREQUENCY > NRF_QSPI_BASE_CLOCK_FREQ) ?
570-
NRF_QSPI_FREQ_DIV1 :
571-
(NRF_QSPI_BASE_CLOCK_FREQ / INST_0_SCK_FREQUENCY) - 1;
577+
initstruct->phy_if.sck_freq = qspi_dts_freq_to_sckfreq();
572578
/* Using MHZ fails checkpatch constant check */
573579
if (INST_0_SCK_FREQUENCY >= 16000000) {
574580
qspi_config->qspi_slave_latency = 1;
@@ -978,7 +984,8 @@ int qspi_wait_while_rpu_awake(const struct device *dev)
978984

979985
/* Configure DTS settings */
980986
if (val & RPU_AWAKE_BIT) {
981-
nrf_qspi_ifconfig1_set(NRF_QSPI, &QSPIconfig.phy_if);
987+
/* Restore QSPI clock frequency from DTS */
988+
QSPIconfig.phy_if.sck_freq = qspi_dts_freq_to_sckfreq();
982989
}
983990

984991
return val;
@@ -1048,14 +1055,9 @@ int qspi_WRSR2(const struct device *dev, uint8_t data)
10481055
int qspi_cmd_wakeup_rpu(const struct device *dev, uint8_t data)
10491056
{
10501057
int ret;
1051-
/* Use lowest 8MHz for waking up RPU */
1052-
const nrf_qspi_phy_conf_t qspi_phy_8mhz = {
1053-
.sck_freq = qspi_freq_to_sckfreq(8),
1054-
.sck_delay = QSPI_SCK_DELAY,
1055-
.spi_mode = NRF_QSPI_MODE_0
1056-
};
10571058

1058-
nrf_qspi_ifconfig1_set(NRF_QSPI, &qspi_phy_8mhz);
1059+
/* Waking RPU works reliably only with lowest frequency (8MHz) */
1060+
QSPIconfig.phy_if.sck_freq = qspi_freq_mhz_to_sckfreq(8);
10591061

10601062
ret = qspi_WRSR2(dev, data);
10611063

0 commit comments

Comments
 (0)