#include <linux/iopoll.h>
#include <linux/module.h>
#include <linux/mod_devicetable.h>
+#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/rtc.h>
#define RZN1_RTC_TIMEC 0x68
#define RZN1_RTC_CALC 0x6c
+struct rzn1_rtc_data {
+ bool has_subu;
+};
+
struct rzn1_rtc {
struct rtc_device *rtcdev;
void __iomem *base;
static int rzn1_rtc_probe(struct platform_device *pdev)
{
+ const struct rzn1_rtc_data *data;
struct device *dev = &pdev->dev;
unsigned long rate = 32768;
struct rzn1_rtc *rtc;
struct clk *xtal;
int irq, ret;
+ data = of_device_get_match_data(dev);
+ if (!data)
+ return -ENODEV;
+
rtc = devm_kzalloc(dev, sizeof(*rtc), GFP_KERNEL);
if (!rtc)
return -ENOMEM;
if (rate < 32000 || rate > BIT(22))
return -EOPNOTSUPP;
- if (rate != 32768)
+ if (rate != 32768 || !data->has_subu)
scmp_val = RZN1_RTC_CTL0_SLSB_SCMP;
+ } else if (!data->has_subu) {
+ /* xtal is NULL here */
+ return dev_err_probe(dev, -EOPNOTSUPP,
+ "No valid XTAL provided and SUBU mode not supported\n");
}
/* Calculate the duration of two RTC_PCLK clock cycles */
return devm_rtc_register_device(rtc->rtcdev);
}
+static const struct rzn1_rtc_data rzn1_rtc_rzn1_data = {
+ .has_subu = true,
+};
+
static const struct of_device_id rzn1_rtc_of_match[] = {
- { .compatible = "renesas,rzn1-rtc" },
+ { .compatible = "renesas,rzn1-rtc", .data = &rzn1_rtc_rzn1_data },
{},
};
MODULE_DEVICE_TABLE(of, rzn1_rtc_of_match);