Line data Source code
1 0 : /* 2 : * Copyright (c) 2024 Nordic Semiconductor ASA 3 : * 4 : * SPDX-License-Identifier: Apache-2.0 5 : */ 6 : 7 : /** 8 : * @brief Header containing QSPI device interface specific declarations for the 9 : * Zephyr OS layer of the Wi-Fi driver. 10 : */ 11 : 12 : #ifndef __QSPI_IF_H__ 13 : #define __QSPI_IF_H__ 14 : 15 : #include <zephyr/kernel.h> 16 : #include <zephyr/drivers/gpio.h> 17 : #ifdef CONFIG_NRF70_ON_QSPI 18 : #include <nrfx_qspi.h> 19 : #endif 20 : 21 1 : #define RPU_WAKEUP_NOW BIT(0) /* WAKEUP RPU - RW */ 22 0 : #define RPU_AWAKE_BIT BIT(1) /* RPU AWAKE FROM SLEEP - RO */ 23 0 : #define RPU_READY_BIT BIT(2) /* RPU IS READY - RO*/ 24 : 25 0 : struct qspi_config { 26 : #ifdef CONFIG_NRF70_ON_QSPI 27 : nrf_qspi_addrmode_t addrmode; 28 : nrf_qspi_readoc_t readoc; 29 : nrf_qspi_writeoc_t writeoc; 30 : nrf_qspi_frequency_t sckfreq; 31 : #endif 32 0 : unsigned char RDC4IO; 33 0 : bool easydma; 34 0 : bool single_op; 35 0 : bool quad_spi; 36 0 : bool encryption; 37 0 : bool CMD_CNONCE; 38 0 : bool enc_enabled; 39 0 : struct k_sem lock; 40 0 : unsigned int addrmask; 41 0 : unsigned char qspi_slave_latency; 42 : #if defined(CONFIG_NRF70_ON_QSPI) && (NRF_QSPI_HAS_XIP_ENC || NRF_QSPI_HAS_DMA_ENC) 43 : nrf_qspi_encryption_t p_cfg; 44 : #endif /*CONFIG_NRF70_ON_QSPI && (NRF_QSPI_HAS_XIP_ENC || NRF_QSPI_HAS_DMA_ENC)*/ 45 0 : int test_hlread; 46 0 : char *test_name; 47 0 : int test_start; 48 0 : int test_end; 49 0 : int test_iterations; 50 0 : int test_timediff_read; 51 0 : int test_timediff_write; 52 0 : int test_status; 53 0 : int test_iteration; 54 : }; 55 0 : struct qspi_dev { 56 0 : int (*deinit)(void); 57 0 : void *config; 58 0 : int (*init)(struct qspi_config *config); 59 0 : int (*write)(unsigned int addr, const void *data, int len); 60 0 : int (*read)(unsigned int addr, void *data, int len); 61 0 : int (*hl_read)(unsigned int addr, void *data, int len); 62 0 : void (*hard_reset)(void); 63 : }; 64 : 65 0 : int qspi_cmd_wakeup_rpu(const struct device *dev, uint8_t data); 66 : 67 0 : int qspi_init(struct qspi_config *config); 68 : 69 0 : int qspi_write(unsigned int addr, const void *data, int len); 70 : 71 0 : int qspi_read(unsigned int addr, void *data, int len); 72 : 73 0 : int qspi_hl_read(unsigned int addr, void *data, int len); 74 : 75 0 : int qspi_deinit(void); 76 : 77 0 : void gpio_free_irq(int pin, struct gpio_callback *button_cb_data); 78 : 79 0 : int gpio_request_irq(int pin, struct gpio_callback *button_cb_data, void (*irq_handler)()); 80 : 81 0 : struct qspi_config *qspi_defconfig(void); 82 : 83 0 : struct qspi_dev *qspi_dev(void); 84 0 : struct qspi_config *qspi_get_config(void); 85 : 86 0 : int qspi_cmd_sleep_rpu(const struct device *dev); 87 : 88 0 : void hard_reset(void); 89 0 : void get_sleep_stats(uint32_t addr, uint32_t *buff, uint32_t wrd_len); 90 : 91 0 : extern struct device qspi_perip; 92 : 93 0 : int qspi_validate_rpu_wake_writecmd(const struct device *dev); 94 : int qspi_cmd_wakeup_rpu(const struct device *dev, uint8_t data); 95 0 : int qspi_wait_while_rpu_awake(const struct device *dev); 96 : 97 0 : int qspi_RDSR1(const struct device *dev, uint8_t *rdsr1); 98 0 : int qspi_RDSR2(const struct device *dev, uint8_t *rdsr2); 99 0 : int qspi_WRSR2(const struct device *dev, const uint8_t wrsr2); 100 : 101 : #ifdef CONFIG_NRF_WIFI_LOW_POWER 102 : int func_rpu_sleep(void); 103 : int func_rpu_wake(void); 104 : int func_rpu_sleep_status(void); 105 : #endif /* CONFIG_NRF_WIFI_LOW_POWER */ 106 : 107 0 : #define QSPI_KEY_LEN_BYTES 16 108 : 109 : /*! \brief Enable encryption 110 : * 111 : * \param key Pointer to the 128-bit key 112 : * \return 0 on success, negative errno code on failure. 113 : */ 114 1 : int qspi_enable_encryption(uint8_t *key); 115 : 116 : #endif /* __QSPI_IF_H__ */