nuttx/arch/arm/src
Daniel P. Carvalho e2d5b8f29c arch/arm/stm32h7: add the PTP hardware clock of the Ethernet MAC.
The MAC has a system time that is the base of the PTP hardware
timestamps, but the driver never started it, and STM32_ETH_PTP only
printed a warning.

Add the registers of the timestamp unit and start the system time with
the fine update method and the digital rollover, so that the nanoseconds
count up to 10^9. The increment is 2 * 10^9 / HCLK ns, and the addend
makes the update rate half of HCLK, which leaves room to trim the
frequency in both directions. The time starts at zero right after the MAC
reset, not with the MAC configuration, so it does not depend on the PHY
having a link. The reset clears it, so it starts again each time the
interface goes up.

With STM32_ETH_PTP_GPIO, start the pulse-per-second output as a pulse
train with a period of one second and a width of half of it, at the whole
seconds of the system time. The fixed frequency mode of the MAC gives a
pulse too short to be seen, so the flexible mode is used. The interrupt
of the timestamp unit is not enabled in the MAC: it is set each time the
target time of the PPS output is reached and is cleared by reading
MACTSSR, which the interrupt handler does not do, so it would stay
pending and keep the handler running until the network stops.

Register /dev/ptp0 when CONFIG_PTP_CLOCK is set, so that a PTP daemon can
read and set the system time and correct its frequency and its phase.
The frequency is corrected by changing the addend, by up to 50% each way.
A step of the time is added or subtracted with the update register; with
the digital rollover a subtraction is programmed with the negated seconds
and with 10^9 minus the nanoseconds. The pulse train counts by itself, so
it does not follow a step of the system time and would be displaced by the
same amount: after the time is set or stepped, it is started again at the
next whole second.

With HCLK at 200 MHz the system time advanced 10.0018 s while a host
clock advanced 10.002 s, and the pulse train was seen on the pin. Reading,
setting, steps of +0.5 s and -1.25 s and a change of 100 ppm were done
through /dev/ptp0 on hardware, and the edges of the PPS output stayed at
the whole seconds of the system time.

