mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-05 08:26:59 +00:00
crypto: sunxi-ss - Add optional reset control support
On sun6i and later platforms, the reset control is split out of the clock gates. Add support for an optional reset control. Signed-off-by: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
parent
ca6bc691b1
commit
7ab64628bb
2 changed files with 24 additions and 0 deletions
|
@ -22,6 +22,7 @@
|
||||||
#include <linux/scatterlist.h>
|
#include <linux/scatterlist.h>
|
||||||
#include <linux/interrupt.h>
|
#include <linux/interrupt.h>
|
||||||
#include <linux/delay.h>
|
#include <linux/delay.h>
|
||||||
|
#include <linux/reset.h>
|
||||||
|
|
||||||
#include "sun4i-ss.h"
|
#include "sun4i-ss.h"
|
||||||
|
|
||||||
|
@ -253,6 +254,14 @@ static int sun4i_ss_probe(struct platform_device *pdev)
|
||||||
}
|
}
|
||||||
dev_dbg(&pdev->dev, "clock ahb_ss acquired\n");
|
dev_dbg(&pdev->dev, "clock ahb_ss acquired\n");
|
||||||
|
|
||||||
|
ss->reset = devm_reset_control_get_optional(&pdev->dev, "ahb");
|
||||||
|
if (IS_ERR(ss->reset)) {
|
||||||
|
if (PTR_ERR(ss->reset) == -EPROBE_DEFER)
|
||||||
|
return PTR_ERR(ss->reset);
|
||||||
|
dev_info(&pdev->dev, "no reset control found\n");
|
||||||
|
ss->reset = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/* Enable both clocks */
|
/* Enable both clocks */
|
||||||
err = clk_prepare_enable(ss->busclk);
|
err = clk_prepare_enable(ss->busclk);
|
||||||
if (err != 0) {
|
if (err != 0) {
|
||||||
|
@ -275,6 +284,15 @@ static int sun4i_ss_probe(struct platform_device *pdev)
|
||||||
goto error_clk;
|
goto error_clk;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Deassert reset if we have a reset control */
|
||||||
|
if (ss->reset) {
|
||||||
|
err = reset_control_deassert(ss->reset);
|
||||||
|
if (err) {
|
||||||
|
dev_err(&pdev->dev, "Cannot deassert reset control\n");
|
||||||
|
goto error_clk;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The only impact on clocks below requirement are bad performance,
|
* The only impact on clocks below requirement are bad performance,
|
||||||
* so do not print "errors"
|
* so do not print "errors"
|
||||||
|
@ -352,6 +370,8 @@ static int sun4i_ss_probe(struct platform_device *pdev)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (ss->reset)
|
||||||
|
reset_control_assert(ss->reset);
|
||||||
error_clk:
|
error_clk:
|
||||||
clk_disable_unprepare(ss->ssclk);
|
clk_disable_unprepare(ss->ssclk);
|
||||||
error_ssclk:
|
error_ssclk:
|
||||||
|
@ -376,6 +396,8 @@ static int sun4i_ss_remove(struct platform_device *pdev)
|
||||||
}
|
}
|
||||||
|
|
||||||
writel(0, ss->base + SS_CTL);
|
writel(0, ss->base + SS_CTL);
|
||||||
|
if (ss->reset)
|
||||||
|
reset_control_assert(ss->reset);
|
||||||
clk_disable_unprepare(ss->busclk);
|
clk_disable_unprepare(ss->busclk);
|
||||||
clk_disable_unprepare(ss->ssclk);
|
clk_disable_unprepare(ss->ssclk);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/of.h>
|
#include <linux/of.h>
|
||||||
#include <linux/platform_device.h>
|
#include <linux/platform_device.h>
|
||||||
|
#include <linux/reset.h>
|
||||||
#include <crypto/scatterwalk.h>
|
#include <crypto/scatterwalk.h>
|
||||||
#include <linux/scatterlist.h>
|
#include <linux/scatterlist.h>
|
||||||
#include <linux/interrupt.h>
|
#include <linux/interrupt.h>
|
||||||
|
@ -129,6 +130,7 @@ struct sun4i_ss_ctx {
|
||||||
int irq;
|
int irq;
|
||||||
struct clk *busclk;
|
struct clk *busclk;
|
||||||
struct clk *ssclk;
|
struct clk *ssclk;
|
||||||
|
struct reset_control *reset;
|
||||||
struct device *dev;
|
struct device *dev;
|
||||||
struct resource *res;
|
struct resource *res;
|
||||||
spinlock_t slock; /* control the use of the device */
|
spinlock_t slock; /* control the use of the device */
|
||||||
|
|
Loading…
Reference in a new issue