arch/powerpc/platforms/chrp/time.c
Source file repositories/reference/linux-study-clean/arch/powerpc/platforms/chrp/time.c
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/platforms/chrp/time.c- Extension
.c- Size
- 4115 bytes
- Lines
- 160
- Domain
- Architecture Layer
- Bucket
- arch/powerpc
- Inferred role
- Architecture Layer: implementation source
- Status
- source 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/errno.hlinux/sched.hlinux/kernel.hlinux/param.hlinux/string.hlinux/mm.hlinux/interrupt.hlinux/time.hlinux/timex.hlinux/kernel_stat.hlinux/mc146818rtc.hlinux/init.hlinux/bcd.hlinux/ioport.hlinux/of_address.hasm/io.hasm/nvram.hasm/sections.hasm/time.hplatforms/chrp/chrp.h
Detected Declarations
function chrp_time_initfunction chrp_cmos_clock_readfunction chrp_cmos_clock_writefunction chrp_set_rtc_timefunction chrp_get_rtc_time
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 1991, 1992, 1995 Linus Torvalds
*
* Adapted for PowerPC (PReP) by Gary Thomas
* Modified by Cort Dougan (cort@cs.nmt.edu).
* Copied and modified from arch/i386/kernel/time.c
*
*/
#include <linux/errno.h>
#include <linux/sched.h>
#include <linux/kernel.h>
#include <linux/param.h>
#include <linux/string.h>
#include <linux/mm.h>
#include <linux/interrupt.h>
#include <linux/time.h>
#include <linux/timex.h>
#include <linux/kernel_stat.h>
#include <linux/mc146818rtc.h>
#include <linux/init.h>
#include <linux/bcd.h>
#include <linux/ioport.h>
#include <linux/of_address.h>
#include <asm/io.h>
#include <asm/nvram.h>
#include <asm/sections.h>
#include <asm/time.h>
#include <platforms/chrp/chrp.h>
#define NVRAM_AS0 0x74
#define NVRAM_AS1 0x75
#define NVRAM_DATA 0x77
static int nvram_as1 = NVRAM_AS1;
static int nvram_as0 = NVRAM_AS0;
static int nvram_data = NVRAM_DATA;
long __init chrp_time_init(void)
{
struct device_node *rtcs;
struct resource r;
int base;
rtcs = of_find_compatible_node(NULL, "rtc", "pnpPNP,b00");
if (rtcs == NULL)
rtcs = of_find_compatible_node(NULL, "rtc", "ds1385-rtc");
if (rtcs == NULL)
return 0;
if (of_address_to_resource(rtcs, 0, &r)) {
of_node_put(rtcs);
return 0;
}
of_node_put(rtcs);
base = r.start;
nvram_as1 = 0;
nvram_as0 = base;
nvram_data = base + 1;
return 0;
}
static int chrp_cmos_clock_read(int addr)
{
if (nvram_as1 != 0)
outb(addr>>8, nvram_as1);
outb(addr, nvram_as0);
return (inb(nvram_data));
}
static void chrp_cmos_clock_write(unsigned long val, int addr)
{
if (nvram_as1 != 0)
outb(addr>>8, nvram_as1);
outb(addr, nvram_as0);
outb(val, nvram_data);
return;
}
/*
* Set the hardware clock. -- Cort
*/
int chrp_set_rtc_time(struct rtc_time *tmarg)
{
unsigned char save_control, save_freq_select;
struct rtc_time tm = *tmarg;
Annotation
- Immediate include surface: `linux/errno.h`, `linux/sched.h`, `linux/kernel.h`, `linux/param.h`, `linux/string.h`, `linux/mm.h`, `linux/interrupt.h`, `linux/time.h`.
- Detected declarations: `function chrp_time_init`, `function chrp_cmos_clock_read`, `function chrp_cmos_clock_write`, `function chrp_set_rtc_time`, `function chrp_get_rtc_time`.
- Atlas domain: Architecture Layer / arch/powerpc.
- 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.