Signed-off-by: Daniel P. Carvalho <danieloak@gmail.com>
Assisted-by: Claude:claude-sonnet-5
2026-09-21 15:11:15 +08:00
..
a1x
am67 Documentation/am67: Document eCAP APWM support on t3-gem-o1. 2026-09-18 16:25:31 +08:00
am335x boards/arm: Add support for the original BeagleBone 2026-08-19 10:11:38 +08:00
arm !arch/arm: Use r9 as the PIC base register. 2026-08-06 01:38:23 +08:00
armv6-m !arch/arm: Use r9 as the PIC base register. 2026-08-06 01:38:23 +08:00
armv7-a nuttx/atomic: replace atomic_fetch_xxx with atomic_xxx just like zephyr 2026-08-24 13:20:45 +08:00
armv7-m !arch/arm: Use r9 as the PIC base register. 2026-08-06 01:38:23 +08:00
armv7-r !arch/arm: Use r9 as the PIC base register. 2026-08-06 01:38:23 +08:00
armv8-m !arch/arm: Use r9 as the PIC base register. 2026-08-06 01:38:23 +08:00
armv8-r !arch/arm: Use r9 as the PIC base register. 2026-08-06 01:38:23 +08:00
at32 {arm,xtensa}/otg: indent switch bodies per the coding standard. 2026-08-25 16:07:35 +08:00
c5471 drivers/efuse/efuse: Drivers Registered With World Write Permissions(Part 1) 2026-07-13 12:08:01 +02:00
cmake arch/arm: Say which linker is missing when FDPIC has none. 2026-09-09 10:21:21 +08:00
common arch/arm/stm32h7: configure the PPS pin only with STM32_ETH_PTP_GPIO. 2026-09-21 15:11:15 +08:00
csk6
cxd32xx
cxd56xx arch/atomic: remove up_testset in spinlock 2026-09-08 08:58:54 +08:00
dm320
efm32 {arm,xtensa}/otg: indent switch bodies per the coding standard. 2026-08-25 16:07:35 +08:00
eoss3
fvp-v8r-aarch32
gd32f4
goldfish
ht32f491x3
imx1
imx6
imx9 arch/arm/imx9, arch/arm64/imx9: Release eDMA lock before callbacks 2026-09-15 08:41:58 -03:00
imxrt arch/arm/imxrt: Add support for ELE FW for imxrt1180-evk 2026-09-19 22:38:45 +08:00
kinetis net, arch: Fix nxstyle errors in files the CAN ioctl merge touches. 2026-09-01 17:40:47 +08:00
kl
lc823450 arch/atomic: remove up_testset in spinlock 2026-09-08 08:58:54 +08:00
lpc17xx_40xx
lpc31xx
lpc43xx
lpc54xx
lpc214x
lpc2378
max326xx
mcx-nxxx
moxart
mps
mx8mp
n32h7 arch/arm/n32h7: Add N32H762IIL7 BSP 2026-09-17 09:39:41 -03:00
nrf52 cmake: Use NUTTX(_DIR/_BIN_DIR) instead CMAKE(_SRC_DIR/_BIN_DIR) 2026-08-09 11:13:08 -03:00
nrf53 arch/arm/nrf53: enable the application core flash cache 2026-09-04 13:50:15 -03:00
nrf91 cmake: Use NUTTX(_DIR/_BIN_DIR) instead CMAKE(_SRC_DIR/_BIN_DIR) 2026-08-09 11:13:08 -03:00
nuc1xx
phy62xx drivers/efuse/efuse: Drivers Registered With World Write Permissions(Part 1) 2026-07-13 12:08:01 +02:00
qemu
ra4
rp23xx arch/atomic: remove up_testset in spinlock 2026-09-08 08:58:54 +08:00
rp2040 arch/arm/rp2040: fix IN endpoint DPSRAM index for bare-eplog callers 2026-09-08 08:22:37 -03:00
rtl8720c nuttx/atomic: replace atomic_fetch_xxx with atomic_xxx just like zephyr 2026-08-24 13:20:45 +08:00
rtl8720f arch/arm/rtl8720f: add timer driver support 2026-09-01 17:41:14 +08:00
rtl8721dx arch/arm/rtl8721dx: add shared Ameba timer driver 2026-09-01 17:41:14 +08:00
rtl8721f arch/arm/rtl8721f: add timer driver support 2026-09-01 17:41:14 +08:00
s32k1xx arch/atomic: remove up_testset in spinlock 2026-09-08 08:58:54 +08:00
s32k3xx arch/atomic: remove up_testset in spinlock 2026-09-08 08:58:54 +08:00
sam34
sama5 drivers/efuse/efuse: Drivers Registered With World Write Permissions(Part 1) 2026-07-13 12:08:01 +02:00
samd2l2
samd5e5
samv7 drivers/audio/i2s: Fix unsigned integers in function signatures 2026-07-05 15:06:04 +08:00
stm32c0 arch/arm/stm32c0: Add USB device support 2026-09-14 18:32:23 -03:00
stm32c5 arch/arm/stm32c5: Add STM32C562 architecture support 2026-08-27 01:07:10 +08:00
stm32f0 boards/nucleo-f072rb: Add USB device support and a CDC/ACM configuration. 2026-08-20 15:16:33 -03:00
stm32f1 !arch/stm32: unify and commonize stm32_uid for all STM32 families. 2026-07-04 18:47:45 +08:00
stm32f2 !arch/stm32: unify and commonize stm32_uid for all STM32 families. 2026-07-04 18:47:45 +08:00
stm32f3 !arch/stm32: unify and commonize stm32_uid for all STM32 families. 2026-07-04 18:47:45 +08:00
stm32f4 arch/arm/stm32f4: add STM32F412CG chip selection 2026-09-01 17:40:30 +08:00
stm32f7 arch/arm/stm32: fix compare-match race and zero-period hang in tickless 2026-09-18 09:30:22 +08:00
stm32g0 arch/arm/stm32: Add USBDEV_M0_V2 IP flag 2026-09-14 18:32:23 -03:00
stm32g4 arch/arm/src/stm32: add G4 RNG base address 2026-07-09 09:59:02 -04:00
stm32h5 arch/arm/stm32h5: Add USART wake from low power. 2026-09-19 08:52:17 -03:00
stm32h7 arch/arm/stm32h7: add the PTP hardware clock of the Ethernet MAC. 2026-09-21 15:11:15 +08:00
stm32l0 boards/nucleo-l073rz: Add USB device support and a CDC/ACM configuration. 2026-08-22 01:23:12 +08:00
stm32l1 !arch/stm32: unify and commonize stm32_uid for all STM32 families. 2026-07-04 18:47:45 +08:00
stm32l4 {arm,xtensa}/otg: indent switch bodies per the coding standard. 2026-08-25 16:07:35 +08:00
stm32l5 arch/arm/stm32: use common SYSTICK_HCLKd8 symbol 2026-08-18 09:34:58 +08:00
stm32n6 arch/stm32/serial: simplify ifdefs in ioctl 2026-07-07 01:57:51 +08:00
stm32u0 arch/arm: add stm32u0 support 2026-08-18 15:00:15 +02:00
stm32u3 arch/arm/stm32: Unify Cortex-M33 RCC include names 2026-08-27 01:07:10 +08:00
stm32u5 arch/arm/stm32: Unify Cortex-M33 RCC include names 2026-08-27 01:07:10 +08:00
stm32wb arch/arm/stm32: fix compare-match race and zero-period hang in tickless 2026-09-18 09:30:22 +08:00
stm32wl5 arch/arm/stm32: use common SYSTICK_HCLKd8 symbol 2026-08-18 09:34:58 +08:00
str71x
tiva
tlsr82 !arch/arm: Use r9 as the PIC base register. 2026-08-06 01:38:23 +08:00
tms570
xmc4 arch/arm: xmc4: fix VADC index bounds checks 2026-07-06 07:47:17 +02:00
.gitignore
CMakeLists.txt
Makefile tools: fix stale archive members surviving a Kconfig-driven CSRCS change 2026-07-28 21:26:03 -03:00