- 
                Notifications
    You must be signed in to change notification settings 
- Fork 8.2k
drivers: counter: added ctimer driver for lpcexpresso55s69 #37613
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
drivers: counter: added ctimer driver for lpcexpresso55s69 #37613
Conversation
| 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. | 
0aa3ddb    to
    d8dc98a      
    Compare
  
    There was a problem hiding this 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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be removed now.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
d8dc98a    to
    3be22a9      
    Compare
  
    | The following west manifest projects have been modified in this Pull Request: 
 Note: This message is automatically posted and updated by the Manifest GitHub Action. | 
3be22a9    to
    46887ab      
    Compare
  
    | I think I have updated west.yml correctly but the build still seems to be breaking. | 
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
46887ab    to
    6c32f88      
    Compare
  
    | Could you please help rebase and resolve conflicts. That should hopefully resolve CI failures | 
abb9c1b    to
    6513613      
    Compare
  
    6513613    to
    24956df      
    Compare
  
    | Conflicts are now resolved. And I have properly updated west.yaml correctly so the builds run. | 
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
24956df    to
    8cd127f      
    Compare
  
    There was a problem hiding this 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.
There was a problem hiding this comment.
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.
        
          
                drivers/counter/CMakeLists.txt
              
                Outdated
          
        
      There was a problem hiding this comment.
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
          
        
      There was a problem hiding this comment.
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.
8cd127f    to
    9189861      
    Compare
  
    9189861    to
    03635cc      
    Compare
  
    There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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]>
03635cc    to
    84f7bea      
    Compare
  
    | | USB | on-chip | USB device | | ||
| +-----------+------------+-------------------------------------+ | ||
| | COUNTER | on-chip | counter | | ||
| +-----------+------------+-------------------------------------+ | 
There was a problem hiding this comment.
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
Added shim driver for the CTIMERs for the lpcexpresso55s69 board.
Fixes: #22705
Signed-off-by: Toby Firth [email protected]