Skip to content

Commit 2e06888

Browse files
Danh Doankartben
authored andcommitted
drivers: pwm: update namming of pwm driver for RA family
- update namming for pwm driver. Signed-off-by: Danh Doan <[email protected]>
1 parent 793bfe1 commit 2e06888

File tree

7 files changed

+68
-66
lines changed

7 files changed

+68
-66
lines changed

drivers/pwm/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ zephyr_library_sources_ifdef(CONFIG_PWM_NUMAKER pwm_numaker.c)
4646
zephyr_library_sources_ifdef(CONFIG_PWM_NXP_FLEXIO pwm_nxp_flexio.c)
4747
zephyr_library_sources_ifdef(CONFIG_PWM_NXP_S32_EMIOS pwm_nxp_s32_emios.c)
4848
zephyr_library_sources_ifdef(CONFIG_PWM_ENE_KB1200 pwm_ene_kb1200.c)
49-
zephyr_library_sources_ifdef(CONFIG_PWM_RENESAS_RA8 pwm_renesas_ra8.c)
49+
zephyr_library_sources_ifdef(CONFIG_PWM_RENESAS_RA pwm_renesas_ra.c)
5050
zephyr_library_sources_ifdef(CONFIG_PWM_INFINEON_CAT1 pwm_ifx_cat1.c)
5151
zephyr_library_sources_ifdef(CONFIG_PWM_FAKE pwm_fake.c)
5252
zephyr_library_sources_ifdef(CONFIG_USERSPACE pwm_handlers.c)

drivers/pwm/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ source "drivers/pwm/Kconfig.nxp_flexio"
112112

113113
source "drivers/pwm/Kconfig.ene"
114114

115-
source "drivers/pwm/Kconfig.renesas_ra8"
115+
source "drivers/pwm/Kconfig.renesas_ra"
116116

117117
source "drivers/pwm/Kconfig.ifx_cat1"
118118

Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Copyright (c) 2024 Renesas Electronics Corporation
22
# SPDX-License-Identifier: Apache-2.0
33

4-
config PWM_RENESAS_RA8
5-
bool "Renesas RA8 PWM driver"
4+
config PWM_RENESAS_RA
5+
bool "Renesas RA PWM driver"
66
default y
7-
depends on DT_HAS_RENESAS_RA8_PWM_ENABLED
7+
depends on DT_HAS_RENESAS_RA_PWM_ENABLED
88
select USE_RA_FSP_GPT
99
select PINCTRL
1010
help
11-
Enable Renesas RA8 PWM Driver.
11+
Enable Renesas RA PWM Driver.
Lines changed: 44 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@
1414
#include <zephyr/logging/log.h>
1515
#include <stdio.h>
1616

17-
LOG_MODULE_REGISTER(pwm_renesas_ra8, CONFIG_PWM_LOG_LEVEL);
17+
LOG_MODULE_REGISTER(pwm_renesas_ra, CONFIG_PWM_LOG_LEVEL);
1818

19-
#define DT_DRV_COMPAT renesas_ra8_pwm
19+
#define DT_DRV_COMPAT renesas_ra_pwm
2020

2121
#define MAX_PIN 2U
2222
#define GPT_PRV_GTIO_HIGH_COMPARE_MATCH_LOW_CYCLE_END 0x6U
2323
#define GPT_PRV_GTIO_LOW_COMPARE_MATCH_HIGH_CYCLE_END 0x9U
2424
#define GPT_PRV_GTIOR_INITIAL_LEVEL_BIT 4
2525
#define GPT_PRV_GTIO_TOGGLE_COMPARE_MATCH 0x3U
2626

