random: meson-rng: read quality from dts

PD#167718: Setup quality in driver probe so that
meson-rng can contribute to entropy pool.

Change-Id: I47aa7c83b9877f5bf08ac6837f36a648624d0040
Signed-off-by: Mingyen Hung <mingyen.hung@amlogic.com>
This commit is contained in:
Mingyen Hung
2018-06-08 16:19:42 +08:00
committed by Jianxin Pan
parent a95777dd0b
commit c4c221ee44
5 changed files with 21 additions and 2 deletions

View File

@@ -184,6 +184,7 @@
#address-cells = <2>;
#size-cells = <2>;
reg = <0x0 0xff634018 0x0 0x4>;
quality = /bits/ 16 <1000>;
};
mailbox: mhu@c883c400 {

View File

@@ -1019,6 +1019,7 @@
rng {
compatible = "amlogic,meson-rng";
reg = <0x0 0x0 0x0 0x4>;
quality = /bits/ 16 <1000>;
};
};

View File

@@ -1127,6 +1127,7 @@
rng {
compatible = "amlogic,meson-rng";
reg = <0x0 0x0 0x0 0x4>;
quality = /bits/ 16 <1000>;
};
};

View File

@@ -900,6 +900,7 @@
rng {
compatible = "amlogic,meson-rng";
reg = <0x0 0x100 0x0 0x4>;
quality = /bits/ 16 <1000>;
};
};/* end of periphs */

View File

@@ -86,7 +86,9 @@ static int meson_rng_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev;
struct meson_rng_data *data;
struct resource *res;
#ifdef CONFIG_OF
int of_ret = 0;
#endif
data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
if (!data)
return -ENOMEM;
@@ -100,7 +102,20 @@ static int meson_rng_probe(struct platform_device *pdev)
data->rng.name = pdev->name;
data->rng.read = meson_rng_read;
#ifdef CONFIG_OF
of_ret =
of_property_read_u16(pdev->dev.of_node, "quality",
&data->rng.quality);
if (of_ret) {
pr_info("Unable to get quality(%d)\n", of_ret);
// If there is no quality value specified in dts,
// set default quality to 1000 for the reason that
// HW RNG should be good source of entropy, and it
// also leaves room for others to give better
// entropy source
data->rng.quality = 1000;
}
#endif
platform_set_drvdata(pdev, data);
return devm_hwrng_register(dev, &data->rng);