* [PATCH 0/4] rtc: ls2x: Add support for the Loongson-2K/LS7A RTC @ 2020-09-23 7:58 WANG Xuerui 2020-09-23 7:58 ` [PATCH 1/4] " WANG Xuerui ` (3 more replies) 0 siblings, 4 replies; 12+ messages in thread From: WANG Xuerui @ 2020-09-23 7:58 UTC (permalink / raw) To: linux-rtc; +Cc: WANG Xuerui, linux-mips, devicetree This patch series adds support for the RTC module found on various Loongson systems with the Loongson-2K SoC or the LS7A bridge chip. The driver is rewritten from an out-of-tree version to meet mainline standards. I write kernel code as a hobby, though, so there might still be overlooked issues. Any suggestions are welcome. Note when applying this series: the 3rd patch depends on commit 262623961478836b from the mips-next tree, so the series should preferably go in via mips-next. Otherwise the patch will conflict in the merge window anyway. WANG Xuerui (4): rtc: ls2x: Add support for the Loongson-2K/LS7A RTC dt-bindings: rtc: Add bindings for LS2X RTC MIPS: Loongson64: DTS: Add RTC support to LS7A MIPS: Loongson: Enable LS2X RTC in loongson3_defconfig .../devicetree/bindings/rtc/trivial-rtc.yaml | 2 + arch/mips/boot/dts/loongson/ls7a-pch.dtsi | 5 + arch/mips/configs/loongson3_defconfig | 1 + drivers/rtc/Kconfig | 11 + drivers/rtc/Makefile | 1 + drivers/rtc/rtc-ls2x.c | 225 ++++++++++++++++++ 6 files changed, 245 insertions(+) create mode 100644 drivers/rtc/rtc-ls2x.c -- 2.28.0 ^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 1/4] rtc: ls2x: Add support for the Loongson-2K/LS7A RTC 2020-09-23 7:58 [PATCH 0/4] rtc: ls2x: Add support for the Loongson-2K/LS7A RTC WANG Xuerui @ 2020-09-23 7:58 ` WANG Xuerui 2020-09-23 9:54 ` Tiezhu Yang 2020-09-23 13:50 ` Jiaxun Yang 2020-09-23 7:58 ` [PATCH 2/4] dt-bindings: rtc: Add bindings for LS2X RTC WANG Xuerui ` (2 subsequent siblings) 3 siblings, 2 replies; 12+ messages in thread From: WANG Xuerui @ 2020-09-23 7:58 UTC (permalink / raw) To: linux-rtc; +Cc: WANG Xuerui, linux-mips, devicetree, Huacai Chen This RTC module is integrated into the Loongson-2K SoC and the LS7A bridge chip. This version is almost entirely rewritten to make use of current kernel API. Signed-off-by: Huacai Chen <chenhc@lemote.com> Signed-off-by: WANG Xuerui <git@xen0n.name> --- drivers/rtc/Kconfig | 11 ++ drivers/rtc/Makefile | 1 + drivers/rtc/rtc-ls2x.c | 225 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 237 insertions(+) create mode 100644 drivers/rtc/rtc-ls2x.c diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index 48c536acd777..41b96633abf3 100644 --- a/drivers/rtc/Kconfig +++ b/drivers/rtc/Kconfig @@ -1301,6 +1301,17 @@ config RTC_DRV_CROS_EC This driver can also be built as a module. If so, the module will be called rtc-cros-ec. +config RTC_DRV_LS2X + tristate "Loongson LS2X RTC" + depends on MACH_LOONGSON64 || COMPILE_TEST + select REGMAP_MMIO + help + If you say yes here you get support for the RTC on the Loongson-2K + SoC and LS7A bridge, which first appeared on the Loongson-2H. + + This driver can also be built as a module. If so, the module + will be called rtc-ls2x. + comment "on-CPU RTC drivers" config RTC_DRV_ASM9260 diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile index 880e08a409c3..ade72f6a2435 100644 --- a/drivers/rtc/Makefile +++ b/drivers/rtc/Makefile @@ -84,6 +84,7 @@ obj-$(CONFIG_RTC_DRV_LOONGSON1) += rtc-ls1x.o obj-$(CONFIG_RTC_DRV_LP8788) += rtc-lp8788.o obj-$(CONFIG_RTC_DRV_LPC24XX) += rtc-lpc24xx.o obj-$(CONFIG_RTC_DRV_LPC32XX) += rtc-lpc32xx.o +obj-$(CONFIG_RTC_DRV_LS2X) += rtc-ls2x.o obj-$(CONFIG_RTC_DRV_M41T80) += rtc-m41t80.o obj-$(CONFIG_RTC_DRV_M41T93) += rtc-m41t93.o obj-$(CONFIG_RTC_DRV_M41T94) += rtc-m41t94.o diff --git a/drivers/rtc/rtc-ls2x.c b/drivers/rtc/rtc-ls2x.c new file mode 100644 index 000000000000..e49cbaceccc2 --- /dev/null +++ b/drivers/rtc/rtc-ls2x.c @@ -0,0 +1,225 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Loongson-2K/7A RTC driver + * + * Based on the out-of-tree Loongson-2H RTC driver for Linux 2.6.32, by + * Shaozong Liu <liushaozong@loongson.cn>. + * + * Maintained out-of-tree by Huacai Chen <chenhc@lemote.com>. + * + * Rewritten for mainline by WANG Xuerui <git@xen0n.name>. + */ + +#include <linux/module.h> +#include <linux/platform_device.h> +#include <linux/regmap.h> +#include <linux/rtc.h> +#include <linux/spinlock.h> + +#define TOY_TRIM_REG 0x20 +#define TOY_WRITE0_REG 0x24 +#define TOY_WRITE1_REG 0x28 +#define TOY_READ0_REG 0x2c +#define TOY_READ1_REG 0x30 +#define TOY_MATCH0_REG 0x34 +#define TOY_MATCH1_REG 0x38 +#define TOY_MATCH2_REG 0x3c +#define RTC_CTRL_REG 0x40 +#define RTC_TRIM_REG 0x60 +#define RTC_WRITE0_REG 0x64 +#define RTC_READ0_REG 0x68 +#define RTC_MATCH0_REG 0x6c +#define RTC_MATCH1_REG 0x70 +#define RTC_MATCH2_REG 0x74 + +#define TOY_MON GENMASK(31, 26) +#define TOY_MON_SHIFT 26 +#define TOY_DAY GENMASK(25, 21) +#define TOY_DAY_SHIFT 21 +#define TOY_HOUR GENMASK(20, 16) +#define TOY_HOUR_SHIFT 16 +#define TOY_MIN GENMASK(15, 10) +#define TOY_MIN_SHIFT 10 +#define TOY_SEC GENMASK(9, 4) +#define TOY_SEC_SHIFT 4 +#define TOY_MSEC GENMASK(3, 0) +#define TOY_MSEC_SHIFT 0 + +struct ls2x_rtc_priv { + struct regmap *regmap; + spinlock_t lock; +}; + +static const struct regmap_config ls2x_rtc_regmap_config = { + .reg_bits = 32, + .val_bits = 32, + .reg_stride = 4, +}; + +struct ls2x_rtc_regs { + u32 reg0; + u32 reg1; +}; + +static inline void ls2x_rtc_regs_to_time(struct ls2x_rtc_regs *regs, + struct rtc_time *tm) +{ + tm->tm_year = regs->reg1; + tm->tm_sec = (regs->reg0 & TOY_SEC) >> TOY_SEC_SHIFT; + tm->tm_min = (regs->reg0 & TOY_MIN) >> TOY_MIN_SHIFT; + tm->tm_hour = (regs->reg0 & TOY_HOUR) >> TOY_HOUR_SHIFT; + tm->tm_mday = (regs->reg0 & TOY_DAY) >> TOY_DAY_SHIFT; + tm->tm_mon = ((regs->reg0 & TOY_MON) >> TOY_MON_SHIFT) - 1; +} + +static inline void ls2x_rtc_time_to_regs(struct rtc_time *tm, + struct ls2x_rtc_regs *regs) +{ + regs->reg0 = (tm->tm_sec << TOY_SEC_SHIFT) & TOY_SEC; + regs->reg0 |= (tm->tm_min << TOY_MIN_SHIFT) & TOY_MIN; + regs->reg0 |= (tm->tm_hour << TOY_HOUR_SHIFT) & TOY_HOUR; + regs->reg0 |= (tm->tm_mday << TOY_DAY_SHIFT) & TOY_DAY; + regs->reg0 |= ((tm->tm_mon + 1) << TOY_MON_SHIFT) & TOY_MON; + regs->reg1 = tm->tm_year; +} + +static int ls2x_rtc_read_time(struct device *dev, struct rtc_time *tm) +{ + struct ls2x_rtc_priv *priv = dev_get_drvdata(dev); + struct ls2x_rtc_regs regs; + int ret; + + spin_lock_irq(&priv->lock); + + ret = regmap_read(priv->regmap, TOY_READ1_REG, ®s.reg1); + if (unlikely(ret)) { + dev_err(dev, "Failed to read time: %d\n", ret); + goto fail; + } + + ret = regmap_read(priv->regmap, TOY_READ0_REG, ®s.reg0); + if (unlikely(ret)) { + dev_err(dev, "Failed to read time: %d\n", ret); + goto fail; + } + + spin_unlock_irq(&priv->lock); + + ls2x_rtc_regs_to_time(®s, tm); + + return 0; + +fail: + spin_unlock_irq(&priv->lock); + return ret; +} + +static int ls2x_rtc_set_time(struct device *dev, struct rtc_time *tm) +{ + struct ls2x_rtc_priv *priv = dev_get_drvdata(dev); + struct ls2x_rtc_regs regs; + int ret; + + ls2x_rtc_time_to_regs(tm, ®s); + + spin_lock_irq(&priv->lock); + + ret = regmap_write(priv->regmap, TOY_WRITE0_REG, regs.reg0); + if (unlikely(ret)) { + dev_err(dev, "Failed to set time: %d\n", ret); + goto fail; + } + + ret = regmap_write(priv->regmap, TOY_WRITE1_REG, regs.reg1); + if (unlikely(ret)) { + dev_err(dev, "Failed to set time: %d\n", ret); + goto fail; + } + + spin_unlock_irq(&priv->lock); + + return 0; + +fail: + spin_unlock_irq(&priv->lock); + return ret; +} + +static struct rtc_class_ops ls2x_rtc_ops = { + .read_time = ls2x_rtc_read_time, + .set_time = ls2x_rtc_set_time, +}; + +static int ls2x_rtc_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct rtc_device *rtc; + struct ls2x_rtc_priv *priv; + void __iomem *regs; + int ret; + + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); + if (unlikely(!priv)) + return -ENOMEM; + + spin_lock_init(&priv->lock); + platform_set_drvdata(pdev, priv); + + regs = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(regs)) { + ret = PTR_ERR(regs); + dev_err(dev, "Failed to map rtc registers: %d\n", ret); + return ret; + } + + priv->regmap = devm_regmap_init_mmio(dev, regs, + &ls2x_rtc_regmap_config); + if (IS_ERR(priv->regmap)) { + ret = PTR_ERR(priv->regmap); + dev_err(dev, "Failed to init regmap: %d\n", ret); + return ret; + } + + rtc = devm_rtc_allocate_device(dev); + if (IS_ERR(rtc)) { + ret = PTR_ERR(rtc); + dev_err(dev, "Failed to allocate rtc device: %d\n", ret); + return ret; + } + + rtc->ops = &ls2x_rtc_ops; + + /* Due to hardware erratum, all years multiple of 4 are considered + * leap year, so only years 2000 through 2099 are usable. + * + * Previous out-of-tree versions of this driver wrote tm_year directly + * into the year register, so epoch 2000 must be used to preserve + * semantics on shipped systems. + */ + rtc->range_min = RTC_TIMESTAMP_BEGIN_2000; + rtc->range_max = RTC_TIMESTAMP_END_2099; + + return rtc_register_device(rtc); +} + +static const struct of_device_id ls2x_rtc_of_match[] = { + { .compatible = "loongson,ls2x-rtc" }, + { /* sentinel */ }, +}; +MODULE_DEVICE_TABLE(of, ls2x_rtc_of_match); + +static struct platform_driver ls2x_rtc_driver = { + .probe = ls2x_rtc_probe, + .driver = { + .name = "ls2x-rtc", + .of_match_table = of_match_ptr(ls2x_rtc_of_match), + }, +}; + +module_platform_driver(ls2x_rtc_driver); + +MODULE_DESCRIPTION("LS2X RTC driver"); +MODULE_AUTHOR("WANG Xuerui"); +MODULE_AUTHOR("Huacai Chen"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:ls2x-rtc"); -- 2.28.0 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 1/4] rtc: ls2x: Add support for the Loongson-2K/LS7A RTC 2020-09-23 7:58 ` [PATCH 1/4] " WANG Xuerui @ 2020-09-23 9:54 ` Tiezhu Yang 2020-09-23 14:31 ` Du Huanpeng 2020-09-24 7:32 ` WANG Xuerui 2020-09-23 13:50 ` Jiaxun Yang 1 sibling, 2 replies; 12+ messages in thread From: Tiezhu Yang @ 2020-09-23 9:54 UTC (permalink / raw) To: WANG Xuerui, linux-rtc; +Cc: linux-mips, devicetree, Huacai Chen On 09/23/2020 03:58 PM, WANG Xuerui wrote: > This RTC module is integrated into the Loongson-2K SoC and the LS7A > bridge chip. This version is almost entirely rewritten to make use of > current kernel API. > > Signed-off-by: Huacai Chen <chenhc@lemote.com> > Signed-off-by: WANG Xuerui <git@xen0n.name> > --- > drivers/rtc/Kconfig | 11 ++ > drivers/rtc/Makefile | 1 + > drivers/rtc/rtc-ls2x.c | 225 +++++++++++++++++++++++++++++++++++++++++ > 3 files changed, 237 insertions(+) > create mode 100644 drivers/rtc/rtc-ls2x.c > > diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig > index 48c536acd777..41b96633abf3 100644 > --- a/drivers/rtc/Kconfig > +++ b/drivers/rtc/Kconfig > @@ -1301,6 +1301,17 @@ config RTC_DRV_CROS_EC > This driver can also be built as a module. If so, the module > will be called rtc-cros-ec. > > +config RTC_DRV_LS2X > + tristate "Loongson LS2X RTC" > + depends on MACH_LOONGSON64 || COMPILE_TEST > + select REGMAP_MMIO > + help > + If you say yes here you get support for the RTC on the Loongson-2K > + SoC and LS7A bridge, which first appeared on the Loongson-2H. > + > + This driver can also be built as a module. If so, the module > + will be called rtc-ls2x. > + Hi Xuerui, rtc-ls2x --> rtc-ls2x-ls7a RTC_DRV_LS2X --> RTC_DRV_LS2X_LS7A Loongson LS2X RTC --> Loongson LS2X/LS7A RTC Maybe the related names include ls7a or LS7A is better to reflect the reality? Thanks, Tiezhu > comment "on-CPU RTC drivers" > > config RTC_DRV_ASM9260 > diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile > index 880e08a409c3..ade72f6a2435 100644 > --- a/drivers/rtc/Makefile > +++ b/drivers/rtc/Makefile > @@ -84,6 +84,7 @@ obj-$(CONFIG_RTC_DRV_LOONGSON1) += rtc-ls1x.o > obj-$(CONFIG_RTC_DRV_LP8788) += rtc-lp8788.o > obj-$(CONFIG_RTC_DRV_LPC24XX) += rtc-lpc24xx.o > obj-$(CONFIG_RTC_DRV_LPC32XX) += rtc-lpc32xx.o > +obj-$(CONFIG_RTC_DRV_LS2X) += rtc-ls2x.o > obj-$(CONFIG_RTC_DRV_M41T80) += rtc-m41t80.o > obj-$(CONFIG_RTC_DRV_M41T93) += rtc-m41t93.o > obj-$(CONFIG_RTC_DRV_M41T94) += rtc-m41t94.o > diff --git a/drivers/rtc/rtc-ls2x.c b/drivers/rtc/rtc-ls2x.c > new file mode 100644 > index 000000000000..e49cbaceccc2 > --- /dev/null > +++ b/drivers/rtc/rtc-ls2x.c > @@ -0,0 +1,225 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * Loongson-2K/7A RTC driver > + * > + * Based on the out-of-tree Loongson-2H RTC driver for Linux 2.6.32, by > + * Shaozong Liu <liushaozong@loongson.cn>. > + * > + * Maintained out-of-tree by Huacai Chen <chenhc@lemote.com>. > + * > + * Rewritten for mainline by WANG Xuerui <git@xen0n.name>. > + */ > + > +#include <linux/module.h> > +#include <linux/platform_device.h> > +#include <linux/regmap.h> > +#include <linux/rtc.h> > +#include <linux/spinlock.h> > + > +#define TOY_TRIM_REG 0x20 > +#define TOY_WRITE0_REG 0x24 > +#define TOY_WRITE1_REG 0x28 > +#define TOY_READ0_REG 0x2c > +#define TOY_READ1_REG 0x30 > +#define TOY_MATCH0_REG 0x34 > +#define TOY_MATCH1_REG 0x38 > +#define TOY_MATCH2_REG 0x3c > +#define RTC_CTRL_REG 0x40 > +#define RTC_TRIM_REG 0x60 > +#define RTC_WRITE0_REG 0x64 > +#define RTC_READ0_REG 0x68 > +#define RTC_MATCH0_REG 0x6c > +#define RTC_MATCH1_REG 0x70 > +#define RTC_MATCH2_REG 0x74 > + > +#define TOY_MON GENMASK(31, 26) > +#define TOY_MON_SHIFT 26 > +#define TOY_DAY GENMASK(25, 21) > +#define TOY_DAY_SHIFT 21 > +#define TOY_HOUR GENMASK(20, 16) > +#define TOY_HOUR_SHIFT 16 > +#define TOY_MIN GENMASK(15, 10) > +#define TOY_MIN_SHIFT 10 > +#define TOY_SEC GENMASK(9, 4) > +#define TOY_SEC_SHIFT 4 > +#define TOY_MSEC GENMASK(3, 0) > +#define TOY_MSEC_SHIFT 0 > + > +struct ls2x_rtc_priv { > + struct regmap *regmap; > + spinlock_t lock; > +}; > + > +static const struct regmap_config ls2x_rtc_regmap_config = { > + .reg_bits = 32, > + .val_bits = 32, > + .reg_stride = 4, > +}; > + > +struct ls2x_rtc_regs { > + u32 reg0; > + u32 reg1; > +}; > + > +static inline void ls2x_rtc_regs_to_time(struct ls2x_rtc_regs *regs, > + struct rtc_time *tm) > +{ > + tm->tm_year = regs->reg1; > + tm->tm_sec = (regs->reg0 & TOY_SEC) >> TOY_SEC_SHIFT; > + tm->tm_min = (regs->reg0 & TOY_MIN) >> TOY_MIN_SHIFT; > + tm->tm_hour = (regs->reg0 & TOY_HOUR) >> TOY_HOUR_SHIFT; > + tm->tm_mday = (regs->reg0 & TOY_DAY) >> TOY_DAY_SHIFT; > + tm->tm_mon = ((regs->reg0 & TOY_MON) >> TOY_MON_SHIFT) - 1; > +} > + > +static inline void ls2x_rtc_time_to_regs(struct rtc_time *tm, > + struct ls2x_rtc_regs *regs) > +{ > + regs->reg0 = (tm->tm_sec << TOY_SEC_SHIFT) & TOY_SEC; > + regs->reg0 |= (tm->tm_min << TOY_MIN_SHIFT) & TOY_MIN; > + regs->reg0 |= (tm->tm_hour << TOY_HOUR_SHIFT) & TOY_HOUR; > + regs->reg0 |= (tm->tm_mday << TOY_DAY_SHIFT) & TOY_DAY; > + regs->reg0 |= ((tm->tm_mon + 1) << TOY_MON_SHIFT) & TOY_MON; > + regs->reg1 = tm->tm_year; > +} > + > +static int ls2x_rtc_read_time(struct device *dev, struct rtc_time *tm) > +{ > + struct ls2x_rtc_priv *priv = dev_get_drvdata(dev); > + struct ls2x_rtc_regs regs; > + int ret; > + > + spin_lock_irq(&priv->lock); > + > + ret = regmap_read(priv->regmap, TOY_READ1_REG, ®s.reg1); > + if (unlikely(ret)) { > + dev_err(dev, "Failed to read time: %d\n", ret); > + goto fail; > + } > + > + ret = regmap_read(priv->regmap, TOY_READ0_REG, ®s.reg0); > + if (unlikely(ret)) { > + dev_err(dev, "Failed to read time: %d\n", ret); > + goto fail; > + } > + > + spin_unlock_irq(&priv->lock); > + > + ls2x_rtc_regs_to_time(®s, tm); > + > + return 0; > + > +fail: > + spin_unlock_irq(&priv->lock); > + return ret; > +} > + > +static int ls2x_rtc_set_time(struct device *dev, struct rtc_time *tm) > +{ > + struct ls2x_rtc_priv *priv = dev_get_drvdata(dev); > + struct ls2x_rtc_regs regs; > + int ret; > + > + ls2x_rtc_time_to_regs(tm, ®s); > + > + spin_lock_irq(&priv->lock); > + > + ret = regmap_write(priv->regmap, TOY_WRITE0_REG, regs.reg0); > + if (unlikely(ret)) { > + dev_err(dev, "Failed to set time: %d\n", ret); > + goto fail; > + } > + > + ret = regmap_write(priv->regmap, TOY_WRITE1_REG, regs.reg1); > + if (unlikely(ret)) { > + dev_err(dev, "Failed to set time: %d\n", ret); > + goto fail; > + } > + > + spin_unlock_irq(&priv->lock); > + > + return 0; > + > +fail: > + spin_unlock_irq(&priv->lock); > + return ret; > +} > + > +static struct rtc_class_ops ls2x_rtc_ops = { > + .read_time = ls2x_rtc_read_time, > + .set_time = ls2x_rtc_set_time, > +}; > + > +static int ls2x_rtc_probe(struct platform_device *pdev) > +{ > + struct device *dev = &pdev->dev; > + struct rtc_device *rtc; > + struct ls2x_rtc_priv *priv; > + void __iomem *regs; > + int ret; > + > + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); > + if (unlikely(!priv)) > + return -ENOMEM; > + > + spin_lock_init(&priv->lock); > + platform_set_drvdata(pdev, priv); > + > + regs = devm_platform_ioremap_resource(pdev, 0); > + if (IS_ERR(regs)) { > + ret = PTR_ERR(regs); > + dev_err(dev, "Failed to map rtc registers: %d\n", ret); > + return ret; > + } > + > + priv->regmap = devm_regmap_init_mmio(dev, regs, > + &ls2x_rtc_regmap_config); > + if (IS_ERR(priv->regmap)) { > + ret = PTR_ERR(priv->regmap); > + dev_err(dev, "Failed to init regmap: %d\n", ret); > + return ret; > + } > + > + rtc = devm_rtc_allocate_device(dev); > + if (IS_ERR(rtc)) { > + ret = PTR_ERR(rtc); > + dev_err(dev, "Failed to allocate rtc device: %d\n", ret); > + return ret; > + } > + > + rtc->ops = &ls2x_rtc_ops; > + > + /* Due to hardware erratum, all years multiple of 4 are considered > + * leap year, so only years 2000 through 2099 are usable. > + * > + * Previous out-of-tree versions of this driver wrote tm_year directly > + * into the year register, so epoch 2000 must be used to preserve > + * semantics on shipped systems. > + */ > + rtc->range_min = RTC_TIMESTAMP_BEGIN_2000; > + rtc->range_max = RTC_TIMESTAMP_END_2099; > + > + return rtc_register_device(rtc); > +} > + > +static const struct of_device_id ls2x_rtc_of_match[] = { > + { .compatible = "loongson,ls2x-rtc" }, > + { /* sentinel */ }, > +}; > +MODULE_DEVICE_TABLE(of, ls2x_rtc_of_match); > + > +static struct platform_driver ls2x_rtc_driver = { > + .probe = ls2x_rtc_probe, > + .driver = { > + .name = "ls2x-rtc", > + .of_match_table = of_match_ptr(ls2x_rtc_of_match), > + }, > +}; > + > +module_platform_driver(ls2x_rtc_driver); > + > +MODULE_DESCRIPTION("LS2X RTC driver"); > +MODULE_AUTHOR("WANG Xuerui"); > +MODULE_AUTHOR("Huacai Chen"); > +MODULE_LICENSE("GPL"); > +MODULE_ALIAS("platform:ls2x-rtc"); ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/4] rtc: ls2x: Add support for the Loongson-2K/LS7A RTC 2020-09-23 9:54 ` Tiezhu Yang @ 2020-09-23 14:31 ` Du Huanpeng 2020-09-25 6:13 ` WANG Xuerui 2020-09-24 7:32 ` WANG Xuerui 1 sibling, 1 reply; 12+ messages in thread From: Du Huanpeng @ 2020-09-23 14:31 UTC (permalink / raw) To: Tiezhu Yang; +Cc: WANG Xuerui, linux-rtc, linux-mips, devicetree, Huacai Chen > rtc-ls2x --> rtc-ls2x-ls7a > RTC_DRV_LS2X --> RTC_DRV_LS2X_LS7A > Loongson LS2X RTC --> Loongson LS2X/LS7A RTC > > Maybe the related names include ls7a or LS7A is better to > reflect the reality? Is there any difference with the rtc IP in loongson 1* SoCs? Regards, Du Huanpeng ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/4] rtc: ls2x: Add support for the Loongson-2K/LS7A RTC 2020-09-23 14:31 ` Du Huanpeng @ 2020-09-25 6:13 ` WANG Xuerui 2020-11-16 12:40 ` Tiezhu Yang 0 siblings, 1 reply; 12+ messages in thread From: WANG Xuerui @ 2020-09-25 6:13 UTC (permalink / raw) To: Du Huanpeng, Tiezhu Yang Cc: WANG Xuerui, linux-rtc, linux-mips, devicetree, Huacai Chen (Re-sending, as the original reply inadvertently contained an HTML part and has been blocked by all of the mailing lists.) Hi Huanpeng, On 2020/9/23 22:31, Du Huanpeng wrote: >> rtc-ls2x --> rtc-ls2x-ls7a >> RTC_DRV_LS2X --> RTC_DRV_LS2X_LS7A >> Loongson LS2X RTC --> Loongson LS2X/LS7A RTC >> >> Maybe the related names include ls7a or LS7A is better to >> reflect the reality? > Is there any difference with the rtc IP in loongson 1* SoCs? From a cursory look at 1A and 7A manuals the registers seem to have the same layout. Some registers are marked as "reserved" on the 7A manual while having real meaning on 1A, like the sys_toytrim and sys_rtctrim registers. I am investigating whether the rtc_ls1x driver could be worked to support DT configuration, along with the hardcoded addresses when compiled for Loongson 1A. If so, adding a separate rtc_ls2x may not be necessary, rtc_ls1x would be turned into something like rtc_loongson instead. > > Regards, > Du Huanpeng ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/4] rtc: ls2x: Add support for the Loongson-2K/LS7A RTC 2020-09-25 6:13 ` WANG Xuerui @ 2020-11-16 12:40 ` Tiezhu Yang 0 siblings, 0 replies; 12+ messages in thread From: Tiezhu Yang @ 2020-11-16 12:40 UTC (permalink / raw) To: WANG Xuerui, Du Huanpeng Cc: WANG Xuerui, linux-rtc, linux-mips, devicetree, Huacai Chen, Jiaxun Yang On 09/25/2020 02:13 PM, WANG Xuerui wrote: > (Re-sending, as the original reply inadvertently contained an HTML part > and has been blocked by all of the mailing lists.) > > Hi Huanpeng, > > On 2020/9/23 22:31, Du Huanpeng wrote: > >>> rtc-ls2x --> rtc-ls2x-ls7a >>> RTC_DRV_LS2X --> RTC_DRV_LS2X_LS7A >>> Loongson LS2X RTC --> Loongson LS2X/LS7A RTC >>> >>> Maybe the related names include ls7a or LS7A is better to >>> reflect the reality? >> Is there any difference with the rtc IP in loongson 1* SoCs? > From a cursory look at 1A and 7A manuals the registers seem to have the > same layout. Some registers are marked as "reserved" on the 7A manual > while having real meaning on 1A, like the sys_toytrim and sys_rtctrim > registers. > > I am investigating whether the rtc_ls1x driver could be worked to > support DT configuration, along with the hardcoded addresses when > compiled for Loongson 1A. If so, adding a separate rtc_ls2x may not be > necessary, rtc_ls1x would be turned into something like rtc_loongson > instead. Hi Xuerui, This patch series work well on the Loongson 3A3000 and 3A4000 platform used with LS7A bridge chip, both read time and write time are OK. So add: Tested-by: Tiezhu Yang <yangtiezhu@loongson.cn> And also, since the implementation between rtc_ls1x.c and rtc_ls2x.c is different, maybe there is no need to add rtc_loongson.c for the combination of rtc_ls1x.c and rtc_ls2x.c, just leave them as they are. Thanks, Tiezhu ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/4] rtc: ls2x: Add support for the Loongson-2K/LS7A RTC 2020-09-23 9:54 ` Tiezhu Yang 2020-09-23 14:31 ` Du Huanpeng @ 2020-09-24 7:32 ` WANG Xuerui 1 sibling, 0 replies; 12+ messages in thread From: WANG Xuerui @ 2020-09-24 7:32 UTC (permalink / raw) To: Tiezhu Yang, linux-rtc; +Cc: linux-mips, devicetree, Huacai Chen Hi Tiezhu, On 2020/9/23 17:54, Tiezhu Yang wrote: > On 09/23/2020 03:58 PM, WANG Xuerui wrote: >> This RTC module is integrated into the Loongson-2K SoC and the LS7A >> bridge chip. This version is almost entirely rewritten to make use of >> current kernel API. >> >> Signed-off-by: Huacai Chen <chenhc@lemote.com> >> Signed-off-by: WANG Xuerui <git@xen0n.name> >> --- >> drivers/rtc/Kconfig | 11 ++ >> drivers/rtc/Makefile | 1 + >> drivers/rtc/rtc-ls2x.c | 225 +++++++++++++++++++++++++++++++++++++++++ >> 3 files changed, 237 insertions(+) >> create mode 100644 drivers/rtc/rtc-ls2x.c >> >> diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig >> index 48c536acd777..41b96633abf3 100644 >> --- a/drivers/rtc/Kconfig >> +++ b/drivers/rtc/Kconfig >> @@ -1301,6 +1301,17 @@ config RTC_DRV_CROS_EC >> This driver can also be built as a module. If so, the module >> will be called rtc-cros-ec. >> +config RTC_DRV_LS2X >> + tristate "Loongson LS2X RTC" >> + depends on MACH_LOONGSON64 || COMPILE_TEST >> + select REGMAP_MMIO >> + help >> + If you say yes here you get support for the RTC on the >> Loongson-2K >> + SoC and LS7A bridge, which first appeared on the Loongson-2H. >> + >> + This driver can also be built as a module. If so, the module >> + will be called rtc-ls2x. >> + > > Hi Xuerui, > > rtc-ls2x --> rtc-ls2x-ls7a > RTC_DRV_LS2X --> RTC_DRV_LS2X_LS7A > Loongson LS2X RTC --> Loongson LS2X/LS7A RTC > > Maybe the related names include ls7a or LS7A is better to > reflect the reality? > The RTC hardware blocks on Loongson 2H, 2K and LS7A all behave the same, from every public documentation I can find. It is entirely reasonable for a chip to behave like another, so I don't think the naming is a problem on its own. That said, if Loongson could start properly naming and versioning the various peripheral blocks (of which there are already many revisions with different quirks added/fixed), that would be a better way forward. I remember seeing things along the line of "probe PRId" or even "see the identification string on the chip package" in some Loongson FAQ docs, just to probe some quirks, and that surely is not desirable... > Thanks, > Tiezhu > >> comment "on-CPU RTC drivers" >> config RTC_DRV_ASM9260 >> diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile >> index 880e08a409c3..ade72f6a2435 100644 >> --- a/drivers/rtc/Makefile >> +++ b/drivers/rtc/Makefile >> @@ -84,6 +84,7 @@ obj-$(CONFIG_RTC_DRV_LOONGSON1) += rtc-ls1x.o >> obj-$(CONFIG_RTC_DRV_LP8788) += rtc-lp8788.o >> obj-$(CONFIG_RTC_DRV_LPC24XX) += rtc-lpc24xx.o >> obj-$(CONFIG_RTC_DRV_LPC32XX) += rtc-lpc32xx.o >> +obj-$(CONFIG_RTC_DRV_LS2X) += rtc-ls2x.o >> obj-$(CONFIG_RTC_DRV_M41T80) += rtc-m41t80.o >> obj-$(CONFIG_RTC_DRV_M41T93) += rtc-m41t93.o >> obj-$(CONFIG_RTC_DRV_M41T94) += rtc-m41t94.o >> diff --git a/drivers/rtc/rtc-ls2x.c b/drivers/rtc/rtc-ls2x.c >> new file mode 100644 >> index 000000000000..e49cbaceccc2 >> --- /dev/null >> +++ b/drivers/rtc/rtc-ls2x.c >> @@ -0,0 +1,225 @@ >> +// SPDX-License-Identifier: GPL-2.0 >> +/* >> + * Loongson-2K/7A RTC driver >> + * >> + * Based on the out-of-tree Loongson-2H RTC driver for Linux 2.6.32, by >> + * Shaozong Liu <liushaozong@loongson.cn>. >> + * >> + * Maintained out-of-tree by Huacai Chen <chenhc@lemote.com>. >> + * >> + * Rewritten for mainline by WANG Xuerui <git@xen0n.name>. >> + */ >> + >> +#include <linux/module.h> >> +#include <linux/platform_device.h> >> +#include <linux/regmap.h> >> +#include <linux/rtc.h> >> +#include <linux/spinlock.h> >> + >> +#define TOY_TRIM_REG 0x20 >> +#define TOY_WRITE0_REG 0x24 >> +#define TOY_WRITE1_REG 0x28 >> +#define TOY_READ0_REG 0x2c >> +#define TOY_READ1_REG 0x30 >> +#define TOY_MATCH0_REG 0x34 >> +#define TOY_MATCH1_REG 0x38 >> +#define TOY_MATCH2_REG 0x3c >> +#define RTC_CTRL_REG 0x40 >> +#define RTC_TRIM_REG 0x60 >> +#define RTC_WRITE0_REG 0x64 >> +#define RTC_READ0_REG 0x68 >> +#define RTC_MATCH0_REG 0x6c >> +#define RTC_MATCH1_REG 0x70 >> +#define RTC_MATCH2_REG 0x74 >> + >> +#define TOY_MON GENMASK(31, 26) >> +#define TOY_MON_SHIFT 26 >> +#define TOY_DAY GENMASK(25, 21) >> +#define TOY_DAY_SHIFT 21 >> +#define TOY_HOUR GENMASK(20, 16) >> +#define TOY_HOUR_SHIFT 16 >> +#define TOY_MIN GENMASK(15, 10) >> +#define TOY_MIN_SHIFT 10 >> +#define TOY_SEC GENMASK(9, 4) >> +#define TOY_SEC_SHIFT 4 >> +#define TOY_MSEC GENMASK(3, 0) >> +#define TOY_MSEC_SHIFT 0 >> + >> +struct ls2x_rtc_priv { >> + struct regmap *regmap; >> + spinlock_t lock; >> +}; >> + >> +static const struct regmap_config ls2x_rtc_regmap_config = { >> + .reg_bits = 32, >> + .val_bits = 32, >> + .reg_stride = 4, >> +}; >> + >> +struct ls2x_rtc_regs { >> + u32 reg0; >> + u32 reg1; >> +}; >> + >> +static inline void ls2x_rtc_regs_to_time(struct ls2x_rtc_regs *regs, >> + struct rtc_time *tm) >> +{ >> + tm->tm_year = regs->reg1; >> + tm->tm_sec = (regs->reg0 & TOY_SEC) >> TOY_SEC_SHIFT; >> + tm->tm_min = (regs->reg0 & TOY_MIN) >> TOY_MIN_SHIFT; >> + tm->tm_hour = (regs->reg0 & TOY_HOUR) >> TOY_HOUR_SHIFT; >> + tm->tm_mday = (regs->reg0 & TOY_DAY) >> TOY_DAY_SHIFT; >> + tm->tm_mon = ((regs->reg0 & TOY_MON) >> TOY_MON_SHIFT) - 1; >> +} >> + >> +static inline void ls2x_rtc_time_to_regs(struct rtc_time *tm, >> + struct ls2x_rtc_regs *regs) >> +{ >> + regs->reg0 = (tm->tm_sec << TOY_SEC_SHIFT) & TOY_SEC; >> + regs->reg0 |= (tm->tm_min << TOY_MIN_SHIFT) & TOY_MIN; >> + regs->reg0 |= (tm->tm_hour << TOY_HOUR_SHIFT) & TOY_HOUR; >> + regs->reg0 |= (tm->tm_mday << TOY_DAY_SHIFT) & TOY_DAY; >> + regs->reg0 |= ((tm->tm_mon + 1) << TOY_MON_SHIFT) & TOY_MON; >> + regs->reg1 = tm->tm_year; >> +} >> + >> +static int ls2x_rtc_read_time(struct device *dev, struct rtc_time *tm) >> +{ >> + struct ls2x_rtc_priv *priv = dev_get_drvdata(dev); >> + struct ls2x_rtc_regs regs; >> + int ret; >> + >> + spin_lock_irq(&priv->lock); >> + >> + ret = regmap_read(priv->regmap, TOY_READ1_REG, ®s.reg1); >> + if (unlikely(ret)) { >> + dev_err(dev, "Failed to read time: %d\n", ret); >> + goto fail; >> + } >> + >> + ret = regmap_read(priv->regmap, TOY_READ0_REG, ®s.reg0); >> + if (unlikely(ret)) { >> + dev_err(dev, "Failed to read time: %d\n", ret); >> + goto fail; >> + } >> + >> + spin_unlock_irq(&priv->lock); >> + >> + ls2x_rtc_regs_to_time(®s, tm); >> + >> + return 0; >> + >> +fail: >> + spin_unlock_irq(&priv->lock); >> + return ret; >> +} >> + >> +static int ls2x_rtc_set_time(struct device *dev, struct rtc_time *tm) >> +{ >> + struct ls2x_rtc_priv *priv = dev_get_drvdata(dev); >> + struct ls2x_rtc_regs regs; >> + int ret; >> + >> + ls2x_rtc_time_to_regs(tm, ®s); >> + >> + spin_lock_irq(&priv->lock); >> + >> + ret = regmap_write(priv->regmap, TOY_WRITE0_REG, regs.reg0); >> + if (unlikely(ret)) { >> + dev_err(dev, "Failed to set time: %d\n", ret); >> + goto fail; >> + } >> + >> + ret = regmap_write(priv->regmap, TOY_WRITE1_REG, regs.reg1); >> + if (unlikely(ret)) { >> + dev_err(dev, "Failed to set time: %d\n", ret); >> + goto fail; >> + } >> + >> + spin_unlock_irq(&priv->lock); >> + >> + return 0; >> + >> +fail: >> + spin_unlock_irq(&priv->lock); >> + return ret; >> +} >> + >> +static struct rtc_class_ops ls2x_rtc_ops = { >> + .read_time = ls2x_rtc_read_time, >> + .set_time = ls2x_rtc_set_time, >> +}; >> + >> +static int ls2x_rtc_probe(struct platform_device *pdev) >> +{ >> + struct device *dev = &pdev->dev; >> + struct rtc_device *rtc; >> + struct ls2x_rtc_priv *priv; >> + void __iomem *regs; >> + int ret; >> + >> + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); >> + if (unlikely(!priv)) >> + return -ENOMEM; >> + >> + spin_lock_init(&priv->lock); >> + platform_set_drvdata(pdev, priv); >> + >> + regs = devm_platform_ioremap_resource(pdev, 0); >> + if (IS_ERR(regs)) { >> + ret = PTR_ERR(regs); >> + dev_err(dev, "Failed to map rtc registers: %d\n", ret); >> + return ret; >> + } >> + >> + priv->regmap = devm_regmap_init_mmio(dev, regs, >> + &ls2x_rtc_regmap_config); >> + if (IS_ERR(priv->regmap)) { >> + ret = PTR_ERR(priv->regmap); >> + dev_err(dev, "Failed to init regmap: %d\n", ret); >> + return ret; >> + } >> + >> + rtc = devm_rtc_allocate_device(dev); >> + if (IS_ERR(rtc)) { >> + ret = PTR_ERR(rtc); >> + dev_err(dev, "Failed to allocate rtc device: %d\n", ret); >> + return ret; >> + } >> + >> + rtc->ops = &ls2x_rtc_ops; >> + >> + /* Due to hardware erratum, all years multiple of 4 are considered >> + * leap year, so only years 2000 through 2099 are usable. >> + * >> + * Previous out-of-tree versions of this driver wrote tm_year >> directly >> + * into the year register, so epoch 2000 must be used to preserve >> + * semantics on shipped systems. >> + */ >> + rtc->range_min = RTC_TIMESTAMP_BEGIN_2000; >> + rtc->range_max = RTC_TIMESTAMP_END_2099; >> + >> + return rtc_register_device(rtc); >> +} >> + >> +static const struct of_device_id ls2x_rtc_of_match[] = { >> + { .compatible = "loongson,ls2x-rtc" }, >> + { /* sentinel */ }, >> +}; >> +MODULE_DEVICE_TABLE(of, ls2x_rtc_of_match); >> + >> +static struct platform_driver ls2x_rtc_driver = { >> + .probe = ls2x_rtc_probe, >> + .driver = { >> + .name = "ls2x-rtc", >> + .of_match_table = of_match_ptr(ls2x_rtc_of_match), >> + }, >> +}; >> + >> +module_platform_driver(ls2x_rtc_driver); >> + >> +MODULE_DESCRIPTION("LS2X RTC driver"); >> +MODULE_AUTHOR("WANG Xuerui"); >> +MODULE_AUTHOR("Huacai Chen"); >> +MODULE_LICENSE("GPL"); >> +MODULE_ALIAS("platform:ls2x-rtc"); > ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/4] rtc: ls2x: Add support for the Loongson-2K/LS7A RTC 2020-09-23 7:58 ` [PATCH 1/4] " WANG Xuerui 2020-09-23 9:54 ` Tiezhu Yang @ 2020-09-23 13:50 ` Jiaxun Yang 1 sibling, 0 replies; 12+ messages in thread From: Jiaxun Yang @ 2020-09-23 13:50 UTC (permalink / raw) To: WANG Xuerui, linux-rtc; +Cc: linux-mips, devicetree, Huacai Chen 在 2020/9/23 15:58, WANG Xuerui 写道: > This RTC module is integrated into the Loongson-2K SoC and the LS7A > bridge chip. This version is almost entirely rewritten to make use of > current kernel API. > > Signed-off-by: Huacai Chen <chenhc@lemote.com> > Signed-off-by: WANG Xuerui <git@xen0n.name> Reviewed-by: Jiaxun Yang <jiaxun.yang@flygoat.com> This driver have been out of tree for around 10yrs, thanks for shaping it to mainline quality! - Jiaxun > --- ^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 2/4] dt-bindings: rtc: Add bindings for LS2X RTC 2020-09-23 7:58 [PATCH 0/4] rtc: ls2x: Add support for the Loongson-2K/LS7A RTC WANG Xuerui 2020-09-23 7:58 ` [PATCH 1/4] " WANG Xuerui @ 2020-09-23 7:58 ` WANG Xuerui 2020-09-29 18:45 ` Rob Herring 2020-09-23 7:58 ` [PATCH 3/4] MIPS: Loongson64: DTS: Add RTC support to LS7A WANG Xuerui 2020-09-23 7:58 ` [PATCH 4/4] MIPS: Loongson: Enable LS2X RTC in loongson3_defconfig WANG Xuerui 3 siblings, 1 reply; 12+ messages in thread From: WANG Xuerui @ 2020-09-23 7:58 UTC (permalink / raw) To: linux-rtc; +Cc: WANG Xuerui, linux-mips, devicetree, Rob Herring Document the binding for the LS2X RTC block found on the Loongson-2K SoC and the LS7A bridge, originally appearing on the Loongson-2H. Signed-off-by: WANG Xuerui <git@xen0n.name> Cc: Rob Herring <robh+dt@kernel.org> Cc: devicetree@vger.kernel.org --- Documentation/devicetree/bindings/rtc/trivial-rtc.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/rtc/trivial-rtc.yaml b/Documentation/devicetree/bindings/rtc/trivial-rtc.yaml index c7d14de214c4..233666c47d97 100644 --- a/Documentation/devicetree/bindings/rtc/trivial-rtc.yaml +++ b/Documentation/devicetree/bindings/rtc/trivial-rtc.yaml @@ -42,6 +42,8 @@ properties: - isil,isl1218 # Intersil ISL12022 Real-time Clock - isil,isl12022 + # Loongson LS2X RTC + - loongson,ls2x-rtc # Real Time Clock Module with I2C-Bus - microcrystal,rv3028 # Real Time Clock Module with I2C-Bus -- 2.28.0 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 2/4] dt-bindings: rtc: Add bindings for LS2X RTC 2020-09-23 7:58 ` [PATCH 2/4] dt-bindings: rtc: Add bindings for LS2X RTC WANG Xuerui @ 2020-09-29 18:45 ` Rob Herring 0 siblings, 0 replies; 12+ messages in thread From: Rob Herring @ 2020-09-29 18:45 UTC (permalink / raw) To: WANG Xuerui; +Cc: Rob Herring, linux-rtc, devicetree, linux-mips On Wed, 23 Sep 2020 15:58:43 +0800, WANG Xuerui wrote: > Document the binding for the LS2X RTC block found on the Loongson-2K SoC > and the LS7A bridge, originally appearing on the Loongson-2H. > > Signed-off-by: WANG Xuerui <git@xen0n.name> > Cc: Rob Herring <robh+dt@kernel.org> > Cc: devicetree@vger.kernel.org > --- > Documentation/devicetree/bindings/rtc/trivial-rtc.yaml | 2 ++ > 1 file changed, 2 insertions(+) > Acked-by: Rob Herring <robh@kernel.org> ^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 3/4] MIPS: Loongson64: DTS: Add RTC support to LS7A 2020-09-23 7:58 [PATCH 0/4] rtc: ls2x: Add support for the Loongson-2K/LS7A RTC WANG Xuerui 2020-09-23 7:58 ` [PATCH 1/4] " WANG Xuerui 2020-09-23 7:58 ` [PATCH 2/4] dt-bindings: rtc: Add bindings for LS2X RTC WANG Xuerui @ 2020-09-23 7:58 ` WANG Xuerui 2020-09-23 7:58 ` [PATCH 4/4] MIPS: Loongson: Enable LS2X RTC in loongson3_defconfig WANG Xuerui 3 siblings, 0 replies; 12+ messages in thread From: WANG Xuerui @ 2020-09-23 7:58 UTC (permalink / raw) To: linux-rtc; +Cc: WANG Xuerui, linux-mips, devicetree, Rob Herring The LS7A RTC module is now supported, enable it. Signed-off-by: WANG Xuerui <git@xen0n.name> Cc: Rob Herring <robh+dt@kernel.org> Cc: devicetree@vger.kernel.org --- arch/mips/boot/dts/loongson/ls7a-pch.dtsi | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/mips/boot/dts/loongson/ls7a-pch.dtsi b/arch/mips/boot/dts/loongson/ls7a-pch.dtsi index f99a7a11fded..39808e97e6e1 100644 --- a/arch/mips/boot/dts/loongson/ls7a-pch.dtsi +++ b/arch/mips/boot/dts/loongson/ls7a-pch.dtsi @@ -19,6 +19,11 @@ pic: interrupt-controller@10000000 { #interrupt-cells = <2>; }; + rtc0: rtc@100d0100 { + compatible = "loongson,ls2x-rtc"; + reg = <0 0x100d0100 0 0x78>; + }; + ls7a_uart0: serial@10080000 { compatible = "ns16550a"; reg = <0 0x10080000 0 0x100>; -- 2.28.0 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 4/4] MIPS: Loongson: Enable LS2X RTC in loongson3_defconfig 2020-09-23 7:58 [PATCH 0/4] rtc: ls2x: Add support for the Loongson-2K/LS7A RTC WANG Xuerui ` (2 preceding siblings ...) 2020-09-23 7:58 ` [PATCH 3/4] MIPS: Loongson64: DTS: Add RTC support to LS7A WANG Xuerui @ 2020-09-23 7:58 ` WANG Xuerui 3 siblings, 0 replies; 12+ messages in thread From: WANG Xuerui @ 2020-09-23 7:58 UTC (permalink / raw) To: linux-rtc; +Cc: WANG Xuerui, linux-mips, devicetree This is now supported, enable for Loongson-2K or LS7A systems. Other systems are unaffected. Signed-off-by: WANG Xuerui <git@xen0n.name> --- arch/mips/configs/loongson3_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/mips/configs/loongson3_defconfig b/arch/mips/configs/loongson3_defconfig index a5005c8cee8a..d15bb0e39f9d 100644 --- a/arch/mips/configs/loongson3_defconfig +++ b/arch/mips/configs/loongson3_defconfig @@ -322,6 +322,7 @@ CONFIG_USB_SERIAL_OPTION=m CONFIG_RTC_CLASS=y CONFIG_RTC_DRV_CMOS=y CONFIG_RTC_DRV_GOLDFISH=y +CONFIG_RTC_DRV_LS2X=y CONFIG_DMADEVICES=y CONFIG_VIRTIO_PCI=y CONFIG_VIRTIO_BALLOON=m -- 2.28.0 ^ permalink raw reply related [flat|nested] 12+ messages in thread
end of thread, other threads:[~2020-11-16 12:40 UTC | newest] Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2020-09-23 7:58 [PATCH 0/4] rtc: ls2x: Add support for the Loongson-2K/LS7A RTC WANG Xuerui 2020-09-23 7:58 ` [PATCH 1/4] " WANG Xuerui 2020-09-23 9:54 ` Tiezhu Yang 2020-09-23 14:31 ` Du Huanpeng 2020-09-25 6:13 ` WANG Xuerui 2020-11-16 12:40 ` Tiezhu Yang 2020-09-24 7:32 ` WANG Xuerui 2020-09-23 13:50 ` Jiaxun Yang 2020-09-23 7:58 ` [PATCH 2/4] dt-bindings: rtc: Add bindings for LS2X RTC WANG Xuerui 2020-09-29 18:45 ` Rob Herring 2020-09-23 7:58 ` [PATCH 3/4] MIPS: Loongson64: DTS: Add RTC support to LS7A WANG Xuerui 2020-09-23 7:58 ` [PATCH 4/4] MIPS: Loongson: Enable LS2X RTC in loongson3_defconfig WANG Xuerui
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).