Bug 245160 - [PATCH] am335x rtc external / internal clock source
Summary: [PATCH] am335x rtc external / internal clock source
Status: In Progress
Alias: None
Product: Base System
Classification: Unclassified
Component: arm (show other bugs)
Version: 12.1-STABLE
Hardware: arm Any
: --- Affects Some People
Assignee: freebsd-arm (Nobody)
Depends on:
Reported: 2020-03-29 10:39 UTC by Oskar Holmlund
Modified: 2020-09-19 12:30 UTC (History)
2 users (show)

See Also:

Use external or internal clock source (1.30 KB, text/plain)
2020-03-29 10:39 UTC, Oskar Holmlund
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Oskar Holmlund 2020-03-29 10:39:47 UTC
Created attachment 212825 [details]
Use external or internal clock source

Tested on stable r359316

The RTC on AM335x are used in the shutdown process of the system. Current code assumes it exists an external 32kHz clock source and configure register RTC_OSC_REG with bit RTC_OSC_REG set [1].

PocketBeagle doent have a external clock as a consequence it cant power down correctly.

Attached patch check if RTC contains a clock [2] it assumes its an external clock  otherwise an internal clock source.
Maybe a better solution is to check the name of the clocks if it contains "ext-clk" as defined in sys/gnu/dts/arm/am335x-bone-common.dtsi (used by BBB)

[1] ch http://www.ti.com/lit/ug/spruh73q/spruh73q.pdf

[2] Documentation/devicetree/bindings/rtc/rtc-omap.txt
Comment 1 Emmanuel Vadot freebsd_committer 2020-04-11 15:46:38 UTC
Since we have no proper clock support on AM33XX I think it would be better the at least check the clock names and do the proper thing based on if ext-clk/int-clk is present. This will not break if pocketbeagle dts is updated to include the internal clock.
Comment 2 Emmanuel Vadot freebsd_committer 2020-09-17 09:25:35 UTC
Hi Oskar,

Is this bug still relevant after your clock driver ?
Comment 3 Oskar Holmlund 2020-09-19 12:30:24 UTC
(In reply to Emmanuel Vadot from comment #2)

Yes, i will update with new code.