Re: [PATCH] ARC: reset: introduce HSDKv1 reset driver

2017-07-19 Thread Philipp Zabel
On Tue, 2017-07-18 at 20:25 +0300, Eugeniy Paltsev wrote:
> The HSDK v1 periphery IPs can be reset by accessing some registers
> from the CGU block.
> 
> The list of available reset lines is documented in the DT bindings.
> 
> Signed-off-by: Eugeniy Paltsev 
> ---
>  .../bindings/reset/snps,hsdk-v1-reset.txt  |  28 
>  MAINTAINERS|   7 +
>  drivers/reset/Kconfig  |   6 +
>  drivers/reset/Makefile |   1 +
>  drivers/reset/reset-hsdk-v1.c  | 141 
> +
>  include/dt-bindings/reset/snps,hsdk-v1-reset.h |  17 +++
>  6 files changed, 200 insertions(+)
>  create mode 100644 
> Documentation/devicetree/bindings/reset/snps,hsdk-v1-reset.txt
>  create mode 100644 drivers/reset/reset-hsdk-v1.c
>  create mode 100644 include/dt-bindings/reset/snps,hsdk-v1-reset.h
> 
> diff --git a/Documentation/devicetree/bindings/reset/snps,hsdk-v1-reset.txt 
> b/Documentation/devicetree/bindings/reset/snps,hsdk-v1-reset.txt
> new file mode 100644
> index 000..4fdea89
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/reset/snps,hsdk-v1-reset.txt
> @@ -0,0 +1,28 @@
> +Binding for the HSDK v1 reset controller
> +
> +This binding uses the common reset binding[1].
> +
> +[1] Documentation/devicetree/bindings/reset/reset.txt
> +
> +Required properties:
> +- compatible: should be "snps,hsdk-v1.0-reset".
> +- reg: should always contain 2 pairs address - length: first for reset
> +  configuration registers and second for corresponding SW reset and status 
> bits
> +  register.
> +- #reset-cells: from common reset binding; Should always be set to 1.
> +
> +Example:
> + reset: reset@880 {
> + compatible = "snps,hsdk-v1.0-reset";
> + #reset-cells = <1>;
> + reg = <0x880 0x80>, <0xFF0 0x4>;
> + };
> +
> +Specifying reset lines connected to IP modules:
> + ethernet@ {
> + 
> + resets = <&reset HSDK_V1_ETH_RESET>;
> + 
> + };
> +
> +The index could be found in 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 09b5ab6..99deabb 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -11307,6 +11307,13 @@ L:   linux-...@vger.kernel.org
>  S:   Maintained
>  F:   drivers/mmc/host/dw_mmc*
>  
> +SYNOPSYS HSDK RESET CONTROLLER DRIVER
> +M:   Eugeniy Paltsev 
> +S:   Supported
> +F:   drivers/reset/reset-hsdk-v1.c
> +F:   include/dt-bindings/reset/snps,hsdk-v1-reset.h
> +F:   Documentation/devicetree/bindings/reset/snps,hsdk-v1-reset.txt
> +
>  SYSTEM TRACE MODULE CLASS
>  M:   Alexander Shishkin 
>  S:   Maintained
> diff --git a/drivers/reset/Kconfig b/drivers/reset/Kconfig
> index d21c07c..cb13f0d 100644
> --- a/drivers/reset/Kconfig
> +++ b/drivers/reset/Kconfig
> @@ -34,6 +34,12 @@ config RESET_BERLIN
>   help
> This enables the reset controller driver for Marvell Berlin SoCs.
>  
> +config RESET_HSDK_V1
> + bool "HSDK v1 Reset Driver"
> + default n

I suppose there will be a SOC_HSDK_V1 or similar in the future so that
we can hide this option and enable it by default like the other reset
drivers?

