Hi Vitor,

On Mon, 2019-04-08 at 12:31 +0200, Vitor Soares wrote:
> Some custom IP-block connected to ARC AXS10x board need assert and
> deassert functions to control reset signal of selected peripherals.
> 
> This patch improve AXS10x reset driver by adding assert and deassert
> callbacks.


In the AXS10x reset driver only 'reset' callback is intentionally implemented.
AXS10x is FPGA based boards and with our default firmware AXS10x reset register 
is implemented as self-deasserted.

Do you have somehow modified AXS10x firmware where reset register is not 
self-deasserted?
In that case "simple-reset" driver will be suitable for you, I guess.
Otherwise this implementation is incorrect - there should be no 'assert' for 
reset controller with self-deasserted logic.


> 
> Signed-off-by: Vitor Soares <[email protected]>
> 
> Cc: Eugeniy Paltsev <[email protected]>
> Cc: Alexey Brodkin <[email protected]>
> Cc: Joao Pinto <[email protected]>
> Cc: Jose Abreu <[email protected]>
> Cc: Luis Oliveira <[email protected]>
> Cc: Gustavo Pimentel <[email protected]>
> Cc: Nelson Costa <[email protected]>
> Cc: Pedro Sousa <[email protected]>
> Cc: Philipp Zabel <[email protected]>
> ---
>  drivers/reset/reset-axs10x.c | 30 +++++++++++++++++++++++++++++-
>  1 file changed, 29 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/reset/reset-axs10x.c b/drivers/reset/reset-axs10x.c
> index a854ef41..12dac8b 100644
> --- a/drivers/reset/reset-axs10x.c
> +++ b/drivers/reset/reset-axs10x.c
> @@ -37,8 +37,36 @@ static int axs10x_reset_reset(struct reset_controller_dev 
> *rcdev,
>       return 0;
>  }
>  
> +static int axs10x_reset_assert(struct reset_controller_dev *rcdev,
> +                            unsigned long id)
> +{
> +     struct axs10x_rst *rst = to_axs10x_rst(rcdev);
> +     unsigned long flags;
> +
> +     spin_lock_irqsave(&rst->lock, flags);
> +     writel(readl(rst->regs_rst) & ~BIT(id), rst->regs_rst);
> +     spin_unlock_irqrestore(&rst->lock, flags);
> +
> +     return 0;
> +}
> +
> +static int axs10x_reset_deassert(struct reset_controller_dev *rcdev,
> +                              unsigned long id)
> +{
> +     struct axs10x_rst *rst = to_axs10x_rst(rcdev);
> +     unsigned long flags;
> +
> +     spin_lock_irqsave(&rst->lock, flags);
> +     writel(readl(rst->regs_rst) | BIT(id), rst->regs_rst);
> +     spin_unlock_irqrestore(&rst->lock, flags);
> +
> +     return 0;
> +}
> +
>  static const struct reset_control_ops axs10x_reset_ops = {
> -     .reset  = axs10x_reset_reset,
> +     .reset          = axs10x_reset_reset,
> +     .assert         = axs10x_reset_assert,
> +     .deassert       = axs10x_reset_deassert,
>  };
>  
>  static int axs10x_reset_probe(struct platform_device *pdev)
-- 
 Eugeniy Paltsev

Reply via email to