Skip to content

drivers: counter: migrate AGT counter to use FSP function #87881

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

Merged

Conversation

thenguyenyf
Copy link
Collaborator

  • Migrate the AGT counter implementation to use FSP r_agt APIs
  • Add support for AGT 32bit
  • Add ztests/samples support for Renesas RA boards

Copy link

github-actions bot commented Mar 31, 2025

The following west manifest projects have changed revision in this Pull Request:

Name Old Revision New Revision Diff

All manifest checks OK

Note: This message is automatically posted and updated by the Manifest GitHub Action.

@github-actions github-actions bot added manifest manifest-hal_renesas DNM (manifest) This PR should not be merged (controlled by action-manifest) labels Mar 31, 2025
@thenguyenyf thenguyenyf force-pushed the renesas_ra_agt_counter_improvement branch from b4be15e to d8d59cc Compare March 31, 2025 07:15
@thenguyenyf thenguyenyf marked this pull request as ready for review March 31, 2025 07:31
@github-actions github-actions bot added area: Counter area: Samples Samples platform: Renesas RA Renesas Electronics Corporation, RA labels Mar 31, 2025
@thenguyenyf thenguyenyf force-pushed the renesas_ra_agt_counter_improvement branch 2 times, most recently from 756a8ad to a8dd5ee Compare April 1, 2025 02:49
@thenguyenyf
Copy link
Collaborator Author

Last push just to rebase and solve conflict

@thenguyenyf thenguyenyf force-pushed the renesas_ra_agt_counter_improvement branch from a8dd5ee to 5d21d8b Compare April 1, 2025 06:05
@thenguyenyf thenguyenyf force-pushed the renesas_ra_agt_counter_improvement branch from 5d21d8b to 6e0f79c Compare April 16, 2025 03:19
@github-actions github-actions bot requested a review from nordic-krch April 16, 2025 03:20
@github-actions github-actions bot removed the DNM (manifest) This PR should not be merged (controlled by action-manifest) label Apr 16, 2025
@thenguyenyf
Copy link
Collaborator Author

Hello @duynguyenxa , @thaoluonguw , @nordic-krch . Could you please take a look?

@thenguyenyf thenguyenyf force-pushed the renesas_ra_agt_counter_improvement branch from 6e0f79c to 3a515b0 Compare May 14, 2025 01:41
@thenguyenyf thenguyenyf added this to the v4.2.0 milestone May 14, 2025
return -ENOTSUP;
err = R_AGT_Start(&data->agt_ctrl);
if (err != FSP_SUCCESS) {
LOG_ERR("counter start failed");
Copy link
Member

Choose a reason for hiding this comment

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

@thenguyenyf , small nit, use upper for first letter

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I fixed it

int ret = 0;

if (cfg->ticks > config->info.max_top_value) {
LOG_ERR("top value exceed maximum value");
Copy link
Member

Choose a reason for hiding this comment

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

diito

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I fixed it

return -EBUSY;
ret = renesas_ra_agt_period_set(dev, cfg->ticks);
if (ret != 0) {
LOG_ERR("counter period set failed");
Copy link
Member

Choose a reason for hiding this comment

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

ditto

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I fixed it

if (reset) {
err = R_AGT_Reset(&data->agt_ctrl);
if (err != FSP_SUCCESS) {
LOG_ERR("counter reset failed");
Copy link
Member

Choose a reason for hiding this comment

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

ditto

int ret = 0;

if (counter_renesas_ra_agt_get_top_value(dev) < guard) {
LOG_ERR("invalid guard rate");
Copy link
Member

Choose a reason for hiding this comment

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

ditto

/* No divider can be used when count source is AGT_CLOCK_AGT_UNDERFLOW */
err = R_AGT_InfoGet(&data->agt_ctrl, &info);
if (err != FSP_SUCCESS) {
LOG_ERR("counter get freq failed");
Copy link
Member

Choose a reason for hiding this comment

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

ditto

return FSP_SUCCESS;
}
if (counter_renesas_ra_agt_get_value(dev, &now) != 0) {
LOG_WRN("error in counter alarm");
Copy link
Member

Choose a reason for hiding this comment

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

ditto

@duynguyenxa
Copy link
Member

hi @thenguyenyf , the renesas,resolution field is to differentiate between the agt (16-bit) and agtw (32-bit), so I think it's better be enum value in dt binding, could you also make the change for that.

@thenguyenyf thenguyenyf force-pushed the renesas_ra_agt_counter_improvement branch 2 times, most recently from 8cd48ec to 317daa7 Compare May 21, 2025 01:53
@thenguyenyf thenguyenyf requested a review from duynguyenxa May 21, 2025 01:54
Modify the expected ticks check to adapt with a downward counter
instance

Signed-off-by: The Nguyen <the.nguyen.yf@renesas.com>
Migrate renesas,ra-agt-counter implementation to use hal_renesas.
Add additional AGT_CLOCK_SUBCLOCK count source.
Add constraint for counter resolution to 32 or 16 bit variant.

Signed-off-by: The Nguyen <the.nguyen.yf@renesas.com>
Add device node for AGT counter support on Renesas RA family

Signed-off-by: The Nguyen <the.nguyen.yf@renesas.com>
Enable test support for renesas,ra-agt-counter

Signed-off-by: The Nguyen <the.nguyen.yf@renesas.com>
Add overlay to enable counter node for Renesas RA devices

Signed-off-by: The Nguyen <the.nguyen.yf@renesas.com>
Because this is a common testing scenario, almost any counter instance
should be able to run. Some counter instances cannot run this sample
should be filtered by platform_exclude or filter keywords.

Signed-off-by: The Nguyen <the.nguyen.yf@renesas.com>
@thenguyenyf thenguyenyf force-pushed the renesas_ra_agt_counter_improvement branch from 317daa7 to 230860d Compare May 22, 2025 03:58
@thenguyenyf
Copy link
Collaborator Author

Hello @thaoluonguw , @duynguyenxa , @nordic-krch . Could you please take a look?

Copy link

@kartben kartben merged commit 022962c into zephyrproject-rtos:main May 27, 2025
41 checks passed
@thenguyenyf thenguyenyf deleted the renesas_ra_agt_counter_improvement branch May 27, 2025 09:51
- s32z2xxdc2/s32z270/rtu1
- s32z2xxdc2@D/s32z270/rtu0
- s32z2xxdc2@D/s32z270/rtu1
- lp_em_cc2340r5
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hi @thenguyenyf
This PR is causing CI errors: https://github.com/zephyrproject-rtos/zephyr/actions/runs/15273910745/job/42955888437?pr=90662
Please provide a fix or return platform_allow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Counter area: Samples Samples platform: Renesas RA Renesas Electronics Corporation, RA
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants