arch/powerpc/platforms/52xx/mpc52xx_gpt.c
Source file repositories/reference/linux-study-clean/arch/powerpc/platforms/52xx/mpc52xx_gpt.c
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/platforms/52xx/mpc52xx_gpt.c- Extension
.c- Size
- 22741 bytes
- Lines
- 781
- Domain
- Architecture Layer
- Bucket
- arch/powerpc
- Inferred role
- Architecture Layer: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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/gpio/driver.hlinux/irq.hlinux/interrupt.hlinux/io.hlinux/list.hlinux/mutex.hlinux/of.hlinux/of_address.hlinux/of_irq.hlinux/platform_device.hlinux/kernel.hlinux/property.hlinux/slab.hlinux/fs.hlinux/watchdog.hlinux/miscdevice.hlinux/uaccess.hlinux/module.hasm/div64.hasm/mpc52xx.h
Detected Declarations
struct mpc52xx_gpt_privfunction mpc52xx_gpt_irq_unmaskfunction mpc52xx_gpt_irq_maskfunction mpc52xx_gpt_irq_ackfunction mpc52xx_gpt_irq_set_typefunction mpc52xx_gpt_irq_cascadefunction mpc52xx_gpt_irq_mapfunction mpc52xx_gpt_irq_xlatefunction mpc52xx_gpt_irq_setupfunction mpc52xx_gpt_gpio_getfunction mpc52xx_gpt_gpio_setfunction mpc52xx_gpt_gpio_dir_infunction mpc52xx_gpt_gpio_dir_outfunction mpc52xx_gpt_gpio_setupfunction mpc52xx_gpt_gpio_setupfunction mpc52xx_gpt_do_startfunction mpc52xx_gpt_start_timerfunction mpc52xx_gpt_stop_timerfunction mpc52xx_gpt_timer_periodfunction mpc52xx_gpt_wdt_pingfunction mpc52xx_wdt_writefunction mpc52xx_wdt_ioctlfunction mpc52xx_wdt_openfunction mpc52xx_wdt_releasefunction mpc52xx_gpt_wdt_initfunction mpc52xx_gpt_wdt_setupfunction mpc52xx_gpt_wdt_initfunction mpc52xx_gpt_wdt_setupfunction mpc52xx_gpt_probefunction of_property_read_boolfunction mpc52xx_gpt_initmodule init mpc52xx_gpt_initmodule init mpc52xx_gpt_wdt_initexport mpc52xx_gpt_from_irqexport mpc52xx_gpt_start_timerexport mpc52xx_gpt_stop_timerexport mpc52xx_gpt_timer_period
Annotated Snippet
static const struct file_operations mpc52xx_wdt_fops = {
.owner = THIS_MODULE,
.write = mpc52xx_wdt_write,
.unlocked_ioctl = mpc52xx_wdt_ioctl,
.compat_ioctl = compat_ptr_ioctl,
.open = mpc52xx_wdt_open,
.release = mpc52xx_wdt_release,
};
static struct miscdevice mpc52xx_wdt_miscdev = {
.minor = WATCHDOG_MINOR,
.name = "watchdog",
.fops = &mpc52xx_wdt_fops,
};
static int mpc52xx_gpt_wdt_init(void)
{
int err;
/* try to register the watchdog misc device */
err = misc_register(&mpc52xx_wdt_miscdev);
if (err)
pr_err("%s: cannot register watchdog device\n", WDT_IDENTITY);
else
pr_info("%s: watchdog device registered\n", WDT_IDENTITY);
return err;
}
static int mpc52xx_gpt_wdt_setup(struct mpc52xx_gpt_priv *gpt,
const u32 *period)
{
u64 real_timeout;
/* remember the gpt for the wdt operation */
mpc52xx_gpt_wdt = gpt;
/* configure the wdt if the device tree contained a timeout */
if (!period || *period == 0)
return 0;
real_timeout = (u64) *period * 1000000000ULL;
if (mpc52xx_gpt_do_start(gpt, real_timeout, 0, 1))
dev_warn(gpt->dev, "starting as wdt failed\n");
else
dev_info(gpt->dev, "watchdog set to %us timeout\n", *period);
return 0;
}
#else
static int mpc52xx_gpt_wdt_init(void)
{
return 0;
}
static inline int mpc52xx_gpt_wdt_setup(struct mpc52xx_gpt_priv *gpt,
const u32 *period)
{
return 0;
}
#endif /* CONFIG_MPC5200_WDT */
/* ---------------------------------------------------------------------
* of_platform bus binding code
*/
static int mpc52xx_gpt_probe(struct platform_device *ofdev)
{
struct mpc52xx_gpt_priv *gpt;
gpt = devm_kzalloc(&ofdev->dev, sizeof *gpt, GFP_KERNEL);
if (!gpt)
return -ENOMEM;
raw_spin_lock_init(&gpt->lock);
gpt->dev = &ofdev->dev;
gpt->ipb_freq = mpc5xxx_get_bus_frequency(&ofdev->dev);
gpt->regs = of_iomap(ofdev->dev.of_node, 0);
if (!gpt->regs)
return -ENOMEM;
dev_set_drvdata(&ofdev->dev, gpt);
mpc52xx_gpt_gpio_setup(gpt);
mpc52xx_gpt_irq_setup(gpt, ofdev->dev.of_node);
mutex_lock(&mpc52xx_gpt_list_mutex);
list_add(&gpt->list, &mpc52xx_gpt_list);
mutex_unlock(&mpc52xx_gpt_list_mutex);
Annotation
- Immediate include surface: `linux/gpio/driver.h`, `linux/irq.h`, `linux/interrupt.h`, `linux/io.h`, `linux/list.h`, `linux/mutex.h`, `linux/of.h`, `linux/of_address.h`.
- Detected declarations: `struct mpc52xx_gpt_priv`, `function mpc52xx_gpt_irq_unmask`, `function mpc52xx_gpt_irq_mask`, `function mpc52xx_gpt_irq_ack`, `function mpc52xx_gpt_irq_set_type`, `function mpc52xx_gpt_irq_cascade`, `function mpc52xx_gpt_irq_map`, `function mpc52xx_gpt_irq_xlate`, `function mpc52xx_gpt_irq_setup`, `function mpc52xx_gpt_gpio_get`.
- Atlas domain: Architecture Layer / arch/powerpc.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.