Skip to content
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

boards: arm: Add BeaglePlay CC1352 #58877

Closed
Closed
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
2 changes: 2 additions & 0 deletions boards/arm/beagle_bcf/beagleconnect_freedom_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ CONFIG_CC13X2_CC26X2_BOOTLOADER_BACKDOOR_PIN=15
# Enable MPU and hardware stack protection
CONFIG_ARM_MPU=y
CONFIG_HW_STACK_PROTECTION=y
# Adjust for oscillator capacitors
CONFIG_CC13X2_CC26X2_XOSC_CAPARRAY_DELTA=0x02
8 changes: 8 additions & 0 deletions boards/arm/beagle_play_cc1352/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# SPDX-License-Identifier: Apache-2.0

zephyr_library()
zephyr_library_sources(
board_antenna.c
)

zephyr_library_compile_definitions("DeviceFamily_CC13X2X7")
21 changes: 21 additions & 0 deletions boards/arm/beagle_play_cc1352/Kconfig.board
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# BeaglePlay CC1352 board configuration

# Copyright (c) 2020 Erik Larson
# Copyright (c) 2021-2022 Jason Kridner, BeagleBoard.org Foundation
# SPDX-License-Identifier: Apache-2.0

config BOARD_BEAGLEPLAY_CC1352
bool "BeaglePlay CC1352"
depends on SOC_CC1352P7

if BOARD_BEAGLEPLAY_CC1352

config BOARD_ANTENNA_INIT_PRIO
int "Board antenna switch initialization priority"
default 70
help
Set the priority for board init, must be greater than
KERNEL_INIT_PRIORITY_DEVICE but smaller than
IEEE802154_CC13XX_CC26XX_SUB_GHZ_INIT_PRIO.

endif # BOARD_BEAGLEPLAY_CC1352
11 changes: 11 additions & 0 deletions boards/arm/beagle_play_cc1352/Kconfig.defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# BeaglePlay CC1352 board configuration

# Copyright (c) 2022 Jason Kridner, BeagleBoard.org Foundation
# SPDX-License-Identifier: Apache-2.0

if BOARD_BEAGLEPLAY_CC1352

config BOARD
default "beagleplay_cc1352"

endif # BOARD_BEAGLEPLAY_CC1352
34 changes: 34 additions & 0 deletions boards/arm/beagle_play_cc1352/beagleplay-cc1352-pinctrl.dtsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright (c) 2022 Vaishnav Achath
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/dt-bindings/pinctrl/cc13xx_cc26xx-pinctrl.h>

&pinctrl {
/* UART0 */
uart0_tx_default: uart0_tx_default {
pinmux = <13 IOC_PORT_MCU_UART0_TX>;
bias-disable;
};
uart0_rx_default: uart0_rx_default {
pinmux = <12 IOC_PORT_MCU_UART0_RX>;
bias-disable;
input-enable;
};

/* On-board antenna pinmux states */
board_ant_tx_pa_off: board_ant_tx_pa_off {
pinmux = <29 IOC_PORT_GPIO>;
};
board_ant_tx_pa_on: board_ant_tx_pa_on {
pinmux = <29 IOC_PORT_RFC_GPO3>;
};
board_ant_subg_off: board_ant_subg_off {
pinmux = <30 IOC_PORT_GPIO>;
};
board_ant_subg_on: board_ant_subg_on {
pinmux = <30 IOC_PORT_RFC_GPO0>;
};
};
96 changes: 96 additions & 0 deletions boards/arm/beagle_play_cc1352/beagleplay_cc1352.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/*
* Copyright (c) 2022 Jason Kridner, BeagleBoard.org Foundation
*
* SPDX-License-Identifier: Apache-2.0
*/

/dts-v1/;

#include <ti/cc1352r7.dtsi>
#include "beagleplay-cc1352-pinctrl.dtsi"

/ {
model = "beagleplay";
compatible = "beagle,beagleplay-cc1352";

aliases {
led0 = &led0;
led1 = &led1;
};

chosen {
zephyr,sram = &sram0;
zephyr,console = &uart0;
zephyr,shell-uart = &uart0;
zephyr,flash = &flash0;
zephyr,ieee802154 = &ieee802154g;
};

leds: leds {
compatible = "gpio-leds";
led0: led_0 {
gpios = <&gpio0 27 GPIO_ACTIVE_HIGH>;
label = "LED1";
};

led1: led_1 {
gpios = <&gpio0 28 GPIO_ACTIVE_HIGH>;
label = "LED2";
};

/* U.FL connector switch */
rf_sw: rf_sw {
label = "RF_SW";
gpios =
<&gpio0 29 GPIO_ACTIVE_HIGH>, // SubG TX +20dB
<&gpio0 30 GPIO_ACTIVE_HIGH>; // SubG TX/RX 0dB
};
};

power-states {
idle: idle {
compatible = "zephyr,power-state";
power-state-name = "suspend-to-idle";
min-residency-us = <1000>;
};

standby: standby {
compatible = "zephyr,power-state";
power-state-name = "standby";
min-residency-us = <5000>;
exit-latency-us = <240>;
};
};
};

