Skip to content

Conversation

@tobyfirth
Copy link
Contributor

Added shim driver for the CTIMERs for the lpcexpresso55s69 board.

Fixes: #22705

Signed-off-by: Toby Firth [email protected]

@tobyfirth
Copy link
Contributor Author

tobyfirth commented Aug 11, 2021

I have had to make a couple of changes to the 'test_multiple_alarms' test to enable it to pass for the ctimers driver. The test takes quite a long time to run as it takes about 45 seconds for each timer to loop around which is required for the test. There might be away to make this faster but I couldn't see a clock configuration that would make this the case.

The frequency of the timer for some of the possible clock configurations for a timer looks like it can only be discovered at runtime unless there is a way to get the frequency of some of the clocks that can be used with the timers at compile time with the device tree macros. So the config struct is not a const struct as the driver updates it when the init function is called.

The ctimers don't have any functionality to do the top alarm api but it could be implemented using one of the timers channels but this would reduce the number of avaible channels for the user by 1. Or maybe some sort of dynamically using one of the channels if the user calls that API. I haven't implemented this but would like to hear people's thoughts on enabling the API call in this way.

@tobyfirth tobyfirth force-pushed the lpcxpresso55s69_counter branch from 0aa3ddb to d8dc98a Compare August 11, 2021 12:26
Copy link
Member

@MaureenHelm MaureenHelm left a comment

Choose a reason for hiding this comment

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

Thank you for the contribution!

Please update west.yml to reference your hal_nxp PR, this will help fix the buildkite CI failure. See https://docs.zephyrproject.org/latest/guides/modules.html#changes-to-existing-module for details.

Comment on lines 36 to 39
Copy link
Member

Choose a reason for hiding this comment

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

Please move all the whitespace changes to a separate commit

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should be removed now.

Copy link
Member

Choose a reason for hiding this comment

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

Please decrease the indentation to match the other entries.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@github-actions
Copy link

github-actions bot commented Aug 12, 2021

The following west manifest projects have been modified in this Pull Request:

Name Old Revision New Revision Diff
hal_nxp zephyrproject-rtos/hal_nxp@ef99b11 zephyrproject-rtos/hal_nxp@6287a07 zephyrproject-rtos/[email protected]

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

@tobyfirth tobyfirth force-pushed the lpcxpresso55s69_counter branch from 3be22a9 to 46887ab Compare August 12, 2021 18:38
@tobyfirth
Copy link
Contributor Author

I think I have updated west.yml correctly but the build still seems to be breaking.

Copy link
Contributor

Choose a reason for hiding this comment

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

i wouldn't do that. It should be possible to setup alarm and then start the timer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have moved the code to the init function now.

Copy link
Contributor

Choose a reason for hiding this comment

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

this looks strange. If it's because ctimer does not support setting top value then i would just skip this test for that counter. You can do this by adding set_top_value_capable() to multiple_channel_alarm_capable check.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That feeds back into one of my earlier comments, the ctimers could support this behaviour by making use of one of the channels to provide the resetting behaviour that setting the top value provides. This could be done by reducing the number of user usable channels from 4 to 3, reserving a channel for detecting the set top value and resetting or if the user sets a top value using one of the channels and producing an error if the user wants to use that channel as well as setting a top value.

Or I could just leave the driver as is and exclude the test as you suggest.

@mmahadevan108
Copy link
Contributor

Could you please help rebase and resolve conflicts. That should hopefully resolve CI failures

@tobyfirth tobyfirth force-pushed the lpcxpresso55s69_counter branch 4 times, most recently from abb9c1b to 6513613 Compare August 20, 2021 13:50
@github-actions github-actions bot added the DNM This PR should not be merged (Do Not Merge) label Aug 20, 2021
@tobyfirth tobyfirth force-pushed the lpcxpresso55s69_counter branch from 6513613 to 24956df Compare August 20, 2021 13:59
@tobyfirth
Copy link
Contributor Author

Conflicts are now resolved. And I have properly updated west.yaml correctly so the builds run.

Copy link
Contributor

Choose a reason for hiding this comment

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

Should we add this change to lpcxpresso55s69_ns.dts

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. Should the config option be also added to Kconfig.defconfig.lpc55S69_cpu1? I am guessing that the ctimers are also addressable for cpu1?

Also since the compile support for the imxrt6xx group of chips was added it should probably be added into the code. I don't actually know which specific boards are based on the imxrt6xx which is why I haven't added the configuration details for the ctimer/counter to be enabled with them.

Copy link
Member

Choose a reason for hiding this comment

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

Don't worry about rt6xx in the main repo yet, we will follow up with another PR. I asked you to go ahead and extend your hal_nxp PR to include rt6xx now because that change is really simple and then we won't have to update west.yml again in the follow-up PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure if we should add to cpu1. For now we can add to _ns.dts file. Also could you please rebase to the latest mainline code to see if it addresses the CI build error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the _ns.dts and _ns.yaml files and rebased.

The build error seems to be related to the clock_control_mcux_syscon.c file. And something to do with the mcux_lpc_syscon_clock_control_get_subsys_rate and mcux_lpc_syscon_clock_control_init functions.

@tobyfirth tobyfirth force-pushed the lpcxpresso55s69_counter branch from 24956df to 8cd127f Compare August 20, 2021 16:35
Copy link
Member

@MaureenHelm MaureenHelm left a comment

Choose a reason for hiding this comment

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

Looks good, almost there.

Copy link
Member

Choose a reason for hiding this comment

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

Don't worry about rt6xx in the main repo yet, we will follow up with another PR. I asked you to go ahead and extend your hal_nxp PR to include rt6xx now because that change is really simple and then we won't have to update west.yml again in the follow-up PR.

Copy link
Member

Choose a reason for hiding this comment

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

Please move this line together with the other mcux drivers.

west.yml Outdated
Copy link
Member

Choose a reason for hiding this comment

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

The hal_nxp PR has now been merged, so you can update this to the new SHA.

@tobyfirth tobyfirth force-pushed the lpcxpresso55s69_counter branch from 8cd127f to 9189861 Compare August 23, 2021 10:51
@github-actions github-actions bot removed the DNM This PR should not be merged (Do Not Merge) label Aug 23, 2021
@tobyfirth tobyfirth force-pushed the lpcxpresso55s69_counter branch from 9189861 to 03635cc Compare August 23, 2021 14:48
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this #endif should move after line 99 so the closing brace for the switch command is available for all test cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Didn't spot that. Fixed it now.

Added shim driver for the CTIMERs for the lpcexpresso55s69 board.

Fixes: zephyrproject-rtos#22705

Signed-off-by: Toby Firth <[email protected]>
@tobyfirth tobyfirth force-pushed the lpcxpresso55s69_counter branch from 03635cc to 84f7bea Compare August 24, 2021 17:09
@MaureenHelm MaureenHelm added this to the v2.7.0 milestone Aug 24, 2021
| USB | on-chip | USB device |
+-----------+------------+-------------------------------------+
| COUNTER | on-chip | counter |
+-----------+------------+-------------------------------------+
Copy link
Contributor

Choose a reason for hiding this comment

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

Just noticed this, should we change COUNTER to CTIMER

@nashif nashif merged commit 893bfc0 into zephyrproject-rtos:main Aug 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement counter driver for lpcxpresso55s69

6 participants