1 /* 2 * Copyright (c) 2023 Cypress Semiconductor Corporation (an Infineon company) or 3 * an affiliate of Cypress Semiconductor Corporation 4 * 5 * SPDX-License-Identifier: Apache-2.0 6 */ 7 8 #include <whd_buffer_api.h> 9 #include <zephyr/drivers/gpio.h> 10 #include <zephyr/net/wifi_mgmt.h> 11 12 #ifdef CONFIG_AIROC_WIFI_BUS_SDIO 13 #include <zephyr/sd/sd.h> 14 #include <zephyr/sd/sdio.h> 15 #endif 16 #ifdef CONFIG_AIROC_WIFI_BUS_SPI 17 #include <zephyr/drivers/spi.h> 18 #endif 19 20 #include <cy_utils.h> 21 22 #define DT_DRV_COMPAT infineon_airoc_wifi 23 24 #if DT_PROP(DT_DRV_INST(0), spi_data_irq_shared) 25 #define SPI_DATA_IRQ_SHARED 26 #include <zephyr/drivers/pinctrl.h> 27 28 #define PINCTRL_STATE_HOST_WAKE PINCTRL_STATE_PRIV_START 29 #endif 30 31 #if defined(CONFIG_AIROC_WIFI_BUS_SPI) 32 #define AIROC_WIFI_SPI_OPERATION (SPI_WORD_SET(DT_PROP_OR(DT_DRV_INST(0), spi_word_size, 8)) \ 33 | (DT_PROP(DT_DRV_INST(0), spi_half_duplex) \ 34 ? SPI_HALF_DUPLEX : SPI_FULL_DUPLEX) \ 35 | SPI_TRANSFER_MSB) 36 #endif 37 38 struct airoc_wifi_data { 39 #if defined(CONFIG_AIROC_WIFI_BUS_SDIO) 40 struct sd_card card; 41 struct sdio_func sdio_func1; 42 struct sdio_func sdio_func2; 43 #endif 44 #if defined(SPI_DATA_IRQ_SHARED) 45 uint8_t prev_irq_state; 46 #endif 47 struct net_if *iface; 48 bool second_interface_init; 49 bool is_ap_up; 50 bool is_sta_connected; 51 uint8_t mac_addr[6]; 52 scan_result_cb_t scan_rslt_cb; 53 whd_ssid_t ssid; 54 whd_scan_result_t scan_result; 55 struct k_sem sema_common; 56 struct k_sem sema_scan; 57 #if defined(CONFIG_NET_STATISTICS_WIFI) 58 struct net_stats_wifi stats; 59 #endif 60 whd_driver_t whd_drv; 61 struct gpio_callback host_oob_pin_cb; 62 uint8_t frame_buf[NET_ETH_MAX_FRAME_SIZE]; 63 }; 64 65 union airoc_wifi_bus { 66 #if defined(CONFIG_AIROC_WIFI_BUS_SDIO) 67 const struct device *bus_sdio; 68 #endif 69 #if defined(CONFIG_AIROC_WIFI_BUS_SPI) 70 const struct spi_dt_spec bus_spi; 71 #endif 72 }; 73 74 struct airoc_wifi_config { 75 const union airoc_wifi_bus bus_dev; 76 struct gpio_dt_spec wifi_reg_on_gpio; 77 struct gpio_dt_spec wifi_host_wake_gpio; 78 struct gpio_dt_spec wifi_dev_wake_gpio; 79 #if defined(CONFIG_AIROC_WIFI_BUS_SPI) 80 struct gpio_dt_spec bus_select_gpio; 81 #if defined(SPI_DATA_IRQ_SHARED) 82 const struct pinctrl_dev_config *pcfg; 83 #endif 84 #endif 85 }; 86 87 /** 88 * \brief This function returns pointer type to handle instance 89 * of whd interface (whd_interface_t) which allocated in 90 * Zephyr AIROC driver (drivers/wifi/infineon/airoc_wifi.c) 91 */ 92 93 whd_interface_t airoc_wifi_get_whd_interface(void); 94