> + help
> +   This enables the reset controller driver for HSDK v1.
> +
>  config RESET_IMX7
>   bool "i.MX7 Reset Driver" if COMPILE_TEST
>   default SOC_IMX7D
> diff --git a/drivers/reset/Makefile b/drivers/reset/Makefile
> index 02a74db..772e5f2 100644
> --- a/drivers/reset/Makefile
> +++ b/drivers/reset/Makefile
> @@ -5,6 +5,7 @@ obj-$(CONFIG_ARCH_TEGRA) += tegra/
>  obj-$(CONFIG_RESET_A10SR) += reset-a10sr.o
>  obj-$(CONFIG_RESET_ATH79) += reset-ath79.o
>  obj-$(CONFIG_RESET_BERLIN) += reset-berlin.o
> +obj-$(CONFIG_RESET_HSDK_V1) += reset-hsdk-v1.o
>  obj-$(CONFIG_RESET_IMX7) += reset-imx7.o
>  obj-$(CONFIG_RESET_LPC18XX) += reset-lpc18xx.o
>  obj-$(CONFIG_RESET_MESON) += reset-meson.o
> diff --git a/drivers/reset/reset-hsdk-v1.c b/drivers/reset/reset-hsdk-v1.c
> new file mode 100644
> index 000..64d2a6e
> --- /dev/null
> +++ b/drivers/reset/reset-hsdk-v1.c
> @@ -0,0 +1,141 @@
> +/*
> + * Copyright (C) 2017 Synopsys.
> + *
> + * Synopsys HSDKv1 SDP reset driver.
> + *
> + * 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.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define to_hsdkv1_rst(p) container_of((p), struct hsdkv1_rst, rcdev)
> +
> +struct hsdkv1_rst {
> + void __iomem*regs_ctl;
> + void __iomem*regs_rst;
> + spinlock_t  lock;
> + struct reset_controller_dev rcdev;
> +};
> +
> +static const u32 rst_map[] = {
> + BIT(16), /* APB_RST  */
> + BIT(17), /* AXI_RST  */
> + BIT(18), /* ETH_RST  */
> + BIT(19), /* USB_RST  */
> +  

Re: [PATCH] ARC: reset: introduce HSDKv1 reset driver

2017-07-19 Thread Eugeniy Paltsev
Hi Philipp,

On Wed, 2017-07-19 at 17:07 +0200, Philipp Zabel wrote:
> On Tue, 2017-07-18 at 20:25 +0300, Eugeniy Paltsev wrote:
> > The HSDK v1 periphery IPs can be reset by accessing some registers
> > from the CGU block.
> > 
> > The list of available reset lines is documented in the DT bindings.
> > 
> > [snip]
> > --- a/drivers/reset/Kconfig
> > +++ b/drivers/reset/Kconfig
> > @@ -34,6 +34,12 @@ config RESET_BERLIN
> >     help
> >       This enables the reset controller driver for Marvell
> > Berlin SoCs.
> >  
> > +config RESET_HSDK_V1
> > +   bool "HSDK v1 Reset Driver"
> > +   default n
> 
> I suppose there will be a SOC_HSDK_V1 or similar in the future so
> that
> we can hide this option and enable it by default like the other reset
> drivers?
Actually we don't have (and don't planning to add) such SOC/board-
specific kconfig option, so I am wondering if it is OK to just left
this option not hidden?

> > [snip]
> > +
> > +#define CGU_ARC_RST_CTRL   0x0
> > +#define CGU_SYS_RST_CTRL   0x20
> > +#define CGU_DDR_RST_CTRL   0x40
> > +#define CGU_TUN_RST_CTRL   0x60
> 
> The ARC, DDR, and TUN reset control registers are never used.
Ok, I'll remove unused register defines.

> > [snip]
> 
> regards
> Philipp
> 
Thanks.
-- 
 Eugeniy Paltsev
___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc

Re: [PATCH] ARC: reset: introduce HSDKv1 reset driver

2017-07-19 Thread Philipp Zabel
Hi Eugeniy,

