staticconststruct 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,
};
/* Subtract the timestamp and the bias to obtain the counter value */
timestamp = rtc_tm_to_time64(t); return regmap_write(d->regmap, RTC_COUNTER, timestamp - d->rtc_bias);
}
staticint gamecube_rtc_ioctl(struct device *dev, unsignedint cmd, unsignedlong arg)
{ struct priv *d = dev_get_drvdata(dev); int value; int control0; int ret;
switch (cmd) { case RTC_VL_READ:
ret = regmap_read(d->regmap, RTC_CONTROL0, &control0); if (ret) return ret;
value = 0; if (control0 & RTC_CONTROL0_UNSTABLE_POWER)
value |= RTC_VL_DATA_INVALID; if (control0 & RTC_CONTROL0_LOW_BATTERY)
value |= RTC_VL_BACKUP_LOW; return put_user(value, (unsignedint __user *)arg);
np = of_find_compatible_node(NULL, NULL, "nintendo,latte-srnprot"); if (!np)
np = of_find_compatible_node(NULL, NULL, "nintendo,hollywood-srnprot"); if (!np) {
pr_info("HW_SRNPROT not found, assuming a GameCube\n"); return regmap_read(d->regmap, RTC_SRAM_BIAS, &d->rtc_bias);
}
ret = of_address_to_resource(np, 0, &res);
of_node_put(np); if (ret) {
pr_err("no io memory range found\n"); return -1;
}
hw_srnprot = ioremap(res.start, resource_size(&res));
old = ioread32be(hw_srnprot);
/* TODO: figure out why we use this magic constant. I obtained it by *readingtheleftovervalueafterboot,afterIOSUalreadyran. * *OnmyWiiU,settingthisregisterto1preventstheconsolefrom *rebootingproperly,sowiiubrew.orgmustbemissingsomething. * *Seehttps://wiiubrew.org/wiki/Hardware/Latte_registers
*/ if (old != 0x7bf)
iowrite32be(0x7bf, hw_srnprot);
/* Get the offset from RTC SRAM. * *ItsdefaultlocationontheGameCubeandontheWiiisintheSRAM, *whileontheWiiUthebootloaderneedstofillitwiththecontents *of/config/rtc.xmlontheSLC(theeMMC).Wedon’tdothatfrom *Linuxsinceitrequiresimplementingaproprietaryfilesystemanddo *filedecryption,insteadwerequirethebootloadertofillthesame *SRAMaddressasonpreviousconsoles.
*/
ret = regmap_read(d->regmap, RTC_SRAM_BIAS, &d->rtc_bias);
/* Reset SRAM access to how it was before, our job here is done. */ if (old != 0x7bf)
iowrite32be(old, hw_srnprot);
d = devm_kzalloc(dev, sizeof(struct priv), GFP_KERNEL); if (!d) return -ENOMEM;
d->iob = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(d->iob)) return PTR_ERR(d->iob);
d->regmap = devm_regmap_init(dev, &exi_bus, d,
&gamecube_rtc_regmap_config); if (IS_ERR(d->regmap)) return PTR_ERR(d->regmap);
ret = gamecube_rtc_read_offset_from_sram(d); if (ret) return ret;
dev_dbg(dev, "SRAM bias: 0x%x", d->rtc_bias);
dev_set_drvdata(dev, d);
rtc = devm_rtc_allocate_device(dev); if (IS_ERR(rtc)) return PTR_ERR(rtc);
/* We can represent further than that, but it depends on the stored *biasandwecan’tmodifyitpersistentlyonallsupportedconsoles, *soherewepretendtobelimitedto2106.
*/
rtc->range_min = 0;
rtc->range_max = U32_MAX;
rtc->ops = &gamecube_rtc_ops;
MODULE_AUTHOR("Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>");
MODULE_DESCRIPTION("Nintendo GameCube, Wii and Wii U RTC driver");
MODULE_LICENSE("GPL");
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.11 Sekunden
(vorverarbeitet am 2026-09-29)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.