drivers/net/ethernet/amd/xgbe/xgbe-pps.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/amd/xgbe/xgbe-pps.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/amd/xgbe/xgbe-pps.c- Extension
.c- Size
- 1889 bytes
- Lines
- 75
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
xgbe.hxgbe-common.h
Detected Declarations
function Copyrightfunction get_pps_cmdfunction get_target_mode_selfunction xgbe_pps_config
Annotated Snippet
// SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-3-Clause)
/*
* Copyright (c) 2014-2025, Advanced Micro Devices, Inc.
* Copyright (c) 2014, Synopsys, Inc.
* All rights reserved
*
* Author: Raju Rangoju <Raju.Rangoju@amd.com>
*/
#include "xgbe.h"
#include "xgbe-common.h"
static u32 get_pps_mask(unsigned int x)
{
return GENMASK(PPS_MAXIDX(x), PPS_MINIDX(x));
}
static u32 get_pps_cmd(unsigned int x, u32 val)
{
return (val & GENMASK(3, 0)) << PPS_MINIDX(x);
}
static u32 get_target_mode_sel(unsigned int x, u32 val)
{
return (val & GENMASK(1, 0)) << (PPS_MAXIDX(x) - 2);
}
int xgbe_pps_config(struct xgbe_prv_data *pdata,
struct xgbe_pps_config *cfg, int index, bool on)
{
unsigned int ppscr = 0;
unsigned int tnsec;
u64 period;
/* Check if target time register is busy */
tnsec = XGMAC_IOREAD(pdata, MAC_PPSx_TTNSR(index));
if (XGMAC_GET_BITS(tnsec, MAC_PPSx_TTNSR, TRGTBUSY0))
return -EBUSY;
ppscr = XGMAC_IOREAD(pdata, MAC_PPSCR);
ppscr &= ~get_pps_mask(index);
if (!on) {
/* Disable PPS output */
ppscr |= get_pps_cmd(index, XGBE_PPSCMD_STOP);
ppscr |= PPSEN0;
XGMAC_IOWRITE(pdata, MAC_PPSCR, ppscr);
return 0;
}
/* Configure start time */
XGMAC_IOWRITE(pdata, MAC_PPSx_TTSR(index), cfg->start.tv_sec);
XGMAC_IOWRITE(pdata, MAC_PPSx_TTNSR(index), cfg->start.tv_nsec);
period = cfg->period.tv_sec * NSEC_PER_SEC + cfg->period.tv_nsec;
period = div_u64(period, XGBE_V2_TSTAMP_SSINC);
if (period < 4)
return -EINVAL;
/* Configure interval and pulse width (50% duty cycle) */
XGMAC_IOWRITE(pdata, MAC_PPSx_INTERVAL(index), period - 1);
XGMAC_IOWRITE(pdata, MAC_PPSx_WIDTH(index), (period >> 1) - 1);
/* Enable PPS with pulse train mode */
ppscr |= get_pps_cmd(index, XGBE_PPSCMD_START);
ppscr |= get_target_mode_sel(index, XGBE_PPSTARGET_PULSE);
ppscr |= PPSEN0;
XGMAC_IOWRITE(pdata, MAC_PPSCR, ppscr);
return 0;
}
Annotation
- Immediate include surface: `xgbe.h`, `xgbe-common.h`.
- Detected declarations: `function Copyright`, `function get_pps_cmd`, `function get_target_mode_sel`, `function xgbe_pps_config`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.