Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ARC: reset: introduce AXS10x reset driver

ARC AXS10x boards support custom IP-block which allows to control
reset signals of selected peripherals. For example DW GMAC, etc...
This block is controlled via memory-mapped register (AKA CREG) which
represents up-to 32 reset lines. This regiter is self-clearing so we
don't need to deassert line after reset.

As of today only the following lines are used:
- DW GMAC - line 5

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>

authored by

Eugeniy Paltsev and committed by
Philipp Zabel
37634923 2bd6bf03

+129
+33
Documentation/devicetree/bindings/reset/snps,axs10x-reset.txt
··· 1 + Binding for the AXS10x reset controller 2 + 3 + This binding describes the ARC AXS10x boards custom IP-block which allows 4 + to control reset signals of selected peripherals. For example DW GMAC, etc... 5 + This block is controlled via memory-mapped register (AKA CREG) which 6 + represents up-to 32 reset lines. 7 + 8 + As of today only the following lines are used: 9 + - DW GMAC - line 5 10 + 11 + This binding uses the common reset binding[1]. 12 + 13 + [1] Documentation/devicetree/bindings/reset/reset.txt 14 + 15 + Required properties: 16 + - compatible: should be "snps,axs10x-reset". 17 + - reg: should always contain pair address - length: for creg reset 18 + bits register. 19 + - #reset-cells: from common reset binding; Should always be set to 1. 20 + 21 + Example: 22 + reset: reset-controller@11220 { 23 + compatible = "snps,axs10x-reset"; 24 + #reset-cells = <1>; 25 + reg = <0x11220 0x4>; 26 + }; 27 + 28 + Specifying reset lines connected to IP modules: 29 + ethernet@.... { 30 + .... 31 + resets = <&reset 5>; 32 + .... 33 + };
+6
MAINTAINERS
··· 12883 12883 F: arch/arc/boot/dts/ax* 12884 12884 F: Documentation/devicetree/bindings/arc/axs10* 12885 12885 12886 + SYNOPSYS AXS10x RESET CONTROLLER DRIVER 12887 + M: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com> 12888 + S: Supported 12889 + F: drivers/reset/reset-axs10x.c 12890 + F: Documentation/devicetree/bindings/reset/snps,axs10x-reset.txt 12891 + 12886 12892 SYNOPSYS DESIGNWARE DMAC DRIVER 12887 12893 M: Viresh Kumar <vireshk@kernel.org> 12888 12894 M: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
+6
drivers/reset/Kconfig
··· 28 28 This enables the ATH79 reset controller driver that supports the 29 29 AR71xx SoC reset controller. 30 30 31 + config RESET_AXS10X 32 + bool "AXS10x Reset Driver" if COMPILE_TEST 33 + default ARC_PLAT_AXS10X 34 + help 35 + This enables the reset controller driver for AXS10x. 36 + 31 37 config RESET_BERLIN 32 38 bool "Berlin Reset Driver" if COMPILE_TEST 33 39 default ARCH_BERLIN
+1
drivers/reset/Makefile
··· 4 4 obj-$(CONFIG_ARCH_TEGRA) += tegra/ 5 5 obj-$(CONFIG_RESET_A10SR) += reset-a10sr.o 6 6 obj-$(CONFIG_RESET_ATH79) += reset-ath79.o 7 + obj-$(CONFIG_RESET_AXS10X) += reset-axs10x.o 7 8 obj-$(CONFIG_RESET_BERLIN) += reset-berlin.o 8 9 obj-$(CONFIG_RESET_HSDK_V1) += reset-hsdk-v1.o 9 10 obj-$(CONFIG_RESET_IMX7) += reset-imx7.o
+83
drivers/reset/reset-axs10x.c
··· 1 + /* 2 + * Copyright (C) 2017 Synopsys. 3 + * 4 + * Synopsys AXS10x reset driver. 5 + * 6 + * This file is licensed under the terms of the GNU General Public 7 + * License version 2. This program is licensed "as is" without any 8 + * warranty of any kind, whether express or implied. 9 + */ 10 + 11 + #include <linux/io.h> 12 + #include <linux/module.h> 13 + #include <linux/platform_device.h> 14 + #include <linux/reset-controller.h> 15 + 16 + #define to_axs10x_rst(p) container_of((p), struct axs10x_rst, rcdev) 17 + 18 + #define AXS10X_MAX_RESETS 32 19 + 20 + struct axs10x_rst { 21 + void __iomem *regs_rst; 22 + spinlock_t lock; 23 + struct reset_controller_dev rcdev; 24 + }; 25 + 26 + static int axs10x_reset_reset(struct reset_controller_dev *rcdev, 27 + unsigned long id) 28 + { 29 + struct axs10x_rst *rst = to_axs10x_rst(rcdev); 30 + unsigned long flags; 31 + 32 + spin_lock_irqsave(&rst->lock, flags); 33 + writel(BIT(id), rst->regs_rst); 34 + spin_unlock_irqrestore(&rst->lock, flags); 35 + 36 + return 0; 37 + } 38 + 39 + static const struct reset_control_ops axs10x_reset_ops = { 40 + .reset = axs10x_reset_reset, 41 + }; 42 + 43 + static int axs10x_reset_probe(struct platform_device *pdev) 44 + { 45 + struct axs10x_rst *rst; 46 + struct resource *mem; 47 + 48 + rst = devm_kzalloc(&pdev->dev, sizeof(*rst), GFP_KERNEL); 49 + if (!rst) 50 + return -ENOMEM; 51 + 52 + mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 53 + rst->regs_rst = devm_ioremap_resource(&pdev->dev, mem); 54 + if (IS_ERR(rst->regs_rst)) 55 + return PTR_ERR(rst->regs_rst); 56 + 57 + spin_lock_init(&rst->lock); 58 + 59 + rst->rcdev.owner = THIS_MODULE; 60 + rst->rcdev.ops = &axs10x_reset_ops; 61 + rst->rcdev.of_node = pdev->dev.of_node; 62 + rst->rcdev.nr_resets = AXS10X_MAX_RESETS; 63 + 64 + return devm_reset_controller_register(&pdev->dev, &rst->rcdev); 65 + } 66 + 67 + static const struct of_device_id axs10x_reset_dt_match[] = { 68 + { .compatible = "snps,axs10x-reset" }, 69 + { }, 70 + }; 71 + 72 + static struct platform_driver axs10x_reset_driver = { 73 + .probe = axs10x_reset_probe, 74 + .driver = { 75 + .name = "axs10x-reset", 76 + .of_match_table = axs10x_reset_dt_match, 77 + }, 78 + }; 79 + builtin_platform_driver(axs10x_reset_driver); 80 + 81 + MODULE_AUTHOR("Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>"); 82 + MODULE_DESCRIPTION("Synopsys AXS10x reset driver"); 83 + MODULE_LICENSE("GPL v2");