&cpu0 {
clock-frequency = <48000000>;
cpu-power-states = <&idle &standby>;
};

&trng {
status = "okay";
};

&gpio0 {
status = "okay";
};

&uart0 {
status = "okay";
current-speed = <115200>;
pinctrl-0 = <&uart0_rx_default &uart0_tx_default>;
pinctrl-names = "default";
};

&rtc {
status = "okay";
};

&ieee802154 {
status = "okay";
};

&ieee802154g {
status = "okay";
};
13 changes: 13 additions & 0 deletions boards/arm/beagle_play_cc1352/beagleplay_cc1352.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
identifier: beagleplay_cc1352
name: BeaglePlay CC1352
type: mcu
arch: arm
ram: 144
flash: 704
toolchain:
- zephyr
- gnuarmemb
- xtools
supported:
- gpio
- uart
24 changes: 24 additions & 0 deletions boards/arm/beagle_play_cc1352/beagleplay_cc1352_defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#
# Copyright (c) 2022 Jason Kridner, BeagleBoard.org Foundation
#
# SPDX-License-Identifier: Apache-2.0
#

CONFIG_SOC_SERIES_CC13X2X7_CC26X2X7=y
CONFIG_SOC_CC1352P7=y
CONFIG_BOARD_BEAGLEPLAY_CC1352=y
CONFIG_BUILD_OUTPUT_HEX=y
CONFIG_CC13X2_CC26X2_HAS_CUSTOM_RF_HWATTRS=y
CONFIG_CC13X2_CC26X2_BOOTLOADER_ENABLE=y
CONFIG_CC13X2_CC26X2_BOOTLOADER_BACKDOOR_ENABLE=y
CONFIG_CC13X2_CC26X2_BOOTLOADER_BACKDOOR_PIN=15
CONFIG_ARM_MPU=y
CONFIG_HW_STACK_PROTECTION=y
CONFIG_PINCTRL=y
CONFIG_PINCTRL_DYNAMIC=y
CONFIG_PINCTRL_CC13XX_CC26XX=y
CONFIG_GPIO=y
CONFIG_SERIAL=y

# Per Seeed recommendation
CONFIG_CC13X2_CC26X2_XOSC_CAPARRAY_DELTA=0xD5
11 changes: 11 additions & 0 deletions boards/arm/beagle_play_cc1352/board.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copyright (c) 2020 Erik Larson
# Copyright (c) 2023 Jason Kridner, BeagleBoard.org Foundation
#
# SPDX-License-Identifier: Apache-2.0

# Copy https://git.beagleboard.org/beagleconnect/cc1352-flasher/-/raw/c99f5e0e8227d8e60171e39b1a45ddb03a6cb763/cc1352-flasher.py here
# Install python gpiod library
# Be sure to disable the bcfserial driver because it will capture /dev/ttyS4

board_set_flasher_ifnset(misc-flasher)
board_finalize_runner_args(misc-flasher "$ENV{ZEPHYR_BASE}/boards/arm/beagle_play_cc1352/cc1352-flasher.py --play")
117 changes: 117 additions & 0 deletions boards/arm/beagle_play_cc1352/board_antenna.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/* SPDX-License-Identifier: Apache-2.0
*
* Copyright (c) 2021 Florin Stancu
* Copyright (c) 2021 Jason Kridner, BeagleBoard.org Foundation
*
*/

/*
* Implements the RF driver callback to configure the on-board antenna
* switch.
*/

#include <zephyr/kernel.h>
#include <zephyr/device.h>
#include <zephyr/init.h>

#include <ti/drivers/rf/RF.h>
#include <driverlib/gpio.h>
#include <driverlib/ioc.h>
#include <driverlib/rom.h>

/* DIOs for RF antenna paths */
#define BOARD_RF_HIGH_PA 29 /* TODO: pull from DT */
#define BOARD_RF_SUB1GHZ 30 /* TODO: pull from DT */

static void board_cc13xx_rf_callback(RF_Handle client, RF_GlobalEvent events,
void *arg);


