Skip to content

drivers: misc: Add driver for Silicon Labs Packet Trace Interface #88035

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
13 changes: 13 additions & 0 deletions MAINTAINERS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1338,6 +1338,18 @@ Release Notes:
labels:
- "area: DAI"

"Drivers: Debug":
status: maintained
maintainers:
- asmellby
collaborators:
- nordic-krch
files:
- drivers/debug/
- dts/bindings/debug/
labels:
- "area: Debugging"

"Drivers: Devmux":
status: maintained
maintainers:
Expand Down Expand Up @@ -3676,6 +3688,7 @@ Silabs Platforms:
- drivers/*/*/*silabs*
- drivers/*/*/*siwx91x*
- tests/boards/silabs/
- snippets/*silabs*/
labels:
- "platform: Silabs"

Expand Down
8 changes: 8 additions & 0 deletions boards/silabs/dev_kits/xg24_dk2601b/xg24_dk2601b-pinctrl.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@
};
};

pti_default: pti_default {
group0 {
pins = <PTI_DOUT_PC6>, <PTI_DFRAME_PC7>;
drive-push-pull;
output-high;
};
};

usart0_default: usart0_default {
group0 {
pins = <USART0_TX_PA5>;
Expand Down
8 changes: 8 additions & 0 deletions boards/silabs/dev_kits/xg24_ek2703a/xg24_ek2703a-pinctrl.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@
};
};

pti_default: pti_default {
group0 {
pins = <PTI_DOUT_PC6>, <PTI_DFRAME_PC7>;
drive-push-pull;
output-high;
};
};

usart0_default: usart0_default {
group0 {
pins = <USART0_TX_PA5>;
Expand Down
8 changes: 8 additions & 0 deletions boards/silabs/dev_kits/xg27_dk2602a/xg27_dk2602a-pinctrl.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@
};
};

pti_default: pti_default {
group0 {
pins = <PTI_DOUT_PC4>, <PTI_DFRAME_PC5>;
drive-push-pull;
output-high;
};
};

usart0_default: usart0_default {
group0 {
pins = <USART0_TX_PC0>, <USART0_CLK_PC2>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,12 @@
silabs,input-filter;
};
};

pti_default: pti_default {
group0 {
pins = <PTI_DOUT_PD4>, <PTI_DFRAME_PD5>;
drive-push-pull;
output-high;
};
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@
};
};

pti_default: pti_default {
group0 {
pins = <PTI_DOUT_PD4>, <PTI_DFRAME_PD5>;
drive-push-pull;
output-high;
};
};

usart0_default: usart0_default {
group0 {
pins = <USART0_TX_PA8>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@
};
};

pti_default: pti_default {
group0 {
pins = <PTI_DOUT_PC4>, <PTI_DFRAME_PC5>;
drive-push-pull;
output-high;
};
};

