-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Add MFD Support for Motorola mc146818 RTC, Counter, and BBRAM #91751
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
base: main
Are you sure you want to change the base?
Conversation
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.
Pull Request Overview
This PR enables the Motorola MC146818 RTC’s 241 byte battery-backed RAM (BBRAM) as a child device of the MC146818 RTC on Raptor Lake-S platforms.
- Extracts and centralizes the RTC driver’s data structure into a shared header.
- Adds device-tree nodes and bindings for the MC146818 BBRAM.
- Introduces and integrates a new
bbram_mc146818
driver, plus corresponding Kconfig and build files.
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
include/zephyr/drivers/rtc/mc146818.h | Define shared rtc_mc146818_data struct |
dts/x86/intel/raptor_lake_s.dtsi | Add bbram@72 node under RTC for battery-backed RAM |
dts/bindings/memory-controllers/motorola,mc146818-bbram.yaml | Create binding for motorola,mc146818-bbram |
drivers/rtc/rtc_mc146818.c | Remove duplicate struct, include new header |
drivers/bbram/bbram_mc146818.c | New driver implementation for MC146818 BBRAM |
drivers/bbram/Kconfig.mc146818 | Add Kconfig option for MC146818 BBRAM |
drivers/bbram/Kconfig | Include the new Kconfig file |
drivers/bbram/CMakeLists.txt | Add bbram_mc146818.c to library sources |
boards/intel/rpl/intel_rpl_s_crb.dts | Alias bbram to the new BBRAM node |
b21938c
to
c4d4ff9
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.
Please check out how the ds3231 is implemented, moving common functions of the "parent" device to include/zephyr/drivers/mfd and implementation of common code to zephyr/drivers/mfd, while keeping the bbram and rtc partial drivers isolated (not sharing data structures between one or the other.
Sure, I will add the modifications suggested. With this approach the intension is to avoid data structures between BBRAM and RTC, but they will be two independent drivers under one MFD driver as its child nodes in DTS. Please confirm if my understanding is correct. |
That is correct :) It should be possible to enable only BBRAM, and only RTC parts of the device. That means, using kconfig to describe it, you should have
|
A small query regarding counter, using this method COUNTER_CMOS will also have dependency on MFD_MC146818. |
Sort if, COUNTER_CMOS and RTC_MC146818 are mutually exclusive, COUNTER_CMOS is just there for legacy reasons, you could refactor it to work with MFD_MC146818 yes, but unless you have a usecase specifically for COUNTER_CMOS I would leave it alone :) |
Okay, I will update the PR accordingly |
c4d4ff9
to
5f1f6b3
Compare
5f1f6b3
to
d38e461
Compare
fa69ee0
to
9ec3de2
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.
Fantastic work! I have a few improvements but overall the addition is great!
drivers/rtc/rtc_mc146818.c
Outdated
RTC_MC146818_INIT_FN_DEFINE(inst) \ | ||
DEVICE_DT_INST_DEFINE(inst, &rtc_mc146818_init##inst, NULL, \ | ||
&rtc_mc146818_data##inst, &rtc_mc146818_config##inst,\ | ||
POST_KERNEL, CONFIG_RTC_INIT_PRIORITY, \ |
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.
Here, update the CONFIG_RTC_INIT_PRIORITY
to UTIL_INC(CONFIG_MFD_MOTOROLA_MC146818_INIT_PRIORITY)
. This will ensure the RTC is always initialized right after the parent :)
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.
do the same for the counter based driver :)
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
drivers/bbram/bbram_mc146818.c
Outdated
DEVICE_DT_INST_DEFINE(n, &bbram_mc146818_init, NULL, \ | ||
&bbram_data_##n, &bbram_config_##n, \ | ||
POST_KERNEL, \ | ||
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, \ |
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.
UTIL_INC(CONFIG_MFD_MOTOROLA_MC146818_INIT_PRIORITY)
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
mfd: mfd@70 { | ||
compatible = "motorola,mc146818-mfd"; | ||
reg = <0x70 0x01 0x71 0x01 0x72 0x01 0x73 0x01>; | ||
|
||
rtc: counter: rtc { | ||
compatible = "motorola,mc146818"; | ||
interrupts = <8 IRQ_TYPE_LOWEST_EDGE_RISING 3>; | ||
interrupt-parent = <&intc>; | ||
alarms-count = <1>; | ||
|
||
status = "okay"; | ||
}; | ||
|
||
bbram: bbram { | ||
compatible = "motorola,mc146818-bbram"; | ||
size = <241>; | ||
status = "okay"; | ||
}; |
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.
add this as an example snippet to the description of the binding for "motorola,mc146818-mfd"
. That way it is clear to users how the MFD is supposed to be added to an soc :)
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
|
||
compatible: "motorola,mc146818-mfd" | ||
|
||
include: base.yaml |
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.
add the following entry here
bus: mc146818-mfd
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.
then extend the bindings for the child devices with on-bus: mc146818-mfd
to help users know the child bindings belong to this parent mfd :)
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
Enabled Motorola, mc146818 MFD, which implements RTC read/write operations and prevents data corruption by synchronizing these operations. Signed-off-by: Anisetti Avinash Krishna <anisetti.avinash.krishna@intel.com>
Enabled support for motorola mc146818 RTC driver. Signed-off-by: Anisetti Avinash Krishna <anisetti.avinash.krishna@intel.com>
Enabled support for MFD in CMOS counter. Signed-off-by: Anisetti Avinash Krishna <anisetti.avinash.krishna@intel.com>
Enables bbram driver for motorola, mc146818 under its MFD to access the RAM of the RTC. Signed-off-by: Anisetti Avinash Krishna <anisetti.avinash.krishna@intel.com>
Added required modifications to dtsi files to support Motorola, mc146818 MFD, Counter, RTC, and BBRAM (for supported devices). Signed-off-by: Anisetti Avinash Krishna <anisetti.avinash.krishna@intel.com>
9ec3de2
to
bd736c3
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.
Nice!
|
Hi @yperess, could you please review the PR |
Please fix the checks, whatever review I give will be dismissed automatically even if it's just a lint check that's failing. |
The check failure is not related to this PR and has to be fixed by another PR. So please continue with the review as I am working on fixing it through another PR. |
PR has been created to resolve the twister issue #93403 |
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!
This PR introduces support for the Motorola mc146818 RTC and its associated functionalities through a Multi-Function Device (MFD) framework. The following key changes are included:
MFD Driver: Added and enabled the motorola, mc146818 MFD driver to manage RTC read/write operations and ensure data integrity through synchronized access.
RTC Driver: Enabled MFD support in the existing RTC driver for mc146818.
Counter Driver: Integrated MFD support into the CMOS counter driver.
BBRAM Driver: Enabled access to RTC RAM via a new BBRAM driver under the MFD hierarchy.
Device Tree Updates: Modified relevant .dtsi files to support the mc146818 MFD, including RTC, Counter, and BBRAM components.
These changes collectively enable full support for the mc146818 device and its subcomponents in a modular and maintainable way.
Signed-off-by: Anisetti Avinash Krishna anisetti.avinash.krishna@intel.com