From 99dd2112a2747ae8a2b339b9f18380c7db876d52 Mon Sep 17 00:00:00 2001 From: Florian Grandel Date: Thu, 6 Jul 2023 15:52:16 +0200 Subject: [PATCH 1/2] soc: ti: cc13/26xx: clean up include hierarchy Removes duplicate code and inconsistencies in the naming of the cc13xx_cc26xx devicetree and RTC driver hierarchy and alignes it with the actual TI product series naming hierarchy. Signed-off-by: Florian Grandel --- CODEOWNERS | 2 +- drivers/timer/CMakeLists.txt | 2 +- drivers/timer/Kconfig | 2 +- ...2_cc26x2_rtc => Kconfig.cc13xx_cc26xx_rtc} | 6 ++--- ..._rtc_timer.c => cc13xx_cc26xx_rtc_timer.c} | 0 dts/arm/ti/cc1352r.dtsi | 2 +- dts/arm/ti/cc1352r7.dtsi | 2 +- ...{cc13x2_cc26x2.dtsi => cc13xx_cc26xx.dtsi} | 0 dts/arm/ti/cc2652r.dtsi | 25 +------------------ soc/arm/ti_simplelink/cc13x2x7_cc26x2x7/soc.c | 4 +-- tests/kernel/sleep/src/usleep.c | 9 +++---- 11 files changed, 15 insertions(+), 39 deletions(-) rename drivers/timer/{Kconfig.cc13x2_cc26x2_rtc => Kconfig.cc13xx_cc26xx_rtc} (72%) rename drivers/timer/{cc13x2_cc26x2_rtc_timer.c => cc13xx_cc26xx_rtc_timer.c} (100%) rename dts/arm/ti/{cc13x2_cc26x2.dtsi => cc13xx_cc26xx.dtsi} (100%) diff --git a/CODEOWNERS b/CODEOWNERS index 44dd1b51cdc2..a1457cf6d3b1 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -445,7 +445,7 @@ /drivers/timer/*riscv_machine* @kgugala @pgielda /drivers/timer/*ite_it8xxx2* @ite /drivers/timer/*xlnx_psttc* @wjliang @stephanosio -/drivers/timer/*cc13x2_cc26x2_rtc* @vanti +/drivers/timer/*cc13xx_cc26xx_rtc* @vanti /drivers/timer/*cavs* @dcpleung /drivers/timer/*stm32_lptim* @FRASTM /drivers/timer/*leon_gptimer* @julius-barendt diff --git a/drivers/timer/CMakeLists.txt b/drivers/timer/CMakeLists.txt index b026a22b137c..ced74f9559c5 100644 --- a/drivers/timer/CMakeLists.txt +++ b/drivers/timer/CMakeLists.txt @@ -8,7 +8,7 @@ zephyr_library_sources_ifdef(CONFIG_APIC_TSC_DEADLINE_TIMER apic_tsc.c) zephyr_library_sources_ifdef(CONFIG_ARCV2_TIMER arcv2_timer0.c) zephyr_library_sources_ifdef(CONFIG_ARM_ARCH_TIMER arm_arch_timer.c) zephyr_library_sources_ifdef(CONFIG_INTEL_ADSP_TIMER intel_adsp_timer.c) -zephyr_library_sources_ifdef(CONFIG_CC13X2_CC26X2_RTC_TIMER cc13x2_cc26x2_rtc_timer.c) +zephyr_library_sources_ifdef(CONFIG_CC13XX_CC26XX_RTC_TIMER cc13xx_cc26xx_rtc_timer.c) zephyr_library_sources_ifdef(CONFIG_CORTEX_M_SYSTICK cortex_m_systick.c) zephyr_library_sources_ifdef(CONFIG_ESP32C3_SYS_TIMER esp32c3_sys_timer.c) zephyr_library_sources_ifdef(CONFIG_GECKO_BURTC_TIMER gecko_burtc_timer.c) diff --git a/drivers/timer/Kconfig b/drivers/timer/Kconfig index 1b6c48712bd0..3631c55e4942 100644 --- a/drivers/timer/Kconfig +++ b/drivers/timer/Kconfig @@ -68,7 +68,7 @@ source "drivers/timer/Kconfig.apic" source "drivers/timer/Kconfig.arcv2" source "drivers/timer/Kconfig.arm_arch" source "drivers/timer/Kconfig.cavs" -source "drivers/timer/Kconfig.cc13x2_cc26x2_rtc" +source "drivers/timer/Kconfig.cc13xx_cc26xx_rtc" source "drivers/timer/Kconfig.cortex_m_systick" source "drivers/timer/Kconfig.esp32c3_sys" source "drivers/timer/Kconfig.gecko" diff --git a/drivers/timer/Kconfig.cc13x2_cc26x2_rtc b/drivers/timer/Kconfig.cc13xx_cc26xx_rtc similarity index 72% rename from drivers/timer/Kconfig.cc13x2_cc26x2_rtc rename to drivers/timer/Kconfig.cc13xx_cc26xx_rtc index b734b1f1d3d1..5b4b82aa3f9d 100644 --- a/drivers/timer/Kconfig.cc13x2_cc26x2_rtc +++ b/drivers/timer/Kconfig.cc13xx_cc26xx_rtc @@ -3,13 +3,13 @@ # Copyright (c) 2019 Intel Corp. # SPDX-License-Identifier: Apache-2.0 -config CC13X2_CC26X2_RTC_TIMER - bool "TI SimpleLink CC13x2/CC26x2 RTC timer" +config CC13XX_CC26XX_RTC_TIMER + bool "TI SimpleLink CC13xx/CC26xx RTC system clock timer" default y depends on DT_HAS_TI_CC13XX_CC26XX_RTC_ENABLED select TICKLESS_CAPABLE select TIMER_HAS_64BIT_CYCLE_COUNTER help This module implements a kernel device driver for the TI SimpleLink - CC13X2_CC26X2 series Real Time Counter and provides the standard + CC13XX_CC26XX series Real Time Counter and provides the standard "system clock driver" interfaces. diff --git a/drivers/timer/cc13x2_cc26x2_rtc_timer.c b/drivers/timer/cc13xx_cc26xx_rtc_timer.c similarity index 100% rename from drivers/timer/cc13x2_cc26x2_rtc_timer.c rename to drivers/timer/cc13xx_cc26xx_rtc_timer.c diff --git a/dts/arm/ti/cc1352r.dtsi b/dts/arm/ti/cc1352r.dtsi index 97c7ad3f72b3..34f36ee64022 100644 --- a/dts/arm/ti/cc1352r.dtsi +++ b/dts/arm/ti/cc1352r.dtsi @@ -5,7 +5,7 @@ */ #include -#include +#include / { sram0: memory@20000000 { diff --git a/dts/arm/ti/cc1352r7.dtsi b/dts/arm/ti/cc1352r7.dtsi index 0b098c81c81f..56bcb9678dcf 100644 --- a/dts/arm/ti/cc1352r7.dtsi +++ b/dts/arm/ti/cc1352r7.dtsi @@ -5,7 +5,7 @@ */ #include -#include +#include / { sram0: memory@20000000 { diff --git a/dts/arm/ti/cc13x2_cc26x2.dtsi b/dts/arm/ti/cc13xx_cc26xx.dtsi similarity index 100% rename from dts/arm/ti/cc13x2_cc26x2.dtsi rename to dts/arm/ti/cc13xx_cc26xx.dtsi diff --git a/dts/arm/ti/cc2652r.dtsi b/dts/arm/ti/cc2652r.dtsi index 97c7ad3f72b3..1f6bdf878d4d 100644 --- a/dts/arm/ti/cc2652r.dtsi +++ b/dts/arm/ti/cc2652r.dtsi @@ -5,27 +5,4 @@ */ #include -#include - -/ { - sram0: memory@20000000 { - reg = <0x20000000 DT_SIZE_K(80)>; - }; -}; - -&flash0 { - reg = <0x0 DT_SIZE_K(352)>; - - partitions { - compatible = "fixed-partitions"; - #address-cells = <1>; - #size-cells = <1>; - - /* CCFG registers occupy the last 88 bytes of flash */ - ti_ccfg_partition: partition@57fa8 { - compatible = "zephyr,memory-region"; - reg = <0x57fa8 88>; - zephyr,memory-region = "FLASH_CCFG"; - }; - }; -}; +#include diff --git a/soc/arm/ti_simplelink/cc13x2x7_cc26x2x7/soc.c b/soc/arm/ti_simplelink/cc13x2x7_cc26x2x7/soc.c index 9db48d9a354c..8c2ea2f5350d 100644 --- a/soc/arm/ti_simplelink/cc13x2x7_cc26x2x7/soc.c +++ b/soc/arm/ti_simplelink/cc13x2x7_cc26x2x7/soc.c @@ -8,7 +8,7 @@ #include -static int ti_cc13x2_cc26x2_init(void) +static int ti_cc13x7_cc26x7_init(void) { /* Performs necessary trim of the device. */ @@ -17,4 +17,4 @@ static int ti_cc13x2_cc26x2_init(void) return 0; } -SYS_INIT(ti_cc13x2_cc26x2_init, PRE_KERNEL_1, 0); +SYS_INIT(ti_cc13x7_cc26x7_init, PRE_KERNEL_1, 0); diff --git a/tests/kernel/sleep/src/usleep.c b/tests/kernel/sleep/src/usleep.c index e014a84ab73c..67037e593c90 100644 --- a/tests/kernel/sleep/src/usleep.c +++ b/tests/kernel/sleep/src/usleep.c @@ -29,12 +29,11 @@ * nRF51, which has a slow CPU clock. */ #define MAXIMUM_SHORTEST_TICKS (IS_ENABLED(CONFIG_SOC_SERIES_NRF51X) ? 6 : 3) -/* - * Similar situation for TI CC13X2/CC26X2 RTC due to the limitation - * that a value too close to the current time cannot be loaded to - * its comparator. +/* Similar situation for TI CC13XX/CC26XX RTC kernel timer due to the + * limitation that a value too close to the current time cannot be + * loaded to its comparator. */ -#elif defined(CONFIG_CC13X2_CC26X2_RTC_TIMER) && \ +#elif defined(CONFIG_CC13XX_CC26XX_RTC_TIMER) && \ (CONFIG_SYS_CLOCK_TICKS_PER_SEC > 16384) #define MAXIMUM_SHORTEST_TICKS 3 #else From e89c6eaad6dd27bdd7ce23865f8daa62e4456c84 Mon Sep 17 00:00:00 2001 From: Florian Grandel Date: Thu, 6 Jul 2023 16:06:19 +0200 Subject: [PATCH 2/2] dts: ti: cc13xx_cc26xx: devicetree sysclk alignment This change introduces the "_rtc_timer" suffix for the system tick timer driver "compatible" property and aligns naming conventions with the actual CC13/26xx SoC series product policy. This frees up the "_rtc" namespace to introduce additional APIs based on the same peripheral in the future (not part of this PR): rtc: rtc@... { compatible = "ti,cc13xx-cc26xx-rtc"; ... timer { compatible = "ti,cc13xx-cc26xx-rtc-timer"; ... }; counter { compatible = "ti,cc13xx-cc26xx-rtc-counter"; ... }; pps { compatible = "ti,cc13xx-cc26xx-rtc-pps"; ... }; }; Or alternatively an MFD pattern with similar requirements. Fixing the namespacing now makes sense standalone as it reduces the chance of custom drivers being broken in the future. Redundant extension of the mandatory system clock devicetree node is replaced with a single `status = "okay"` which seems to be the more sensible default to avoid user error when defining custom boards. Knowledgeable users can still override this if really needed. Signed-off-by: Florian Grandel --- boards/arm/beagle_bcf/beagleconnect_freedom.dts | 4 ---- boards/arm/cc1352p1_launchxl/cc1352p1_launchxl.dts | 4 ---- boards/arm/cc1352r1_launchxl/cc1352r1_launchxl.dts | 4 ---- boards/arm/cc1352r_sensortag/cc1352r_sensortag.dts | 4 ---- boards/arm/cc26x2r1_launchxl/cc26x2r1_launchxl.dts | 4 ---- drivers/timer/Kconfig.cc13xx_cc26xx_rtc | 2 +- drivers/timer/cc13xx_cc26xx_rtc_timer.c | 2 +- dts/arm/ti/cc13xx_cc26xx.dtsi | 5 +++-- dts/bindings/rtc/ti,cc13xx-cc26xx-rtc.yaml | 2 +- 9 files changed, 6 insertions(+), 25 deletions(-) diff --git a/boards/arm/beagle_bcf/beagleconnect_freedom.dts b/boards/arm/beagle_bcf/beagleconnect_freedom.dts index 154928bc8c79..c41d642ebfe7 100644 --- a/boards/arm/beagle_bcf/beagleconnect_freedom.dts +++ b/boards/arm/beagle_bcf/beagleconnect_freedom.dts @@ -201,10 +201,6 @@ }; }; -&rtc { - status = "okay"; -}; - &ieee802154 { status = "okay"; }; diff --git a/boards/arm/cc1352p1_launchxl/cc1352p1_launchxl.dts b/boards/arm/cc1352p1_launchxl/cc1352p1_launchxl.dts index 06053065c8fe..50ab7b4fdc4f 100644 --- a/boards/arm/cc1352p1_launchxl/cc1352p1_launchxl.dts +++ b/boards/arm/cc1352p1_launchxl/cc1352p1_launchxl.dts @@ -131,10 +131,6 @@ cs-gpios = <&gpio0 11 GPIO_ACTIVE_LOW>; }; -&rtc { - status = "okay"; -}; - &radio { status = "okay"; }; diff --git a/boards/arm/cc1352r1_launchxl/cc1352r1_launchxl.dts b/boards/arm/cc1352r1_launchxl/cc1352r1_launchxl.dts index 71c2214ed942..4f6cc4864b87 100644 --- a/boards/arm/cc1352r1_launchxl/cc1352r1_launchxl.dts +++ b/boards/arm/cc1352r1_launchxl/cc1352r1_launchxl.dts @@ -111,10 +111,6 @@ cs-gpios = <&gpio0 11 GPIO_ACTIVE_LOW>; }; -&rtc { - status = "okay"; -}; - &radio { status = "okay"; }; diff --git a/boards/arm/cc1352r_sensortag/cc1352r_sensortag.dts b/boards/arm/cc1352r_sensortag/cc1352r_sensortag.dts index 0df448d6f31f..0d50b59e778e 100644 --- a/boards/arm/cc1352r_sensortag/cc1352r_sensortag.dts +++ b/boards/arm/cc1352r_sensortag/cc1352r_sensortag.dts @@ -141,10 +141,6 @@ /* TODO: "jedec,spi-nor" for the mx25r8035 */ }; -&rtc { - status = "okay"; -}; - &radio { status = "okay"; }; diff --git a/boards/arm/cc26x2r1_launchxl/cc26x2r1_launchxl.dts b/boards/arm/cc26x2r1_launchxl/cc26x2r1_launchxl.dts index 6021603165d3..271e63b920bc 100644 --- a/boards/arm/cc26x2r1_launchxl/cc26x2r1_launchxl.dts +++ b/boards/arm/cc26x2r1_launchxl/cc26x2r1_launchxl.dts @@ -111,10 +111,6 @@ cs-gpios = <&gpio0 11 GPIO_ACTIVE_LOW>; }; -&rtc { - status = "okay"; -}; - &wdt0 { status = "okay"; }; diff --git a/drivers/timer/Kconfig.cc13xx_cc26xx_rtc b/drivers/timer/Kconfig.cc13xx_cc26xx_rtc index 5b4b82aa3f9d..e6fbef0bfabc 100644 --- a/drivers/timer/Kconfig.cc13xx_cc26xx_rtc +++ b/drivers/timer/Kconfig.cc13xx_cc26xx_rtc @@ -6,7 +6,7 @@ config CC13XX_CC26XX_RTC_TIMER bool "TI SimpleLink CC13xx/CC26xx RTC system clock timer" default y - depends on DT_HAS_TI_CC13XX_CC26XX_RTC_ENABLED + depends on DT_HAS_TI_CC13XX_CC26XX_RTC_TIMER_ENABLED select TICKLESS_CAPABLE select TIMER_HAS_64BIT_CYCLE_COUNTER help diff --git a/drivers/timer/cc13xx_cc26xx_rtc_timer.c b/drivers/timer/cc13xx_cc26xx_rtc_timer.c index bf0895f32a3c..9a64c779248b 100644 --- a/drivers/timer/cc13xx_cc26xx_rtc_timer.c +++ b/drivers/timer/cc13xx_cc26xx_rtc_timer.c @@ -4,7 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -#define DT_DRV_COMPAT ti_cc13xx_cc26xx_rtc +#define DT_DRV_COMPAT ti_cc13xx_cc26xx_rtc_timer /* * TI SimpleLink CC13X2/CC26X2 RTC-based system timer diff --git a/dts/arm/ti/cc13xx_cc26xx.dtsi b/dts/arm/ti/cc13xx_cc26xx.dtsi index dd32e43755f9..57c07c2b121d 100644 --- a/dts/arm/ti/cc13xx_cc26xx.dtsi +++ b/dts/arm/ti/cc13xx_cc26xx.dtsi @@ -123,11 +123,12 @@ status = "disabled"; }; + /* The RTC peripheral backs the kernel system clock and tick timer. */ rtc: rtc@40092000 { - compatible = "ti,cc13xx-cc26xx-rtc"; + compatible = "ti,cc13xx-cc26xx-rtc-timer"; reg = <0x40092000 0x1000>; interrupts = <4 0>; /* interrupt #20 = 4 + 16 */ - status = "disabled"; + status = "okay"; /* the system clock timer is mandatory */ }; radio: radio@40040000 { diff --git a/dts/bindings/rtc/ti,cc13xx-cc26xx-rtc.yaml b/dts/bindings/rtc/ti,cc13xx-cc26xx-rtc.yaml index 93f7912d3cd6..861efc3a8f4c 100644 --- a/dts/bindings/rtc/ti,cc13xx-cc26xx-rtc.yaml +++ b/dts/bindings/rtc/ti,cc13xx-cc26xx-rtc.yaml @@ -6,7 +6,7 @@ description: TI SimpleLink CC13xx/CC26xx RTC -compatible: "ti,cc13xx-cc26xx-rtc" +compatible: "ti,cc13xx-cc26xx-rtc-timer" include: rtc.yaml