/* * Note on RYRAR and RCR3: Up until this point most of the register * definitions are consistent across all of the available parts. However, * the placement of the optional RYRAR and RCR3 (the RYRAR control * register used to control RYRCNT/RYRAR compare) varies considerably * across various parts, occasionally being mapped in to a completely * unrelated address space. For proper RYRAR support a separate resource * would have to be handed off, but as this is purely optional in * practice, we simply opt not to support it, thereby keeping the code * quite a bit more simplified.
*/
/* ALARM Bits - or with BCD encoded value */ #define AR_ENB BIT(7) /* Enable for alarm cmp */
staticinlinevoid sh_rtc_write_alarm_value(struct sh_rtc *rtc, int value, int reg_off)
{ /* < 0 for a value that is ignored */ if (value < 0)
writeb(0, rtc->regbase + reg_off); else
writeb(bin2bcd(value) | AR_ENB, rtc->regbase + reg_off);
}
rtc = devm_kzalloc(&pdev->dev, sizeof(*rtc), GFP_KERNEL); if (unlikely(!rtc)) return -ENOMEM;
spin_lock_init(&rtc->lock);
ret = platform_get_irq(pdev, 0); if (unlikely(ret <= 0)) {
dev_err(&pdev->dev, "No IRQ resource\n"); return -ENOENT;
}
if (!pdev->dev.of_node)
rtc->alarm_irq = platform_get_irq(pdev, 2); else
rtc->alarm_irq = ret;
res = platform_get_resource(pdev, IORESOURCE_IO, 0); if (!res)
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) {
dev_err(&pdev->dev, "No IO resource\n"); return -ENOENT;
}
rtc->clk = devm_clk_get(&pdev->dev, clk_name); if (IS_ERR(rtc->clk)) { /* * No error handling for rtc->clk intentionally, not all * platforms will have a unique clock for the RTC, and * the clk API can handle the struct clk pointer being * NULL.
*/
rtc->clk = NULL;
}
rtc->rtc_dev = devm_rtc_allocate_device(&pdev->dev); if (IS_ERR(rtc->rtc_dev)) return PTR_ERR(rtc->rtc_dev);
clk_enable(rtc->clk);
rtc->capabilities = RTC_DEF_CAPABILITIES;
#ifdef CONFIG_SUPERH if (dev_get_platdata(&pdev->dev)) { struct sh_rtc_platform_info *pinfo =
dev_get_platdata(&pdev->dev);
/* * Some CPUs have special capabilities in addition to the * default set. Add those in here.
*/
rtc->capabilities |= pinfo->capabilities;
} #endif
ret = devm_request_irq(&pdev->dev, rtc->alarm_irq, sh_rtc_alarm, 0, "sh-rtc", rtc); if (ret) {
dev_err(&pdev->dev, "request alarm IRQ failed with %d, IRQ %d\n",
ret, rtc->alarm_irq); goto err_unmap;
}
/* * sh_rtc_remove() lives in .exit.text. For drivers registered via * module_platform_driver_probe() this is ok because they cannot get unbound at * runtime. So mark the driver struct with __refdata to prevent modpost * triggering a section mismatch warning.
*/ staticstruct platform_driver sh_rtc_platform_driver __refdata = {
.driver = {
.name = DRV_NAME,
.pm = pm_sleep_ptr(&sh_rtc_pm_ops),
.of_match_table = sh_rtc_of_match,
},
.remove = __exit_p(sh_rtc_remove),
};
¤ 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.0.12Bemerkung:
(vorverarbeitet am 2026-06-08)
¤
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.