drivers/hwtracing/intel_th/gth.c
Source file repositories/reference/linux-study-clean/drivers/hwtracing/intel_th/gth.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hwtracing/intel_th/gth.c- Extension
.c- Size
- 21178 bytes
- Lines
- 851
- Domain
- Driver Families
- Bucket
- drivers/hwtracing
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/types.hlinux/module.hlinux/device.hlinux/io.hlinux/mm.hlinux/slab.hlinux/bitmap.hlinux/pm_runtime.hintel_th.hgth.h
Detected Declarations
struct gth_devicestruct gth_outputstruct gth_devicestruct master_attributestruct output_attributefunction gth_output_setfunction gth_output_getfunction gth_smcfreq_setfunction gth_smcfreq_getfunction gth_master_setfunction master_attr_showfunction master_attr_storefunction gth_output_parm_setfunction gth_output_parm_getfunction intel_th_gth_resetfunction output_attr_showfunction output_attr_storefunction intel_th_master_attributesfunction intel_th_output_attributesfunction intel_th_gth_stopfunction intel_th_gth_startfunction intel_th_gth_disablefunction for_each_set_bitfunction gth_tscu_resyncfunction intel_th_gth_preparefunction intel_th_gth_enablefunction intel_th_gth_switchfunction intel_th_gth_assignfunction intel_th_gth_unassignfunction intel_th_gth_set_outputfunction intel_th_gth_probefunction intel_th_gth_remove
Annotated Snippet
struct gth_output {
struct gth_device *gth;
struct intel_th_output *output;
unsigned int index;
unsigned int port_type;
DECLARE_BITMAP(master, TH_CONFIGURABLE_MASTERS + 1);
};
/**
* struct gth_device - GTH device
* @dev: driver core's device
* @base: register window base address
* @output_group: attributes describing output ports
* @master_group: attributes describing master assignments
* @output: output ports
* @master: master/output port assignments
* @gth_lock: serializes accesses to GTH bits
*/
struct gth_device {
struct device *dev;
void __iomem *base;
struct attribute_group output_group;
struct attribute_group master_group;
struct gth_output output[TH_POSSIBLE_OUTPUTS];
signed char master[TH_CONFIGURABLE_MASTERS + 1];
spinlock_t gth_lock;
};
static void gth_output_set(struct gth_device *gth, int port,
unsigned int config)
{
unsigned long reg = port & 4 ? REG_GTH_GTHOPT1 : REG_GTH_GTHOPT0;
u32 val;
int shift = (port & 3) * 8;
val = ioread32(gth->base + reg);
val &= ~(0xff << shift);
val |= config << shift;
iowrite32(val, gth->base + reg);
}
static unsigned int gth_output_get(struct gth_device *gth, int port)
{
unsigned long reg = port & 4 ? REG_GTH_GTHOPT1 : REG_GTH_GTHOPT0;
u32 val;
int shift = (port & 3) * 8;
val = ioread32(gth->base + reg);
val &= 0xff << shift;
val >>= shift;
return val;
}
static void gth_smcfreq_set(struct gth_device *gth, int port,
unsigned int freq)
{
unsigned long reg = REG_GTH_SMCR0 + ((port / 2) * 4);
int shift = (port & 1) * 16;
u32 val;
val = ioread32(gth->base + reg);
val &= ~(0xffff << shift);
val |= freq << shift;
iowrite32(val, gth->base + reg);
}
static unsigned int gth_smcfreq_get(struct gth_device *gth, int port)
{
unsigned long reg = REG_GTH_SMCR0 + ((port / 2) * 4);
int shift = (port & 1) * 16;
u32 val;
val = ioread32(gth->base + reg);
val &= 0xffff << shift;
val >>= shift;
return val;
}
/*
* "masters" attribute group
*/
struct master_attribute {
struct device_attribute attr;
struct gth_device *gth;
unsigned int master;
};
Annotation
- Immediate include surface: `linux/types.h`, `linux/module.h`, `linux/device.h`, `linux/io.h`, `linux/mm.h`, `linux/slab.h`, `linux/bitmap.h`, `linux/pm_runtime.h`.
- Detected declarations: `struct gth_device`, `struct gth_output`, `struct gth_device`, `struct master_attribute`, `struct output_attribute`, `function gth_output_set`, `function gth_output_get`, `function gth_smcfreq_set`, `function gth_smcfreq_get`, `function gth_master_set`.
- Atlas domain: Driver Families / drivers/hwtracing.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.