On Wed, 2017-07-19 at 15:32 +, Eugeniy Paltsev wrote:
> Hi Philipp,
> 
> On Wed, 2017-07-19 at 17:07 +0200, Philipp Zabel wrote:
> > On Tue, 2017-07-18 at 20:25 +0300, Eugeniy Paltsev wrote:
> > > The HSDK v1 periphery IPs can be reset by accessing some registers
> > > from the CGU block.
> > > 
> > > The list of available reset lines is documented in the DT bindings.
> > > 
> > > [snip]
> > > --- a/drivers/reset/Kconfig
> > > +++ b/drivers/reset/Kconfig
> > > @@ -34,6 +34,12 @@ config RESET_BERLIN
> > >   help
> > > This enables the reset controller driver for Marvell
> > > Berlin SoCs.
> > >  
> > > +config RESET_HSDK_V1
> > > + bool "HSDK v1 Reset Driver"
> > > + default n
> > 
> > I suppose there will be a SOC_HSDK_V1 or similar in the future so
> > that
> > we can hide this option and enable it by default like the other reset
> > drivers?
> Actually we don't have (and don't planning to add) such SOC/board-
> specific kconfig option, so I am wondering if it is OK to just left
> this option not hidden?

Not a problem, I just prefer to enable reset controllers by default when
building kernels for SoCs that may need them. Sometimes they are even
necessary to boot the system. In those cases, allowing to disable the
reset controller driver at all is not very helpful.

regards
Philipp


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH v2] ARC: reset: introduce HSDKv1 reset driver

2017-07-19 Thread Eugeniy Paltsev
The HSDK v1 periphery IPs can be reset by accessing some registers
from the CGU block.

The list of available reset lines is documented in the DT bindings.

Signed-off-by: Eugeniy Paltsev 
---
Changes v1 -> v2:
 - Remove defines of the unused registers.
 - Map io memory only for single CGU_SYS_RST_CTRL register instead
   of CGU_SYS_*_CTRL, as we use only CGU_SYS_RST_CTRL.


 .../bindings/reset/snps,hsdk-v1-reset.txt  |  28 +
 MAINTAINERS|   7 ++
 drivers/reset/Kconfig  |   6 +
 drivers/reset/Makefile |   1 +
 drivers/reset/reset-hsdk-v1.c  | 137 +
 include/dt-bindings/reset/snps,hsdk-v1-reset.h |  17 +++
 6 files changed, 196 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/reset/snps,hsdk-v1-reset.txt
 create mode 100644 drivers/reset/reset-hsdk-v1.c
 create mode 100644 include/dt-bindings/reset/snps,hsdk-v1-reset.h

diff --git a/Documentation/devicetree/bindings/reset/snps,hsdk-v1-reset.txt 
b/Documentation/devicetree/bindings/reset/snps,hsdk-v1-reset.txt
new file mode 100644
index 000..6a68146
--- /dev/null
+++ b/Documentation/devicetree/bindings/reset/snps,hsdk-v1-reset.txt
@@ -0,0 +1,28 @@
+Binding for the HSDK v1 reset controller
+
+This binding uses the common reset binding[1].
+
+[1] Documentation/devicetree/bindings/reset/reset.txt
+
+Required properties:
+- compatible: should be "snps,hsdk-v1.0-reset".
+- reg: should always contain 2 pairs address - length: first for reset
+  configuration register and second for corresponding SW reset and status bits
+  register.
+- #reset-cells: from common reset binding; Should always be set to 1.
+
+Example:
+   reset: reset@880 {
+   compatible = "snps,hsdk-v1.0-reset";
+   #reset-cells = <1>;
+   reg = <0x8A0 0x4>, <0xFF0 0x4>;
+   };
+
+Specifying reset lines connected to IP modules:
+   ethernet@ {
+   
+   resets = <&reset HSDK_V1_ETH_RESET>;
+   
+   };
+
+The index could be found in 
diff --git a/MAINTAINERS b/MAINTAINERS
index 09b5ab6..99deabb 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -11307,6 +11307,13 @@ L: linux-...@vger.kernel.org
 S: Maintained
 F: drivers/mmc/host/dw_mmc*
 
