* [PATCH v1 1/3] dt: bindings: add documentation for zx2967 family reset controller
@ 2017-01-14 7:05 Baoyou Xie
2017-01-14 7:05 ` [PATCH v1 2/3] MAINTAINERS: add zx2967 reset controller driver to ARM ZTE architecture Baoyou Xie
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: Baoyou Xie @ 2017-01-14 7:05 UTC (permalink / raw)
To: jun.nie, p.zabel, robh+dt, mark.rutland
Cc: devicetree, xie.baoyou, linux-kernel, chen.chaokai, wang.qiang01,
baoyou.xie, shawnguo, linux-arm-kernel
This patch adds dt-binding documentation for zx2967 family
reset controller.
Signed-off-by: Baoyou Xie <baoyou.xie@linaro.org>
---
.../devicetree/bindings/reset/zte,zx2967-reset.txt | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
create mode 100644 Documentation/devicetree/bindings/reset/zte,zx2967-reset.txt
diff --git a/Documentation/devicetree/bindings/reset/zte,zx2967-reset.txt b/Documentation/devicetree/bindings/reset/zte,zx2967-reset.txt
new file mode 100644
index 0000000..22d590e
--- /dev/null
+++ b/Documentation/devicetree/bindings/reset/zte,zx2967-reset.txt
@@ -0,0 +1,20 @@
+ZTE zx2967 SoCs Reset Controller
+=======================================
+
+Please also refer to reset.txt in this directory for common reset
+controller binding usage.
+
+Required properties:
+- compatible: should be one of the following.
+ * zte,zx296718-reset
+- reg: physical base address of the controller and length of memory mapped
+ region.
+- #reset-cells: must be 1.
+
+example:
+
+ toprst: reset@1461060 {
+ compatible = "zte,zx296718-reset";
+ reg = <0x01461060 0x8>;
+ #reset-cells = <1>;
+ };
--
2.7.4
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH v1 2/3] MAINTAINERS: add zx2967 reset controller driver to ARM ZTE architecture 2017-01-14 7:05 [PATCH v1 1/3] dt: bindings: add documentation for zx2967 family reset controller Baoyou Xie @ 2017-01-14 7:05 ` Baoyou Xie 2017-01-14 7:05 ` [PATCH v1 3/3] reset: zx2967: add reset controller driver for ZTE's zx2967 family Baoyou Xie ` (2 subsequent siblings) 3 siblings, 0 replies; 8+ messages in thread From: Baoyou Xie @ 2017-01-14 7:05 UTC (permalink / raw) To: jun.nie, p.zabel, robh+dt, mark.rutland Cc: devicetree, xie.baoyou, linux-kernel, chen.chaokai, wang.qiang01, baoyou.xie, shawnguo, linux-arm-kernel Add the zx2967 reset controller driver as maintained by ARM ZTE architecture maintainers, as they're parts of the core IP. Signed-off-by: Baoyou Xie <baoyou.xie@linaro.org> --- MAINTAINERS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 2793808..08f8155 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1980,10 +1980,12 @@ L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) S: Maintained F: arch/arm/mach-zx/ F: drivers/clk/zte/ +F: drivers/reset/reset-zx2967.c F: drivers/soc/zte/ F: drivers/thermal/zx* F: Documentation/devicetree/bindings/arm/zte.txt F: Documentation/devicetree/bindings/clock/zx296702-clk.txt +F: Documentation/devicetree/bindings/reset/zte,zx2967-reset.txt F: Documentation/devicetree/bindings/soc/zte/ F: Documentation/devicetree/bindings/thermal/zx* F: include/dt-bindings/soc/zx*.h -- 2.7.4 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v1 3/3] reset: zx2967: add reset controller driver for ZTE's zx2967 family 2017-01-14 7:05 [PATCH v1 1/3] dt: bindings: add documentation for zx2967 family reset controller Baoyou Xie 2017-01-14 7:05 ` [PATCH v1 2/3] MAINTAINERS: add zx2967 reset controller driver to ARM ZTE architecture Baoyou Xie @ 2017-01-14 7:05 ` Baoyou Xie [not found] ` <1484377530-30635-3-git-send-email-baoyou.xie-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> ` (2 more replies) 2017-01-16 7:09 ` [PATCH v1 1/3] dt: bindings: add documentation for zx2967 family reset controller Shawn Guo [not found] ` <1484377530-30635-1-git-send-email-baoyou.xie-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> 3 siblings, 3 replies; 8+ messages in thread From: Baoyou Xie @ 2017-01-14 7:05 UTC (permalink / raw) To: jun.nie, p.zabel, robh+dt, mark.rutland Cc: devicetree, xie.baoyou, linux-kernel, chen.chaokai, wang.qiang01, baoyou.xie, shawnguo, linux-arm-kernel This patch adds reset controller driver for ZTE's zx2967 family. Signed-off-by: Baoyou Xie <baoyou.xie@linaro.org> --- drivers/reset/Kconfig | 6 ++ drivers/reset/Makefile | 1 + drivers/reset/reset-zx2967.c | 136 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 143 insertions(+) create mode 100644 drivers/reset/reset-zx2967.c diff --git a/drivers/reset/Kconfig b/drivers/reset/Kconfig index 172dc96..972d077 100644 --- a/drivers/reset/Kconfig +++ b/drivers/reset/Kconfig @@ -92,6 +92,12 @@ config RESET_ZYNQ help This enables the reset controller driver for Xilinx Zynq SoCs. +config RESET_ZX2967 + bool "ZX2967 Reset Driver" + depends on ARCH_ZX || COMPILE_TEST + help + This enables the reset controller driver for ZTE zx2967 family. + source "drivers/reset/sti/Kconfig" source "drivers/reset/hisilicon/Kconfig" source "drivers/reset/tegra/Kconfig" diff --git a/drivers/reset/Makefile b/drivers/reset/Makefile index 13b346e..807b77b 100644 --- a/drivers/reset/Makefile +++ b/drivers/reset/Makefile @@ -14,3 +14,4 @@ obj-$(CONFIG_RESET_SUNXI) += reset-sunxi.o obj-$(CONFIG_TI_SYSCON_RESET) += reset-ti-syscon.o obj-$(CONFIG_RESET_UNIPHIER) += reset-uniphier.o obj-$(CONFIG_RESET_ZYNQ) += reset-zynq.o +obj-$(CONFIG_RESET_ZX2967) += reset-zx2967.o diff --git a/drivers/reset/reset-zx2967.c b/drivers/reset/reset-zx2967.c new file mode 100644 index 0000000..63f9c41 --- /dev/null +++ b/drivers/reset/reset-zx2967.c @@ -0,0 +1,136 @@ +/* + * ZTE's zx2967 family thermal sensor driver + * + * Copyright (C) 2017 ZTE Ltd. + * + * Author: Baoyou Xie <baoyou.xie@linaro.org> + * + * License terms: GNU General Public License (GPL) version 2 + */ + +#include <linux/module.h> +#include <linux/of_address.h> +#include <linux/platform_device.h> +#include <linux/reset-controller.h> + +struct zx2967_reset { + void __iomem *reg_base; + spinlock_t lock; + struct reset_controller_dev rcdev; +}; + +static int zx2967_reset_assert(struct reset_controller_dev *rcdev, + unsigned long id) +{ + struct zx2967_reset *reset = NULL; + int bank = id / 32; + int offset = id % 32; + unsigned int reg; + unsigned long flags; + + reset = container_of(rcdev, struct zx2967_reset, rcdev); + + spin_lock_irqsave(&reset->lock, flags); + + reg = readl(reset->reg_base + (bank * 4)); + writel(reg & ~BIT(offset), reset->reg_base + (bank * 4)); + reg = readl(reset->reg_base + (bank * 4)); + + spin_unlock_irqrestore(&reset->lock, flags); + + return 0; +} + +static int zx2967_reset_deassert(struct reset_controller_dev *rcdev, + unsigned long id) +{ + struct zx2967_reset *reset = NULL; + int bank = id / 32; + int offset = id % 32; + unsigned int reg; + unsigned long flags; + + reset = container_of(rcdev, struct zx2967_reset, rcdev); + + spin_lock_irqsave(&reset->lock, flags); + + reg = readl(reset->reg_base + (bank * 4)); + writel(reg | BIT(offset), reset->reg_base + (bank * 4)); + reg = readl(reset->reg_base + (bank * 4)); + + spin_unlock_irqrestore(&reset->lock, flags); + + return 0; +} + +static struct reset_control_ops zx2967_reset_ops = { + .assert = zx2967_reset_assert, + .deassert = zx2967_reset_deassert, +}; + +static int zx2967_reset_probe(struct platform_device *pdev) +{ + struct zx2967_reset *reset; + struct resource *res; + + reset = devm_kzalloc(&pdev->dev, sizeof(*reset), GFP_KERNEL); + if (!reset) + return -ENOMEM; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + reset->reg_base = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(reset->reg_base)) + return PTR_ERR(reset->reg_base); + + spin_lock_init(&reset->lock); + + reset->rcdev.owner = THIS_MODULE; + reset->rcdev.nr_resets = resource_size(res) * 8; + reset->rcdev.ops = &zx2967_reset_ops; + reset->rcdev.of_node = pdev->dev.of_node; + + dev_info(&pdev->dev, "reset controller cnt:%d", + reset->rcdev.nr_resets); + + return reset_controller_register(&reset->rcdev); +} + +static int zx2967_reset_remove(struct platform_device *pdev) +{ + struct zx2967_reset *reset = platform_get_drvdata(pdev); + + reset_controller_unregister(&reset->rcdev); + + return 0; +} + +static const struct of_device_id zx2967_reset_dt_ids[] = { + { .compatible = "zte,zx296718-reset", }, + {}, +}; +MODULE_DEVICE_TABLE(of, zx2967_reset_dt_ids); + +static struct platform_driver zx2967_reset_driver = { + .probe = zx2967_reset_probe, + .remove = zx2967_reset_remove, + .driver = { + .name = "zx2967-reset", + .of_match_table = zx2967_reset_dt_ids, + }, +}; + +static int __init zx2967_reset_init(void) +{ + return platform_driver_register(&zx2967_reset_driver); +} +arch_initcall(zx2967_reset_init); + +static void __exit zx2967_reset_exit(void) +{ + platform_driver_unregister(&zx2967_reset_driver); +} +module_exit(zx2967_reset_exit); + +MODULE_AUTHOR("Baoyou Xie <baoyou.xie@linaro.org>"); +MODULE_DESCRIPTION("ZTE zx2967 Reset Controller Driver"); +MODULE_LICENSE("GPL"); -- 2.7.4 ^ permalink raw reply related [flat|nested] 8+ messages in thread
[parent not found: <1484377530-30635-3-git-send-email-baoyou.xie-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>]
* Re: [PATCH v1 3/3] reset: zx2967: add reset controller driver for ZTE's zx2967 family [not found] ` <1484377530-30635-3-git-send-email-baoyou.xie-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> @ 2017-01-16 7:44 ` Shawn Guo 0 siblings, 0 replies; 8+ messages in thread From: Shawn Guo @ 2017-01-16 7:44 UTC (permalink / raw) To: Baoyou Xie Cc: jun.nie-QSEj5FYQhm4dnm+yROfE0A, p.zabel-bIcnvbaLZ9MEGnE8C9+IrQ, robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, devicetree-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA, xie.baoyou-Th6q7B73Y6EnDS1+zs4M5A, chen.chaokai-Th6q7B73Y6EnDS1+zs4M5A, wang.qiang01-Th6q7B73Y6EnDS1+zs4M5A On Sat, Jan 14, 2017 at 03:05:30PM +0800, Baoyou Xie wrote: > This patch adds reset controller driver for ZTE's zx2967 family. > > Signed-off-by: Baoyou Xie <baoyou.xie-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> > --- > drivers/reset/Kconfig | 6 ++ > drivers/reset/Makefile | 1 + > drivers/reset/reset-zx2967.c | 136 +++++++++++++++++++++++++++++++++++++++++++ > 3 files changed, 143 insertions(+) > create mode 100644 drivers/reset/reset-zx2967.c > > diff --git a/drivers/reset/Kconfig b/drivers/reset/Kconfig > index 172dc96..972d077 100644 > --- a/drivers/reset/Kconfig > +++ b/drivers/reset/Kconfig > @@ -92,6 +92,12 @@ config RESET_ZYNQ > help > This enables the reset controller driver for Xilinx Zynq SoCs. > > +config RESET_ZX2967 > + bool "ZX2967 Reset Driver" > + depends on ARCH_ZX || COMPILE_TEST > + help > + This enables the reset controller driver for ZTE zx2967 family. > + The config options seem to be sorted alphabetically, so RESET_ZX2967 should be put before RESET_ZYNQ. > source "drivers/reset/sti/Kconfig" > source "drivers/reset/hisilicon/Kconfig" > source "drivers/reset/tegra/Kconfig" > diff --git a/drivers/reset/Makefile b/drivers/reset/Makefile > index 13b346e..807b77b 100644 > --- a/drivers/reset/Makefile > +++ b/drivers/reset/Makefile > @@ -14,3 +14,4 @@ obj-$(CONFIG_RESET_SUNXI) += reset-sunxi.o > obj-$(CONFIG_TI_SYSCON_RESET) += reset-ti-syscon.o > obj-$(CONFIG_RESET_UNIPHIER) += reset-uniphier.o > obj-$(CONFIG_RESET_ZYNQ) += reset-zynq.o > +obj-$(CONFIG_RESET_ZX2967) += reset-zx2967.o Ditto > diff --git a/drivers/reset/reset-zx2967.c b/drivers/reset/reset-zx2967.c > new file mode 100644 > index 0000000..63f9c41 > --- /dev/null > +++ b/drivers/reset/reset-zx2967.c > @@ -0,0 +1,136 @@ > +/* > + * ZTE's zx2967 family thermal sensor driver > + * > + * Copyright (C) 2017 ZTE Ltd. > + * > + * Author: Baoyou Xie <baoyou.xie-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> > + * > + * License terms: GNU General Public License (GPL) version 2 > + */ > + > +#include <linux/module.h> > +#include <linux/of_address.h> > +#include <linux/platform_device.h> > +#include <linux/reset-controller.h> > + > +struct zx2967_reset { > + void __iomem *reg_base; > + spinlock_t lock; > + struct reset_controller_dev rcdev; > +}; > + > +static int zx2967_reset_assert(struct reset_controller_dev *rcdev, > + unsigned long id) > +{ > + struct zx2967_reset *reset = NULL; > + int bank = id / 32; > + int offset = id % 32; > + unsigned int reg; > + unsigned long flags; > + > + reset = container_of(rcdev, struct zx2967_reset, rcdev); > + > + spin_lock_irqsave(&reset->lock, flags); > + > + reg = readl(reset->reg_base + (bank * 4)); > + writel(reg & ~BIT(offset), reset->reg_base + (bank * 4)); > + reg = readl(reset->reg_base + (bank * 4)); > + > + spin_unlock_irqrestore(&reset->lock, flags); > + > + return 0; > +} > + > +static int zx2967_reset_deassert(struct reset_controller_dev *rcdev, > + unsigned long id) > +{ > + struct zx2967_reset *reset = NULL; > + int bank = id / 32; > + int offset = id % 32; > + unsigned int reg; > + unsigned long flags; > + > + reset = container_of(rcdev, struct zx2967_reset, rcdev); > + > + spin_lock_irqsave(&reset->lock, flags); > + > + reg = readl(reset->reg_base + (bank * 4)); > + writel(reg | BIT(offset), reset->reg_base + (bank * 4)); > + reg = readl(reset->reg_base + (bank * 4)); > + > + spin_unlock_irqrestore(&reset->lock, flags); > + > + return 0; > +} > + > +static struct reset_control_ops zx2967_reset_ops = { > + .assert = zx2967_reset_assert, > + .deassert = zx2967_reset_deassert, > +}; > + > +static int zx2967_reset_probe(struct platform_device *pdev) > +{ > + struct zx2967_reset *reset; > + struct resource *res; > + > + reset = devm_kzalloc(&pdev->dev, sizeof(*reset), GFP_KERNEL); > + if (!reset) > + return -ENOMEM; > + > + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); > + reset->reg_base = devm_ioremap_resource(&pdev->dev, res); > + if (IS_ERR(reset->reg_base)) > + return PTR_ERR(reset->reg_base); > + > + spin_lock_init(&reset->lock); > + > + reset->rcdev.owner = THIS_MODULE; > + reset->rcdev.nr_resets = resource_size(res) * 8; > + reset->rcdev.ops = &zx2967_reset_ops; > + reset->rcdev.of_node = pdev->dev.of_node; > + > + dev_info(&pdev->dev, "reset controller cnt:%d", > + reset->rcdev.nr_resets); > + > + return reset_controller_register(&reset->rcdev); Use devm_reset_controller_register(), then we can save the call to reset_controller_unregister(). Shawn > +} > + > +static int zx2967_reset_remove(struct platform_device *pdev) > +{ > + struct zx2967_reset *reset = platform_get_drvdata(pdev); > + > + reset_controller_unregister(&reset->rcdev); > + > + return 0; > +} > + > +static const struct of_device_id zx2967_reset_dt_ids[] = { > + { .compatible = "zte,zx296718-reset", }, > + {}, > +}; > +MODULE_DEVICE_TABLE(of, zx2967_reset_dt_ids); > + > +static struct platform_driver zx2967_reset_driver = { > + .probe = zx2967_reset_probe, > + .remove = zx2967_reset_remove, > + .driver = { > + .name = "zx2967-reset", > + .of_match_table = zx2967_reset_dt_ids, > + }, > +}; > + > +static int __init zx2967_reset_init(void) > +{ > + return platform_driver_register(&zx2967_reset_driver); > +} > +arch_initcall(zx2967_reset_init); > + > +static void __exit zx2967_reset_exit(void) > +{ > + platform_driver_unregister(&zx2967_reset_driver); > +} > +module_exit(zx2967_reset_exit); > + > +MODULE_AUTHOR("Baoyou Xie <baoyou.xie-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>"); > +MODULE_DESCRIPTION("ZTE zx2967 Reset Controller Driver"); > +MODULE_LICENSE("GPL"); > -- > 2.7.4 > -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v1 3/3] reset: zx2967: add reset controller driver for ZTE's zx2967 family 2017-01-14 7:05 ` [PATCH v1 3/3] reset: zx2967: add reset controller driver for ZTE's zx2967 family Baoyou Xie [not found] ` <1484377530-30635-3-git-send-email-baoyou.xie-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> @ 2017-01-16 7:58 ` Shawn Guo 2017-01-16 9:58 ` Philipp Zabel 2 siblings, 0 replies; 8+ messages in thread From: Shawn Guo @ 2017-01-16 7:58 UTC (permalink / raw) To: Baoyou Xie Cc: jun.nie, p.zabel, robh+dt, mark.rutland, linux-arm-kernel, devicetree, linux-kernel, xie.baoyou, chen.chaokai, wang.qiang01 On Sat, Jan 14, 2017 at 03:05:30PM +0800, Baoyou Xie wrote: > +static int zx2967_reset_assert(struct reset_controller_dev *rcdev, > + unsigned long id) > +{ > + struct zx2967_reset *reset = NULL; > + int bank = id / 32; > + int offset = id % 32; > + unsigned int reg; u32 is probably better for register value. > + unsigned long flags; > + > + reset = container_of(rcdev, struct zx2967_reset, rcdev); > + > + spin_lock_irqsave(&reset->lock, flags); > + > + reg = readl(reset->reg_base + (bank * 4)); > + writel(reg & ~BIT(offset), reset->reg_base + (bank * 4)); > + reg = readl(reset->reg_base + (bank * 4)); Is this read on the register is necessary? If so, we should probably have a comment for that. > + > + spin_unlock_irqrestore(&reset->lock, flags); > + > + return 0; > +} > + > +static int zx2967_reset_deassert(struct reset_controller_dev *rcdev, > + unsigned long id) Please indent the line right after parentheses. > +{ > + struct zx2967_reset *reset = NULL; > + int bank = id / 32; > + int offset = id % 32; > + unsigned int reg; > + unsigned long flags; > + > + reset = container_of(rcdev, struct zx2967_reset, rcdev); > + > + spin_lock_irqsave(&reset->lock, flags); > + > + reg = readl(reset->reg_base + (bank * 4)); > + writel(reg | BIT(offset), reset->reg_base + (bank * 4)); > + reg = readl(reset->reg_base + (bank * 4)); > + > + spin_unlock_irqrestore(&reset->lock, flags); > + > + return 0; > +} Only difference between these two functions is only one line. Should we consolidate them a bit? Shawn ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v1 3/3] reset: zx2967: add reset controller driver for ZTE's zx2967 family 2017-01-14 7:05 ` [PATCH v1 3/3] reset: zx2967: add reset controller driver for ZTE's zx2967 family Baoyou Xie [not found] ` <1484377530-30635-3-git-send-email-baoyou.xie-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> 2017-01-16 7:58 ` Shawn Guo @ 2017-01-16 9:58 ` Philipp Zabel 2 siblings, 0 replies; 8+ messages in thread From: Philipp Zabel @ 2017-01-16 9:58 UTC (permalink / raw) To: Baoyou Xie Cc: jun.nie, robh+dt, mark.rutland, linux-arm-kernel, devicetree, linux-kernel, shawnguo, xie.baoyou, chen.chaokai, wang.qiang01 On Sat, 2017-01-14 at 15:05 +0800, Baoyou Xie wrote: > This patch adds reset controller driver for ZTE's zx2967 family. > > Signed-off-by: Baoyou Xie <baoyou.xie@linaro.org> > --- > drivers/reset/Kconfig | 6 ++ > drivers/reset/Makefile | 1 + > drivers/reset/reset-zx2967.c | 136 +++++++++++++++++++++++++++++++++++++++++++ > 3 files changed, 143 insertions(+) > create mode 100644 drivers/reset/reset-zx2967.c > > diff --git a/drivers/reset/Kconfig b/drivers/reset/Kconfig > index 172dc96..972d077 100644 > --- a/drivers/reset/Kconfig > +++ b/drivers/reset/Kconfig > @@ -92,6 +92,12 @@ config RESET_ZYNQ > help > This enables the reset controller driver for Xilinx Zynq SoCs. > > +config RESET_ZX2967 > + bool "ZX2967 Reset Driver" > + depends on ARCH_ZX || COMPILE_TEST > + help > + This enables the reset controller driver for ZTE zx2967 family. > + > source "drivers/reset/sti/Kconfig" > source "drivers/reset/hisilicon/Kconfig" > source "drivers/reset/tegra/Kconfig" > diff --git a/drivers/reset/Makefile b/drivers/reset/Makefile > index 13b346e..807b77b 100644 > --- a/drivers/reset/Makefile > +++ b/drivers/reset/Makefile > @@ -14,3 +14,4 @@ obj-$(CONFIG_RESET_SUNXI) += reset-sunxi.o > obj-$(CONFIG_TI_SYSCON_RESET) += reset-ti-syscon.o > obj-$(CONFIG_RESET_UNIPHIER) += reset-uniphier.o > obj-$(CONFIG_RESET_ZYNQ) += reset-zynq.o > +obj-$(CONFIG_RESET_ZX2967) += reset-zx2967.o > diff --git a/drivers/reset/reset-zx2967.c b/drivers/reset/reset-zx2967.c > new file mode 100644 > index 0000000..63f9c41 > --- /dev/null > +++ b/drivers/reset/reset-zx2967.c > @@ -0,0 +1,136 @@ > +/* > + * ZTE's zx2967 family thermal sensor driver This description is incorrect. > + * > + * Copyright (C) 2017 ZTE Ltd. > + * > + * Author: Baoyou Xie <baoyou.xie@linaro.org> > + * > + * License terms: GNU General Public License (GPL) version 2 > + */ > + > +#include <linux/module.h> > +#include <linux/of_address.h> > +#include <linux/platform_device.h> > +#include <linux/reset-controller.h> > + > +struct zx2967_reset { > + void __iomem *reg_base; > + spinlock_t lock; > + struct reset_controller_dev rcdev; > +}; > + > +static int zx2967_reset_assert(struct reset_controller_dev *rcdev, > + unsigned long id) > +{ > + struct zx2967_reset *reset = NULL; > + int bank = id / 32; > + int offset = id % 32; > + unsigned int reg; > + unsigned long flags; > + > + reset = container_of(rcdev, struct zx2967_reset, rcdev); > + > + spin_lock_irqsave(&reset->lock, flags); > + > + reg = readl(reset->reg_base + (bank * 4)); > + writel(reg & ~BIT(offset), reset->reg_base + (bank * 4)); > + reg = readl(reset->reg_base + (bank * 4)); > + > + spin_unlock_irqrestore(&reset->lock, flags); > + > + return 0; > +} > + > +static int zx2967_reset_deassert(struct reset_controller_dev *rcdev, > + unsigned long id) > +{ > + struct zx2967_reset *reset = NULL; > + int bank = id / 32; > + int offset = id % 32; > + unsigned int reg; > + unsigned long flags; > + > + reset = container_of(rcdev, struct zx2967_reset, rcdev); > + > + spin_lock_irqsave(&reset->lock, flags); > + > + reg = readl(reset->reg_base + (bank * 4)); > + writel(reg | BIT(offset), reset->reg_base + (bank * 4)); > + reg = readl(reset->reg_base + (bank * 4)); > + > + spin_unlock_irqrestore(&reset->lock, flags); > + > + return 0; > +} > + > +static struct reset_control_ops zx2967_reset_ops = { > + .assert = zx2967_reset_assert, > + .deassert = zx2967_reset_deassert, > +}; > + > +static int zx2967_reset_probe(struct platform_device *pdev) > +{ > + struct zx2967_reset *reset; > + struct resource *res; > + > + reset = devm_kzalloc(&pdev->dev, sizeof(*reset), GFP_KERNEL); > + if (!reset) > + return -ENOMEM; > + > + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); > + reset->reg_base = devm_ioremap_resource(&pdev->dev, res); > + if (IS_ERR(reset->reg_base)) > + return PTR_ERR(reset->reg_base); > + > + spin_lock_init(&reset->lock); > + > + reset->rcdev.owner = THIS_MODULE; > + reset->rcdev.nr_resets = resource_size(res) * 8; > + reset->rcdev.ops = &zx2967_reset_ops; > + reset->rcdev.of_node = pdev->dev.of_node; > + > + dev_info(&pdev->dev, "reset controller cnt:%d", > + reset->rcdev.nr_resets); > + > + return reset_controller_register(&reset->rcdev); As Shawn suggested, use the devm_ variant here. It allows you to drop the remove function below. > +} > + > +static int zx2967_reset_remove(struct platform_device *pdev) > +{ > + struct zx2967_reset *reset = platform_get_drvdata(pdev); > + > + reset_controller_unregister(&reset->rcdev); > + > + return 0; > +} > + > +static const struct of_device_id zx2967_reset_dt_ids[] = { > + { .compatible = "zte,zx296718-reset", }, > + {}, > +}; > +MODULE_DEVICE_TABLE(of, zx2967_reset_dt_ids); > + > +static struct platform_driver zx2967_reset_driver = { > + .probe = zx2967_reset_probe, > + .remove = zx2967_reset_remove, > + .driver = { > + .name = "zx2967-reset", > + .of_match_table = zx2967_reset_dt_ids, > + }, > +}; > + > +static int __init zx2967_reset_init(void) > +{ > + return platform_driver_register(&zx2967_reset_driver); > +} > +arch_initcall(zx2967_reset_init); > + > +static void __exit zx2967_reset_exit(void) > +{ > + platform_driver_unregister(&zx2967_reset_driver); > +} > +module_exit(zx2967_reset_exit); > + > +MODULE_AUTHOR("Baoyou Xie <baoyou.xie@linaro.org>"); > +MODULE_DESCRIPTION("ZTE zx2967 Reset Controller Driver"); > +MODULE_LICENSE("GPL"); regards Philipp ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v1 1/3] dt: bindings: add documentation for zx2967 family reset controller 2017-01-14 7:05 [PATCH v1 1/3] dt: bindings: add documentation for zx2967 family reset controller Baoyou Xie 2017-01-14 7:05 ` [PATCH v1 2/3] MAINTAINERS: add zx2967 reset controller driver to ARM ZTE architecture Baoyou Xie 2017-01-14 7:05 ` [PATCH v1 3/3] reset: zx2967: add reset controller driver for ZTE's zx2967 family Baoyou Xie @ 2017-01-16 7:09 ` Shawn Guo [not found] ` <1484377530-30635-1-git-send-email-baoyou.xie-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> 3 siblings, 0 replies; 8+ messages in thread From: Shawn Guo @ 2017-01-16 7:09 UTC (permalink / raw) To: Baoyou Xie Cc: jun.nie, p.zabel, robh+dt, mark.rutland, linux-arm-kernel, devicetree, linux-kernel, xie.baoyou, chen.chaokai, wang.qiang01 On Sat, Jan 14, 2017 at 03:05:28PM +0800, Baoyou Xie wrote: > This patch adds dt-binding documentation for zx2967 family > reset controller. > > Signed-off-by: Baoyou Xie <baoyou.xie@linaro.org> Reviewed-by: Shawn Guo <shawnguo@kernel.org> ^ permalink raw reply [flat|nested] 8+ messages in thread
[parent not found: <1484377530-30635-1-git-send-email-baoyou.xie-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>]
* Re: [PATCH v1 1/3] dt: bindings: add documentation for zx2967 family reset controller [not found] ` <1484377530-30635-1-git-send-email-baoyou.xie-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> @ 2017-01-16 9:57 ` Philipp Zabel 0 siblings, 0 replies; 8+ messages in thread From: Philipp Zabel @ 2017-01-16 9:57 UTC (permalink / raw) To: Baoyou Xie Cc: jun.nie-QSEj5FYQhm4dnm+yROfE0A, robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, devicetree-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA, shawnguo-DgEjT+Ai2ygdnm+yROfE0A, xie.baoyou-Th6q7B73Y6EnDS1+zs4M5A, chen.chaokai-Th6q7B73Y6EnDS1+zs4M5A, wang.qiang01-Th6q7B73Y6EnDS1+zs4M5A Hi, On Sat, 2017-01-14 at 15:05 +0800, Baoyou Xie wrote: > This patch adds dt-binding documentation for zx2967 family > reset controller. > > Signed-off-by: Baoyou Xie <baoyou.xie-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> > --- > .../devicetree/bindings/reset/zte,zx2967-reset.txt | 20 ++++++++++++++++++++ > 1 file changed, 20 insertions(+) > create mode 100644 Documentation/devicetree/bindings/reset/zte,zx2967-reset.txt > > diff --git a/Documentation/devicetree/bindings/reset/zte,zx2967-reset.txt b/Documentation/devicetree/bindings/reset/zte,zx2967-reset.txt > new file mode 100644 > index 0000000..22d590e > --- /dev/null > +++ b/Documentation/devicetree/bindings/reset/zte,zx2967-reset.txt > @@ -0,0 +1,20 @@ > +ZTE zx2967 SoCs Reset Controller > +======================================= > + > +Please also refer to reset.txt in this directory for common reset > +controller binding usage. > + > +Required properties: > +- compatible: should be one of the following. > + * zte,zx296718-reset > +- reg: physical base address of the controller and length of memory mapped > + region. > +- #reset-cells: must be 1. > + > +example: > + > + toprst: reset@1461060 { That node should be named reset-controller. > + compatible = "zte,zx296718-reset"; > + reg = <0x01461060 0x8>; > + #reset-cells = <1>; > + }; regards Philipp -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2017-01-16 9:58 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-14 7:05 [PATCH v1 1/3] dt: bindings: add documentation for zx2967 family reset controller Baoyou Xie
2017-01-14 7:05 ` [PATCH v1 2/3] MAINTAINERS: add zx2967 reset controller driver to ARM ZTE architecture Baoyou Xie
2017-01-14 7:05 ` [PATCH v1 3/3] reset: zx2967: add reset controller driver for ZTE's zx2967 family Baoyou Xie
[not found] ` <1484377530-30635-3-git-send-email-baoyou.xie-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2017-01-16 7:44 ` Shawn Guo
2017-01-16 7:58 ` Shawn Guo
2017-01-16 9:58 ` Philipp Zabel
2017-01-16 7:09 ` [PATCH v1 1/3] dt: bindings: add documentation for zx2967 family reset controller Shawn Guo
[not found] ` <1484377530-30635-1-git-send-email-baoyou.xie-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2017-01-16 9:57 ` Philipp Zabel
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).