* [PATCH 0/4] hwrng: exynos - Add Device Tree support
@ 2015-10-19 4:37 Krzysztof Kozlowski
2015-10-19 4:37 ` [PATCH 1/4] dt-bindings: rng: Describe Exynos4 PRNG bindings Krzysztof Kozlowski
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Krzysztof Kozlowski @ 2015-10-19 4:37 UTC (permalink / raw)
To: Kukjin Kim, Krzysztof Kozlowski, Matt Mackall, Herbert Xu,
devicetree, linux-arm-kernel, linux-samsung-soc, linux-kernel,
linux-crypto
Cc: Heiner Kallweit
Hi,
The patchset fixes known issues in Exynos hardware random number
generator and adds Device Tree support for it.
The device was tested on Trats2 board (Exynos4412). It should work
on other Exynos4 and Exynos5 as well... altough it seems that
on some of Exynos542x boards the SSS module is secured.
Best regards,
Krzysztof
Krzysztof Kozlowski (4):
dt-bindings: rng: Describe Exynos4 PRNG bindings
hwrng: exynos - Add timeout for waiting on init done
hwrng: exynos - Fix missing configuration after suspend to RAM
hwrng: exynos - Add Device Tree support
.../bindings/rng/samsung,exynos-rng4.txt | 17 +++++++
drivers/char/hw_random/exynos-rng.c | 56 ++++++++++++++++++----
2 files changed, 65 insertions(+), 8 deletions(-)
create mode 100644 Documentation/devicetree/bindings/rng/samsung,exynos-rng4.txt
--
1.9.1
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH 1/4] dt-bindings: rng: Describe Exynos4 PRNG bindings 2015-10-19 4:37 [PATCH 0/4] hwrng: exynos - Add Device Tree support Krzysztof Kozlowski @ 2015-10-19 4:37 ` Krzysztof Kozlowski 2015-10-19 4:37 ` [PATCH 2/4] hwrng: exynos - Add timeout for waiting on init done Krzysztof Kozlowski ` (2 subsequent siblings) 3 siblings, 0 replies; 7+ messages in thread From: Krzysztof Kozlowski @ 2015-10-19 4:37 UTC (permalink / raw) To: Kukjin Kim, Krzysztof Kozlowski, Matt Mackall, Herbert Xu, devicetree, linux-arm-kernel, linux-samsung-soc, linux-kernel, linux-crypto Cc: Heiner Kallweit Document the bindings used by exynos-rng Pseudo Random Number Generator driver. Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> --- .../devicetree/bindings/rng/samsung,exynos-rng4.txt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 Documentation/devicetree/bindings/rng/samsung,exynos-rng4.txt diff --git a/Documentation/devicetree/bindings/rng/samsung,exynos-rng4.txt b/Documentation/devicetree/bindings/rng/samsung,exynos-rng4.txt new file mode 100644 index 000000000000..4ca8dd4d7e66 --- /dev/null +++ b/Documentation/devicetree/bindings/rng/samsung,exynos-rng4.txt @@ -0,0 +1,17 @@ +Exynos Pseudo Random Number Generator + +Required properties: + +- compatible : Should be "samsung,exynos4-rng". +- reg : Specifies base physical address and size of the registers map. +- clocks : Phandle to clock-controller plus clock-specifier pair. +- clock-names : "secss" as a clock name. + +Example: + + rng@10830400 { + compatible = "samsung,exynos4-rng"; + reg = <0x10830400 0x200>; + clocks = <&clock CLK_SSS>; + clock-names = "secss"; + }; -- 1.9.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/4] hwrng: exynos - Add timeout for waiting on init done 2015-10-19 4:37 [PATCH 0/4] hwrng: exynos - Add Device Tree support Krzysztof Kozlowski 2015-10-19 4:37 ` [PATCH 1/4] dt-bindings: rng: Describe Exynos4 PRNG bindings Krzysztof Kozlowski @ 2015-10-19 4:37 ` Krzysztof Kozlowski 2015-10-19 4:37 ` [PATCH 4/4] hwrng: exynos - Add Device Tree support Krzysztof Kozlowski [not found] ` <1445229462-32395-1-git-send-email-k.kozlowski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org> 3 siblings, 0 replies; 7+ messages in thread From: Krzysztof Kozlowski @ 2015-10-19 4:37 UTC (permalink / raw) To: Kukjin Kim, Krzysztof Kozlowski, Matt Mackall, Herbert Xu, devicetree, linux-arm-kernel, linux-samsung-soc, linux-kernel, linux-crypto Cc: Heiner Kallweit Driver may hang waiting indefinitely for PRNG to finish its initialization stage. Instead of stalling return -ETIMEDOUT error. Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> --- drivers/char/hw_random/exynos-rng.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/char/hw_random/exynos-rng.c b/drivers/char/hw_random/exynos-rng.c index dc4701fd814f..dfaaaafb8ddd 100644 --- a/drivers/char/hw_random/exynos-rng.c +++ b/drivers/char/hw_random/exynos-rng.c @@ -81,14 +81,17 @@ static int exynos_read(struct hwrng *rng, void *buf, struct exynos_rng *exynos_rng = container_of(rng, struct exynos_rng, rng); u32 *data = buf; + int retry = 100; pm_runtime_get_sync(exynos_rng->dev); exynos_rng_writel(exynos_rng, PRNG_START, 0); while (!(exynos_rng_readl(exynos_rng, - EXYNOS_PRNG_STATUS_OFFSET) & PRNG_DONE)) + EXYNOS_PRNG_STATUS_OFFSET) & PRNG_DONE) && --retry) cpu_relax(); + if (!retry) + return -ETIMEDOUT; exynos_rng_writel(exynos_rng, PRNG_DONE, EXYNOS_PRNG_STATUS_OFFSET); -- 1.9.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 4/4] hwrng: exynos - Add Device Tree support 2015-10-19 4:37 [PATCH 0/4] hwrng: exynos - Add Device Tree support Krzysztof Kozlowski 2015-10-19 4:37 ` [PATCH 1/4] dt-bindings: rng: Describe Exynos4 PRNG bindings Krzysztof Kozlowski 2015-10-19 4:37 ` [PATCH 2/4] hwrng: exynos - Add timeout for waiting on init done Krzysztof Kozlowski @ 2015-10-19 4:37 ` Krzysztof Kozlowski [not found] ` <1445229462-32395-1-git-send-email-k.kozlowski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org> 3 siblings, 0 replies; 7+ messages in thread From: Krzysztof Kozlowski @ 2015-10-19 4:37 UTC (permalink / raw) To: Kukjin Kim, Krzysztof Kozlowski, Matt Mackall, Herbert Xu, devicetree, linux-arm-kernel, linux-samsung-soc, linux-kernel, linux-crypto Cc: Heiner Kallweit Add Device Tree support for the driver. The Pseudo Random Number Generator module is the same in almost all of Exynos SoCs, since Exynos4210 (however the tests were done only on Trats2 board with Exynos4412). There are some differences on newer Exynos Octa (Exynos542x) SoCs. Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> --- drivers/char/hw_random/exynos-rng.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/char/hw_random/exynos-rng.c b/drivers/char/hw_random/exynos-rng.c index 162adbda1b70..7077c7741dae 100644 --- a/drivers/char/hw_random/exynos-rng.c +++ b/drivers/char/hw_random/exynos-rng.c @@ -188,10 +188,19 @@ static const struct dev_pm_ops exynos_rng_pm_ops = { exynos_rng_runtime_resume, NULL) }; +static const struct of_device_id exynos_rng_dt_match[] = { + { + .compatible = "samsung,exynos4-rng", + }, + { }, +}; +MODULE_DEVICE_TABLE(of, exynos_rng_dt_match); + static struct platform_driver exynos_rng_driver = { .driver = { .name = "exynos-rng", .pm = &exynos_rng_pm_ops, + .of_match_table = exynos_rng_dt_match, }, .probe = exynos_rng_probe, }; -- 1.9.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
[parent not found: <1445229462-32395-1-git-send-email-k.kozlowski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>]
* [PATCH 3/4] hwrng: exynos - Fix missing configuration after suspend to RAM [not found] ` <1445229462-32395-1-git-send-email-k.kozlowski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org> @ 2015-10-19 4:37 ` Krzysztof Kozlowski 2015-10-19 5:03 ` Krzysztof Kozlowski 2015-10-20 14:24 ` [PATCH 0/4] hwrng: exynos - Add Device Tree support Herbert Xu 1 sibling, 1 reply; 7+ messages in thread From: Krzysztof Kozlowski @ 2015-10-19 4:37 UTC (permalink / raw) To: Kukjin Kim, Krzysztof Kozlowski, Matt Mackall, Herbert Xu, devicetree-u79uwXL29TY76Z2rM5mHXA, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA, linux-crypto-u79uwXL29TY76Z2rM5mHXA Cc: Heiner Kallweit After suspend to RAM the device stopped to work with ETIMEDOUT error: $ dd if=/dev/hwrng of=/dev/null bs=1 count=16 dd: reading `/dev/hwrng': Connection timed out In the STATUS register the bits #5 (PRNG_DONE) and #1 (SEED_SETTING_DONE) were not set. Instead PRNG_ERROR (seventh bit) was high. After each system suspend initialize the seed to fix the error. Signed-off-by: Krzysztof Kozlowski <k.kozlowski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org> --- drivers/char/hw_random/exynos-rng.c | 42 ++++++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/drivers/char/hw_random/exynos-rng.c b/drivers/char/hw_random/exynos-rng.c index dfaaaafb8ddd..162adbda1b70 100644 --- a/drivers/char/hw_random/exynos-rng.c +++ b/drivers/char/hw_random/exynos-rng.c @@ -53,15 +53,11 @@ static void exynos_rng_writel(struct exynos_rng *rng, u32 val, u32 offset) __raw_writel(val, rng->mem + offset); } -static int exynos_init(struct hwrng *rng) +static int exynos_rng_configure(struct exynos_rng *exynos_rng) { - struct exynos_rng *exynos_rng = container_of(rng, - struct exynos_rng, rng); int i; int ret = 0; - pm_runtime_get_sync(exynos_rng->dev); - for (i = 0 ; i < 5 ; i++) exynos_rng_writel(exynos_rng, jiffies, EXYNOS_PRNG_SEED_OFFSET + 4*i); @@ -70,6 +66,17 @@ static int exynos_init(struct hwrng *rng) & SEED_SETTING_DONE)) ret = -EIO; + return ret; +} + +static int exynos_init(struct hwrng *rng) +{ + struct exynos_rng *exynos_rng = container_of(rng, + struct exynos_rng, rng); + int ret = 0; + + pm_runtime_get_sync(exynos_rng->dev); + ret = exynos_rng_configure(exynos_rng); pm_runtime_put_noidle(exynos_rng->dev); return ret; @@ -155,10 +162,31 @@ static int exynos_rng_runtime_resume(struct device *dev) return clk_prepare_enable(exynos_rng->clk); } + +static int exynos_rng_suspend(struct device *dev) +{ + return pm_runtime_force_suspend(dev); +} + +static int exynos_rng_resume(struct device *dev) +{ + struct platform_device *pdev = to_platform_device(dev); + struct exynos_rng *exynos_rng = platform_get_drvdata(pdev); + int ret; + + ret = pm_runtime_force_resume(dev); + if (ret) + return ret; + + return exynos_rng_configure(exynos_rng); +} #endif -static UNIVERSAL_DEV_PM_OPS(exynos_rng_pm_ops, exynos_rng_runtime_suspend, - exynos_rng_runtime_resume, NULL); +static const struct dev_pm_ops exynos_rng_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(exynos_rng_suspend, exynos_rng_resume) + SET_RUNTIME_PM_OPS(exynos_rng_runtime_suspend, + exynos_rng_runtime_resume, NULL) +}; static struct platform_driver exynos_rng_driver = { .driver = { -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 3/4] hwrng: exynos - Fix missing configuration after suspend to RAM 2015-10-19 4:37 ` [PATCH 3/4] hwrng: exynos - Fix missing configuration after suspend to RAM Krzysztof Kozlowski @ 2015-10-19 5:03 ` Krzysztof Kozlowski 0 siblings, 0 replies; 7+ messages in thread From: Krzysztof Kozlowski @ 2015-10-19 5:03 UTC (permalink / raw) To: Kukjin Kim, Matt Mackall, Herbert Xu, devicetree, linux-arm-kernel, linux-samsung-soc, linux-kernel, linux-crypto Cc: Heiner Kallweit On 19.10.2015 13:37, Krzysztof Kozlowski wrote: > After suspend to RAM the device stopped to work with ETIMEDOUT error: > > $ dd if=/dev/hwrng of=/dev/null bs=1 count=16 > dd: reading `/dev/hwrng': Connection timed out > > In the STATUS register the bits #5 (PRNG_DONE) and #1 > (SEED_SETTING_DONE) were not set. Instead PRNG_ERROR (seventh bit) was > high. > > After each system suspend initialize the seed to fix the error. > > Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> > --- > drivers/char/hw_random/exynos-rng.c | 42 ++++++++++++++++++++++++++++++------- > 1 file changed, 35 insertions(+), 7 deletions(-) > Oh, I forgot about stable. Fixes: b329669ea0b5 ("hwrng: exynos - Add support for Exynos random number generator") Cc: <stable@vger.kernel.org> I'll add it in respin (if there would be such). Best regards, Krzysztof > diff --git a/drivers/char/hw_random/exynos-rng.c b/drivers/char/hw_random/exynos-rng.c > index dfaaaafb8ddd..162adbda1b70 100644 > --- a/drivers/char/hw_random/exynos-rng.c > +++ b/drivers/char/hw_random/exynos-rng.c > @@ -53,15 +53,11 @@ static void exynos_rng_writel(struct exynos_rng *rng, u32 val, u32 offset) > __raw_writel(val, rng->mem + offset); > } > > -static int exynos_init(struct hwrng *rng) > +static int exynos_rng_configure(struct exynos_rng *exynos_rng) > { > - struct exynos_rng *exynos_rng = container_of(rng, > - struct exynos_rng, rng); > int i; > int ret = 0; > > - pm_runtime_get_sync(exynos_rng->dev); > - > for (i = 0 ; i < 5 ; i++) > exynos_rng_writel(exynos_rng, jiffies, > EXYNOS_PRNG_SEED_OFFSET + 4*i); > @@ -70,6 +66,17 @@ static int exynos_init(struct hwrng *rng) > & SEED_SETTING_DONE)) > ret = -EIO; > > + return ret; > +} > + > +static int exynos_init(struct hwrng *rng) > +{ > + struct exynos_rng *exynos_rng = container_of(rng, > + struct exynos_rng, rng); > + int ret = 0; > + > + pm_runtime_get_sync(exynos_rng->dev); > + ret = exynos_rng_configure(exynos_rng); > pm_runtime_put_noidle(exynos_rng->dev); > > return ret; > @@ -155,10 +162,31 @@ static int exynos_rng_runtime_resume(struct device *dev) > > return clk_prepare_enable(exynos_rng->clk); > } > + > +static int exynos_rng_suspend(struct device *dev) > +{ > + return pm_runtime_force_suspend(dev); > +} > + > +static int exynos_rng_resume(struct device *dev) > +{ > + struct platform_device *pdev = to_platform_device(dev); > + struct exynos_rng *exynos_rng = platform_get_drvdata(pdev); > + int ret; > + > + ret = pm_runtime_force_resume(dev); > + if (ret) > + return ret; > + > + return exynos_rng_configure(exynos_rng); > +} > #endif > > -static UNIVERSAL_DEV_PM_OPS(exynos_rng_pm_ops, exynos_rng_runtime_suspend, > - exynos_rng_runtime_resume, NULL); > +static const struct dev_pm_ops exynos_rng_pm_ops = { > + SET_SYSTEM_SLEEP_PM_OPS(exynos_rng_suspend, exynos_rng_resume) > + SET_RUNTIME_PM_OPS(exynos_rng_runtime_suspend, > + exynos_rng_runtime_resume, NULL) > +}; > > static struct platform_driver exynos_rng_driver = { > .driver = { > ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 0/4] hwrng: exynos - Add Device Tree support [not found] ` <1445229462-32395-1-git-send-email-k.kozlowski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org> 2015-10-19 4:37 ` [PATCH 3/4] hwrng: exynos - Fix missing configuration after suspend to RAM Krzysztof Kozlowski @ 2015-10-20 14:24 ` Herbert Xu 1 sibling, 0 replies; 7+ messages in thread From: Herbert Xu @ 2015-10-20 14:24 UTC (permalink / raw) To: Krzysztof Kozlowski Cc: Kukjin Kim, Matt Mackall, devicetree-u79uwXL29TY76Z2rM5mHXA, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA, linux-crypto-u79uwXL29TY76Z2rM5mHXA, Heiner Kallweit On Mon, Oct 19, 2015 at 01:37:38PM +0900, Krzysztof Kozlowski wrote: > Hi, > > The patchset fixes known issues in Exynos hardware random number > generator and adds Device Tree support for it. > > The device was tested on Trats2 board (Exynos4412). It should work > on other Exynos4 and Exynos5 as well... altough it seems that > on some of Exynos542x boards the SSS module is secured. All applied. Thanks. -- Email: Herbert Xu <herbert-lOAM2aK0SrRLBo1qDEOMRrpzq4S04n8Q@public.gmane.org> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2015-10-20 14:24 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-19 4:37 [PATCH 0/4] hwrng: exynos - Add Device Tree support Krzysztof Kozlowski
2015-10-19 4:37 ` [PATCH 1/4] dt-bindings: rng: Describe Exynos4 PRNG bindings Krzysztof Kozlowski
2015-10-19 4:37 ` [PATCH 2/4] hwrng: exynos - Add timeout for waiting on init done Krzysztof Kozlowski
2015-10-19 4:37 ` [PATCH 4/4] hwrng: exynos - Add Device Tree support Krzysztof Kozlowski
[not found] ` <1445229462-32395-1-git-send-email-k.kozlowski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2015-10-19 4:37 ` [PATCH 3/4] hwrng: exynos - Fix missing configuration after suspend to RAM Krzysztof Kozlowski
2015-10-19 5:03 ` Krzysztof Kozlowski
2015-10-20 14:24 ` [PATCH 0/4] hwrng: exynos - Add Device Tree support Herbert Xu
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).