Skip to content

Commit 0b3b90a

Browse files
committed
parisc: Add PDC PAT call to get free running 64-bit counter
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>
1 parent 5ff7842 commit 0b3b90a

2 files changed

Lines changed: 31 additions & 3 deletions

File tree

arch/parisc/include/asm/pdcpat.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@
179179
#define PDC_PAT_PD 74L /* Protection Domain Info */
180180
#define PDC_PAT_PD_GET_ADDR_MAP 0L /* Get Address Map */
181181
#define PDC_PAT_PD_GET_PDC_INTERF_REV 1L /* Get PDC Interface Revisions */
182+
#define PDC_PAT_PD_GET_PLATFORM_COUNTER 10L /* Get 64-bit free running counter */
182183

183184
#define PDC_PAT_CAPABILITY_BIT_PDC_SERIALIZE (1UL << 0)
184185
#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,
373374
unsigned long count, unsigned long offset);
374375
extern int pdc_pat_pd_get_pdc_revisions(unsigned long *legacy_rev,
375376
unsigned long *pat_rev, unsigned long *pdc_cap);
377+
extern int pdc_pat_pd_get_platform_counter(uint64_t **addr,
378+
unsigned long *freq, unsigned long *uniq);
376379

377-
extern int pdc_pat_io_pci_cfg_read(unsigned long pci_addr, int pci_size, u32 *val);
378-
extern int pdc_pat_io_pci_cfg_write(unsigned long pci_addr, int pci_size, u32 val);
380+
extern int pdc_pat_io_pci_cfg_read(unsigned long pci_addr, int pci_size, u32 *val);
381+
extern int pdc_pat_io_pci_cfg_write(unsigned long pci_addr, int pci_size, u32 val);
379382

380383
extern int pdc_pat_mem_pdt_info(struct pdc_pat_mem_retinfo *rinfo);
381384
extern int pdc_pat_mem_pdt_cell_info(struct pdc_pat_mem_cell_pdt_retinfo *rinfo,

arch/parisc/kernel/firmware.c

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1643,11 +1643,36 @@ int pdc_pat_pd_get_pdc_revisions(unsigned long *legacy_rev,
16431643
return retval;
16441644
}
16451645

1646+
/**
1647+
* pdc_pat_pd_get_platform_counter - Retrieve address of free-running 64-bit counter.
1648+
* @addr: The address of the 64-bit counter.
1649+
* @freq: The frequency of the counter, or -1 if unknown.
1650+
* @unique: Although monotonic growing, may it return the same number twice?
1651+
*
1652+
*/
1653+
int pdc_pat_pd_get_platform_counter(uint64_t **addr,
1654+
unsigned long *freq, unsigned long *unique)
1655+
{
1656+
int retval;
1657+
unsigned long flags;
1658+
1659+
spin_lock_irqsave(&pdc_lock, flags);
1660+
retval = mem_pdc_call(PDC_PAT_PD, PDC_PAT_PD_GET_PLATFORM_COUNTER,
1661+
__pa(pdc_result));
1662+
if (retval == PDC_OK) {
1663+
*addr = (uint64_t *)pdc_result[0];
1664+
*freq = pdc_result[1];
1665+
*unique = pdc_result[2];
1666+
}
1667+
spin_unlock_irqrestore(&pdc_lock, flags);
1668+
1669+
return retval;
1670+
}
16461671

16471672
/**
16481673
* pdc_pat_io_pci_cfg_read - Read PCI configuration space.
16491674
* @pci_addr: PCI configuration space address for which the read request is being made.
1650-
* @pci_size: Size of read in bytes. Valid values are 1, 2, and 4.
1675+
* @pci_size: Size of read in bytes. Valid values are 1, 2, and 4.
16511676
* @mem_addr: Pointer to return memory buffer.
16521677
*
16531678
*/

0 commit comments

Comments
 (0)