firmware/br-ext-chip-allwinner/board/v83x/kernel/patches/00000-drivers_rtc_rtc-sunxi...

56 lines
1.6 KiB
Diff

diff -drupN a/drivers/rtc/rtc-sunxi-common.h b/drivers/rtc/rtc-sunxi-common.h
--- a/drivers/rtc/rtc-sunxi-common.h 1970-01-01 03:00:00.000000000 +0300
+++ b/drivers/rtc/rtc-sunxi-common.h 2022-06-12 05:28:14.000000000 +0300
@@ -0,0 +1,51 @@
+/*
+ * Some macro and struct of SUNXI.
+ *
+ * Copyright (C) 2018 Allwinner.
+ *
+ * Matteo <duanmintao@allwinnertech.com>
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2. This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ */
+
+#ifndef _RTC_SUNXI_COMMON_H_
+#define _RTC_SUNXI_COMMON_H_
+
+/*
+ * Time unit conversions
+ */
+#define SEC_IN_MIN 60
+#define SEC_IN_HOUR (60 * SEC_IN_MIN)
+#define SEC_IN_DAY (24 * SEC_IN_HOUR)
+
+/*
+ * The year parameter passed to the driver is usually an offset relative to
+ * the year 1900. This macro is used to convert this offset to another one
+ * relative to the minimum year allowed by the hardware.
+ */
+#define SUNXI_YEAR_OFF(x) ((x)->min - 1900)
+
+/*
+ * min and max year are arbitrary set considering the limited range of the
+ * hardware register field
+ */
+struct sunxi_rtc_data_year {
+ unsigned int min; /* min year allowed */
+ unsigned int max; /* max year allowed */
+ unsigned int mask; /* mask for the year field */
+ unsigned int yshift; /* bit shift to get the year */
+ unsigned char leap_shift; /* bit shift to get the leap year */
+};
+
+struct sunxi_rtc_dev {
+ struct rtc_device *rtc;
+ struct device *dev;
+ struct sunxi_rtc_data_year *data_year;
+ void __iomem *base;
+ void __iomem *prcm_base;
+ int irq;
+};
+#endif /* end of _RTC_SUNXI_COMMON_H_ */
+