From a08ccfeacbfe443c78cdc14e1d74f87690bfcd96 Mon Sep 17 00:00:00 2001 From: Jilay Pandya Date: Mon, 16 Dec 2024 17:38:50 +0100 Subject: [PATCH 1/3] drivers: stepper: tmc: create rampstat Kconfig template create rampstat Kconfig template to enable respective tmc drivers to reuse the common configurations Signed-off-by: Jilay Pandya --- drivers/stepper/adi_tmc/Kconfig.tmc5041 | 20 +++---------------- .../adi_tmc/Kconfig.tmc_rampgen_template | 20 +++++++++++++++++++ 2 files changed, 23 insertions(+), 17 deletions(-) create mode 100644 drivers/stepper/adi_tmc/Kconfig.tmc_rampgen_template diff --git a/drivers/stepper/adi_tmc/Kconfig.tmc5041 b/drivers/stepper/adi_tmc/Kconfig.tmc5041 index af3e0de4f82016..e6f01ebb1aea7e 100644 --- a/drivers/stepper/adi_tmc/Kconfig.tmc5041 +++ b/drivers/stepper/adi_tmc/Kconfig.tmc5041 @@ -9,20 +9,6 @@ config STEPPER_ADI_TMC5041 help Stepper driver for TMC5041. -config STEPPER_ADI_TMC5041_RAMPSTAT_POLL - bool "TMC5041 poll ramp status" - depends on STEPPER_ADI_TMC5041 - default y - help - When enabled, the ramp status will be polled on TMC5041, to check for events: - - TMC5041_POS_REACHED_EVENT - - TMC5041_STOP_SG_EVENT - - TMC5041_STOP_LEFT_EVENT - - TMC5041_STOP_RIGHT_EVENT - -config STEPPER_ADI_TMC5041_RAMPSTAT_POLL_INTERVAL_IN_MSEC - int "TMC5041 poll ramp status interval in ms" - depends on STEPPER_ADI_TMC5041_RAMPSTAT_POLL - default 100 - help - The interval in ms to poll the ramp status on TMC5041. +module = TMC5041 +module-str = tmc5041 +rsource "Kconfig.tmc_rampgen_template" diff --git a/drivers/stepper/adi_tmc/Kconfig.tmc_rampgen_template b/drivers/stepper/adi_tmc/Kconfig.tmc_rampgen_template new file mode 100644 index 00000000000000..b42ff208635547 --- /dev/null +++ b/drivers/stepper/adi_tmc/Kconfig.tmc_rampgen_template @@ -0,0 +1,20 @@ +# SPDX-FileCopyrightText: Copyright (c) 2024 Jilay Sandeep Pandya +# SPDX-License-Identifier: Apache-2.0 + +config STEPPER_ADI_$(module)_RAMPSTAT_POLL + bool "$(module-str) poll ramp status" + depends on STEPPER_ADI_$(module) + default y + help + When enabled, the ramp status will be polled on TMC, to check for events: + - TMC_POS_REACHED_EVENT + - TMC_STOP_SG_EVENT + - TMC_STOP_LEFT_EVENT + - TMC_STOP_RIGHT_EVENT + +config STEPPER_ADI_$(module)_RAMPSTAT_POLL_INTERVAL_IN_MSEC + int "$(module-str) poll ramp status interval in ms" + depends on STEPPER_ADI_$(module)_RAMPSTAT_POLL + default 100 + help + The interval in ms to poll the ramp status on TMC. From 37e28b66c0b297ee9bca7f1093969ac15babb426 Mon Sep 17 00:00:00 2001 From: Jilay Pandya Date: Mon, 16 Dec 2024 20:07:04 +0100 Subject: [PATCH 2/3] drivers: stepper: tmc: add CONFIG_STEPPER_ADI_TMC5041_RAMP_GEN rename CONFIG_STEPPER_ADI_RAMP_GEN to CONFIG_STEPPER_ADI_TMC5041_RAMP_GEN Signed-off-by: Jilay Pandya --- drivers/stepper/adi_tmc/Kconfig | 7 ------- drivers/stepper/adi_tmc/Kconfig.tmc_rampgen_template | 7 +++++++ .../stepper/adi_tmc/adi_tmc5041_stepper_controller.c | 10 +++++----- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/stepper/adi_tmc/Kconfig b/drivers/stepper/adi_tmc/Kconfig index db6c6ed7f05c88..51060a5d46974d 100644 --- a/drivers/stepper/adi_tmc/Kconfig +++ b/drivers/stepper/adi_tmc/Kconfig @@ -10,13 +10,6 @@ menuconfig STEPPER_ADI_TMC if STEPPER_ADI_TMC -config STEPPER_ADI_TMC_RAMP_GEN - bool "Use Trinamic Stepper Controller with Ramp Generator" - depends on STEPPER_ADI_TMC - default y - help - Enable ramp generator for trinamic stepper controller - config STEPPER_ADI_TMC_SPI bool "Use Trinamic Stepper Controller with SPI" depends on STEPPER_ADI_TMC diff --git a/drivers/stepper/adi_tmc/Kconfig.tmc_rampgen_template b/drivers/stepper/adi_tmc/Kconfig.tmc_rampgen_template index b42ff208635547..34064f73b227bc 100644 --- a/drivers/stepper/adi_tmc/Kconfig.tmc_rampgen_template +++ b/drivers/stepper/adi_tmc/Kconfig.tmc_rampgen_template @@ -18,3 +18,10 @@ config STEPPER_ADI_$(module)_RAMPSTAT_POLL_INTERVAL_IN_MSEC default 100 help The interval in ms to poll the ramp status on TMC. + +config STEPPER_ADI_$(module)_RAMP_GEN + bool "Use $(module-str) with Ramp Generator" + depends on STEPPER_ADI_$(module) + default y + help + Enable ramp generator for trinamic stepper controller diff --git a/drivers/stepper/adi_tmc/adi_tmc5041_stepper_controller.c b/drivers/stepper/adi_tmc/adi_tmc5041_stepper_controller.c index efb88d24304edd..fd89e99c0c2f81 100644 --- a/drivers/stepper/adi_tmc/adi_tmc5041_stepper_controller.c +++ b/drivers/stepper/adi_tmc/adi_tmc5041_stepper_controller.c @@ -49,7 +49,7 @@ struct tmc5041_stepper_config { const uint32_t sg_threshold_velocity; /* parent controller required for bus communication */ const struct device *controller; -#ifdef CONFIG_STEPPER_ADI_TMC_RAMP_GEN +#ifdef CONFIG_STEPPER_ADI_TMC5041_RAMP_GEN const struct tmc_ramp_generator_data default_ramp_config; #endif }; @@ -537,7 +537,7 @@ static int tmc5041_stepper_run(const struct device *dev, const enum stepper_dire return 0; } -#ifdef CONFIG_STEPPER_ADI_TMC_RAMP_GEN +#ifdef CONFIG_STEPPER_ADI_TMC5041_RAMP_GEN int tmc5041_stepper_set_ramp(const struct device *dev, const struct tmc_ramp_generator_data *ramp_data) @@ -676,7 +676,7 @@ static int tmc5041_stepper_init(const struct device *dev) } } -#ifdef CONFIG_STEPPER_ADI_TMC_RAMP_GEN +#ifdef CONFIG_STEPPER_ADI_TMC5041_RAMP_GEN err = tmc5041_stepper_set_ramp(dev, &stepper_config->default_ramp_config); if (err != 0) { return -EIO; @@ -702,7 +702,7 @@ static int tmc5041_stepper_init(const struct device *dev) COND_CODE_1(DT_PROP_EXISTS(child, stallguard_threshold_velocity), \ BUILD_ASSERT(DT_PROP(child, stallguard_threshold_velocity), \ "stallguard threshold velocity must be a positive value"), ()); \ - IF_ENABLED(CONFIG_STEPPER_ADI_TMC_RAMP_GEN, (CHECK_RAMP_DT_DATA(child))); \ + IF_ENABLED(CONFIG_STEPPER_ADI_TMC5041_RAMP_GEN, (CHECK_RAMP_DT_DATA(child))); \ static const struct tmc5041_stepper_config tmc5041_stepper_config_##child = { \ .controller = DEVICE_DT_GET(DT_PARENT(child)), \ .default_micro_step_res = DT_PROP(child, micro_step_res), \ @@ -712,7 +712,7 @@ static int tmc5041_stepper_init(const struct device *dev) .sg_velocity_check_interval_ms = DT_PROP(child, \ stallguard_velocity_check_interval_ms), \ .is_sg_enabled = DT_PROP(child, activate_stallguard2), \ - IF_ENABLED(CONFIG_STEPPER_ADI_TMC_RAMP_GEN, \ + IF_ENABLED(CONFIG_STEPPER_ADI_TMC5041_RAMP_GEN, \ (.default_ramp_config = TMC_RAMP_DT_SPEC_GET(child))) }; #define TMC5041_STEPPER_DATA_DEFINE(child) \ From 7c5f0dfac9c9861408fcc530dca92fe2e500e716 Mon Sep 17 00:00:00 2001 From: Jilay Pandya Date: Mon, 16 Dec 2024 20:17:58 +0100 Subject: [PATCH 3/3] doc: migration guide: 4.1: add deprecation info of STEPPER_ADI_TMC_RAMP_GEN STEPPER_ADI_TMC_RAMP_GEN renamed to template STEPPER_ADI_TMC5041_RAMP_GEN Signed-off-by: Jilay Pandya --- doc/releases/migration-guide-4.1.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/releases/migration-guide-4.1.rst b/doc/releases/migration-guide-4.1.rst index d999f086274760..f8bdb8de4d2ec6 100644 --- a/doc/releases/migration-guide-4.1.rst +++ b/doc/releases/migration-guide-4.1.rst @@ -206,6 +206,8 @@ Stepper * Renamed the ``stepper_enable_constant_velocity_mode`` function to :c:func:`stepper_run`. * Renamed the ``stepper_move`` function to :c:func:`stepper_move_by`. * Renamed the ``stepper_set_target_position`` function to :c:func:`stepper_move_to`. + * The :kconfig:option:`STEPPER_ADI_TMC_RAMP_GEN` is now deprecated and is replaced with the new + :kconfig:option:`STEPPER_ADI_TMC5041_RAMP_GEN` option. SPI ===