const RFCC26XX_HWAttrsV2 RFCC26XX_hwAttrs = {
.hwiPriority = INT_PRI_LEVEL7,
.swiPriority = 0,
.xoscHfAlwaysNeeded = true,
/* RF driver callback for custom antenna switching */
.globalCallback = board_cc13xx_rf_callback,
/* Subscribe to events */
.globalEventMask = (RF_GlobalEventRadioSetup |
RF_GlobalEventRadioPowerDown),
};

/**
* Antenna switch GPIO init routine.
*/
static int board_antenna_init(const struct device *dev)
{
ARG_UNUSED(dev);

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jadonk can you please drop const struct device *dev ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this was just changed to void somewhat recently

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Ayush1325 Ping, since you are actively working on BeagleConnect freedom and Beagleplay, can you fixup the minor changes required in this PR?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vaishnavachath This PR totally slipped by radar. I already do have a PR for beagleplay on-board cc1352: #64718. Other than caparray delta (which I am planning to add after #65048, my PR also contains everything rebased on upstream zephyr

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem @Ayush1325 , can you add the Caparray delta to #65048 (new commit) rather than creating a new PR for that alone? and please confirm if this can be closed as duplicate.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vaishnavachath Yes, I will add caparray to #65048

/* set all paths to low */
IOCPinTypeGpioOutput(BOARD_RF_HIGH_PA);
GPIO_setOutputEnableDio(BOARD_RF_HIGH_PA, GPIO_OUTPUT_DISABLE);
IOCPinTypeGpioOutput(BOARD_RF_SUB1GHZ);
GPIO_setOutputEnableDio(BOARD_RF_SUB1GHZ, GPIO_OUTPUT_DISABLE);
return 0;
}

SYS_INIT(board_antenna_init, POST_KERNEL, CONFIG_BOARD_ANTENNA_INIT_PRIO);

void board_cc13xx_rf_callback(RF_Handle client, RF_GlobalEvent events, void *arg)
{
bool sub1GHz = false;
uint8_t loDivider = 0;

/* Switch off all paths first. Needs to be done anyway in every sub-case below. */
GPIO_setOutputEnableDio(BOARD_RF_HIGH_PA, GPIO_OUTPUT_DISABLE);
GPIO_setOutputEnableDio(BOARD_RF_SUB1GHZ, GPIO_OUTPUT_DISABLE);

if (events & RF_GlobalEventRadioSetup) {
/* Decode the current PA configuration. */
RF_TxPowerTable_PAType paType = (RF_TxPowerTable_PAType)
RF_getTxPower(client).paType;
/* Decode the generic argument as a setup command. */
RF_RadioSetup *setupCommand = (RF_RadioSetup *)arg;

switch (setupCommand->common.commandNo) {
case (CMD_RADIO_SETUP):
case (CMD_BLE5_RADIO_SETUP):
loDivider = RF_LODIVIDER_MASK & setupCommand->common.loDivider;
/* Sub-1GHz front-end. */
if (loDivider != 0)
sub1GHz = true;
break;
case (CMD_PROP_RADIO_DIV_SETUP):
loDivider = RF_LODIVIDER_MASK & setupCommand->prop_div.loDivider;
/* Sub-1GHz front-end. */
if (loDivider != 0)
sub1GHz = true;
break;
default:
break;
}

/* Sub-1 GHz */
if (paType == RF_TxPowerTable_HighPA) {
/* PA enable --> HIGH PA */
/* LNA enable --> Sub-1 GHz */
/* Note: RFC_GPO3 is a work-around because the RFC_GPO1 */
/* is sometimes not de-asserted on CC1352 Rev A. */
IOCPortConfigureSet(BOARD_RF_HIGH_PA,
IOC_PORT_RFC_GPO3, IOC_IOMODE_NORMAL);
IOCPortConfigureSet(BOARD_RF_SUB1GHZ,
IOC_PORT_RFC_GPO0, IOC_IOMODE_NORMAL);
} else {
/* RF core active --> Sub-1 GHz */
IOCPortConfigureSet(BOARD_RF_HIGH_PA,
IOC_PORT_GPIO, IOC_IOMODE_NORMAL);
IOCPortConfigureSet(BOARD_RF_SUB1GHZ,
IOC_PORT_GPIO, IOC_IOMODE_NORMAL);
GPIO_setOutputEnableDio(BOARD_RF_SUB1GHZ, GPIO_OUTPUT_ENABLE);
}
} else {
/* Reset the IO multiplexer to GPIO functionality */
IOCPortConfigureSet(BOARD_RF_HIGH_PA,
IOC_PORT_GPIO, IOC_IOMODE_NORMAL);
IOCPortConfigureSet(BOARD_RF_SUB1GHZ,
IOC_PORT_GPIO, IOC_IOMODE_NORMAL);
}
}
Binary file not shown.
Loading