All of lore.kernel.org
 help / color / mirror / Atom feed
From: Philipp Zabel <p.zabel@pengutronix.de>
To: Damien Le Moal <damien.lemoal@wdc.com>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	linux-riscv@lists.infradead.org, Rob Herring <robh+dt@kernel.org>,
	devicetree@vger.kernel.org, Stephen Boyd <sboyd@kernel.org>,
	linux-clk@vger.kernel.org,
	Linus Walleij <linus.walleij@linaro.org>,
	linux-gpio@vger.kernel.org
Cc: Sean Anderson <seanga2@gmail.com>
Subject: Re: [PATCH v4 13/21] riscv: Add Canaan Kendryte K210 reset controller
Date: Fri, 04 Dec 2020 11:49:19 +0100	[thread overview]
Message-ID: <aad38b7cbaa2b22092ad466cf01ec7e0c1f08b72.camel@pengutronix.de> (raw)
In-Reply-To: <20201202032500.206346-14-damien.lemoal@wdc.com>

Hi Damien,

On Wed, 2020-12-02 at 12:24 +0900, Damien Le Moal wrote:
> Add a reset controller driver for the Canaan Kendryte K210 SoC. This
> driver relies on its syscon compatible parent node (sysctl) for its
> register mapping. Automatically select this driver for compilation
> when the SOC_CANAAN option is selected.
> 
> The MAINTAINERS file is updated, adding the entry "CANAAN/KENDRYTE K210
> SOC RESET CONTROLLER DRIVER" with myself listed as maintainer for this
> driver.
> 
> Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
> ---
>  MAINTAINERS                |   8 +++
>  arch/riscv/Kconfig.socs    |   3 +
>  drivers/reset/Kconfig      |   9 +++
>  drivers/reset/Makefile     |   1 +
>  drivers/reset/reset-k210.c | 141 +++++++++++++++++++++++++++++++++++++
>  5 files changed, 162 insertions(+)
>  create mode 100644 drivers/reset/reset-k210.c
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index a059ab02fa8a..c2b3d6e48cd5 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -3837,6 +3837,14 @@ L:	linux-gpio@vger.kernel.org (pinctrl driver)
>  F:	Documentation/devicetree/bindings/pinctrl/canaan,k210-fpioa.yaml
>  F:	drivers/pinctrl/pinctrl-k210.c
>  
> +CANAAN/KENDRYTE K210 SOC RESET CONTROLLER DRIVER
> +M:	Damien Le Moal <damien.lemoal@wdc.com>
> +L:	linux-kernel@vger.kernel.org
> +L:	linux-riscv@lists.infradead.org
> +S:	Maintained
> +F:	Documentation/devicetree/bindings/reset/canaan,k210-rst.yaml
> +F:	drivers/reset/reset-k210.c
> +
>  CANAAN/KENDRYTE K210 SOC SYSTEM CONTROLLER DRIVER
>  M:	Damien Le Moal <damien.lemoal@wdc.com>
>  L:	linux-riscv@lists.infradead.org
> diff --git a/arch/riscv/Kconfig.socs b/arch/riscv/Kconfig.socs
> index 68bdd664b5c2..b3cd253ec2c2 100644
> --- a/arch/riscv/Kconfig.socs
> +++ b/arch/riscv/Kconfig.socs
> @@ -33,6 +33,9 @@ config SOC_CANAAN
>  	select CLK_K210
>  	select PINCTRL
>  	select PINCTRL_K210
> +	select ARCH_HAS_RESET_CONTROLLER
> +	select RESET_CONTROLLER
> +	select RESET_K210
>  	help
>  	  This enables support for Canaan Kendryte K210 SoC platform hardware.
>  
> diff --git a/drivers/reset/Kconfig b/drivers/reset/Kconfig
> index 07d162b179fc..529d206cfdfd 100644
> --- a/drivers/reset/Kconfig
> +++ b/drivers/reset/Kconfig
> @@ -245,6 +245,15 @@ config RESET_ZYNQ
>  	help
>  	  This enables the reset controller driver for Xilinx Zynq SoCs.
>  
> +config RESET_K210
> +	bool "Reset controller driver for Canaan Kendryte K210 SoC"
> +	depends on RISCV && SOC_CANAAN
> +	depends on OF && MFD_SYSCON
> +	help
> +	  Support for the Canaan Kendryte K210 RISC-V SoC reset controller.
> +	  Say Y if you want to control reset signals provided by this
> +	  controller.
> +
>  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 16947610cc3b..1730a31e6871 100644
> --- a/drivers/reset/Makefile
> +++ b/drivers/reset/Makefile
> @@ -33,4 +33,5 @@ obj-$(CONFIG_RESET_UNIPHIER) += reset-uniphier.o
>  obj-$(CONFIG_RESET_UNIPHIER_GLUE) += reset-uniphier-glue.o
>  obj-$(CONFIG_RESET_ZYNQ) += reset-zynq.o
>  obj-$(CONFIG_ARCH_ZYNQMP) += reset-zynqmp.o
> +obj-$(CONFIG_RESET_K210) += reset-k210.o
>  
> diff --git a/drivers/reset/reset-k210.c b/drivers/reset/reset-k210.c
> new file mode 100644
> index 000000000000..2cf9a63c763d
> --- /dev/null
> +++ b/drivers/reset/reset-k210.c
> @@ -0,0 +1,141 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Copyright (c) 2020 Western Digital Corporation or its affiliates.
> + */
> +#include <linux/of.h>
> +#include <linux/of_device.h>
> +#include <linux/platform_device.h>
> +#include <linux/reset-controller.h>
> +#include <linux/delay.h>
> +#include <linux/mfd/syscon.h>
> +#include <linux/regmap.h>
> +#include <soc/canaan/k210-sysctl.h>
> +
> +#include <dt-bindings/reset/k210-rst.h>
> +
> +#define K210_RST_MASK	0x27FFFFFF
> +
> +struct k210_rst {
> +	struct regmap *map;
> +	struct reset_controller_dev rcdev;
> +};
> +
> +static inline struct k210_rst *
> +to_k210_rst(struct reset_controller_dev *rcdev)
> +{
> +	return container_of(rcdev, struct k210_rst, rcdev);
> +}
> +
> +static inline int k210_rst_assert(struct reset_controller_dev *rcdev,
> +				  unsigned long id)
> +{
> +	struct k210_rst *ksr = to_k210_rst(rcdev);
> +	u32 bit = BIT(id);
> +
> +	if (!(bit & K210_RST_MASK))
> +		return -EINVAL;

Instead of checking this mask in the k210_rst_assert/deassert/status()
functions, you could implement a custom .of_xlate callback and disallow
requesting invalid resets in the first place.

regards
Philipp

WARNING: multiple messages have this Message-ID (diff)
From: Philipp Zabel <p.zabel@pengutronix.de>
To: Damien Le Moal <damien.lemoal@wdc.com>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	 linux-riscv@lists.infradead.org,
	Rob Herring <robh+dt@kernel.org>,
	 devicetree@vger.kernel.org, Stephen Boyd <sboyd@kernel.org>,
	 linux-clk@vger.kernel.org,
	Linus Walleij <linus.walleij@linaro.org>,
	 linux-gpio@vger.kernel.org
Cc: Sean Anderson <seanga2@gmail.com>
Subject: Re: [PATCH v4 13/21] riscv: Add Canaan Kendryte K210 reset controller
Date: Fri, 04 Dec 2020 11:49:19 +0100	[thread overview]
Message-ID: <aad38b7cbaa2b22092ad466cf01ec7e0c1f08b72.camel@pengutronix.de> (raw)
In-Reply-To: <20201202032500.206346-14-damien.lemoal@wdc.com>

Hi Damien,

On Wed, 2020-12-02 at 12:24 +0900, Damien Le Moal wrote:
> Add a reset controller driver for the Canaan Kendryte K210 SoC. This
> driver relies on its syscon compatible parent node (sysctl) for its
> register mapping. Automatically select this driver for compilation
> when the SOC_CANAAN option is selected.
> 
> The MAINTAINERS file is updated, adding the entry "CANAAN/KENDRYTE K210
> SOC RESET CONTROLLER DRIVER" with myself listed as maintainer for this
> driver.
> 
> Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
> ---
>  MAINTAINERS                |   8 +++
>  arch/riscv/Kconfig.socs    |   3 +
>  drivers/reset/Kconfig      |   9 +++
>  drivers/reset/Makefile     |   1 +
>  drivers/reset/reset-k210.c | 141 +++++++++++++++++++++++++++++++++++++
>  5 files changed, 162 insertions(+)
>  create mode 100644 drivers/reset/reset-k210.c
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index a059ab02fa8a..c2b3d6e48cd5 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -3837,6 +3837,14 @@ L:	linux-gpio@vger.kernel.org (pinctrl driver)
>  F:	Documentation/devicetree/bindings/pinctrl/canaan,k210-fpioa.yaml
>  F:	drivers/pinctrl/pinctrl-k210.c
>  
> +CANAAN/KENDRYTE K210 SOC RESET CONTROLLER DRIVER
> +M:	Damien Le Moal <damien.lemoal@wdc.com>
> +L:	linux-kernel@vger.kernel.org
> +L:	linux-riscv@lists.infradead.org
> +S:	Maintained
> +F:	Documentation/devicetree/bindings/reset/canaan,k210-rst.yaml
> +F:	drivers/reset/reset-k210.c
> +
>  CANAAN/KENDRYTE K210 SOC SYSTEM CONTROLLER DRIVER
>  M:	Damien Le Moal <damien.lemoal@wdc.com>
>  L:	linux-riscv@lists.infradead.org
> diff --git a/arch/riscv/Kconfig.socs b/arch/riscv/Kconfig.socs
> index 68bdd664b5c2..b3cd253ec2c2 100644
> --- a/arch/riscv/Kconfig.socs
> +++ b/arch/riscv/Kconfig.socs
> @@ -33,6 +33,9 @@ config SOC_CANAAN
>  	select CLK_K210
>  	select PINCTRL
>  	select PINCTRL_K210
> +	select ARCH_HAS_RESET_CONTROLLER
> +	select RESET_CONTROLLER
> +	select RESET_K210
>  	help
>  	  This enables support for Canaan Kendryte K210 SoC platform hardware.
>  
> diff --git a/drivers/reset/Kconfig b/drivers/reset/Kconfig
> index 07d162b179fc..529d206cfdfd 100644
> --- a/drivers/reset/Kconfig
> +++ b/drivers/reset/Kconfig
> @@ -245,6 +245,15 @@ config RESET_ZYNQ
>  	help
>  	  This enables the reset controller driver for Xilinx Zynq SoCs.
>  
> +config RESET_K210
> +	bool "Reset controller driver for Canaan Kendryte K210 SoC"
> +	depends on RISCV && SOC_CANAAN
> +	depends on OF && MFD_SYSCON
> +	help
> +	  Support for the Canaan Kendryte K210 RISC-V SoC reset controller.
> +	  Say Y if you want to control reset signals provided by this
> +	  controller.
> +
>  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 16947610cc3b..1730a31e6871 100644
> --- a/drivers/reset/Makefile
> +++ b/drivers/reset/Makefile
> @@ -33,4 +33,5 @@ obj-$(CONFIG_RESET_UNIPHIER) += reset-uniphier.o
>  obj-$(CONFIG_RESET_UNIPHIER_GLUE) += reset-uniphier-glue.o
>  obj-$(CONFIG_RESET_ZYNQ) += reset-zynq.o
>  obj-$(CONFIG_ARCH_ZYNQMP) += reset-zynqmp.o
> +obj-$(CONFIG_RESET_K210) += reset-k210.o
>  
> diff --git a/drivers/reset/reset-k210.c b/drivers/reset/reset-k210.c
> new file mode 100644
> index 000000000000..2cf9a63c763d
> --- /dev/null
> +++ b/drivers/reset/reset-k210.c
> @@ -0,0 +1,141 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Copyright (c) 2020 Western Digital Corporation or its affiliates.
> + */
> +#include <linux/of.h>
> +#include <linux/of_device.h>
> +#include <linux/platform_device.h>
> +#include <linux/reset-controller.h>
> +#include <linux/delay.h>
> +#include <linux/mfd/syscon.h>
> +#include <linux/regmap.h>
> +#include <soc/canaan/k210-sysctl.h>
> +
> +#include <dt-bindings/reset/k210-rst.h>
> +
> +#define K210_RST_MASK	0x27FFFFFF
> +
> +struct k210_rst {
> +	struct regmap *map;
> +	struct reset_controller_dev rcdev;
> +};
> +
> +static inline struct k210_rst *
> +to_k210_rst(struct reset_controller_dev *rcdev)
> +{
> +	return container_of(rcdev, struct k210_rst, rcdev);
> +}
> +
> +static inline int k210_rst_assert(struct reset_controller_dev *rcdev,
> +				  unsigned long id)
> +{
> +	struct k210_rst *ksr = to_k210_rst(rcdev);
> +	u32 bit = BIT(id);
> +
> +	if (!(bit & K210_RST_MASK))
> +		return -EINVAL;

Instead of checking this mask in the k210_rst_assert/deassert/status()
functions, you could implement a custom .of_xlate callback and disallow
requesting invalid resets in the first place.

regards
Philipp

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

  reply	other threads:[~2020-12-04 10:50 UTC|newest]

Thread overview: 78+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-02  3:24 [PATCH v4 00/21] RISC-V Kendryte K210 support improvements Damien Le Moal
2020-12-02  3:24 ` Damien Le Moal
2020-12-02  3:24 ` [PATCH v4 01/21] riscv: Fix kernel time_init() Damien Le Moal
2020-12-02  3:24   ` Damien Le Moal
2020-12-05  5:41   ` Stephen Boyd
2020-12-05  5:41     ` Stephen Boyd
2020-12-02  3:24 ` [PATCH v4 02/21] riscv: Fix sifive serial driver Damien Le Moal
2020-12-02  3:24   ` Damien Le Moal
2020-12-02  3:24 ` [PATCH v4 03/21] riscv: Enable interrupts during syscalls with M-Mode Damien Le Moal
2020-12-02  3:24   ` Damien Le Moal
2020-12-02  3:24 ` [PATCH v4 04/21] riscv: Fix builtin DTB handling Damien Le Moal
2020-12-02  3:24   ` Damien Le Moal
2020-12-04 15:11   ` Geert Uytterhoeven
2020-12-04 15:11     ` Geert Uytterhoeven
2020-12-02  3:24 ` [PATCH v4 05/21] riscv: Use vendor name for K210 SoC support Damien Le Moal
2020-12-02  3:24   ` Damien Le Moal
2020-12-02  3:24 ` [PATCH v4 06/21] dt-bindings: Add Canaan vendor prefix Damien Le Moal
2020-12-02  3:24   ` Damien Le Moal
2020-12-02  3:24 ` [PATCH v4 07/21] dt-binding: clock: Document canaan,k210-clk bindings Damien Le Moal
2020-12-02  3:24   ` [PATCH v4 07/21] dt-binding: clock: Document canaan, k210-clk bindings Damien Le Moal
2020-12-05  5:46   ` [PATCH v4 07/21] dt-binding: clock: Document canaan,k210-clk bindings Stephen Boyd
2020-12-05  5:46     ` [PATCH v4 07/21] dt-binding: clock: Document canaan, k210-clk bindings Stephen Boyd
2020-12-02  3:24 ` [PATCH v4 08/21] dt-bindings: reset: Document canaan,k210-rst bindings Damien Le Moal
2020-12-02  3:24   ` [PATCH v4 08/21] dt-bindings: reset: Document canaan, k210-rst bindings Damien Le Moal
2020-12-02  3:24 ` [PATCH v4 09/21] dt-bindings: pinctrl: Document canaan,k210-fpioa bindings Damien Le Moal
2020-12-02  3:24   ` [PATCH v4 09/21] dt-bindings: pinctrl: Document canaan, k210-fpioa bindings Damien Le Moal
2020-12-02  3:24 ` [PATCH v4 10/21] dt-binding: mfd: Document canaan,k210-sysctl bindings Damien Le Moal
2020-12-02  3:24   ` [PATCH v4 10/21] dt-binding: mfd: Document canaan, k210-sysctl bindings Damien Le Moal
2020-12-02  3:24 ` [PATCH v4 11/21] riscv: Add Canaan Kendryte K210 clock driver Damien Le Moal
2020-12-02  3:24   ` Damien Le Moal
2020-12-05  6:19   ` Stephen Boyd
2020-12-05  6:19     ` Stephen Boyd
2020-12-05  7:43     ` Damien Le Moal
2020-12-05  7:43       ` Damien Le Moal
2020-12-05 13:43       ` Sean Anderson
2020-12-05 13:43         ` Sean Anderson
2020-12-05 14:13         ` Damien Le Moal
2020-12-05 14:13           ` Damien Le Moal
     [not found]       ` <160736612827.1580929.7802371235304556600@swboyd.mtv.corp.google.com>
2020-12-08  7:48         ` Damien Le Moal
2020-12-08  7:48           ` Damien Le Moal
2020-12-07  3:50     ` Damien Le Moal
2020-12-07  3:50       ` Damien Le Moal
2020-12-07  8:43       ` Geert Uytterhoeven
2020-12-07  8:43         ` Geert Uytterhoeven
2020-12-07  9:55         ` Damien Le Moal
2020-12-07  9:55           ` Damien Le Moal
2020-12-07 10:06           ` Geert Uytterhoeven
2020-12-07 10:06             ` Geert Uytterhoeven
2020-12-07 10:14             ` Damien Le Moal
2020-12-07 10:14               ` Damien Le Moal
2020-12-07 22:58               ` Sean Anderson
2020-12-07 22:58                 ` Sean Anderson
2020-12-07 11:34             ` Damien Le Moal
2020-12-07 11:34               ` Damien Le Moal
2020-12-02  3:24 ` [PATCH v4 12/21] riscv: Add Canaan Kendryte K210 FPIOA driver Damien Le Moal
2020-12-02  3:24   ` Damien Le Moal
2020-12-02  3:24 ` [PATCH v4 13/21] riscv: Add Canaan Kendryte K210 reset controller Damien Le Moal
2020-12-02  3:24   ` Damien Le Moal
2020-12-04 10:49   ` Philipp Zabel [this message]
2020-12-04 10:49     ` Philipp Zabel
2020-12-04 11:16     ` Damien Le Moal
2020-12-04 11:16       ` Damien Le Moal
2020-12-02  3:24 ` [PATCH v4 14/21] riscv: Update Canaan Kendryte K210 device tree Damien Le Moal
2020-12-02  3:24   ` Damien Le Moal
2020-12-02  3:24 ` [PATCH v4 15/21] riscv: Add SiPeed MAIX BiT board " Damien Le Moal
2020-12-02  3:24   ` Damien Le Moal
2020-12-02  3:24 ` [PATCH v4 16/21] riscv: Add SiPeed MAIX DOCK " Damien Le Moal
2020-12-02  3:24   ` Damien Le Moal
2020-12-02  3:24 ` [PATCH v4 17/21] riscv: Add SiPeed MAIX GO " Damien Le Moal
2020-12-02  3:24   ` Damien Le Moal
2020-12-02  3:24 ` [PATCH v4 18/21] riscv: Add SiPeed MAIXDUINO " Damien Le Moal
2020-12-02  3:24   ` Damien Le Moal
2020-12-02  3:24 ` [PATCH v4 19/21] riscv: Add Kendryte KD233 " Damien Le Moal
2020-12-02  3:24   ` Damien Le Moal
2020-12-02  3:24 ` [PATCH v4 20/21] riscv: Update Canaan Kendryte K210 defconfig Damien Le Moal
2020-12-02  3:24   ` Damien Le Moal
2020-12-02  3:25 ` [PATCH v4 21/21] riscv: Add Canaan Kendryte K210 SD card defconfig Damien Le Moal
2020-12-02  3:25   ` Damien Le Moal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aad38b7cbaa2b22092ad466cf01ec7e0c1f08b72.camel@pengutronix.de \
    --to=p.zabel@pengutronix.de \
    --cc=damien.lemoal@wdc.com \
    --cc=devicetree@vger.kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@dabbelt.com \
    --cc=robh+dt@kernel.org \
    --cc=sboyd@kernel.org \
    --cc=seanga2@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.