Unable to remove the built-in RTC

Hi I’m db410c board Debian10 setup, kernel version 4.14, now want to add a new RTC flooding.
Found the RTC has been in module is loaded, even delete/lib/module. Ko file, or modify the relevant,Or change the compiler configuration is still will be loaded into rtc0, how do I delete them.In this what is the difference between a and debian9.
thank you。

The best way to stop the kernel loading a driver it to disable the corresponding device tree nodes. Either compile the kernel and modify the DT as part of the kernel build process or use https://github.com/96boards/dt-update (in the same way we currently use overlays to enable things like spidev we can also use overlays to disable nodes).

After configuration, the related nodes of the device tree can indeed prevent pm8xxx from loading, but there will be problems if it is manually loaded.If i delete rtc-pm8xxx.ko, the driver will still be loaded. Now the problem is to know which module loads pm8xxx as a module,Or that .ko file is associated with this one.Very important to me, thanks

If I understand correctly, you have deleted the module from the system directory, but it is almost certainly being loaded from the ramdisk.

When I remove the entire lib/module, i2c_qcom_cci and rtc_pm8xxx are left. As for whether I am not sure in the ramdisk, I now connect an rtc to the db410c board. I need to control the loading order to be compatible with two rtc. ,thank you very much

If you have the devicetree correct then there will be no problems if rtc-pm8xxx gets manually loads because it will not find any device to bind to (because it is not in the devicetree).

You can remove the .ko file from the initial ramdisk if you wish to. It won’t do any harm but isn’t really worth the time. Changing the devicetree is “the right way to do it”.

Daniel, is modifying the device tree preferred over using module_blacklist?

Interesting question…

I was, perhaps a bit hasty saying disabling the node is the right thing to do… because it isn’t. In fact all solutions that focus on stopping rtc-pm8xxx loading are looking at the problem in the wrong way. The question isn’t how to I stop the internal RTC taking rtc0… the question is how to I ensure that the external RTC becomes rtc0.

When the question is posed like this it is (somewhat) obvious that the answer is to use devicetree aliases.

For example looking at one of the nVidia SoC which has two RTC devices we can see how the aliases are used to choose which RTC will be rtc0 (from https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm64/boot/dts/nvidia/tegra132-norrin.dts#n11):

aliases {
	rtc0 = "/i2c@7000d000/as3722@40";
	rtc1 = "/rtc@7000e000";
	// ...
};