27-
struct pwm_ra8_capture_data {
27+
struct pwm_renesas_ra_capture_data {
2828
pwm_capture_callback_handler_t callback;
2929
void *user_data;
3030
uint64_t period;
@@ -35,25 +35,25 @@ struct pwm_ra8_capture_data {
3535
bool continuous;
3636
};
3737

38-
struct pwm_ra8_data {
38+
struct pwm_renesas_ra_data {
3939
gpt_instance_ctrl_t fsp_ctrl;
4040
timer_cfg_t fsp_cfg;
4141
gpt_extended_cfg_t extend_cfg;
4242
uint16_t capture_a_event;
4343
uint16_t overflow_event;
4444

4545
#ifdef CONFIG_PWM_CAPTURE
46-
struct pwm_ra8_capture_data capture;
46+
struct pwm_renesas_ra_capture_data capture;
4747
#endif /* CONFIG_PWM_CAPTURE */
4848
};
4949

50-
struct pwm_ra8_config {
50+
struct pwm_renesas_ra_config {
5151
const struct device *clock_dev;
5252
struct clock_control_ra_subsys_cfg clock_subsys;
5353
const struct pinctrl_dev_config *pincfg;
5454
};
5555

56-
static uint32_t pwm_ra8_gtior_calculate(gpt_pin_level_t const stop_level)
56+
static uint32_t pwm_renesas_ra_gtior_calculate(gpt_pin_level_t const stop_level)
5757
{
5858
/* The stop level is used as both the initial level and the stop level. */
5959
uint32_t gtior = R_GPT0_GTIOR_OAE_Msk | ((uint32_t)stop_level << R_GPT0_GTIOR_OADFLT_Pos) |
@@ -67,8 +67,8 @@ static uint32_t pwm_ra8_gtior_calculate(gpt_pin_level_t const stop_level)
6767
return gtior;
6868
}
6969

70-
static int pwm_ra8_apply_gtior_config(gpt_instance_ctrl_t *const p_ctrl,
71-
timer_cfg_t const *const p_cfg)
70+
static int pwm_renesas_ra_apply_gtior_config(gpt_instance_ctrl_t *const p_ctrl,
71+
timer_cfg_t const *const p_cfg)
7272
{
7373
gpt_extended_cfg_t *p_extend = (gpt_extended_cfg_t *)p_cfg->p_extend;
7474
uint32_t gtior = p_extend->gtior_setting.gtior;
@@ -80,14 +80,14 @@ static int pwm_ra8_apply_gtior_config(gpt_instance_ctrl_t *const p_ctrl,
8080
/* If custom GTIOR settings are not provided, calculate GTIOR. */
8181
if (p_extend->gtioca.output_enabled) {
8282
uint32_t gtioca_gtior =
83-
pwm_ra8_gtior_calculate(p_extend->gtioca.stop_level);
83+
pwm_renesas_ra_gtior_calculate(p_extend->gtioca.stop_level);
8484

8585
gtior |= gtioca_gtior << R_GPT0_GTIOR_GTIOA_Pos;
8686
}
8787

8888
if (p_extend->gtiocb.output_enabled) {
8989
uint32_t gtiocb_gtior =
90-
pwm_ra8_gtior_calculate(p_extend->gtiocb.stop_level);
90+
pwm_renesas_ra_gtior_calculate(p_extend->gtiocb.stop_level);
9191

9292
gtior |= gtiocb_gtior << R_GPT0_GTIOR_GTIOB_Pos;
9393
}
@@ -127,10 +127,10 @@ static int pwm_ra8_apply_gtior_config(gpt_instance_ctrl_t *const p_ctrl,
127127
return 0;
128128
}
129129

130-
static int pwm_ra8_set_cycles(const struct device *dev, uint32_t pin, uint32_t period_cycles,
131-
uint32_t pulse_cycles, pwm_flags_t flags)
130+
static int pwm_renesas_ra_set_cycles(const struct device *dev, uint32_t pin, uint32_t period_cycles,
131+
uint32_t pulse_cycles, pwm_flags_t flags)
132132
{
133-
struct pwm_ra8_data *data = dev->data;
133+
struct pwm_renesas_ra_data *data = dev->data;
134134
uint32_t pulse;
135135
fsp_err_t err;
136136

@@ -155,7 +155,7 @@ static int pwm_ra8_set_cycles(const struct device *dev, uint32_t pin, uint32_t p
155155
pulse = (flags & PWM_POLARITY_INVERTED) ? period_cycles - pulse_cycles : pulse_cycles;
156156

157157
/* Apply gtio output setting */
158-
pwm_ra8_apply_gtior_config(&data->fsp_ctrl, &data->fsp_cfg);
158+
pwm_renesas_ra_apply_gtior_config(&data->fsp_ctrl, &data->fsp_cfg);
159159

160160
/* Stop timer */
161161
err = R_GPT_Stop(&data->fsp_ctrl);
@@ -187,9 +187,10 @@ static int pwm_ra8_set_cycles(const struct device *dev, uint32_t pin, uint32_t p
187187
return 0;
188188
};
189189

190-
static int pwm_ra8_get_cycles_per_sec(const struct device *dev, uint32_t pin, uint64_t *cycles)
190+
static int pwm_renesas_ra_get_cycles_per_sec(const struct device *dev, uint32_t pin,
191+
uint64_t *cycles)
191192
{
192-
struct pwm_ra8_data *data = dev->data;
193+
struct pwm_renesas_ra_data *data = dev->data;
193194
timer_info_t info;
194195
fsp_err_t err;
195196

@@ -226,10 +227,11 @@ static void disable_irq(IRQn_Type irq)
226227
}
227228
}
228229

229-
static int pwm_ra8_configure_capture(const struct device *dev, uint32_t pin, pwm_flags_t flags,
230-
pwm_capture_callback_handler_t cb, void *user_data)
230+
static int pwm_renesas_ra_configure_capture(const struct device *dev, uint32_t pin,
231+
pwm_flags_t flags, pwm_capture_callback_handler_t cb,
232+
void *user_data)
231233
{
232-
struct pwm_ra8_data *data = dev->data;
234+
struct pwm_renesas_ra_data *data = dev->data;
233235

234236
if (pin != GPT_IO_PIN_GTIOCA) {
235237
LOG_ERR("Feature only support for gtioca");
@@ -306,9 +308,9 @@ static int pwm_ra8_configure_capture(const struct device *dev, uint32_t pin, pwm
306308
return 0;
307309
}
308310

309-
static int pwm_ra8_enable_capture(const struct device *dev, uint32_t pin)
311+
static int pwm_renesas_ra_enable_capture(const struct device *dev, uint32_t pin)
310312
{
311-
struct pwm_ra8_data *data = dev->data;
313+
struct pwm_renesas_ra_data *data = dev->data;
312314
fsp_err_t err;
313315

314316
if (pin != GPT_IO_PIN_GTIOCA) {
@@ -344,9 +346,9 @@ static int pwm_ra8_enable_capture(const struct device *dev, uint32_t pin)
344346
return 0;
345347
}
346348

347-
static int pwm_ra8_disable_capture(const struct device *dev, uint32_t pin)
349+
static int pwm_renesas_ra_disable_capture(const struct device *dev, uint32_t pin)
348350
{
349-
struct pwm_ra8_data *data = dev->data;
351+
struct pwm_renesas_ra_data *data = dev->data;
350352
fsp_err_t err;
351353

352354
if (pin != GPT_IO_PIN_GTIOCA) {
@@ -386,7 +388,7 @@ static int pwm_ra8_disable_capture(const struct device *dev, uint32_t pin)
386388
static void fsp_callback(timer_callback_args_t *p_args)
387389
{
388390
const struct device *dev = p_args->p_context;
389-
struct pwm_ra8_data *data = dev->data;
391+
struct pwm_renesas_ra_data *data = dev->data;
390392
timer_info_t info;
391393

392394
(void)R_GPT_InfoGet(&data->fsp_ctrl, &info);
@@ -422,7 +424,7 @@ static void fsp_callback(timer_callback_args_t *p_args)
422424
data->capture.overflows = 0U;
423425
/* Disable capture in single mode */
424426
if (data->capture.continuous == false) {
425-
pwm_ra8_disable_capture(dev, GPT_IO_PIN_GTIOCA);
427+
pwm_renesas_ra_disable_capture(dev, GPT_IO_PIN_GTIOCA);
426428
}
427429
}
428430
} else if (p_args->event == TIMER_EVENT_CYCLE_END) {
@@ -435,20 +437,20 @@ static void fsp_callback(timer_callback_args_t *p_args)
435437

436438
#endif /* CONFIG_PWM_CAPTURE */
437439

438-
static DEVICE_API(pwm, pwm_ra8_driver_api) = {
439-
.get_cycles_per_sec = pwm_ra8_get_cycles_per_sec,
440-
.set_cycles = pwm_ra8_set_cycles,
440+
static const struct pwm_driver_api pwm_renesas_ra_driver_api = {
441+
.get_cycles_per_sec = pwm_renesas_ra_get_cycles_per_sec,
442+
.set_cycles = pwm_renesas_ra_set_cycles,
441443
#ifdef CONFIG_PWM_CAPTURE
442-
.configure_capture = pwm_ra8_configure_capture,
443-
.enable_capture = pwm_ra8_enable_capture,
444-
.disable_capture = pwm_ra8_disable_capture,
444+
.configure_capture = pwm_renesas_ra_configure_capture,
445+
.enable_capture = pwm_renesas_ra_enable_capture,
446+
.disable_capture = pwm_renesas_ra_disable_capture,
445447
#endif /* CONFIG_PWM_CAPTURE */
446448
};
447449

448-
static int pwm_ra8_init(const struct device *dev)
450+
static int pwm_renesas_ra_init(const struct device *dev)
449451
{
450-
struct pwm_ra8_data *data = dev->data;
451-
const struct pwm_ra8_config *cfg = dev->config;
452+
struct pwm_renesas_ra_data *data = dev->data;
453+
const struct pwm_renesas_ra_config *cfg = dev->config;
452454
int err;
453455

454456
if (!device_is_ready(cfg->clock_dev)) {
@@ -534,7 +536,7 @@ static int pwm_ra8_init(const struct device *dev)
534536
.p_pwm_cfg = NULL, \
535537
.gtior_setting.gtior = (0x0U), \
536538
}; \
537-
static struct pwm_ra8_data pwm_ra8_data_##index = { \
539+
static struct pwm_renesas_ra_data pwm_renesas_ra_data_##index = { \
538540
.fsp_cfg = \
539541
{ \
540542
.mode = TIMER_MODE_PWM, \
@@ -547,24 +549,24 @@ static int pwm_ra8_init(const struct device *dev)
547549
.capture_a_event = ELC_EVENT_GPT_CAPTURE_COMPARE_A(DT_INST_PROP(index, channel)), \
548550
.overflow_event = ELC_EVENT_GPT_COUNTER_OVERFLOW(DT_INST_PROP(index, channel)), \
549551
}; \
550-
static const struct pwm_ra8_config pwm_ra8_config_##index = { \
552+
static const struct pwm_renesas_ra_config pwm_renesas_ra_config_##index = { \
551553
.pincfg = PINCTRL_DT_INST_DEV_CONFIG_GET(index), \
552554
.clock_dev = DEVICE_DT_GET(DT_INST_CLOCKS_CTLR(index)), \
553555
.clock_subsys = { \
554556
.mstp = (uint32_t)DT_INST_CLOCKS_CELL_BY_IDX(index, 0, mstp), \
555557
.stop_bit = DT_INST_CLOCKS_CELL_BY_IDX(index, 0, stop_bit), \
556558
}}; \
557-
static int pwm_ra8_init_##index(const struct device *dev) \
559+
static int pwm_renesas_ra_init_##index(const struct device *dev) \
558560
{ \
559561
PWM_RA_IRQ_CONFIG_INIT(index); \
560-
int err = pwm_ra8_init(dev); \
562+
int err = pwm_renesas_ra_init(dev); \
561563
if (err != 0) { \
562564
return err; \
563565
} \
564566
return 0; \
565567
} \
566-
DEVICE_DT_INST_DEFINE(index, pwm_ra8_init_##index, NULL, &pwm_ra8_data_##index, \
567-
&pwm_ra8_config_##index, POST_KERNEL, CONFIG_PWM_INIT_PRIORITY, \
568-
&pwm_ra8_driver_api);
568+
DEVICE_DT_INST_DEFINE(index, pwm_renesas_ra_init_##index, NULL, \
569+
&pwm_renesas_ra_data_##index, &pwm_renesas_ra_config_##index, \
570+
POST_KERNEL, CONFIG_PWM_INIT_PRIORITY, &pwm_renesas_ra_driver_api);
569571

570572
DT_INST_FOREACH_STATUS_OKAY(PWM_RA8_INIT);

0 commit comments

Comments
 (0)