usart1_default: usart1_default {
group0 {
pins = <USART1_TX_PA5>;
Expand Down
1 change: 1 addition & 0 deletions drivers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ add_subdirectory_ifdef(CONFIG_COUNTER counter)
add_subdirectory_ifdef(CONFIG_CRYPTO crypto)
add_subdirectory_ifdef(CONFIG_DAC dac)
add_subdirectory_ifdef(CONFIG_DAI dai)
add_subdirectory_ifdef(CONFIG_DEBUG_DRIVER debug)
add_subdirectory_ifdef(CONFIG_DISPLAY display)
add_subdirectory_ifdef(CONFIG_DMA dma)
add_subdirectory_ifdef(CONFIG_DP_DRIVER dp)
Expand Down
1 change: 1 addition & 0 deletions drivers/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ source "drivers/counter/Kconfig"
source "drivers/crypto/Kconfig"
source "drivers/dac/Kconfig"
source "drivers/dai/Kconfig"
source "drivers/debug/Kconfig"
source "drivers/disk/Kconfig"
source "drivers/display/Kconfig"
source "drivers/dma/Kconfig"
Expand Down
8 changes: 8 additions & 0 deletions drivers/debug/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Copyright (c) 2025 Silicon Laboratories Inc.
# SPDX-License-Identifier: Apache-2.0

zephyr_library()

# zephyr-keep-sorted-start
zephyr_library_sources_ifdef(CONFIG_DEBUG_SILABS_PTI debug_silabs_pti.c)
# zephyr-keep-sorted-stop
25 changes: 25 additions & 0 deletions drivers/debug/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright (c) 2025 Silicon Laboratories Inc.
# SPDX-License-Identifier: Apache-2.0

menuconfig DEBUG_DRIVER
bool "Debug drivers"
help
Enable support for debug drivers

if DEBUG_DRIVER

config DEBUG_DRIVER_INIT_PRIORITY
int "Initialization priority"
default KERNEL_INIT_PRIORITY_DEVICE
help
Debug drivers initialization priority.

# zephyr-keep-sorted-start
source "drivers/debug/Kconfig.silabs"
# zephyr-keep-sorted-stop

module = DEBUG_DRIVER
module-str = debug_driver
source "subsys/logging/Kconfig.template.log_config"

endif
12 changes: 12 additions & 0 deletions drivers/debug/Kconfig.silabs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright (c) 2025 Silicon Laboratories Inc.
# SPDX-License-Identifier: Apache-2.0

config DEBUG_SILABS_PTI
bool "Silicon Labs Packet Trace Interface"
default y
depends on DT_HAS_SILABS_PTI_ENABLED
depends on PINCTRL
depends on SOC_GECKO_USE_RAIL
help
Enable the Packet Trace Interface, providing a mechanism for viewing
transmitted and received radio packets for network sniffing or debugging.
72 changes: 72 additions & 0 deletions drivers/debug/debug_silabs_pti.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* Copyright (c) 2025 Silicon Laboratories Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/drivers/pinctrl.h>

#include <rail.h>

#define DT_DRV_COMPAT silabs_pti

struct silabs_pti_config {
const struct pinctrl_dev_config *pcfg;
RAIL_PtiMode_t mode;
uint32_t baud;
};

int silabs_pti_init(const struct device *dev)
{
const struct silabs_pti_config *config = dev->config;
const struct pinctrl_state *state;
RAIL_PtiConfig_t pti_config = {
.mode = config->mode,
.baud = config->baud,
};
int err;

/* The RAIL API to configure PTI requires GPIO port and pin as part of its configuration
* struct, and does the pin configuration itself internally. Create the configuration
* struct from the pinctrl node instead of using pinctrl_apply_state().
*/
err = pinctrl_lookup_state(config->pcfg, PINCTRL_STATE_DEFAULT, &state);
if (err < 0) {
return err;
}
for (int i = 0; i < state->pin_cnt; i++) {
switch (state->pins[i].en_bit) {
case _GPIO_FRC_ROUTEEN_DCLKPEN_SHIFT:
pti_config.dclkPort = state->pins[i].port;
pti_config.dclkPin = state->pins[i].pin;
break;
case _GPIO_FRC_ROUTEEN_DFRAMEPEN_SHIFT:
pti_config.dframePort = state->pins[i].port;
pti_config.dframePin = state->pins[i].pin;
break;
case _GPIO_FRC_ROUTEEN_DOUTPEN_SHIFT:
pti_config.doutPort = state->pins[i].port;
pti_config.doutPin = state->pins[i].pin;
break;
default:
return -EINVAL;
}
}
RAIL_ConfigPti(RAIL_EFR32_HANDLE, &pti_config);

return 0;
}

#define SILABS_PTI_INIT(idx) \
PINCTRL_DT_INST_DEFINE(idx); \
\
static const struct silabs_pti_config silabs_pti_config_##idx = { \
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(idx), \
.mode = DT_INST_ENUM_IDX(idx, mode), \
.baud = DT_INST_PROP(idx, clock_frequency), \
}; \
\
DEVICE_DT_INST_DEFINE(idx, &silabs_pti_init, NULL, NULL, &silabs_pti_config_##idx, \
POST_KERNEL, CONFIG_DEBUG_DRIVER_INIT_PRIORITY, NULL);

DT_INST_FOREACH_STATUS_OKAY(SILABS_PTI_INIT)
7 changes: 7 additions & 0 deletions dts/arm/silabs/xg21/efr32xg21.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@
pa-ramp-time-us = <10>;
pa-voltage-mv = <3300>;
pa-2p4ghz = "highest";

pti: pti {
compatible = "silabs,pti";
clock-frequency = <DT_FREQ_K(1600)>;
mode = "uart";
status = "disabled";
};
};
};
};
6 changes: 6 additions & 0 deletions dts/arm/silabs/xg22/efr32xg22.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
pa-voltage-mv = <3300>;
pa-2p4ghz = "highest";

