drivers/clocksource/samsung_pwm_timer.c
Source file repositories/reference/linux-study-clean/drivers/clocksource/samsung_pwm_timer.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/clocksource/samsung_pwm_timer.c- Extension
.c- Size
- 12898 bytes
- Lines
- 517
- Domain
- Driver Families
- Bucket
- drivers/clocksource
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/interrupt.hlinux/irq.hlinux/err.hlinux/clk.hlinux/clockchips.hlinux/list.hlinux/module.hlinux/of.hlinux/of_address.hlinux/of_irq.hlinux/platform_device.hlinux/slab.hlinux/sched_clock.hclocksource/samsung_pwm.h
Detected Declarations
struct samsung_pwm_clocksourcefunction samsung_timer_set_prescalefunction samsung_timer_set_divisorfunction samsung_time_stopfunction samsung_time_setupfunction samsung_time_startfunction samsung_set_next_eventfunction samsung_shutdownfunction samsung_set_periodicfunction samsung_clockevent_resumefunction samsung_clock_event_isrfunction samsung_clockevent_initfunction samsung_clocksource_suspendfunction samsung_clocksource_resumefunction samsung_clocksource_readfunction samsung_read_sched_clockfunction samsung_clocksource_initfunction samsung_timer_resourcesfunction _samsung_pwm_clocksource_initfunction samsung_pwm_clocksource_initfunction samsung_pwm_allocfunction of_property_for_each_u32function s3c2410_pwm_clocksource_initfunction s3c64xx_pwm_clocksource_initfunction s5p64x0_pwm_clocksource_initfunction s5p_pwm_clocksource_initexport samsung_pwm_lock
Annotated Snippet
struct samsung_pwm_clocksource {
void __iomem *base;
const void __iomem *source_reg;
unsigned int irq[SAMSUNG_PWM_NUM];
struct samsung_pwm_variant variant;
struct clk *timerclk;
unsigned int event_id;
unsigned int source_id;
unsigned int tcnt_max;
unsigned int tscaler_div;
unsigned int tdiv;
unsigned long clock_count_per_tick;
};
static struct samsung_pwm_clocksource pwm;
static void samsung_timer_set_prescale(unsigned int channel, u16 prescale)
{
unsigned long flags;
u8 shift = 0;
u32 reg;
if (channel >= 2)
shift = TCFG0_PRESCALER1_SHIFT;
spin_lock_irqsave(&samsung_pwm_lock, flags);
reg = readl(pwm.base + REG_TCFG0);
reg &= ~(TCFG0_PRESCALER_MASK << shift);
reg |= (prescale - 1) << shift;
writel(reg, pwm.base + REG_TCFG0);
spin_unlock_irqrestore(&samsung_pwm_lock, flags);
}
static void samsung_timer_set_divisor(unsigned int channel, u8 divisor)
{
u8 shift = TCFG1_SHIFT(channel);
unsigned long flags;
u32 reg;
u8 bits;
bits = (fls(divisor) - 1) - pwm.variant.div_base;
spin_lock_irqsave(&samsung_pwm_lock, flags);
reg = readl(pwm.base + REG_TCFG1);
reg &= ~(TCFG1_MUX_MASK << shift);
reg |= bits << shift;
writel(reg, pwm.base + REG_TCFG1);
spin_unlock_irqrestore(&samsung_pwm_lock, flags);
}
static void samsung_time_stop(unsigned int channel)
{
unsigned long tcon;
unsigned long flags;
if (channel > 0)
++channel;
spin_lock_irqsave(&samsung_pwm_lock, flags);
tcon = readl_relaxed(pwm.base + REG_TCON);
tcon &= ~TCON_START(channel);
writel_relaxed(tcon, pwm.base + REG_TCON);
spin_unlock_irqrestore(&samsung_pwm_lock, flags);
}
static void samsung_time_setup(unsigned int channel, unsigned long tcnt)
{
unsigned long tcon;
unsigned long flags;
unsigned int tcon_chan = channel;
if (tcon_chan > 0)
++tcon_chan;
spin_lock_irqsave(&samsung_pwm_lock, flags);
tcon = readl_relaxed(pwm.base + REG_TCON);
tcon &= ~(TCON_START(tcon_chan) | TCON_AUTORELOAD(tcon_chan));
tcon |= TCON_MANUALUPDATE(tcon_chan);
Annotation
- Immediate include surface: `linux/interrupt.h`, `linux/irq.h`, `linux/err.h`, `linux/clk.h`, `linux/clockchips.h`, `linux/list.h`, `linux/module.h`, `linux/of.h`.
- Detected declarations: `struct samsung_pwm_clocksource`, `function samsung_timer_set_prescale`, `function samsung_timer_set_divisor`, `function samsung_time_stop`, `function samsung_time_setup`, `function samsung_time_start`, `function samsung_set_next_event`, `function samsung_shutdown`, `function samsung_set_periodic`, `function samsung_clockevent_resume`.
- Atlas domain: Driver Families / drivers/clocksource.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.