lkml.org 
[lkml]   [2019]   [Jun]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
Subject[Example code] crypto: qcom-rng: Add interconnect devfreq support
From
This is just an example code and I'm not actually trying to get this
merged.

Bjorn,

This is what the code would look like. It compiles, but I can't test it.
I'm not sending this as part of the patch series as I'm not sure what
the interconnects property should be set to in DT for qcom-rng device
nor is QCOM RNG an ideal candidate for bandwidth scaling using devfreq.
It can probably just set the bandwidth to some fixed low value like 1
KB/s. But this is pretty much all the code one would need if they wanted
to enable interconnect scaling for their interconnect path using
devfreq.

-Saravana

Signed-off-by: Saravana Kannan <saravanak@google.com>
---
drivers/crypto/qcom-rng.c | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/drivers/crypto/qcom-rng.c b/drivers/crypto/qcom-rng.c
index e54249ccc009..7a92238061ca 100644
--- a/drivers/crypto/qcom-rng.c
+++ b/drivers/crypto/qcom-rng.c
@@ -9,6 +9,7 @@
#include <linux/crypto.h>
#include <linux/module.h>
#include <linux/of.h>
+#include <linux/interconnect.h>
#include <linux/platform_device.h>

/* Device specific register offsets */
@@ -37,6 +38,7 @@ struct qcom_rng_ctx {
};

static struct qcom_rng *qcom_rng_dev;
+static struct icc_devfreq *icc_df;

static int qcom_rng_read(struct qcom_rng *rng, u8 *data, unsigned int max)
{
@@ -186,6 +188,13 @@ static int qcom_rng_probe(struct platform_device *pdev)
qcom_rng_dev = NULL;
}

+ ret = dev_pm_opp_of_add_table_indexed(&pdev->dev, 0);
+ if (ret)
+ return ret;
+ icc_df = icc_create_devfreq(&pdev->dev, "prng-slv");
+ if (IS_ERR(icc_df))
+ return PTR_ERR(icc_df);
+
return ret;
}

--
2.22.0.rc2.383.gf4fbbf30c2-goog
\
 
 \ /
  Last update: 2019-06-11 01:12    [W:0.076 / U:0.500 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site