+SYNOPSYS HSDK RESET CONTROLLER DRIVER
+M: Eugeniy Paltsev 
+S: Supported
+F: drivers/reset/reset-hsdk-v1.c
+F: include/dt-bindings/reset/snps,hsdk-v1-reset.h
+F: Documentation/devicetree/bindings/reset/snps,hsdk-v1-reset.txt
+
 SYSTEM TRACE MODULE CLASS
 M: Alexander Shishkin 
 S: Maintained
diff --git a/drivers/reset/Kconfig b/drivers/reset/Kconfig
index d21c07c..cb13f0d 100644
--- a/drivers/reset/Kconfig
+++ b/drivers/reset/Kconfig
@@ -34,6 +34,12 @@ config RESET_BERLIN
help
  This enables the reset controller driver for Marvell Berlin SoCs.
 
+config RESET_HSDK_V1
+   bool "HSDK v1 Reset Driver"
+   default n
+   help
+ This enables the reset controller driver for HSDK v1.
+
 config RESET_IMX7
bool "i.MX7 Reset Driver" if COMPILE_TEST
default SOC_IMX7D
diff --git a/drivers/reset/Makefile b/drivers/reset/Makefile
index 02a74db..772e5f2 100644
--- a/drivers/reset/Makefile
+++ b/drivers/reset/Makefile
@@ -5,6 +5,7 @@ obj-$(CONFIG_ARCH_TEGRA) += tegra/
 obj-$(CONFIG_RESET_A10SR) += reset-a10sr.o
 obj-$(CONFIG_RESET_ATH79) += reset-ath79.o
 obj-$(CONFIG_RESET_BERLIN) += reset-berlin.o
+obj-$(CONFIG_RESET_HSDK_V1) += reset-hsdk-v1.o
 obj-$(CONFIG_RESET_IMX7) += reset-imx7.o
 obj-$(CONFIG_RESET_LPC18XX) += reset-lpc18xx.o
 obj-$(CONFIG_RESET_MESON) += reset-meson.o
diff --git a/drivers/reset/reset-hsdk-v1.c b/drivers/reset/reset-hsdk-v1.c
new file mode 100644
index 000..bca13e4
--- /dev/null
+++ b/drivers/reset/reset-hsdk-v1.c
@@ -0,0 +1,137 @@
+/*
+ * Copyright (C) 2017 Synopsys.
+ *
+ * Synopsys HSDKv1 SDP reset driver.
+ *
+ * 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.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define to_hsdkv1_rst(p)   container_of((p), struct hsdkv1_rst, rcdev)
+
+struct hsdkv1_rst {
+   void __iomem*regs_ctl;
+   void __iomem*regs_rst;
+   spinlock_t  lock;
+   struct reset_controller_dev rcdev;
+};
+
+static const u32 rst_map[] = {
+   BIT(16), /* APB_RST  */
+   BIT(17), /* AXI_RST  */
+   BIT(18), /* ETH_RST  */
+   BIT(19), /* USB_RST  */
+   BIT(20), /* SDIO_RST */
+   BIT(21), /* HDMI_RST */
+   BIT(22), /* GFX_RST  */
+   BIT(25), /* DMAC_RST */
+   BIT(31), /* EBI_RST  */
+};
+
+#define HSDK_MAX_RESETSARRAY_SIZE(rst_map)
+
+#define

Re: [PATCH] NET: dwmac: Make dwmac reset unconditional

2017-07-19 Thread David Miller
From: Eugeniy Paltsev 
Date: Tue, 18 Jul 2017 17:07:15 +0300

> Unconditional reset dwmac before HW init if reset controller is present.
> 
> In existing implementation we reset dwmac only after second module
> probing:
> (module load -> unload -> load again [reset happens])
> 
> Now we reset dwmac at every module load:
> (module load [reset happens] -> unload -> load again [reset happens])
> 
> Also some reset controllers have only reset callback instead of
> assert + deassert callbacks pair, so handle this case.
> 
> Signed-off-by: Eugeniy Paltsev 

Applied.

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc