arch/m68k/coldfire/device.c | 28 ++++++++++++++++++++++++++++ arch/m68k/coldfire/m5441x.c | 2 +- arch/m68k/include/asm/m5441xsim.h | 9 +++++++++ drivers/char/hw_random/Kconfig | 3 ++- drivers/char/hw_random/imx-rngc.c | 9 ++++++++- 5 files changed, 48 insertions(+), 3 deletions(-)
Add platform device support for the MCF54418 RNGB hardware with clock
enabled at platform initialization.
The imx-rngc driver now uses devm_clk_get_optional() to support both
Coldfire (always-on clock) and i.MX platforms (managed clock).
Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@yoseli.org>
---
arch/m68k/coldfire/device.c | 28 ++++++++++++++++++++++++++++
arch/m68k/coldfire/m5441x.c | 2 +-
arch/m68k/include/asm/m5441xsim.h | 9 +++++++++
drivers/char/hw_random/Kconfig | 3 ++-
drivers/char/hw_random/imx-rngc.c | 9 ++++++++-
5 files changed, 48 insertions(+), 3 deletions(-)
diff --git a/arch/m68k/coldfire/device.c b/arch/m68k/coldfire/device.c
index b6958ec2a220cf91a78a14fc7fa18749451412f7..9d8f844e319a98f0afb79cceb544c2d3029482a4 100644
--- a/arch/m68k/coldfire/device.c
+++ b/arch/m68k/coldfire/device.c
@@ -622,6 +622,31 @@ static struct platform_device mcf_flexcan0 = {
};
#endif /* MCFFLEXCAN_SIZE */
+#ifdef MCF_RNG_BASE
+/*
+ * Random Number Generator (RNG) - only on MCF54418
+ */
+static struct resource mcf_rng_resource[] = {
+ {
+ .start = MCF_RNG_BASE,
+ .end = MCF_RNG_BASE + MCF_RNG_SIZE - 1,
+ .flags = IORESOURCE_MEM,
+ },
+ {
+ .start = MCF_IRQ_RNG,
+ .end = MCF_IRQ_RNG,
+ .flags = IORESOURCE_IRQ,
+ },
+};
+
+static struct platform_device mcf_rng = {
+ .name = "imx-rngc",
+ .id = -1,
+ .num_resources = ARRAY_SIZE(mcf_rng_resource),
+ .resource = mcf_rng_resource,
+};
+#endif /* MCF_RNG_BASE */
+
static struct platform_device *mcf_devices[] __initdata = {
&mcf_uart,
#ifdef MCFFEC_BASE0
@@ -660,6 +685,9 @@ static struct platform_device *mcf_devices[] __initdata = {
#ifdef MCFFLEXCAN_SIZE
&mcf_flexcan0,
#endif
+#ifdef MCF_RNG_BASE
+ &mcf_rng,
+#endif
};
/*
diff --git a/arch/m68k/coldfire/m5441x.c b/arch/m68k/coldfire/m5441x.c
index 7a25cfc7ac07570ff15da3c55d080a717cf93a06..ab5b006372379294db3b522820de88137bfb7e78 100644
--- a/arch/m68k/coldfire/m5441x.c
+++ b/arch/m68k/coldfire/m5441x.c
@@ -158,6 +158,7 @@ static struct clk * const enable_clks[] __initconst = {
&__clk_0_33, /* pit.1 */
&__clk_0_37, /* eport */
&__clk_0_48, /* pll */
+ &__clk_0_49, /* rng */
&__clk_0_51, /* esdhc */
&__clk_1_36, /* CCM/reset module/Power management */
@@ -179,7 +180,6 @@ static struct clk * const disable_clks[] __initconst = {
&__clk_0_44, /* usb otg */
&__clk_0_45, /* usb host */
&__clk_0_47, /* ssi.0 */
- &__clk_0_49, /* rng */
&__clk_0_50, /* ssi.1 */
&__clk_0_53, /* enet-fec */
&__clk_0_54, /* enet-fec */
diff --git a/arch/m68k/include/asm/m5441xsim.h b/arch/m68k/include/asm/m5441xsim.h
index f48cf63bd7822fd53c33788128f984585c0c421a..dd64cdfcad3e810254c6854b9de5b6bbeb67b950 100644
--- a/arch/m68k/include/asm/m5441xsim.h
+++ b/arch/m68k/include/asm/m5441xsim.h
@@ -198,6 +198,15 @@
#define MCFRTC_SIZE (0xfc0a8840 - 0xfc0a8000)
#define MCF_IRQ_RTC (MCFINT2_VECBASE + MCFINT2_RTC)
+/*
+ * Random Number Generator (RNG) Module.
+ * Note: Only present in MCF54418, not in MCF54410/54415/54417
+ */
+#define MCF_RNG_BASE 0xfc0c4000
+#define MCF_RNG_SIZE 0x1c
+#define MCFINT2_RNG 28
+#define MCF_IRQ_RNG (MCFINT2_VECBASE + MCFINT2_RNG)
+
/*
* GPIO Module.
*/
diff --git a/drivers/char/hw_random/Kconfig b/drivers/char/hw_random/Kconfig
index 492a2a61a65be8bd9e46b0a70f3e43703973512e..e046eabaac2d9053a5a4a98c6e3733bb19258e54 100644
--- a/drivers/char/hw_random/Kconfig
+++ b/drivers/char/hw_random/Kconfig
@@ -270,12 +270,13 @@ config HW_RANDOM_MXC_RNGA
config HW_RANDOM_IMX_RNGC
tristate "Freescale i.MX RNGC Random Number Generator"
depends on HAS_IOMEM
- depends on SOC_IMX25 || SOC_IMX6SL || SOC_IMX6SLL || SOC_IMX6UL || COMPILE_TEST
+ depends on SOC_IMX25 || SOC_IMX6SL || SOC_IMX6SLL || SOC_IMX6UL || M5441x || COMPILE_TEST
default HW_RANDOM
help
This driver provides kernel-side support for the Random Number
Generator Version C hardware found on some Freescale i.MX
processors. Version B is also supported by this driver.
+ Also supports RNGB on Freescale MCF54418 (Coldfire V4e).
To compile this driver as a module, choose M here: the
module will be called imx-rngc.
diff --git a/drivers/char/hw_random/imx-rngc.c b/drivers/char/hw_random/imx-rngc.c
index 241664a9b5d9ac7244f15cbe5d5302ca3787ebea..44f20a05de0a425cb6ff7b2a347b111750ac3702 100644
--- a/drivers/char/hw_random/imx-rngc.c
+++ b/drivers/char/hw_random/imx-rngc.c
@@ -259,7 +259,7 @@ static int __init imx_rngc_probe(struct platform_device *pdev)
if (IS_ERR(rngc->base))
return PTR_ERR(rngc->base);
- rngc->clk = devm_clk_get(&pdev->dev, NULL);
+ rngc->clk = devm_clk_get_optional(&pdev->dev, NULL);
if (IS_ERR(rngc->clk))
return dev_err_probe(&pdev->dev, PTR_ERR(rngc->clk), "Cannot get rng_clk\n");
@@ -353,12 +353,19 @@ static const struct of_device_id imx_rngc_dt_ids[] = {
};
MODULE_DEVICE_TABLE(of, imx_rngc_dt_ids);
+static const struct platform_device_id imx_rngc_devtype[] = {
+ { .name = "imx-rngc" },
+ { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(platform, imx_rngc_devtype);
+
static struct platform_driver imx_rngc_driver = {
.driver = {
.name = KBUILD_MODNAME,
.pm = pm_ptr(&imx_rngc_pm_ops),
.of_match_table = imx_rngc_dt_ids,
},
+ .id_table = imx_rngc_devtype,
};
module_platform_driver_probe(imx_rngc_driver, imx_rngc_probe);
---
base-commit: dc77806cf3b4788d328fddf245e86c5b529f31a2
change-id: 20251106-m5441x-add-rng-support-0cf16a7cc2a1
Best regards,
--
Jean-Michel Hautbois <jeanmichel.hautbois@yoseli.org>
On Thu, Nov 06, 2025 at 08:10:08AM +0100, Jean-Michel Hautbois wrote:
> Add platform device support for the MCF54418 RNGB hardware with clock
> enabled at platform initialization.
>
> The imx-rngc driver now uses devm_clk_get_optional() to support both
> Coldfire (always-on clock) and i.MX platforms (managed clock).
>
> Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@yoseli.org>
> ---
> arch/m68k/coldfire/device.c | 28 ++++++++++++++++++++++++++++
> arch/m68k/coldfire/m5441x.c | 2 +-
> arch/m68k/include/asm/m5441xsim.h | 9 +++++++++
> drivers/char/hw_random/Kconfig | 3 ++-
> drivers/char/hw_random/imx-rngc.c | 9 ++++++++-
> 5 files changed, 48 insertions(+), 3 deletions(-)
>
> diff --git a/arch/m68k/coldfire/device.c b/arch/m68k/coldfire/device.c
> index b6958ec2a220cf91a78a14fc7fa18749451412f7..9d8f844e319a98f0afb79cceb544c2d3029482a4 100644
> --- a/arch/m68k/coldfire/device.c
> +++ b/arch/m68k/coldfire/device.c
> @@ -622,6 +622,31 @@ static struct platform_device mcf_flexcan0 = {
> };
> #endif /* MCFFLEXCAN_SIZE */
>
> +#ifdef MCF_RNG_BASE
> +/*
> + * Random Number Generator (RNG) - only on MCF54418
> + */
> +static struct resource mcf_rng_resource[] = {
const?
Frank
> + {
> + .start = MCF_RNG_BASE,
> + .end = MCF_RNG_BASE + MCF_RNG_SIZE - 1,
> + .flags = IORESOURCE_MEM,
> + },
> + {
> + .start = MCF_IRQ_RNG,
> + .end = MCF_IRQ_RNG,
> + .flags = IORESOURCE_IRQ,
> + },
> +};
...
Hi Frank,
Le jeudi 6 novembre 2025, 17:05:15 heure normale d’Europe centrale Frank Li a
écrit :
> On Thu, Nov 06, 2025 at 08:10:08AM +0100, Jean-Michel Hautbois wrote:
> > Add platform device support for the MCF54418 RNGB hardware with clock
> > enabled at platform initialization.
> >
> > The imx-rngc driver now uses devm_clk_get_optional() to support both
> > Coldfire (always-on clock) and i.MX platforms (managed clock).
> >
> > Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@yoseli.org>
> > ---
> >
> > arch/m68k/coldfire/device.c | 28 ++++++++++++++++++++++++++++
> > arch/m68k/coldfire/m5441x.c | 2 +-
> > arch/m68k/include/asm/m5441xsim.h | 9 +++++++++
> > drivers/char/hw_random/Kconfig | 3 ++-
> > drivers/char/hw_random/imx-rngc.c | 9 ++++++++-
> > 5 files changed, 48 insertions(+), 3 deletions(-)
> >
> > diff --git a/arch/m68k/coldfire/device.c b/arch/m68k/coldfire/device.c
> > index
> > b6958ec2a220cf91a78a14fc7fa18749451412f7..9d8f844e319a98f0afb79cceb544c2d
> > 3029482a4 100644 --- a/arch/m68k/coldfire/device.c
> > +++ b/arch/m68k/coldfire/device.c
> > @@ -622,6 +622,31 @@ static struct platform_device mcf_flexcan0 = {
> >
> > };
> > #endif /* MCFFLEXCAN_SIZE */
> >
> > +#ifdef MCF_RNG_BASE
> > +/*
> > + * Random Number Generator (RNG) - only on MCF54418
> > + */
> > +static struct resource mcf_rng_resource[] = {
>
> const?
Why not, but I wanted to be consistent with all the other structures in this
file.
JM
> Frank
>
> > + {
> > + .start = MCF_RNG_BASE,
> > + .end = MCF_RNG_BASE + MCF_RNG_SIZE - 1,
> > + .flags = IORESOURCE_MEM,
> > + },
> > + {
> > + .start = MCF_IRQ_RNG,
> > + .end = MCF_IRQ_RNG,
> > + .flags = IORESOURCE_IRQ,
> > + },
> > +};
>
> ...
On Thu, Nov 06, 2025 at 07:16:17PM +0100, Jean-Michel Hautbois wrote:
> Hi Frank,
>
> Le jeudi 6 novembre 2025, 17:05:15 heure normale d’Europe centrale Frank Li a
> écrit :
> > On Thu, Nov 06, 2025 at 08:10:08AM +0100, Jean-Michel Hautbois wrote:
> > > Add platform device support for the MCF54418 RNGB hardware with clock
> > > enabled at platform initialization.
> > >
> > > The imx-rngc driver now uses devm_clk_get_optional() to support both
> > > Coldfire (always-on clock) and i.MX platforms (managed clock).
> > >
> > > Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@yoseli.org>
> > > ---
> > >
> > > arch/m68k/coldfire/device.c | 28 ++++++++++++++++++++++++++++
> > > arch/m68k/coldfire/m5441x.c | 2 +-
> > > arch/m68k/include/asm/m5441xsim.h | 9 +++++++++
> > > drivers/char/hw_random/Kconfig | 3 ++-
> > > drivers/char/hw_random/imx-rngc.c | 9 ++++++++-
> > > 5 files changed, 48 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/arch/m68k/coldfire/device.c b/arch/m68k/coldfire/device.c
> > > index
> > > b6958ec2a220cf91a78a14fc7fa18749451412f7..9d8f844e319a98f0afb79cceb544c2d
> > > 3029482a4 100644 --- a/arch/m68k/coldfire/device.c
> > > +++ b/arch/m68k/coldfire/device.c
> > > @@ -622,6 +622,31 @@ static struct platform_device mcf_flexcan0 = {
> > >
> > > };
> > > #endif /* MCFFLEXCAN_SIZE */
> > >
> > > +#ifdef MCF_RNG_BASE
> > > +/*
> > > + * Random Number Generator (RNG) - only on MCF54418
> > > + */
> > > +static struct resource mcf_rng_resource[] = {
> >
> > const?
>
> Why not, but I wanted to be consistent with all the other structures in this
> file.
You can add new patch before this one, which just add const.
Frank
>
> JM
>
> > Frank
> >
> > > + {
> > > + .start = MCF_RNG_BASE,
> > > + .end = MCF_RNG_BASE + MCF_RNG_SIZE - 1,
> > > + .flags = IORESOURCE_MEM,
> > > + },
> > > + {
> > > + .start = MCF_IRQ_RNG,
> > > + .end = MCF_IRQ_RNG,
> > > + .flags = IORESOURCE_IRQ,
> > > + },
> > > +};
> >
> > ...
>
>
>
>
© 2016 - 2026 Red Hat, Inc.