]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
parisc: Add PDC PAT call to get free running 64-bit counter
authorHelge Deller <deller@gmx.de>
Fri, 6 Feb 2026 20:26:40 +0000 (21:26 +0100)
committerHelge Deller <deller@gmx.de>
Fri, 6 Feb 2026 23:45:19 +0000 (00:45 +0100)
PDC PAT defines this optional function. Testing on my C8000 workstation
and a rp3440 server did not indicate that they provide such counter.
Nevertheless, add the function since we should try to use such a
counter if it's available. In Qemu it should be simple to add it.

Signed-off-by: Helge Deller <deller@gmx.de>
arch/parisc/include/asm/pdcpat.h
arch/parisc/kernel/firmware.c

index 84ac81b1addec67b265276e787f2168ec4f54b21..ec97eefa4ef6fa3df554d02006cf3f022553f1c8 100644 (file)
 #define PDC_PAT_PD             74L         /* Protection Domain Info   */
 #define PDC_PAT_PD_GET_ADDR_MAP                0L  /* Get Address Map          */
 #define PDC_PAT_PD_GET_PDC_INTERF_REV  1L  /* Get PDC Interface Revisions */
+#define PDC_PAT_PD_GET_PLATFORM_COUNTER        10L /* Get 64-bit free running counter */
 
 #define PDC_PAT_CAPABILITY_BIT_PDC_SERIALIZE   (1UL << 0)
 #define PDC_PAT_CAPABILITY_BIT_PDC_POLLING     (1UL << 1)
@@ -373,9 +374,11 @@ extern int pdc_pat_pd_get_addr_map(unsigned long *actual_len, void *mem_addr,
                unsigned long count, unsigned long offset);
 extern int pdc_pat_pd_get_pdc_revisions(unsigned long *legacy_rev,
                unsigned long *pat_rev, unsigned long *pdc_cap);
+extern int pdc_pat_pd_get_platform_counter(uint64_t **addr,
+               unsigned long *freq, unsigned long *uniq);
 
-extern int pdc_pat_io_pci_cfg_read(unsigned long pci_addr, int pci_size, u32 *val); 
-extern int pdc_pat_io_pci_cfg_write(unsigned long pci_addr, int pci_size, u32 val); 
+extern int pdc_pat_io_pci_cfg_read(unsigned long pci_addr, int pci_size, u32 *val);
+extern int pdc_pat_io_pci_cfg_write(unsigned long pci_addr, int pci_size, u32 val);
 
 extern int pdc_pat_mem_pdt_info(struct pdc_pat_mem_retinfo *rinfo);
 extern int pdc_pat_mem_pdt_cell_info(struct pdc_pat_mem_cell_pdt_retinfo *rinfo,
index 042343492a28010ce9c055d8c8673d21710aaa16..c35a348097437c801be6c08e638a95ec811706e6 100644 (file)
@@ -1643,11 +1643,36 @@ int pdc_pat_pd_get_pdc_revisions(unsigned long *legacy_rev,
        return retval;
 }
 
+/**
+ * pdc_pat_pd_get_platform_counter - Retrieve address of free-running 64-bit counter.
+ * @addr: The address of the 64-bit counter.
+ * @freq: The frequency of the counter, or -1 if unknown.
+ * @unique: Although monotonic growing, may it return the same number twice?
+ *
+ */
+int pdc_pat_pd_get_platform_counter(uint64_t **addr,
+               unsigned long *freq, unsigned long *unique)
+{
+       int retval;
+       unsigned long flags;
+
+       spin_lock_irqsave(&pdc_lock, flags);
+       retval = mem_pdc_call(PDC_PAT_PD, PDC_PAT_PD_GET_PLATFORM_COUNTER,
+                               __pa(pdc_result));
+       if (retval == PDC_OK) {
+               *addr = (uint64_t *)pdc_result[0];
+               *freq = pdc_result[1];
+               *unique = pdc_result[2];
+       }
+       spin_unlock_irqrestore(&pdc_lock, flags);
+
+       return retval;
+}
 
 /**
  * pdc_pat_io_pci_cfg_read - Read PCI configuration space.
  * @pci_addr: PCI configuration space address for which the read request is being made.
- * @pci_size: Size of read in bytes. Valid values are 1, 2, and 4. 
+ * @pci_size: Size of read in bytes. Valid values are 1, 2, and 4.
  * @mem_addr: Pointer to return memory buffer.
  *
  */