mirror of
https://github.com/Fishwaldo/build.git
synced 2025-04-17 19:41:37 +00:00
* [Early WIP] Update sunxi-next to kernel 4.17 * Switch Allwinner 32 and 64bit to U-boot 2018.05 * Adjust patched for 4.17.y / sunxi-next - adjust both configurations - removing FAT support from u-boot (breaks if you try to save) Tested those boards: Cubietruck: wlan fails http://ix.io/1fYS USB OK, HDMI yes Bananapi R40: http://ix.io/1fZm USB OK, HDMI yes Lime A64: USB no, HDMI no, wireless buggy, eMMC yes Orangepi prime H5: OK http://ix.io/1fZJ DVFS no Orangepi2e: DVFS OK, HDMI OK, net OK, wifi OK, eMMC ok, http://ix.io/1fZT * Kernel config update, enabling HDMI on CT+ * Trying to fix A64 HDMI but failed. Fixed M64 ethernet instead * Update orangepioneplus.wip * Update orangepioneplus.wip * Fix H6 build process * Add regulator bits for Orangepizero+, thanks to @5kft * add H5 support for optional 1.3v regulator and 1.3GHz operation This patch adds two optional overlays that can be used to: 1) enable the 1.1v/1.3v regulator on boards that provide the necessary compatible H/W support 2) modify the default CPU clock operating table to add new 1.2GHz and 1.3GHz clocks Note that the generated regulator overlay will only support boards whose 1.1v/1.3v regulator is controlled by GPIO PL6. * updates for the NanoPi NEO Plus2 This change introduces a patch that provides two changes for the NanoPi NEO Plus2: * Configure the "cpu0" to use the "vdd_cpux" regulator; this enables the ability to use higher CPU clocks * Correct the configurations of the on-board power and status LEDs * Adjust nightly building and few boards config cleanup
121 lines
4.1 KiB
Diff
121 lines
4.1 KiB
Diff
|
|
This adds a sysfs 'clock_source' attribute which can be used to query
|
|
and set the clock source of the RTC, either 'internal' or 'external'.
|
|
|
|
Important note: Probing the pins of the 32kHz crystal with a scope will
|
|
not reliably tell you whether the (usually) more accurate external is
|
|
selected! On a 'Cubietech Cubietruck' board, the author saw a stable
|
|
32768Hz signal on the crystal, even though the internal oscillator was
|
|
selected and the clock wildly drifting.
|
|
|
|
Using adjtimex might help to figure out which oscillator is selected:
|
|
|
|
~# echo internal > /sys/devices/.../1c20d00.rtc/clock_source
|
|
~# adjtimex -n -c=3
|
|
--- current --- -- suggested --
|
|
cmos time system-cmos error_ppm tick freq tick freq
|
|
1469627826 31.224561
|
|
1469627835 31.858098 63353.6 10000 0
|
|
1469627844 32.490782 63268.4 10000 0 9367 2069425
|
|
~# echo external > /sys/devices/.../1c20d00.rtc/clock_source
|
|
~# adjtimex -n -c=3
|
|
--- current --- -- suggested --
|
|
cmos time system-cmos error_ppm tick freq tick freq
|
|
1469627851 32.883407
|
|
1469627861 32.883380 -2.7 10000 0
|
|
1469627871 32.883352 -2.8 10000 0 10000 185937
|
|
|
|
Signed-off-by: Onno Kortmann <on...@gmx.net>
|
|
---
|
|
drivers/rtc/rtc-sunxi.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++
|
|
1 file changed, 54 insertions(+)
|
|
|
|
diff --git a/drivers/rtc/rtc-sunxi.c b/drivers/rtc/rtc-sunxi.c
|
|
index abada60..3fcf571 100644
|
|
--- a/drivers/rtc/rtc-sunxi.c
|
|
+++ b/drivers/rtc/rtc-sunxi.c
|
|
@@ -36,6 +36,8 @@
|
|
#define SUNXI_LOSC_CTRL 0x0000
|
|
#define SUNXI_LOSC_CTRL_RTC_HMS_ACC BIT(8)
|
|
#define SUNXI_LOSC_CTRL_RTC_YMD_ACC BIT(7)
|
|
+#define SUNXI_LOSC_OSC32K_SRC_SEL BIT(0)
|
|
+#define SUNXI_LOSC_KEY_VALUE 0x16aa0000
|
|
|
|
#define SUNXI_RTC_YMD 0x0004
|
|
|
|
@@ -432,6 +434,50 @@ static const struct of_device_id sunxi_rtc_dt_ids[] = {
|
|
};
|
|
MODULE_DEVICE_TABLE(of, sunxi_rtc_dt_ids);
|
|
|
|
+/* As per page 126 of the A20 manual, the lowest bit in LOSC_CTRL_REG controls
|
|
+ * the 32.768KHz clock source to use for the RTC. Using the clock_source sysfs
|
|
+ * attribute, the clock can be selected between external (accurate 32kHz
|
|
+ * crystal) and internal (seems to be an inaccurate RC oscillator) mode. It
|
|
+ * appears that this bit is non-volatile and will be kept in the RTC when the
|
|
+ * system is powered off.
|
|
+ */
|
|
+static ssize_t sunxi_rtc_show_clock_source(struct device *dev,
|
|
+ struct device_attribute *attr,
|
|
+ char *buf)
|
|
+{
|
|
+ struct sunxi_rtc_dev *chip = dev_get_drvdata(dev);
|
|
+ u32 val = readl(chip->base + SUNXI_LOSC_CTRL);
|
|
+ if (val & SUNXI_LOSC_OSC32K_SRC_SEL)
|
|
+ return sprintf(buf, "internal [external]\n");
|
|
+ else
|
|
+ return sprintf(buf, "[internal] external\n");
|
|
+}
|
|
+
|
|
+static ssize_t sunxi_rtc_store_clock_source(struct device *dev,
|
|
+ struct device_attribute *attr,
|
|
+ const char *buf, size_t count) {
|
|
+ struct sunxi_rtc_dev *chip = dev_get_drvdata(dev);
|
|
+ u32 val = readl(chip->base + SUNXI_LOSC_CTRL);
|
|
+
|
|
+ if (strncmp(buf, "external", 8) == 0)
|
|
+ val|=SUNXI_LOSC_OSC32K_SRC_SEL;
|
|
+ else if (strncmp(buf, "internal", 8) == 0)
|
|
+ val&=~SUNXI_LOSC_OSC32K_SRC_SEL;
|
|
+ else
|
|
+ return -EINVAL;
|
|
+
|
|
+ /* Writing this bit requires setting the upper 16 bit to 0x16aa (key
|
|
+ * value). */
|
|
+ val |= SUNXI_LOSC_KEY_VALUE;
|
|
+
|
|
+ writel(val, chip->base + SUNXI_LOSC_CTRL);
|
|
+ return count;
|
|
+}
|
|
+
|
|
+static DEVICE_ATTR(clock_source, S_IRUGO | S_IWUSR,
|
|
+ sunxi_rtc_show_clock_source,
|
|
+ sunxi_rtc_store_clock_source);
|
|
+
|
|
static int sunxi_rtc_probe(struct platform_device *pdev)
|
|
{
|
|
struct sunxi_rtc_dev *chip;
|
|
@@ -490,6 +536,13 @@ static int sunxi_rtc_probe(struct platform_device *pdev)
|
|
|
|
dev_info(&pdev->dev, "RTC enabled\n");
|
|
|
|
+ ret = device_create_file(&pdev->dev, &dev_attr_clock_source);
|
|
+ if (ret) {
|
|
+ dev_err(&pdev->dev, "Unable to create sysfs entry: %s\n",
|
|
+ dev_attr_clock_source.attr.name);
|
|
+ return ret;
|
|
+ }
|
|
+
|
|
return 0;
|
|
}
|
|
|
|
@@ -499,6 +552,7 @@ static int sunxi_rtc_remove(struct platform_device *pdev)
|
|
|
|
rtc_device_unregister(chip->rtc);
|
|
|
|
+ device_remove_file(&pdev->dev, &dev_attr_clock_source);
|
|
return 0;
|
|
}
|
|
|
|
--
|
|
2.2.0.34.gb8f29bf
|
|
|