From: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
To: Philipp Zabel <p.zabel@pengutronix.de>
Cc: mturquette@baylibre.com, sboyd@kernel.org, afaerber@suse.de,
robh+dt@kernel.org, linux-clk@vger.kernel.org,
liuwei@actions-semi.com, mp-cs@actions-semi.com,
96boards@ucrobotics.com, devicetree@vger.kernel.org,
daniel.thompson@linaro.org, amit.kucheria@linaro.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, hzhang@ucrobotics.com,
bdong@ucrobotics.com, manivannanece23@gmail.com,
thomas.liau@actions-semi.com, jeff.chen@actions-semi.com,
pn@denx.de, edgar.righi@lsitec.org.br, sravanhome@gmail.com
Subject: Re: [PATCH 7/9] clk: actions: Add Actions Semi Owl SoCs Reset Management Unit support
Date: Wed, 1 Aug 2018 09:04:16 +0530 [thread overview]
Message-ID: <20180801033416.GA15529@Mani-XPS-13-9360> (raw)
In-Reply-To: <1532946112.3471.2.camel@pengutronix.de>
Hi Philipp,
On Mon, Jul 30, 2018 at 12:21:52PM +0200, Philipp Zabel wrote:
> Hi Manivannan,
>
> Thank you for the patch, a few small comments below:
>
> On Sat, 2018-07-28 at 00:15 +0530, Manivannan Sadhasivam wrote:
> > Add Reset Management Unit (RMU) support for Actions Semi Owl SoCs.
> >
> > Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> > ---
> > drivers/clk/actions/Kconfig | 1 +
> > drivers/clk/actions/Makefile | 1 +
> > drivers/clk/actions/owl-common.h | 2 +
> > drivers/clk/actions/owl-reset.c | 72 ++++++++++++++++++++++++++++++++
> > drivers/clk/actions/owl-reset.h | 32 ++++++++++++++
> > 5 files changed, 108 insertions(+)
> > create mode 100644 drivers/clk/actions/owl-reset.c
> > create mode 100644 drivers/clk/actions/owl-reset.h
> >
> > diff --git a/drivers/clk/actions/Kconfig b/drivers/clk/actions/Kconfig
> > index dc38c85a4833..04f0a6355726 100644
> > --- a/drivers/clk/actions/Kconfig
> > +++ b/drivers/clk/actions/Kconfig
> > @@ -2,6 +2,7 @@ config CLK_ACTIONS
> > bool "Clock driver for Actions Semi SoCs"
> > depends on ARCH_ACTIONS || COMPILE_TEST
> > select REGMAP_MMIO
> > + select RESET_CONTROLLER
> > default ARCH_ACTIONS
> >
> > if CLK_ACTIONS
> > diff --git a/drivers/clk/actions/Makefile b/drivers/clk/actions/Makefile
> > index 78c17d56f991..ccfdf9781cef 100644
> > --- a/drivers/clk/actions/Makefile
> > +++ b/drivers/clk/actions/Makefile
> > @@ -7,6 +7,7 @@ clk-owl-y += owl-divider.o
> > clk-owl-y += owl-factor.o
> > clk-owl-y += owl-composite.o
> > clk-owl-y += owl-pll.o
> > +clk-owl-y += owl-reset.o
> >
> > # SoC support
> > obj-$(CONFIG_CLK_OWL_S700) += owl-s700.o
> > diff --git a/drivers/clk/actions/owl-common.h b/drivers/clk/actions/owl-common.h
> > index 56f01f7774aa..4dc7f286831f 100644
> > --- a/drivers/clk/actions/owl-common.h
> > +++ b/drivers/clk/actions/owl-common.h
> > @@ -26,6 +26,8 @@ struct owl_clk_desc {
> > struct owl_clk_common **clks;
> > unsigned long num_clks;
> > struct clk_hw_onecell_data *hw_clks;
> > + struct owl_reset_map *resets;
>
> Could this be:
> const struct owl_reset_map *resets;
> ?
>
Ack.
> > + unsigned long num_resets;
> > struct regmap *regmap;
> > };
> >
> > diff --git a/drivers/clk/actions/owl-reset.c b/drivers/clk/actions/owl-reset.c
> > new file mode 100644
> > index 000000000000..91b161cc68de
> > --- /dev/null
> > +++ b/drivers/clk/actions/owl-reset.c
> > @@ -0,0 +1,72 @@
> > +// SPDX-License-Identifier: GPL-2.0-or-later
> > +//
> > +// Actions Semi Owl SoCs Reset Management Unit driver
> > +//
> > +// Copyright (c) 2018 Linaro Ltd.
> > +// Author: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> > +
> > +#include <linux/delay.h>
> > +#include <linux/io.h>
>
> This seems unnecessary, since register access is done via regmap.
>
Will remove this header.
> > +#include <linux/regmap.h>
> > +#include <linux/reset-controller.h>
> > +
> > +#include "owl-reset.h"
> > +
> > +static int owl_reset_assert(struct reset_controller_dev *rcdev,
> > + unsigned long id)
> > +{
> > + struct owl_reset *reset = to_owl_reset(rcdev);
> > + const struct owl_reset_map *map = &reset->reset_map[id];
> > + u32 reg;
> > +
> > + regmap_read(reset->regmap, map->reg, ®);
> > + regmap_write(reset->regmap, map->reg, reg & ~map->bit);
>
> This read-modify-write sequence needs locking against concurrent
> register access. Better use regmap_update_bits():
>
> return regmap_update_bits(reset->regmap, map->reg, map->bit, 0);
>
Ack.
> > +
> > + return 0;
> > +}
> > +
> > +static int owl_reset_deassert(struct reset_controller_dev *rcdev,
> > + unsigned long id)
> > +{
> > + struct owl_reset *reset = to_owl_reset(rcdev);
> > + const struct owl_reset_map *map = &reset->reset_map[id];
> > + u32 reg;
> > +
> > + regmap_read(reset->regmap, map->reg, ®);
> > + regmap_write(reset->regmap, map->reg, reg | map->bit);
>
> Better:
>
> return regmap_update_bits(reset->regmap, map->reg, map->bit, map->bit);
>
Ack.
> > +
> > + return 0;
> > +}
> > +
> > +static int owl_reset_reset(struct reset_controller_dev *rcdev,
> > + unsigned long id)
> > +{
> > + owl_reset_assert(rcdev, id);
> > + udelay(1);
>
> Is the delay valid for all IP cores on all SoCs variants?
>
It is valid for S900 and S700 for now but I'm not sure about S500. Will
make sure while adding S500 support.
> > + owl_reset_deassert(rcdev, id);
> > +
> > + return 0;
> > +}
> > +
> > +static int owl_reset_status(struct reset_controller_dev *rcdev,
> > + unsigned long id)
> > +{
> > + struct owl_reset *reset = to_owl_reset(rcdev);
> > + const struct owl_reset_map *map = &reset->reset_map[id];
> > + u32 reg;
> > +
> > + regmap_read(reset->regmap, map->reg, ®);
>
> If this could return an error, better report it.
>
Ack.
> > +
> > + /*
> > + * The reset control API expects 0 if reset is not asserted,
> > + * which is the opposite of what our hardware uses.
> > + */
> > + return !(map->bit & reg);
> > +}
> > +
> > +const struct reset_control_ops owl_reset_ops = {
> > + .assert = owl_reset_assert,
> > + .deassert = owl_reset_deassert,
> > + .reset = owl_reset_reset,
> > + .status = owl_reset_status,
> > +};
> > diff --git a/drivers/clk/actions/owl-reset.h b/drivers/clk/actions/owl-reset.h
> > new file mode 100644
> > index 000000000000..1a5e987ba99b
> > --- /dev/null
> > +++ b/drivers/clk/actions/owl-reset.h
> > @@ -0,0 +1,32 @@
> > +// SPDX-License-Identifier: GPL-2.0-or-later
> > +//
> > +// Actions Semi Owl SoCs Reset Management Unit driver
> > +//
> > +// Copyright (c) 2018 Linaro Ltd.
> > +// Author: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> > +
> > +#ifndef _OWL_RESET_H_
> > +#define _OWL_RESET_H_
> > +
> > +#include <linux/reset-controller.h>
> > +#include <linux/spinlock.h>
>
> spinlock?
>
Oops. Not needed, will remove that.
> > +
> > +struct owl_reset_map {
> > + u16 reg;
>
> Note that this will be aligned to 32-bits. If the intention was to save
> space, consider storing an u8 bit index instead of the mask.
>
Better to change it to u32, no need of memory saving here :)
> > + u32 bit;
> > +};
> > +
> > +struct owl_reset {
> > + struct reset_controller_dev rcdev;
> > + struct owl_reset_map *reset_map;
>
> Could this be
> const struct owl_reset_map *reset_map;
> ?
>
Ack.
Thanks,
Mani
> > + struct regmap *regmap;
> > +};
> > +
> > +static inline struct owl_reset *to_owl_reset(struct reset_controller_dev *rcdev)
> > +{
> > + return container_of(rcdev, struct owl_reset, rcdev);
> > +}
> > +
> > +extern const struct reset_control_ops owl_reset_ops;
> > +
> > +#endif /* _OWL_RESET_H_ */
>
> regards
> Philipp
next prev parent reply other threads:[~2018-08-01 3:34 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-27 18:45 [PATCH 0/9] Add Reset Controller support for Actions Semi Owl SoCs Manivannan Sadhasivam
2018-07-27 18:45 ` [PATCH 1/9] clk: actions: Cache regmap info in private clock descriptor Manivannan Sadhasivam
2018-07-27 18:45 ` [PATCH 2/9] dt-bindings: clock: Add reset controller bindings for Actions Semi Owl SoCs Manivannan Sadhasivam
2018-08-07 18:48 ` Rob Herring
2018-07-27 18:45 ` [PATCH 3/9] dt-bindings: reset: Add binding constants for Actions Semi S700 RMU Manivannan Sadhasivam
2018-08-07 18:49 ` Rob Herring
2018-07-27 18:45 ` [PATCH 4/9] dt-bindings: reset: Add binding constants for Actions Semi S900 RMU Manivannan Sadhasivam
2018-08-07 18:50 ` Rob Herring
2018-07-27 18:45 ` [PATCH 5/9] arm64: dts: actions: Add Reset Controller support for S700 SoC Manivannan Sadhasivam
2018-07-29 18:34 ` Parthiban Nallathambi
2018-07-27 18:45 ` [PATCH 6/9] arm64: dts: actions: Add Reset Controller support for S900 SoC Manivannan Sadhasivam
2018-07-27 18:45 ` [PATCH 7/9] clk: actions: Add Actions Semi Owl SoCs Reset Management Unit support Manivannan Sadhasivam
2018-07-30 10:21 ` Philipp Zabel
2018-08-01 3:34 ` Manivannan Sadhasivam [this message]
2018-07-27 18:45 ` [PATCH 8/9] clk: actions: Add Actions Semi S700 SoC " Manivannan Sadhasivam
2018-07-30 10:40 ` Philipp Zabel
2018-07-27 18:45 ` [PATCH 9/9] clk: actions: Add Actions Semi S900 " Manivannan Sadhasivam
2018-07-30 10:26 ` [PATCH 0/9] Add Reset Controller support for Actions Semi Owl SoCs Andreas Färber
2018-07-30 15:11 ` Manivannan Sadhasivam
2018-07-30 15:38 ` Philipp Zabel
2018-07-30 16:09 ` Manivannan Sadhasivam
2018-08-07 18:47 ` Rob Herring
2018-08-08 17:29 ` Manivannan Sadhasivam
2018-08-08 18:21 ` Rob Herring
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=20180801033416.GA15529@Mani-XPS-13-9360 \
--to=manivannan.sadhasivam@linaro.org \
--cc=96boards@ucrobotics.com \
--cc=afaerber@suse.de \
--cc=amit.kucheria@linaro.org \
--cc=bdong@ucrobotics.com \
--cc=daniel.thompson@linaro.org \
--cc=devicetree@vger.kernel.org \
--cc=edgar.righi@lsitec.org.br \
--cc=hzhang@ucrobotics.com \
--cc=jeff.chen@actions-semi.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liuwei@actions-semi.com \
--cc=manivannanece23@gmail.com \
--cc=mp-cs@actions-semi.com \
--cc=mturquette@baylibre.com \
--cc=p.zabel@pengutronix.de \
--cc=pn@denx.de \
--cc=robh+dt@kernel.org \
--cc=sboyd@kernel.org \
--cc=sravanhome@gmail.com \
--cc=thomas.liau@actions-semi.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 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).