diff --git a/boards/arm/beagle_play_cc1352/CMakeLists.txt b/boards/arm/beagle_play_cc1352/CMakeLists.txt new file mode 100644 index 000000000000..165ab5220a8d --- /dev/null +++ b/boards/arm/beagle_play_cc1352/CMakeLists.txt @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: Apache-2.0 + +zephyr_library() +zephyr_library_sources( + board_antenna.c + ) + +zephyr_library_compile_definitions("DeviceFamily_CC13X2X7") diff --git a/boards/arm/beagle_play_cc1352/Kconfig.board b/boards/arm/beagle_play_cc1352/Kconfig.board new file mode 100644 index 000000000000..4d094b727224 --- /dev/null +++ b/boards/arm/beagle_play_cc1352/Kconfig.board @@ -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 diff --git a/boards/arm/beagle_play_cc1352/Kconfig.defconfig b/boards/arm/beagle_play_cc1352/Kconfig.defconfig new file mode 100644 index 000000000000..da573b0cbfbc --- /dev/null +++ b/boards/arm/beagle_play_cc1352/Kconfig.defconfig @@ -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 diff --git a/boards/arm/beagle_play_cc1352/beagleplay-cc1352-pinctrl.dtsi b/boards/arm/beagle_play_cc1352/beagleplay-cc1352-pinctrl.dtsi new file mode 100644 index 000000000000..78985a336747 --- /dev/null +++ b/boards/arm/beagle_play_cc1352/beagleplay-cc1352-pinctrl.dtsi @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022 Vaishnav Achath + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include + +&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>; + }; +}; diff --git a/boards/arm/beagle_play_cc1352/beagleplay_cc1352.dts b/boards/arm/beagle_play_cc1352/beagleplay_cc1352.dts new file mode 100644 index 000000000000..d85146276d82 --- /dev/null +++ b/boards/arm/beagle_play_cc1352/beagleplay_cc1352.dts @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2022 Jason Kridner, BeagleBoard.org Foundation + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; + +#include +#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"; +}; diff --git a/boards/arm/beagle_play_cc1352/beagleplay_cc1352.yaml b/boards/arm/beagle_play_cc1352/beagleplay_cc1352.yaml new file mode 100644 index 000000000000..ebb7d83aa176 --- /dev/null +++ b/boards/arm/beagle_play_cc1352/beagleplay_cc1352.yaml @@ -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 diff --git a/boards/arm/beagle_play_cc1352/beagleplay_cc1352_defconfig b/boards/arm/beagle_play_cc1352/beagleplay_cc1352_defconfig new file mode 100644 index 000000000000..e396f020dd37 --- /dev/null +++ b/boards/arm/beagle_play_cc1352/beagleplay_cc1352_defconfig @@ -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 diff --git a/boards/arm/beagle_play_cc1352/board.cmake b/boards/arm/beagle_play_cc1352/board.cmake new file mode 100644 index 000000000000..efaf3ad622f3 --- /dev/null +++ b/boards/arm/beagle_play_cc1352/board.cmake @@ -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") diff --git a/boards/arm/beagle_play_cc1352/board_antenna.c b/boards/arm/beagle_play_cc1352/board_antenna.c new file mode 100644 index 000000000000..005aad042b5b --- /dev/null +++ b/boards/arm/beagle_play_cc1352/board_antenna.c @@ -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 +#include +#include + +#include +#include +#include +#include + +/* 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); + + /* 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); + } +} diff --git a/boards/arm/beagle_play_cc1352/doc/index.rst b/boards/arm/beagle_play_cc1352/doc/index.rst new file mode 100644 index 000000000000..456691a9f26a --- /dev/null +++ b/boards/arm/beagle_play_cc1352/doc/index.rst @@ -0,0 +1,157 @@ +.. _beagleplay_cc1352: + +BeaglePlay (CC1352) +################### + +Overview +******** + +BeagleBoard.org BeaglePlay is an open hardware single board computer based on a TI Sitara AM6254 +quad-core ARM Cortex-A53 SoC with an external TI SimpleLink multi-standard CC1352P7 wireless MCU +providing long-range, low-power connectivity. + + +.. figure:: img/beagleplay.png + :width: 400px + :align: center + :alt: BeagleBoard.org BeaglePlay + + BeagleBoard.org BeaglePlay + +Hardware +******** + +* Processors + * TI Sitara AM6252 SoC + * 4x ARM Cortex-A53 + * ARM Cortex-R5 + * ARM Cortex-M4 + * Dual-core 32-bit RISC Programmble Real-Time Unit (PRU) + * TI SimpleLink CC1352P7 Wireless MCU + * ARM Cortex-M4F programmable MCU + * ARM Cortex-M0+ software-defined radio processor +* Memory + * 2GB DDR4 + * 16GB eMMC flash + * I2C EEPROM +* Wired connectivity + * Gigabit Ethernet (RJ45) + * Single-pair Ethernet with 5V/250mA PoDL output (RJ11) + * HDMI + * USB Type-A (host) + * USB Type-C (client/power) +* Wireless connectivity + * TI WL1807 2.4GHz/5GHz WiFi + * BLE/SubG via CC1352P7 +* Expansion + * mikroBUS + * Grove + * QWIIC + +BeaglePlay ARM Cortex-A53 CPUs typically run Linux, while the CC1352P7 Cortex-M4 typically runs Zephyr. + + +Supported Features +================== + +The board configuration supports the following hardware features: + ++-----------+------------+----------------------+ +| Interface | Controller | Driver/Component | ++===========+============+======================+ +| GPIO | on-chip | gpio | ++-----------+------------+----------------------+ +| MPU | on-chip | arch/arm | ++-----------+------------+----------------------+ +| NVIC | on-chip | arch/arm | ++-----------+------------+----------------------+ +| PINMUX | on-chip | pinmux | ++-----------+------------+----------------------+ +| UART | on-chip | serial | ++-----------+------------+----------------------+ + +Connections and IOs +=================== + +CC1352 reset is connected to AM62 GPIO0_14. + ++-------+--------------+-------------------------------------+ +| Pin | Function | Usage | ++=======+==============+=====================================+ +| DIO5 | N/C | | ++-------+--------------+-------------------------------------+ +| DIO6 | N/C | | ++-------+--------------+-------------------------------------+ +| DIO7 | N/C | | ++-------+--------------+-------------------------------------+ +| DIO8 | N/C | | ++-------+--------------+-------------------------------------+ +| DIO9 | N/C | | ++-------+--------------+-------------------------------------+ +| DIO10 | N/C | | ++-------+--------------+-------------------------------------+ +| DIO11 | N/C | | ++-------+--------------+-------------------------------------+ +| DIO12 | CC1352_RX | AM62 UART6_TXD | ++-------+--------------+-------------------------------------+ +| DIO13 | CC1352_TX | AM62 UART6_RXD | ++-------+--------------+-------------------------------------+ +| DIO14 | N/C | | ++-------+--------------+-------------------------------------+ +| DIO15 | CC1352_BOOT | AM62 GPIO0_13 | ++-------+--------------+-------------------------------------+ +| DIO16 | CC1352_TDO | TAG-CONNECT TDO | ++-------+--------------+-------------------------------------+ +| DIO17 | CC1352_TDI | TAG-CONNECT TDI | ++-------+--------------+-------------------------------------+ +| DIO18 | N/C | | ++-------+--------------+-------------------------------------+ +| DIO19 | N/C | | ++-------+--------------+-------------------------------------+ +| DIO20 | N/C | | ++-------+--------------+-------------------------------------+ +| DIO21 | N/C | | ++-------+--------------+-------------------------------------+ +| DIO22 | N/C | | ++-------+--------------+-------------------------------------+ +| DIO23 | N/C | | ++-------+--------------+-------------------------------------+ +| DIO24 | N/C | | ++-------+--------------+-------------------------------------+ +| DIO25 | N/C | | ++-------+--------------+-------------------------------------+ +| DIO26 | N/C | | ++-------+--------------+-------------------------------------+ +| DIO27 | LED1 | CC1352_LED1 yellow LED9 | ++-------+--------------+-------------------------------------+ +| DIO28 | LED2 | CC1352_LED2 yellow LED8 | ++-------+--------------+-------------------------------------+ +| DIO29 | RF_PA | Antenna mux PA enable | ++-------+--------------+-------------------------------------+ +| DIO30 | RF_SUB1G | Antenna mux SubG enable | ++-------+--------------+-------------------------------------+ + +Programming and Debugging +************************* + +Flashing +======== + +To flash, disable the existing driver that ties up the serial port and use +the customized BSL Python script. + +* https://docs.beagleboard.org/latest/boards/beagleplay/demos-and-tutorials/zephyr-cc1352-development.html + +Debugging +========= + +For debugging, you can use the serial port or JTAG. You can use OpenOCD +over the Tag-Connect header on the board. + +* https://docs.beagleboard.org/latest/accessories/cables.html#tagconnect-jtag + +References +********** + +BeagleBoard.org BeaglePlay reference: + https://beagleplay.org