-
Notifications
You must be signed in to change notification settings - Fork 7.4k
drivers: rtc: rtc_mc146818: Added RTC driver for Motorola MC146818B #56334
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
Conversation
First of, happy to see drivers being written for the new API :) Regarding the naming Looking at the current driver base however, there is already a With this little trick, we can have the new driver and the old one coexist without breaking anything, and allow other boards to use the driver as well :) Otherwise, we need to replace the old dts file and in-tree boards using it, which might be a good solution, but not something we should do within a single PR. |
Yeah, |
The motorola mc146818 is a real-time clock, right? The existing driver that is using that devicetree binding is just using the counter API, its not a counter on a hardware level as I understand it. I agree with the naming, but I lack understanding of the existing counter node. The .dtsi looks kind of odd from my perspective. It seems there are two instances of the RTC hardware, one at address <0x70 0x0D>, and the one you have added at <0x71, 0x50>, is that accurate? I have no experience with raptor_lake, It would be great if you could help me understand it :) |
Motorola mc146818 is a real-time clock and used as counter. Raptor lake has only one instance of RTC, but if I give same reg address it is not accepting. So, I have given the "target" address instead of "index" for RTC instance. |
In this case, I recommend we reuse the existing devicetree compatible:
This solution keeps one device binding for the one device, which is appropriate, then allows the user to select the appropriate driver for it by manually including CONFIG_COUNTER, and or CONFIG_RTC, while keeping the dtsi backwards compatible :) |
Thank you for these changes, but for backward compatibility I may need to mark alarm-count property in rtc-device.yaml as "required: false". If I change it to false in mc146818.yaml it is throwing an error. Could you please suggest any better method to change this without disturbing rtc-device.yaml. Thanks |
You should be able to have the Like the |
I checked and confirmed that counter is not used on raptor lake, so instead of disturbing counter yaml, I just removed counter instance from dtsi file and added rtc only. |
This is a breaking change for potential downstream boards currently using the cmos_counter.c driver. If we are breaking it, we should probably go all the way and replace the cmos_counter.c driver entirely, for the other 4 in-tree overlays (apollo_lake, atom, elkhart, ia32) using it as well :) I think this is the most proper change to align the devices and drivers, no motorola,mc146818 and motorola,mc146818-rtc, just the first one, using the better fit RTC driver :) |
I don't think this will break downstream boards, I am not disturbing counter of older boards. They will still use counter_cmos.c. |
In that case I agree with just removing the counter node from the new board :) |
drivers/rtc/Kconfig.mc146818
Outdated
config RTC_MOTOROLA_MC146818 | ||
bool "RTC driver for x86 CMOS/RTC clock" | ||
default y | ||
depends on DT_HAS_MOTOROLA_MC146818_ENABLED && SOC_RAPTOR_LAKE |
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.
Why did you add the SoC dependency here? I don’t think that’s the right thing to do. What are you trying to solve with that?
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 there instead be default y if !COUNTER_CMOS
?
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.
Why did you add the SoC dependency here? I don’t think that’s the right thing to do. What are you trying to solve with that?
If this is not added, while running rtc tests for other boards with just counter instance and compatible "motorola,mc146818" status okay, is building rtc driver without instance and failing.
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.
Other way is that if we have counter instance with compatible "motorola,mc164818" in dts then we can add RTC instance for those boards also.
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.
Well, whatever the solution, it can't be that we restrict using the driver to only one specific SoC.
If this is not added, while running rtc tests for other boards with just counter instance and compatible "motorola,mc146818" status okay, is building rtc driver without instance and failing.
Would one solution for this be to introduce a supported: rtc
property to the board yaml files, and then we enable RTC tests only if the board indicates support for RTC? Any comments from @bjarki-trackunit ?
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.
Would one solution for this be to introduce a
supported: rtc
property to the board yaml files, and then we enable RTC tests only if the board indicates support for RTC? Any comments from @bjarki-trackunit ?
Actually, isn't this already the case? I see depends_on: rtc
in the testcase.yaml
files of RTC tests, so they should only get enabled if the board declares supported: rtc
. @akanisetti what were the problematic boards exactly?
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.
depends_on: rtc is not there for test/drivers/rtc/rtc_api_helpers/tetscase.yaml file. It is failing for all x86 boards which doesn't have an rtc instance in dts but motorola,mc146818 compatible is okay status. Build of rpl_api_helpers test application is failing on qemu_x86 on CI.
@akanisetti looks like |
Yes. |
The The tests should build and run without error based on this test run https://github.com/zephyrproject-rtos/zephyr/actions/runs/4756340536/jobs/8451830119?pr=57087 from a previous PR. Not sure why the test can not be built for this PR... |
It is failing for the boards which has counter instance in dts as following,
when "tests/drivers/rtc/rtc_api_helpers" is tested, it is enabling CONFIG_RTC and from dts motorola,mc146818 is enabled. So this counter@70 instance is trying to build with rtc_motorola_mc146818.c driver file and is failing to get interrupt details from dts. Solution could be modifying all cmos_counter instances to support both rtc and counter as it is done in rpl_crb dts. As same hardware and same register address in all those instances. |
I believe this is the best solution :) |
49ae941
to
b4c3c78
Compare
@@ -689,11 +689,15 @@ | |||
status = "okay"; | |||
}; | |||
|
|||
counter: counter@70 { | |||
rtc: counter: rtc@70 { |
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.
Since you're making this change, would it make sense to add supported: rtc
to the board definition of ehl_crb too (as well as an alias to the board dts)? Same for the ia32
change and any boards that use that? It can of course be done as a follow-up PR as well, but I feel like it'd be good to be consistent with this, i.e. if the dts has an rtc node label, then boards using it should declare supported: rtc
.
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.
Sure, will add these changes.
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 by adding supported: rtc for ia32 I am enabling rtc tests on qemu_x86 which will fail. I should remove supported: rtc or instead remove rtc/counter instance from ia32.dtsi file as it doesn't work in qemu anyway. Please provide your suggestions. @jhedberg @bjarki-trackunit
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.
You should remove supported: rtc
from the qemu_x86.yaml
file :) The x86/acrn
board also uses the ia32.dtsi
. I don't know it it uses the counter node either, but I think it is safest to keep the rtc/counter node in the ia32.dtsi
file.
e0a3ae8
to
f2a2754
Compare
Added RTC driver that supports Motorola MC146818B Enabled RTC set/get time and alarm, alarm callback and update callback. Counter and RTC uses same hardware in case of Motorola MC146818, so they can't be used at a time. Updated stand-alone mc146818 counter dts instances to support rtc and counter with same compatible string of "motorola,mc146818" on ia32, atom, apollo_lake, elhart_lake and raptor_lake platforms. Signed-off-by: Anisetti Avinash Krishna <[email protected]>
Nice work @akanisetti :) |
Thank you for the support @bjarki-trackunit and @jhedberg |
Added RTC driver that supports Motorola MC146818B
Enabled RTC set/get time and alarm, alarm callback
and update callback.
Counter and RTC uses same hardware in case of
motorola mc146818, so they can't be used at a time.
Updated stand-alone mc146818 counter dts instances
to support RTC and counter with same compatible
string of "motorola,mc146818" on ia32, atom,
apollo_lake, elhart_lake and raptor_lake platforms.
Signed-off-by: Anisetti Avinash Krishna [email protected]