Re: [PATCH v3 09/10] arch: arm: boot: dts: Introduce HPE GXP Device tree

From: Arnd Bergmann
Date: Mon Apr 04 2022 - 18:49:58 EST


On Mon, Apr 4, 2022 at 10:22 PM Hawkins, Nick <nick.hawkins@xxxxxxx> wrote:
> > > I would put it into drivers/clocksource/, I don't think drivers/mtd would be any better, but there is a chance that the clocksource maintainers don't want to have the watchdog code in their tree.
>
> While trying to discover how to creating two devices in one driver I ran across an interesting .dtsi and I was wondering if this would be a valid approach for my situation as well. The pertinent files are:
> 1) drivers/clocksource/timer-digicolor.c
> 2) arch/arm/boot/dts/cx92755.dtsi
> 3) drivers/watchdog/digicolor_wdt.c
>
> Here they are just sharing the same register area:
>
> timer@f0000fc0 {
> compatible = "cnxt,cx92755-timer";
> reg = <0xf0000fc0 0x40>;
> interrupts = <19>, <31>, <34>, <35>, <52>, <53>, <54>, <55>;
> clocks = <&main_clk>;
> };
>
> rtc@f0000c30 {
> compatible = "cnxt,cx92755-rtc";
> reg = <0xf0000c30 0x18>;
> interrupts = <25>;
> };
>
> watchdog@f0000fc0 {
> compatible = "cnxt,cx92755-wdt";
> reg = <0xf0000fc0 0x8>;
> clocks = <&main_clk>;
> timeout-sec = <15>;
> };

Right, it is possible to make this work, but it's not recommended, and you have
to work around the sanity checks in the code that try to keep you from doing it
wrong, as well as any tooling that tries to check for these in the DT.

Arnd