pti: pti {
compatible = "silabs,pti";
clock-frequency = <DT_FREQ_K(1600)>;
mode = "uart";
status = "disabled";
};
};
};
};
7 changes: 7 additions & 0 deletions dts/arm/silabs/xg23/efr32xg23.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@
pa-ramp-time-us = <10>;
pa-voltage-mv = <3300>;
pa-subghz = "highest";

pti: pti {
compatible = "silabs,pti";
clock-frequency = <DT_FREQ_K(1600)>;
mode = "uart";
status = "disabled";
};
};
};
};
7 changes: 7 additions & 0 deletions dts/arm/silabs/xg24/efr32xg24.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@
compatible = "silabs,bt-hci-efr32";
status = "disabled";
};

pti: pti {
compatible = "silabs,pti";
clock-frequency = <DT_FREQ_K(1600)>;
mode = "uart";
status = "disabled";
};
};
};
};
7 changes: 7 additions & 0 deletions dts/arm/silabs/xg27/efr32xg27.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@
compatible = "silabs,bt-hci-efr32";
status = "disabled";
};

pti: pti {
compatible = "silabs,pti";
clock-frequency = <DT_FREQ_K(1600)>;
mode = "uart";
status = "disabled";
};
};
};
};
7 changes: 7 additions & 0 deletions dts/arm/silabs/xg29/efr32xg29.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@
compatible = "silabs,bt-hci-efr32";
status = "disabled";
};

pti: pti {
compatible = "silabs,pti";
clock-frequency = <DT_FREQ_K(1600)>;
mode = "uart";
status = "disabled";
};
};
};
};
24 changes: 24 additions & 0 deletions dts/bindings/debug/silabs,pti.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright (c) 2025 Silicon Laboratories Inc.
# SPDX-License-Identifier: Apache-2.0

description: Silicon Labs Packet Trace Interface

compatible: "silabs,pti"

include: [base.yaml, pinctrl-device.yaml]

properties:
clock-frequency:
type: int
description: |
Clock frequency for PTI signal in Hz.

mode:
type: string
enum:
- disabled
- spi
- uart
- uart-onewire
description: |
Packet Trace mode.
21 changes: 21 additions & 0 deletions snippets/silabs-pti/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.. _silabs-pti:

Silicon Labs Packet Trace Interface (silabs-pti)
################################################

Overview
********

This snippet allows users to build Zephyr applications for Silicon Labs Series 2 devices
where radio packets are emitted over the Packet Trace Interface for use by debugging tools.

.. code-block:: console

west build -S silabs-pti [...]

Requirements
************

Hardware support for :dtcompatible:`silabs,pti`.

A pinctrl configuration with nodelabel ``pti_default`` containing PTI pinout.
4 changes: 4 additions & 0 deletions snippets/silabs-pti/pti.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright (c) 2024 Silicon Laboratories Inc.
# SPDX-License-Identifier: Apache-2.0

CONFIG_DEBUG_DRIVER=y
11 changes: 11 additions & 0 deletions snippets/silabs-pti/pti.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* Copyright (c) 2025 Silicon Laboratories Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/

&pti {
pinctrl-0 = <&pti_default>;
pinctrl-names = "default";
status = "okay";
};
Loading