Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions boards/raspberrypi/rpi_pico/Kconfig.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,15 @@ endif # I2C_DW
config USB_SELF_POWERED
default n

if BOARD_RPI_PICO_RP2040_W && WIFI_AIROC

config MAIN_STACK_SIZE
default 4096

config HEAP_MEM_POOL_ADD_SIZE_BOARD
int
default 16384

endif # BOARD_RPI_PICO_RP2040_W && WIFI_AIROC

endif # BOARD_RPI_PICO
17 changes: 17 additions & 0 deletions boards/raspberrypi/rpi_pico/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,23 @@ devices as well as both PIO devices).
Programming and Debugging
*************************

System requirements
===================

Prerequisites for the Pico W
----------------------------

Building for the Raspberry Pi Pico W requires the AIROC binary blobs
provided by Infineon. Run the command below to retrieve those files:

.. code-block:: console

west blobs fetch hal_infineon

.. note::

It is recommended running the command above after :file:`west update`.

Flashing
========

Expand Down
58 changes: 58 additions & 0 deletions boards/raspberrypi/rpi_pico/rpi_pico_rp2040_w.dts
Original file line number Diff line number Diff line change
@@ -1,9 +1,67 @@
/*
* Copyright (c) 2023 Dave Rensberger - Beechwoods Software
* Copyright (c) 2024 Steve Boylan <[email protected]>
*
* SPDX-License-Identifier: Apache-2.0
*/

/dts-v1/;

#include "rpi_pico-common.dtsi"

&pinctrl {
pio0_spi0_default: pio0_spi0_default {
/* gpio 25 is used for chip select, not assigned to the PIO */
group1 {
pinmux = <PIO0_P29>;
};
};

airoc_wifi_default: airoc_wifi_default {
/* Control of GPIO24 is done through the WiFi driver */
group1 {
pinmux = <PIO0_P24>;
input-enable;
};
};

airoc_wifi_host_wake: airoc_wifi_host_wake {
/* Assign GPIO24 to SIO (GPIO) for use as an interrupt source */
group1 {
/* Lacking a specific SIO pin definition, use the RP2040_PINMUX macro */
pinmux = <RP2040_PINMUX(24, RP2_PINCTRL_GPIO_FUNC_SIO)>;
input-enable;
};
};
};

&pio0 {
status = "okay";

pio0_spi0: pio0_spi0 {
compatible = "raspberrypi,pico-spi-pio";
clocks = < &clocks RPI_PICO_CLKID_CLK_SYS >;
#address-cells = <1>;
#size-cells = <0>;
cs-gpios = <&gpio0 25 GPIO_ACTIVE_LOW>;
clk-gpios = <&gpio0 29 GPIO_ACTIVE_HIGH>;
sio-gpios = <&gpio0 24 GPIO_ACTIVE_HIGH>;
pinctrl-0 = <&pio0_spi0_default>;
pinctrl-names = "default";
status = "okay";
airoc-wifi@0 {
compatible = "infineon,airoc-wifi";
reg = < 0 >;
wifi-reg-on-gpios = < &gpio0 23 GPIO_ACTIVE_HIGH >;
bus-select-gpios = < &gpio0 24 GPIO_ACTIVE_HIGH >;
wifi-host-wake-gpios = < &gpio0 24 GPIO_ACTIVE_HIGH >;
spi-max-frequency = < 10000000 >;
spi-half-duplex;
spi-data-irq-shared;
pinctrl-0 = <&airoc_wifi_default>;
pinctrl-1 = <&airoc_wifi_host_wake>;
pinctrl-names = "default", "host_wake";
status = "okay";
};
};
};
3 changes: 3 additions & 0 deletions boards/raspberrypi/rpi_pico/rpi_pico_rp2040_w_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ CONFIG_BUILD_OUTPUT_HEX=y
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_RESET=y
CONFIG_CLOCK_CONTROL=y

# Default networking configuration
CONFIG_CYW43439=y
8 changes: 6 additions & 2 deletions drivers/wifi/infineon/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@

zephyr_include_directories(./)

zephyr_library_sources_ifdef(CONFIG_WIFI_AIROC airoc_wifi.c)
zephyr_library_sources_ifdef(CONFIG_WIFI_AIROC airoc_whd_hal.c)
zephyr_library_sources_ifdef(CONFIG_WIFI_AIROC
airoc_wifi.c
airoc_whd_hal_common.c
)
zephyr_library_sources_ifdef(CONFIG_AIROC_WIFI_BUS_SDIO airoc_whd_hal_sdio.c)
zephyr_library_sources_ifdef(CONFIG_AIROC_WIFI_BUS_SPI airoc_whd_hal_spi.c)

zephyr_compile_definitions(CYBSP_WIFI_CAPABLE)
zephyr_compile_definitions(CY_RTOS_AWARE)
Expand Down
23 changes: 20 additions & 3 deletions drivers/wifi/infineon/Kconfig.airoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,37 @@

menuconfig WIFI_AIROC
bool "Infineon AIROC SoC Wi-Fi support"
depends on DT_HAS_INFINEON_AIROC_WIFI_ENABLED
default y
select THREAD_CUSTOM_DATA
select WIFI_OFFLOAD
select NET_L2_ETHERNET
select NET_L2_WIFI_MGMT
select SDIO_STACK
select SDHC
select GPIO
select WIFI_USE_NATIVE_NETWORKING
select USE_INFINEON_ABSTRACTION_RTOS
depends on DT_HAS_INFINEON_AIROC_WIFI_ENABLED
help
Enable Infineon AIROC SoC Wi-Fi support.

