# BCM54210PE PTP hardware The Raspberry Pi CM4 and CM5 both use the Broadcom BCM54210PE as their Ethernet PHY. The BCM54210PE supports IEEE 1588 (PTP). Broadcom has not published a datasheet for the BCM54210PE. This document is an attempt to describe how its PTP hardware works without one. It is reverse-engineered from three sources: the Linux driver; Broadcom's OpenBCM SDK, which supports related PHYs; and measurements on CM4 and CM5 boards. The BCM54210PE reports the same PHY ID as the BCM54213PE, which is used on the Raspberry Pi 4/5 and does not support PTP. Mainline Linux calls this BCM54210E. The document was written by an AI coding assistant, working from these sources under my direction. ## Overview The PHY is the chip between the Ethernet controller (the MAC) and the cable. Packets pass between the MAC and the PHY. The processor reads and writes the PHY's registers separately, over a two-wire management bus called MDIO. The PTP hardware has three parts. The first is a clock, which Linux exposes as a PTP hardware clock (PHC). The second is packet processing, which recognizes PTP event messages passing through the PHY in each direction, timestamps them, and can modify them. The third is a synchronization interface, which connects the clock to the SYNC_IN and SYNC_OUT pins and to events triggered by software. Broadcom calls the clock and the synchronization interface together the network synchronization engine (NSE). OpenBCM calls the packet processing for one port a slice. ```mermaid flowchart LR MAC[Ethernet MAC] <-->|packets| PKT subgraph PHY[BCM54210PE] PKT[Packet processing:
recognize, edit,
store transmit timestamps] NSE[Clock] SYN[Synchronization interface:
capture the time,
generate pulses] NSE -->|time| PKT NSE <--> SYN end PKT <-->|line signals| CABLE[Ethernet cable] SYN <--> PINS[SYNC_IN, SYNC_OUT pins] CPU[Processor] -->|MDIO| PHY ``` ## Registers ### Access The PTP registers are in the PHY's expansion register space. To access one, write its address to MDIO register 0x17, then read or write its value through MDIO register 0x15. All registers are 16 bits wide. Larger values are spread over several registers, usually with the lowest 16 bits in the first. OpenBCM reaches the same registers through a different mechanism, called RDB. For most of them, expansion address 0x08xx is RDB address 0xAxx: for example, TX_TS_CAPTURE is expansion register 0x0821 and RDB register 0xA21. TIME_SYNC is an exception: expansion register 0x0FF5 is in another bank, and is RDB register 0x0F5. Some of OpenBCM's bit layouts differ from this PHY's, for example the order of the sequenceId and the message type of a transmit timestamp. ### Ports Many of the registers have a bit, or a field, for each of up to 8 ports. The BCM54210PE has one port, port 0, so only the bits for port 0 matter. For example, SLICE_CTRL has the transmit enable for port n in bit n and the receive enable in bit 8+n. The register reference at the end gives the bit fields of each register. Names are those of the Linux driver, or OpenBCM's where Linux has none. ## PTP hardware clock ### Frequency The clock is driven by a numerically controlled oscillator (NCO). On each tick of a 125 MHz reference clock, the NCO adds an increment to the time. The increment is in NCO_FREQ_MSB and NCO_FREQ_LSB, in units of 2^-28 ns, so 8 ns, the nominal increment, is 0x80000000. A larger value makes the clock run faster. The frequency can come from this value or from an internal digital phase-locked loop (DPLL). Bit 14 of NCO_TIME_2_CTRL (FREQ_MDIO_SEL) selects the value written over MDIO. With bit 14 clear, the clock ignores NCO_FREQ and runs at the nominal 8 ns per tick. NCO_TIME_2_CTRL also holds the top 12 bits of the local time to be loaded (below), in bits 11:0, so writing the local time must also set bit 14, or the frequency adjustment is lost. ### Global mode Bits 15:14 of NSE_CTRL select the global mode of the clock. The values are 1 free-running, 2 synchronized from SYNC_IN, and 3 CPU. This document describes mode 3. ### Time The clock keeps time in two forms. The time code is 48 bits of seconds and 32 bits of nanoseconds. It is loaded through TIME_CODE_0..4: TIME_CODE_0 and TIME_CODE_1 hold the nanoseconds, low half first, and TIME_CODE_2 to TIME_CODE_4 the seconds, low part first. Timestamps come from the time code. The local time is a 48-bit count of nanoseconds, which wraps after about 78 hours. It is loaded through NCO_TIME_0..2 as bits 47:4, that is, the count divided by 16, so a loaded value has a granularity of 16 ns. SYNC_OUT pulses are timed against the local time. The two forms advance together, but are loaded separately. For SYNC_OUT pulses to be timed correctly, the local time must be loaded with the same instant as the time code, expressed in nanoseconds. Both can be loaded in the same framesync. Since the local time can only be loaded to a multiple of 16 ns, it can be up to 15 ns behind the time code. ### Framesync A framesync is a single instant at which the clock acts on settings that software has prepared in advance. It is how the clock makes something happen at a precise time, rather than whenever an MDIO write happens to arrive. A framesync can do two things, which software enables separately: load new settings into the clock, and capture the current time. It has nothing to do with packets, and it can happen with no Ethernet traffic. A framesync is triggered by an event from a source that software selects. Bits 5:2 of NSE_CTRL select the sources: | Source | Event | NSE_CTRL bit | | --- | --- | --- | | SYNC_IN0 | a long pulse on SYNC_IN0 | 2 | | SYNC_IN1 | an edge on SYNC_IN1 | 3 | | SYNC_OUT | the PHY's own SYNC_OUT event | 4 | | CPU | a write to NSE_CTRL that sets the bit | 5 | SYNC_IN0 and SYNC_IN1 are OpenBCM's names for the two sources that are driven by external signals. Which connector pins carry them is described under Pins. A CPU framesync needs a 0 to 1 transition of bit 5. Bit 12 of NSE_CTRL (NSE_INIT) must be set for a framesync to load the time code. #### Loading settings Setting the time or the frequency takes several 16-bit register writes. If each write took effect at once, the clock would run for a while on a mixture of old and new values. Instead, the writes go into shadow registers, and the clock keeps running on its active values. At a framesync, selected groups of shadow values become active together. Two registers select the groups, with the same bit layout: | Bit | Group | | --- | --- | | 10 | time code | | 9 | SYNC_OUT settings | | 7 | local time | | 6 | frequency | SHADOW_LOAD selects the groups to load at the next framesync. SHADOW_CTRL selects groups to load at every framesync. With bit 12 of NSE_CTRL set, SHADOW_LOAD clears itself after the load; otherwise software clears it. ```mermaid sequenceDiagram participant SW as Software participant SH as Shadow registers participant ACT as Clock SW->>SH: write the new values (several 16-bit writes) SW->>SH: SHADOW_LOAD: select the groups to load SW->>ACT: framesync (CPU write to NSE_CTRL, or SYNC_IN edge) SH->>ACT: the selected groups take effect together ACT-->>SW: heartbeat timestamp of the framesync, if capture is enabled ``` #### Capturing the time A framesync can also capture the time at which it happened. This is the heartbeat timestamp. Bit 13 of NSE_CTRL enables it. Bit 6 of DPLL_SELECT selects a heartbeat timestamp of 32 bits of seconds and 32 bits of nanoseconds. Bit 0 of INTR_STATUS is set when a heartbeat timestamp has been captured. Reading INTR_STATUS does not clear it; reading the heartbeat timestamp does. A framesync with capture disabled does not set it. To read the timestamp, write 0x0400 (bit 10) to HB_STAT_CTRL, read HB_REG_0 and HB_REG_1 for the nanoseconds and HB_REG_2 and HB_REG_3 for the seconds, each low half first, then write 0x0800 (bit 11) and then 0 to HB_STAT_CTRL. A CPU framesync with capture enabled reads the clock: the timestamp is the time of the framesync. The PHY holds one heartbeat timestamp. A framesync that happens before the timestamp is read replaces it. Nothing indicates which source caused a framesync, so a timestamp from SYNC_IN cannot be told apart from one caused by a CPU framesync. A captured heartbeat timestamp does not raise an interrupt, even with bit 0 unmasked in INTR_MASK. On the CM4 the PHY interrupt is not wired. So software has to poll bit 0 of INTR_STATUS. ## External timestamps The PHY can timestamp an edge on a SYNC_IN input. The edge triggers a framesync with capture enabled, and the framesync captures the time as a heartbeat timestamp. Linux calls this an external timestamp (EXTTS). To use it, select SYNC_IN1 as a framesync source (NSE_CTRL bit 3) and enable capture (bit 13). A framesync from SYNC_IN1 also loads any shadow values that are selected, in SHADOW_LOAD or SHADOW_CTRL. External timestamps and reading the clock use the same heartbeat capture, so they interfere. Reading the clock with a CPU framesync replaces an external timestamp that has not yet been read, which is then lost. While the clock is being read, SYNC_IN1 has to be deselected as a source, or an edge could be taken for the CPU's framesync; an edge in that window is not timestamped. Without an Ethernet carrier, the clock does not run normally: an external timestamp then keeps returning the same stale time. SYNC_IN_DIVIDER is set to 1 for a PPS input. Rising edges are captured. ### Pins The PHY's sync signals are the two framesync inputs, SYNC_IN0 and SYNC_IN1, and the periodic output, SYNC_OUT. Broadcom describes the pins for them in an application note, "IEEE-1588 for Timing Applications", which is not public (according to a former Broadcom engineer in [raspberrypi/linux#4151](https://github.com/raspberrypi/linux/issues/4151#issuecomment-785418272)). OpenBCM has no register that routes these signals to pins. The datasheet names of the module connector pins do not match the signals: | Connector pin | CM4 datasheet name | CM5 datasheet name | CM4 IO board | PHY signals | | --- | --- | --- | --- | --- | | 16 | Ethernet_SYNC_IN | Fan_Tacho | J2 pin 8 | SYNC_IN0 on the CM4; none on the CM5 | | 18 | Ethernet_SYNC_OUT | Ethernet_SYNC_OUT | J2 pin 9 | SYNC_OUT and SYNC_IN1 on both | So the pin named SYNC_OUT is also the input that timestamps edges. The CM5 datasheet says that this pin may be configured as an input; the CM4 datasheet calls it an output, but SYNC_IN1 works on it in the same way. The pin named SYNC_IN, on the CM4 only, carries SYNC_IN0, which does not timestamp edges in the usual way (see SYNC_IN0 below). These connections are fixed. Pin 18 is one electrical node: the SYNC_OUT driver can drive it, and the SYNC_IN1 input sees its voltage, whatever is driving it. It is not known whether this is one pad on the PHY, or two pads that the module joins. When the output mode (NSE_CTRL bits 1:0) is 0, the PHY does not drive the pin, since an external PPS on it is timestamped normally. It is not known whether the pin is driven between pulses in one-shot mode. So external timestamps and periodic output share one pin, and cannot be used at the same time with two different signals. Because the input sees the pin's own output, SYNC_IN1 can timestamp the PHY's own pulses. With SYNC_IN1 selected while a one-shot pulse fires, the heartbeat timestamp is 40 to 47 ns after the pulse's target time in register-level experiments, and exactly 40 ns in every event in a test with a modified Linux driver. This is the delay from the target time through the output path, the pin and the input path. It does not depend on the pulse width. It cannot be split into its output and input parts, but it is an upper bound on each. It was measured with nothing connected to the pin. The Linux driver has one PTP pin, named SYNC_OUT, which is connector pin 18. Its EXTTS channel 0 is SYNC_IN1 with heartbeat capture, and its PEROUT channel 0 is SYNC_OUT. Assigning a function to the pin writes no register; it only decides which of the two channels can be enabled. ### SYNC_IN0 SYNC_IN0 is on connector pin 16 of the CM4 only. It does not timestamp edges in the way SYNC_IN1 does. OpenBCM describes its framesync as "long pulse on SyncIn0", and configures it with two registers: a length threshold, 0x0880, and an event offset, 0x0881. Measurements on a CM4 fit this model: 1. A counter starts at the rising edge of a pulse. It counts nanoseconds and wraps every 2^20 ns, about 1.05 ms. 2. At the falling edge, the pulse is accepted if it was longer than 8 ns times the length threshold. 3. After the falling edge, the framesync happens the next time the counter equals 8 ns times the event offset. The heartbeat timestamp is then the rising edge + 8 ns x offset + about 41 ns + n x 2^20 ns, where n is the number of times the counter wrapped before the framesync. The 41 ns was measured with a SYNC_OUT pulse looped back to SYNC_IN0 by a jumper, so it includes the delay of the output path as well as the input path. Both registers are in units of 8 ns. Their reset values are 4 (32 ns) and 8 (64 ns). The largest offset, 0xFFFF, is 524 us. A threshold of 0 accepts no pulses. The comparison with the threshold does not wrap: a 100 ms pulse is accepted with thresholds of 0xB000, 0xC000 and 0xFFFF. Where the pulse falls within the second makes no difference. So with the reset values, for the pulses tested (100 ns to 100 ms), the timestamp is 2^20 ns plus about 105 ns after the rising edge. If the offset reaches past the falling edge, the framesync happens at the matching count, without a wrap. For pulses longer than 524 us, there is always a wrap, and nothing records how many. The rising edge can then only be recovered if the pulse width is known to within about 0.5 ms. For example, a 100 ms GNSS PPS gives n = 96 with the reset offset, and n = 95 with an offset of 0xC000 (393 us). This also explains reports that SYNC_IN0 timestamps the falling edge. With an offset of 0x200 (4096 ns) and the widest periodic output pulse (4088 ns), the timestamp falls about 50 ns after the falling edge, and in some seconds 2^20 ns later. ## Periodic output The PHY generates pulses on SYNC_OUT from its clock. Linux calls this periodic output (PEROUT). The output is driven by comparing the local time with a target time: when the local time reaches the target, the PHY starts a pulse. Software sets up the pulse in advance, so the timing of the edge does not depend on when software runs. NSE_CTRL bits 1:0 select the output mode: | Value | Mode | Output | | --- | --- | --- | | 0 | Disabled | nothing | | 1 | One-shot | one pulse, when the local time reaches the target | | 2 | Pulse train | pulses repeating at a fixed interval | | 3 | Pulse train with sync | a pulse train combined with a one-shot pulse | The target time is in SYNOUT_TS_0..2, as a 48-bit local time in nanoseconds, of which only bits 47:4 are used. SYNC_OUT_0..2 hold the interval of a pulse train and two pulse widths: | Field | Bits | Registers | | --- | --- | --- | | Interval | 30 | SYNC_OUT_0 bits 15:0, SYNC_OUT_1 bits 13:0 | | Pulse 1 width | 9 | SYNC_OUT_1 bits 15:14, SYNC_OUT_2 bits 6:0 | | Pulse 2 width | 9 | SYNC_OUT_2 bits 15:7 | The pulse widths are in units of 8 ns, so the widest pulse, 511 units, is about 4.1 us. Pulse output needs an Ethernet link: the port must have a carrier. The target, widths and interval are shadow values, in the SYNC_OUT group (bit 9 of SHADOW_LOAD). They take effect at a framesync. A one-shot pulse is armed by a 0 to 1 transition of NSE_CTRL bit 0, together with bit 12. For a one-shot pulse, the Linux driver writes 0x3FFFFFFF, the largest possible value, to the interval. We don't know why. A pulse per second can be generated by arming a one-shot pulse for each second before it is due. ## Packet timestamping ### PTP terms PTP messages start with a 34-byte header. Byte offsets below count from the start of this header. The correctionField is a signed 64-bit field in the header, in nanoseconds multiplied by 65536. It carries a time interval to be added to the timestamps in the message. In two-step operation, software sends an event message, obtains its transmit timestamp afterwards, and sends that timestamp in a second, general message, such as a Follow_Up after a Sync. In one-step operation, the hardware puts the timing information into the event message itself as it is sent. In the peer-to-peer (P2P) delay mechanism, a port measures the delay of its own link. The requester sends a Pdelay_Req at time t1, which the responder receives at t2. The responder sends a Pdelay_Resp at t3, which the requester receives at t4. The requester needs t3 - t2, the responder's turnaround time. A two-step responder sends t2 in the Pdelay_Resp, in bytes 34-43 (requestReceiptTimestamp), and t3 in a Pdelay_Resp_Follow_Up. A one-step responder sends neither, and puts t3 - t2 into the correctionField of the Pdelay_Resp instead. A timestamp in a PTP message is 10 bytes: 6 bytes of seconds and 4 bytes of nanoseconds. ### Recognition The PHY recognizes the four PTP event messages: Sync, Delay_Req, Pdelay_Req and Pdelay_Resp. It does not recognize PTP version 2.1 messages (minorVersionPTP 1), which linuxptp 4.x sends by default, so these are not timestamped. It recognizes only PTP: other packets, such as NTP, cannot be timestamped. It recognizes them in Ethernet frames (L2) and in UDP over IPv4 and IPv6. RX_CTL (0x0861) enables recognition of 802.1AS, L2, UDPv4 and UDPv6 on receive; its reset value, 0x000f, enables all four. ### Enabling SLICE_CTRL bit 0 enables transmit processing for port 0, and bit 8 receive processing. TX_TS_CAPTURE bit 0 enables capture of transmit timestamps. TIME_SYNC bit 0 enables start-of-packet capture. RX_TS_CAPTURE does not need to be set for receive timestamps to be inserted. With SLICE_RX_EN clear, received messages pass through unchanged: no timestamp is inserted, and the correctionField is not updated. Transmit processing is not affected. ### Modes TX_EVENT_MODE and RX_EVENT_MODE each have a 2-bit mode for each event message type: bits 1:0 for Sync, 3:2 for Delay_Req, 5:4 for Pdelay_Req and 7:6 for Pdelay_Resp. The upper byte has the same fields, for what Linux calls the CPU side. ```mermaid flowchart LR subgraph TX[Transmit] direction LR T0[from MAC] --> TP{mode for this
message type} TP -->|0| TA[unchanged] TP -->|1| TB[correctionField
plus transmit time] TP -->|3| TC[transmit time written
into bytes 34-43] TA --> TW[to cable] TB --> TW TC --> TW TP -.->|capture| TS[(transmit
timestamp store)] end subgraph RX[Receive] direction LR R0[from cable] --> RP{mode for this
message type} RP -->|1| RB[correctionField
minus receive time] RP -->|3| RC[8-byte receive time
inserted after header] RB --> RW[to MAC] RC --> RW end ``` | Mode | Transmit | Receive | | --- | --- | --- | | 0 | The message is sent unchanged, and the transmit timestamp is captured. | The message is unchanged. | | 1 (UPDATE_CF) | The transmit time is added to the correctionField, the UDP checksum is kept valid, and the transmit timestamp is captured. | The receive time is subtracted from the correctionField, and the UDP checksum is kept valid. | | 2 (REPLACE_TS_CF, INSERT_TS_48) | - | 8 bytes are inserted after the header: the receive time as a 64-bit count of nanoseconds, with the top 16 bits zero. Over IPv4 the UDP checksum is set to zero. | | 3 (REPLACE_TS, INSERT_TS_64) | The transmit timestamp is captured, and the transmit time is written into bytes 34-43. The UDP checksum is set to zero. | 8 bytes are inserted after the header: the receive time as 32 bits of seconds and 32 bits of nanoseconds. Over IPv4 the UDP checksum is set to zero. | In transmit mode 3, the transmit time is written into bytes 34-43 of each event message. In Sync and Delay_Req these bytes are the originTimestamp. In a two-step Pdelay_Resp they are requestReceiptTimestamp, which mode 3 overwrites with t3. Transmit mode 3 is what one-step Sync uses. The UDP checksum is set to zero in transmit mode 3 over IPv4 and IPv6. A zero checksum is allowed with IPv4 but not with IPv6, so a receiver discards such a message sent over UDPv6. In mode 1 the arithmetic is modulo 2^48 ns, on the 48 bits of whole nanoseconds in the correctionField (bits 63:16). The time used is a 48-bit count of nanoseconds, which wraps after about 78 hours. Because the arithmetic is modular, subtracting t2 on receive and adding t3 on transmit leaves t3 - t2 whatever the time. So one-step P2P works with Pdelay_Req in receive mode 1, Pdelay_Resp in transmit mode 1, and software copying the correctionField of the Pdelay_Req into the Pdelay_Resp. ### Transmit timestamp store The PHY stores the transmit timestamps it captures until software reads them. Bit 1 of INTR_STATUS is set when a timestamp is waiting. To read one, write 1 (bit 0) to TS_READ_CTRL, read TS_REG_0..3 and TS_INFO_0..1, then write 2 (bit 1) and then 0 to TS_READ_CTRL. TS_REG_0 and TS_REG_1 hold the nanoseconds and TS_REG_2 and TS_REG_3 the seconds, each low half first. TIMECODE_CTRL bit 0 selects this 32-bit seconds and 32-bit nanoseconds format for transmit; bit 8 is the corresponding bit for receive. TS_INFO_0 holds the sequenceId of the message. In TS_INFO_1, bits 15:12 are the message type, and bit 11 is set for a transmitted message. Software matches a timestamp to the message it sent by message type and sequenceId. Timestamps are captured in transmit modes 0, 1 and 3, so one-step messages produce captures too. ### Receive timestamp insertion In receive mode 3 the PHY inserts the receive timestamp into the message, as 4 bytes of seconds and then 4 bytes of nanoseconds, most significant byte first, immediately after the 34-byte header. The rest of the message follows unchanged, 8 bytes later. The frame becomes 8 bytes longer, but the IP and UDP length fields are not changed, and over IPv4 the UDP checksum is set to zero. Removing the 8 bytes restores the message as it was sent, apart from the checksum, which IPv4 allows to be zero. ### Latency The hardware does not correct timestamps for the PHY's ingress and egress latency. ## Register reference The Source column says where each field comes from: L the Linux driver, O OpenBCM, M measurement. The RDB column gives the address in OpenBCM's RDB space. HB_REG_3 and HB_REG_4 are not defined in OpenBCM; their RDB addresses follow the same rule as the others. Where a field has bits for several ports, only port 0 is listed. | Address | RDB | Register | Bits | Field | Source | | --- | --- | --- | --- | --- | --- | | 0x0810 | 0xA10 | SLICE_CTRL | 0 | transmit processing enable | L, O, M | | | | | 8 | receive processing enable | L, O, M | | 0x0811 | 0xA11 | TX_EVENT_MODE | 1:0 | Sync transmit mode | L, O, M | | | | | 3:2 | Delay_Req transmit mode | L, O, M | | | | | 5:4 | Pdelay_Req transmit mode | L, O, M | | | | | 7:6 | Pdelay_Resp transmit mode | L, O, M | | | | | 15:8 | the same fields, for the "CPU" side | L | | 0x0819 | 0xA19 | RX_EVENT_MODE | 7:0 | receive modes, laid out as TX_EVENT_MODE | L, O, M | | | | | 15:8 | the same fields, for the "CPU" side | L | | 0x0821 | 0xA21 | TX_TS_CAPTURE | 0 | transmit timestamp capture enable | L, O | | 0x0822 | 0xA22 | RX_TS_CAPTURE | | reads 0; not needed for receive timestamp insertion | M | | 0x0854 | 0xA54 | TIME_CODE_0 | 15:0 | time code nanoseconds, bits 15:0 | L | | 0x0855 | 0xA55 | TIME_CODE_1 | 15:0 | time code nanoseconds, bits 31:16 | L | | 0x0856 | 0xA56 | TIME_CODE_2 | 15:0 | time code seconds, bits 15:0 | L | | 0x0857 | 0xA57 | TIME_CODE_3 | 15:0 | time code seconds, bits 31:16 | L | | 0x0858 | 0xA58 | TIME_CODE_4 | 15:0 | time code seconds, bits 47:32 | L | | 0x085B | 0xA5B | DPLL_SELECT | 6 | heartbeat timestamp in seconds and nanoseconds | L | | 0x085C | 0xA5C | SHADOW_CTRL | 10, 9, 7, 6 | load at every framesync: time code, SYNC_OUT, local time, frequency | L, O | | 0x085D | 0xA5D | SHADOW_LOAD | 10, 9, 7, 6 | load at the next framesync: the same groups | L, O | | 0x085E | 0xA5E | INTR_MASK | 0 | heartbeat interrupt mask; unmasking it raises no interrupt | M | | 0x085F | 0xA5F | INTR_STATUS | 0 | heartbeat timestamp captured; cleared by reading the heartbeat timestamp | L, M | | | | | 1 | transmit timestamp waiting | L, M | | 0x0860 | 0xA60 | TX_CTL | | packet recognition on transmit; reads 0xc000 | O, M | | 0x0861 | 0xA61 | RX_CTL | 3:0 | recognition enables on receive for 802.1AS, L2, UDPv4 and UDPv6, in OpenBCM's layout; reads 0x000f | O, M | | 0x0873 | 0xA73 | NCO_FREQ_LSB | 15:0 | NCO increment, bits 15:0, in units of 2^-28 ns | L | | 0x0874 | 0xA74 | NCO_FREQ_MSB | 15:0 | NCO increment, bits 31:16 | L | | 0x0875 | 0xA75 | NCO_TIME_0 | 15:0 | local time to load, bits 19:4 | L | | 0x0876 | 0xA76 | NCO_TIME_1 | 15:0 | local time to load, bits 35:20 | L | | 0x0877 | 0xA77 | NCO_TIME_2_CTRL | 11:0 | local time to load, bits 47:36 | L | | | | | 14 | frequency from NCO_FREQ (FREQ_MDIO_SEL); clear: nominal 8 ns | L, O, M | | 0x0878 | 0xA78 | SYNC_OUT_0 | 15:0 | pulse train interval, bits 15:0 | L, O | | 0x0879 | 0xA79 | SYNC_OUT_1 | 13:0 | pulse train interval, bits 29:16 | L, O | | | | | 15:14 | pulse 1 width, bits 1:0, in units of 8 ns | L, O, M | | 0x087A | 0xA7A | SYNC_OUT_2 | 6:0 | pulse 1 width, bits 8:2 | L, O | | | | | 15:7 | pulse 2 width | L, O | | 0x087B | 0xA7B | SYNC_IN_DIVIDER | | timestamp divider; 1 for every edge | L, O | | 0x087C | 0xA7C | SYNOUT_TS_0 | 15:0 | SYNC_OUT target local time, bits 15:0 (bits 3:0 unused, per OpenBCM) | L, O | | 0x087D | 0xA7D | SYNOUT_TS_1 | 15:0 | target, bits 31:16 | L, O | | 0x087E | 0xA7E | SYNOUT_TS_2 | 15:0 | target, bits 47:32 | L, O | | 0x087F | 0xA7F | NSE_CTRL | 1:0 | SYNC_OUT mode: 0 off, 1 one-shot, 2 pulse train, 3 pulse train with sync | L, O | | | | | 2 | framesync source SYNC_IN0 | O | | | | | 3 | framesync source SYNC_IN1 | L, O, M | | | | | 4 | framesync source SYNC_OUT | O | | | | | 5 | framesync source CPU; a 0 to 1 transition triggers a framesync | L, O, M | | | | | 12 | NSE_INIT, framesync enable; needed to load the time code | L, O | | | | | 13 | heartbeat capture enable | L, O, M | | | | | 15:14 | global mode: 1 free-running, 2 SYNC_IN, 3 CPU | L, O | | 0x0880 | 0xA80 | SYNC_IN0 threshold | 15:0 | shortest pulse accepted on SYNC_IN0, in units of 8 ns; reset 4 | O, M | | 0x0881 | 0xA81 | SYNC_IN0 offset | 15:0 | SYNC_IN0 framesync at this count from the rising edge, in units of 8 ns, after the falling edge; reset 8 | O, M | | 0x0885 | 0xA85 | TS_READ_CTRL | 0 | start reading a transmit timestamp | L | | | | | 1 | end reading | L | | 0x0886 | 0xA86 | HB_REG_0 | 15:0 | heartbeat nanoseconds, bits 15:0 | L, M | | 0x0887 | 0xA87 | HB_REG_1 | 15:0 | heartbeat nanoseconds, bits 31:16 | L, M | | 0x0888 | 0xA88 | HB_REG_2 | 15:0 | heartbeat seconds, bits 15:0 | L, M | | 0x08EC | 0xAEC | HB_REG_3 | 15:0 | heartbeat seconds, bits 31:16 | L, M | | 0x08ED | 0xAED | HB_REG_4 | | reads 0 | L, M | | 0x0889 | 0xA89 | TS_REG_0 | 15:0 | transmit timestamp nanoseconds, bits 15:0 | L, M | | 0x088A | 0xA8A | TS_REG_1 | 15:0 | transmit timestamp nanoseconds, bits 31:16 | L, M | | 0x088B | 0xA8B | TS_REG_2 | 15:0 | transmit timestamp seconds, bits 15:0 | L, M | | 0x08C4 | 0xAC4 | TS_REG_3 | 15:0 | transmit timestamp seconds, bits 31:16 | L, M | | 0x088C | 0xA8C | TS_INFO_0 | 15:0 | sequenceId of the message | L, M | | 0x088D | 0xA8D | TS_INFO_1 | 11 | set for a transmitted message | L | | | | | 15:12 | message type | L, M | | 0x088E | 0xA8E | HB_STAT_CTRL | 10 | start reading a heartbeat timestamp | L, O | | | | | 11 | end reading | L, O | | 0x08C3 | 0xAC3 | TIMECODE_CTRL | 0 | 64-bit (seconds and nanoseconds) transmit timestamps | L, O | | | | | 8 | the same for receive | O | | 0x0FF5 | 0x0F5 | TIME_SYNC | 0 | start-of-packet capture enable | L | ## Sources - Linux `drivers/net/phy/bcm-phy-ptp.c`, `bcm-phy-lib.c` and `broadcom.c`. - The Raspberry Pi kernel's `drivers/net/phy/bcm-phy-ptp.c` and `include/linux/brcmphy.h`, for the PHY ID. - OpenBCM SDK 6.5.27: `src/soc/phy/phy542xx.c`, `src/soc/phy/phy542xx_regdefs.h`, `include/bcm/port.h` and `include/shared/port.h`. - The Raspberry Pi CM4 and CM5 datasheets, section 2.2 and the connector pinouts. - Measurements on Raspberry Pi CM4 and CM5 boards with linuxptp 4.2 against an Intel I226, with packet captures at the I226, register reads on the CM5, register experiments on the CM4 with captures of received messages on the CM4, and experiments on the CM4 with periodic output pulses looped back to the sync inputs and with a GNSS PPS on SYNC_IN. - Lasse Johnsen's comments in [raspberrypi/linux#4151](https://github.com/raspberrypi/linux/issues/4151) (2022-05-25 and 2022-08-15) and his `lj-jl-merge` branch of timebeat-app/linux, for the SYNC_IN0 registers and the report that SYNC_IN0 timestamps the falling edge.