Skip to content

Commit 0c0ef9e

Browse files
tmlindherbertx
authored andcommitted
hwrng: omap3-rom - Fix missing clock by probing with device tree
Commit 0ed266d ("clk: ti: omap3: cleanup unnecessary clock aliases") removed old omap3 clock framework aliases but caused omap3-rom-rng to stop working with clock not found error. Based on discussions on the mailing list it was requested by Tero Kristo that it would be best to fix this issue by probing omap3-rom-rng using device tree to provide a proper clk property. The other option would be to add back the missing clock alias, but that does not help moving things forward with removing old legacy platform_data. Let's also add a proper device tree binding and keep it together with the fix. Cc: [email protected] Cc: Aaro Koskinen <[email protected]> Cc: Adam Ford <[email protected]> Cc: Pali Rohár <[email protected]> Cc: Rob Herring <[email protected]> Cc: Sebastian Reichel <[email protected]> Cc: Tero Kristo <[email protected]> Fixes: 0ed266d ("clk: ti: omap3: cleanup unnecessary clock aliases") Reported-by: Aaro Koskinen <[email protected]> Signed-off-by: Tony Lindgren <[email protected]> Acked-by: Rob Herring <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 7fb61af commit 0c0ef9e

File tree

4 files changed

+49
-13
lines changed

4 files changed

+49
-13
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
OMAP ROM RNG driver binding
2+
3+
Secure SoCs may provide RNG via secure ROM calls like Nokia N900 does. The
4+
implementation can depend on the SoC secure ROM used.
5+
6+
- compatible:
7+
Usage: required
8+
Value type: <string>
9+
Definition: must be "nokia,n900-rom-rng"
10+
11+
- clocks:
12+
Usage: required
13+
Value type: <prop-encoded-array>
14+
Definition: reference to the the RNG interface clock
15+
16+
- clock-names:
17+
Usage: required
18+
Value type: <stringlist>
19+
Definition: must be "ick"
20+
21+
Example:
22+
23+
rom_rng: rng {
24+
compatible = "nokia,n900-rom-rng";
25+
clocks = <&rng_ick>;
26+
clock-names = "ick";
27+
};

arch/arm/boot/dts/omap3-n900.dts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,12 @@
155155
pwms = <&pwm9 0 26316 0>; /* 38000 Hz */
156156
};
157157

158+
rom_rng: rng {
159+
compatible = "nokia,n900-rom-rng";
160+
clocks = <&rng_ick>;
161+
clock-names = "ick";
162+
};
163+
158164
/* controlled (enabled/disabled) directly by bcm2048 and wl1251 */
159165
vctcxo: vctcxo {
160166
compatible = "fixed-clock";

arch/arm/mach-omap2/pdata-quirks.c

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -262,14 +262,6 @@ static void __init am3517_evm_legacy_init(void)
262262
am35xx_emac_reset();
263263
}
264264

265-
static struct platform_device omap3_rom_rng_device = {
266-
.name = "omap3-rom-rng",
267-
.id = -1,
268-
.dev = {
269-
.platform_data = rx51_secure_rng_call,
270-
},
271-
};
272-
273265
static void __init nokia_n900_legacy_init(void)
274266
{
275267
hsmmc2_internal_input_clk();
@@ -285,9 +277,6 @@ static void __init nokia_n900_legacy_init(void)
285277
pr_warn("RX-51: Not enabling ARM errata 430973 workaround\n");
286278
pr_warn("Thumb binaries may crash randomly without this workaround\n");
287279
}
288-
289-
pr_info("RX-51: Registering OMAP3 HWRNG device\n");
290-
platform_device_register(&omap3_rom_rng_device);
291280
}
292281
}
293282

@@ -627,6 +616,7 @@ static struct of_dev_auxdata omap_auxdata_lookup[] = {
627616
OF_DEV_AUXDATA("ti,davinci_mdio", 0x5c030000, "davinci_mdio.0", NULL),
628617
OF_DEV_AUXDATA("ti,am3517-emac", 0x5c000000, "davinci_emac.0",
629618
&am35xx_emac_pdata),
619+
OF_DEV_AUXDATA("nokia,n900-rom-rng", 0, NULL, rx51_secure_rng_call),
630620
/* McBSP modules with sidetone core */
631621
#if IS_ENABLED(CONFIG_SND_SOC_OMAP_MCBSP)
632622
OF_DEV_AUXDATA("ti,omap3-mcbsp", 0x49022000, "49022000.mcbsp", &mcbsp_pdata),

drivers/char/hw_random/omap3-rom-rng.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#include <linux/workqueue.h>
2121
#include <linux/clk.h>
2222
#include <linux/err.h>
23+
#include <linux/of.h>
24+
#include <linux/of_device.h>
2325
#include <linux/platform_device.h>
2426

2527
#define RNG_RESET 0x01
@@ -86,14 +88,18 @@ static int omap3_rom_rng_read(struct hwrng *rng, void *data, size_t max, bool w)
8688

8789
static struct hwrng omap3_rom_rng_ops = {
8890
.name = "omap3-rom",
89-
.read = omap3_rom_rng_read,
9091
};
9192

9293
static int omap3_rom_rng_probe(struct platform_device *pdev)
9394
{
9495
int ret = 0;
9596

96-
pr_info("initializing\n");
97+
omap3_rom_rng_ops.read = of_device_get_match_data(&pdev->dev);
98+
if (!omap3_rom_rng_ops.read) {
99+
dev_err(&pdev->dev, "missing rom code handler\n");
100+
101+
return -ENODEV;
102+
}
97103

98104
omap3_rom_rng_call = pdev->dev.platform_data;
99105
if (!omap3_rom_rng_call) {
@@ -125,9 +131,16 @@ static int omap3_rom_rng_remove(struct platform_device *pdev)
125131
return 0;
126132
}
127133

134+
static const struct of_device_id omap_rom_rng_match[] = {
135+
{ .compatible = "nokia,n900-rom-rng", .data = omap3_rom_rng_read, },
136+
{ /* sentinel */ },
137+
};
138+
MODULE_DEVICE_TABLE(of, omap_rom_rng_match);
139+
128140
static struct platform_driver omap3_rom_rng_driver = {
129141
.driver = {
130142
.name = "omap3-rom-rng",
143+
.of_match_table = omap_rom_rng_match,
131144
},
132145
.probe = omap3_rom_rng_probe,
133146
.remove = omap3_rom_rng_remove,

0 commit comments

Comments
 (0)