if WIFI_AIROC

config AIROC_WIFI_BUS_SDIO
bool
default y
depends on $(dt_compat_on_bus,$(DT_COMPAT_INFINEON_AIROC_WIFI),sd)
select SDHC
select SDIO_STACK
help
Enable SDIO bus support.

config AIROC_WIFI_BUS_SPI
bool
default y
depends on $(dt_compat_on_bus,$(DT_COMPAT_INFINEON_AIROC_WIFI),spi)
select SPI
help
Enable SPI bus support

config AIROC_WIFI_EVENT_TASK_STACK_SIZE
int "Event Task Stack Size"
default 4096
Expand Down
84 changes: 84 additions & 0 deletions drivers/wifi/infineon/airoc_whd_hal_common.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
* Copyright (c) 2023 Cypress Semiconductor Corporation (an Infineon company) or
* an affiliate of Cypress Semiconductor Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/

#include "airoc_whd_hal_common.h"
#include "airoc_wifi.h"

#include <zephyr/kernel.h>
#include <zephyr/drivers/gpio.h>

LOG_MODULE_DECLARE(infineon_airoc_wifi, CONFIG_WIFI_LOG_LEVEL);

#ifdef __cplusplus
extern "C" {
#endif

/******************************************************
* Function
******************************************************/

int airoc_wifi_power_on(const struct device *dev)
{
#if DT_INST_NODE_HAS_PROP(0, wifi_reg_on_gpios)
int ret;
const struct airoc_wifi_config *config = dev->config;

/* Check WIFI REG_ON gpio instance */
if (!device_is_ready(config->wifi_reg_on_gpio.port)) {
LOG_ERR("Error: failed to configure wifi_reg_on %s pin %d",
config->wifi_reg_on_gpio.port->name, config->wifi_reg_on_gpio.pin);
return -EIO;
}

/* Configure wifi_reg_on as output */
ret = gpio_pin_configure_dt(&config->wifi_reg_on_gpio, GPIO_OUTPUT);
if (ret) {
LOG_ERR("Error %d: failed to configure wifi_reg_on %s pin %d", ret,
config->wifi_reg_on_gpio.port->name, config->wifi_reg_on_gpio.pin);
return ret;
}
ret = gpio_pin_set_dt(&config->wifi_reg_on_gpio, 0);
if (ret) {
return ret;
}

/* Allow CBUCK regulator to discharge */
k_msleep(WLAN_CBUCK_DISCHARGE_MS);

/* WIFI power on */
ret = gpio_pin_set_dt(&config->wifi_reg_on_gpio, 1);
if (ret) {
return ret;
}
k_msleep(WLAN_POWER_UP_DELAY_MS);
#endif /* DT_INST_NODE_HAS_PROP(0, reg_on_gpios) */

return 0;
}

/*
* Implement WHD memory wrappers
*/

void *whd_mem_malloc(size_t size)
{
return k_malloc(size);
}

void *whd_mem_calloc(size_t nitems, size_t size)
{
return k_calloc(nitems, size);
}

void whd_mem_free(void *ptr)
{
k_free(ptr);
}

#ifdef __cplusplus
} /* extern "C" */
#endif
51 changes: 51 additions & 0 deletions drivers/wifi/infineon/airoc_whd_hal_common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright (c) 2023 Cypress Semiconductor Corporation (an Infineon company) or
* an affiliate of Cypress Semiconductor Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <whd.h>
#include <zephyr/device.h>

/** Defines the amount of stack memory available for the wifi thread. */
#if !defined(CY_WIFI_THREAD_STACK_SIZE)
#define CY_WIFI_THREAD_STACK_SIZE (5120)
#endif

/** Defines the priority of the thread that services wifi packets. Legal values are defined by the
* RTOS being used.
*/
#if !defined(CY_WIFI_THREAD_PRIORITY)
#define CY_WIFI_THREAD_PRIORITY (CY_RTOS_PRIORITY_HIGH)
#endif

/** Defines the country this will operate in for wifi initialization parameters. See the
* wifi-host-driver's whd_country_code_t for legal options.
*/
#if !defined(CY_WIFI_COUNTRY)
#define CY_WIFI_COUNTRY (WHD_COUNTRY_AUSTRALIA)
#endif

/** Defines the priority of the interrupt that handles out-of-band notifications from the wifi
* chip. Legal values are defined by the MCU running this code.
*/
#if !defined(CY_WIFI_OOB_INTR_PRIORITY)
#define CY_WIFI_OOB_INTR_PRIORITY (2)
#endif

/** Defines whether to use the out-of-band pin to allow the WIFI chip to wake up the MCU. */
#if defined(CY_WIFI_HOST_WAKE_SW_FORCE)
#define CY_USE_OOB_INTR (CY_WIFI_HOST_WAKE_SW_FORCE)
#else
#define CY_USE_OOB_INTR (1u)
#endif /* defined(CY_WIFI_HOST_WAKE_SW_FORCE) */

#define CY_WIFI_HOST_WAKE_IRQ_EVENT GPIO_INT_TRIG_LOW
#define DEFAULT_OOB_PIN (0)
#define WLAN_POWER_UP_DELAY_MS (250)
#define WLAN_CBUCK_DISCHARGE_MS (10)

extern whd_resource_source_t resource_ops;

int airoc_wifi_power_on(const struct device *dev);
Loading
Loading