drivers/rtc/rtc-gamecube.c
Source file repositories/reference/linux-study-clean/drivers/rtc/rtc-gamecube.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/rtc/rtc-gamecube.c- Extension
.c- Size
- 10490 bytes
- Lines
- 383
- Domain
- Driver Families
- Bucket
- drivers/rtc
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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/init.hlinux/module.hlinux/of.hlinux/of_address.hlinux/platform_device.hlinux/regmap.hlinux/rtc.hlinux/time.h
Detected Declarations
struct privfunction exi_readfunction exi_writefunction gamecube_rtc_read_timefunction gamecube_rtc_set_timefunction gamecube_rtc_ioctlfunction gamecube_rtc_read_offset_from_sramfunction gamecube_rtc_probe
Annotated Snippet
struct priv {
struct regmap *regmap;
void __iomem *iob;
u32 rtc_bias;
};
static int exi_read(void *context, u32 reg, u32 *data)
{
struct priv *d = (struct priv *)context;
void __iomem *iob = d->iob;
/* The spin loops here loop about 15~16 times each, so there is no need
* to use a more expensive sleep method.
*/
/* Write register offset */
iowrite32be(RTC_EXICSR, iob + EXICSR);
iowrite32be(reg << 8, iob + EXIDATA);
iowrite32be(RTC_EXICR_W, iob + EXICR);
while (!(ioread32be(iob + EXICSR) & EXICSR_INTSET))
cpu_relax();
/* Read data */
iowrite32be(RTC_EXICSR, iob + EXICSR);
iowrite32be(RTC_EXICR_R, iob + EXICR);
while (!(ioread32be(iob + EXICSR) & EXICSR_INTSET))
cpu_relax();
*data = ioread32be(iob + EXIDATA);
/* Clear channel parameters */
iowrite32be(0, iob + EXICSR);
return 0;
}
static int exi_write(void *context, u32 reg, u32 data)
{
struct priv *d = (struct priv *)context;
void __iomem *iob = d->iob;
/* The spin loops here loop about 15~16 times each, so there is no need
* to use a more expensive sleep method.
*/
/* Write register offset */
iowrite32be(RTC_EXICSR, iob + EXICSR);
iowrite32be(RTC_EXIDATA_W | (reg << 8), iob + EXIDATA);
iowrite32be(RTC_EXICR_W, iob + EXICR);
while (!(ioread32be(iob + EXICSR) & EXICSR_INTSET))
cpu_relax();
/* Write data */
iowrite32be(RTC_EXICSR, iob + EXICSR);
iowrite32be(data, iob + EXIDATA);
iowrite32be(RTC_EXICR_W, iob + EXICR);
while (!(ioread32be(iob + EXICSR) & EXICSR_INTSET))
cpu_relax();
/* Clear channel parameters */
iowrite32be(0, iob + EXICSR);
return 0;
}
static const struct regmap_bus exi_bus = {
/* TODO: is that true? Not that it matters here, but still. */
.fast_io = true,
.reg_read = exi_read,
.reg_write = exi_write,
};
static int gamecube_rtc_read_time(struct device *dev, struct rtc_time *t)
{
struct priv *d = dev_get_drvdata(dev);
int ret;
u32 counter;
time64_t timestamp;
ret = regmap_read(d->regmap, RTC_COUNTER, &counter);
if (ret)
return ret;
/* Add the counter and the bias to obtain the timestamp */
timestamp = (time64_t)d->rtc_bias + counter;
rtc_time64_to_tm(timestamp, t);
return 0;
}
static int gamecube_rtc_set_time(struct device *dev, struct rtc_time *t)
Annotation
- Immediate include surface: `linux/init.h`, `linux/module.h`, `linux/of.h`, `linux/of_address.h`, `linux/platform_device.h`, `linux/regmap.h`, `linux/rtc.h`, `linux/time.h`.
- Detected declarations: `struct priv`, `function exi_read`, `function exi_write`, `function gamecube_rtc_read_time`, `function gamecube_rtc_set_time`, `function gamecube_rtc_ioctl`, `function gamecube_rtc_read_offset_from_sram`, `function gamecube_rtc_probe`.
- Atlas domain: Driver Families / drivers/rtc.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
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.