<commit_before>Introduction

PTIMER is a small functional unit used to measure time by the card. It has
a 56-bit tick counter connected to a programmable clock source. The current
value of this counter is used for timestamping by many other units on the GPU.
Two such timestamps can be substracted to get the wall time elapsed between
their creation and measure eg. command execution time. Also, it's possible to
set up an interrupt that will be triggered when the low 27 bits of the counter
reach a specified value.

The PTIMER's MMIO range is 0x9000:0xa000. It is enabled by PMC.ENABLE bit 16,
and its interrupt line is connected to PMC.INTR line 20. It's available on all
cards, starting with nv01.

Curiously, on NV41+ the PTIMER is also used to report MMIO faults, ie. MMIO
space accesses from host that failed for some reason.


MMIO register list

* means a NV41+ only register
# means a register available only on [XXX: check which chipsets]

009060# ???		???
009064# ???		???
009080# ???		???
[XXX: figure these out]
009084* MMIO_FAULT_ADDR	address and type of last MMIO fault
009088* MMIO_FAULT_DATA	data written on last MMIO fault
[XXX: document these]
009100  INTR		interrupt status / acknowledge
009140  INTR_EN		interrupt enable
009200  CLOCK_DIV	clock divider
009210  CLOCK_MUL	clock multiplier
009220* CLOCK_SOURCE	clock source selection
009400  TIME_LOW	low part of the time counter
009410  TIME_HIGH	high part of the time counter
009420  ALARM		the TIME_LOW value to interrupt on


The clock source

The clock that PTIMER counts is generated by applying a selectable ratio to
a clock source. The clock source depends on the card:

 - NV01:NV04: the clock source is the MPLL output [see pramdac.txt]
 - NV04:NV40: the clock source is the NVPLL output [see pramdac.txt]
 - NV40:NV41: the clock source is selectable through PCONTROL [see pcontrol.txt]
 - NV41:NVA3: the clock source can be bound to either the internal clock source
   or external clock source. Internal clock source is the crystal
   [see pstraps.txt] frequency multiplied by a small ratio, while external
   clock source is selectable through PCONTROL like on NV40<commit_msg>ptimer: Check variants on unknown regs.<commit_after>Introduction

PTIMER is a small functional unit used to measure time by the card. It has
a 56-bit tick counter connected to a programmable clock source. The current
value of this counter is used for timestamping by many other units on the GPU.
Two such timestamps can be substracted to get the wall time elapsed between
their creation and measure eg. command execution time. Also, it's possible to
set up an interrupt that will be triggered when the low 27 bits of the counter
reach a specified value.

The PTIMER's MMIO range is 0x9000:0xa000. It is enabled by PMC.ENABLE bit 16,
and its interrupt line is connected to PMC.INTR line 20. It's available on all
cards, starting with nv01.

Curiously, on NV41+ the PTIMER is also used to report MMIO faults, ie. MMIO
space accesses from host that failed for some reason.


MMIO register list

no annotation - available on all cards
[1] - available on NV17:NV20 and NV25:NV50
[2] - available on NV41+
[3] - available on NV50+
[4] - available on NVC0+

009060[3] ???			???
009064[3] ???			???
009080[1] ???			???
009080[4] ???			???
[XXX: figure these out]
009084[2] MMIO_FAULT_ADDR	address and type of last MMIO fault
009088[2] MMIO_FAULT_DATA	data written on last MMIO fault
[XXX: document these]
009100    INTR			interrupt status / acknowledge
009140    INTR_EN		interrupt enable
009200    CLOCK_DIV		clock divider
009210    CLOCK_MUL		clock multiplier
009220[2] CLOCK_SOURCE		clock source selection
009400    TIME_LOW		low part of the time counter
009410    TIME_HIGH		high part of the time counter
009420    ALARM			the TIME_LOW value to interrupt on


The clock source

The clock that PTIMER counts is generated by applying a selectable ratio to
a clock source. The clock source depends on the card:

 - NV01:NV04: the clock source is the MPLL output [see pramdac.txt]
 - NV04:NV40: the clock source is the NVPLL output [see pramdac.txt]
 - NV40:NV41: the clock source is selectable through PCONTROL [see pcontrol.txt]
 - NV41:NVA3: the clock source can be bound to either the internal clock source
   or external clock source. Internal clock source is the crystal
   [see pstraps.txt] frequency multiplied by a small ratio, while external
   clock source is selectable through PCONTROL like on NV40
{'fraction_non_alphanumeric': 0.047512326311071267, 'fraction_numerical': 0.05916629314208875, 'mean_word_length': 4.171494785631518, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6143378', 'n_tokens_mistral': 1514, 'n_tokens_neox': 1316, 'n_words': 676}