bcm63xx-rng conversion to bcm2835-rng
Subsystems (5)
cover bcm63xx-rng conversion to bcm2835-rng
Hi,
As it usually happens when there is a fair amount of HW IP block re-use, competing implementations show up. In that case the BCM2835 HWRNG driver and the BCM63xx RNG driver have exactly the same register offsets and this is indeed the same piece of HW.
This patch series first prepares the bcm2835-rng to be more future proof and support newer platforms, and the last part brings in what is necessary to migrate the bcm63xx-rng over to bcm2835-rng. Finally we delete bcm63xx-rng completely.
The reason why BCM2835 RNG was kept over BCM63xx RNG is because the former deals correctly with a warm up count and the number of words available in the FIFO size.
Thanks!
Florian Fainelli (12):
hwrng: bcm2835-rng: Obtain base register via resource
hwrng: bcm2835-rng: Define a driver private context
hwrng: bcm2835-rng: Move enabling to hwrng::init
hwrng: bcm2835-rng: Implementation cleanup callback
hwrng: bcm2835-rng: Use device managed helpers
hwrng: bcm2835-rng: Rework interrupt masking
hwrng: bcm2835-rng: Manage an optional clock
hwrng: bcm2835-rng: Abstract I/O accessors
hwrng: bcm2835-rng: Add Broadcom MIPS I/O accessors
dt-bindings: rng: Incorporate brcm,bcm6368.txt binding
hwrng: bcm2835-rng: Enable BCM2835 RNG to work on BCM63xx platforms
hwrng: bcm63xx-rng: Remove since bcm2835-rng takes over
.../devicetree/bindings/rng/brcm,bcm2835.txt | 22 ++- .../devicetree/bindings/rng/brcm,bcm6368.txt | 17 --- drivers/char/hw_random/Kconfig | 20 +-- drivers/char/hw_random/Makefile | 1 - drivers/char/hw_random/bcm2835-rng.c | 166 ++++++++++++++------- drivers/char/hw_random/bcm63xx-rng.c | 154 ------------------- 6 files changed, 139 insertions(+), 241 deletions(-) delete mode 100644 Documentation/devicetree/bindings/rng/brcm,bcm6368.txt delete mode 100644 drivers/char/hw_random/bcm63xx-rng.c
Signature · 1 line
2.9.3
PATCH 1/12 hwrng: bcm2835-rng: Obtain base register via resource
In preparation for consolidating bcm63xx-rng into bcm2835-rng, make sure that we obtain the base register via platform_get_resource() since we need to support the non-DT enabled MIPS-based BCM63xx DSL SoCs.
--- drivers/char/hw_random/bcm2835-rng.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/char/hw_random/bcm2835-rng.c +10 -10
@@ -81,21 +81,23 @@ static int bcm2835_rng_probe(struct platform_device *pdev)void (*rng_setup)(void __iomem *base);const struct of_device_id *rng_id;void __iomem *rng_base; +struct resource *r;int err; + r =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +/* map peripheral */ - rng_base =of_iomap (np,0 ); -if (!rng_base) { + rng_base =devm_ioremap_resource (dev, r); +if (IS_ERR (rng_base)) {dev_err (dev,"failed to remap rng regs" ); -return -ENODEV ; +return PTR_ERR (rng_base); } bcm2835_rng_ops.priv = (unsigned long )rng_base; rng_id =of_match_node (bcm2835_rng_of_match, np); -if (!rng_id) { -iounmap (rng_base); +if (!rng_id)return -EINVAL ; - } +/* Check for rng init function, execute it */ rng_setup = rng_id->data;if (rng_setup)
@@ -107,10 +109,9 @@ static int bcm2835_rng_probe(struct platform_device *pdev)/* register driver */ err =hwrng_register (&bcm2835_rng_ops); -if (err) { +if (err)dev_err (dev,"hwrng registration failed\n" ); -iounmap (rng_base); - }else +else dev_info (dev,"hwrng registered\n" );return err;
@@ -125,7 +126,6 @@ static int bcm2835_rng_remove(struct platform_device *pdev)/* unregister driver */ hwrng_unregister (&bcm2835_rng_ops); -iounmap (rng_base);return 0 ; }
Signature · 1 line
2.9.3
PATCH 2/12 hwrng: bcm2835-rng: Define a driver private context
In reply to Florian FainelliInstead of making hwrng::priv host the base register address, define a driver private context, make it per platform device instance and pass it down the different functions.
--- drivers/char/hw_random/bcm2835-rng.c | 55 ++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 21 deletions(-)
drivers/char/hw_random/bcm2835-rng.c +34 -21
@@ -29,6 +29,11 @@#define RNG_INT_OFF 0x1 +struct bcm2835_rng_priv { +struct hwrng rng; +void __iomem *base; +}; +static void __init nsp_rng_init (void __iomem *base) {u32 val;
@@ -39,34 +44,34 @@ static void __init nsp_rng_init(void __iomem *base)writel (val, base +RNG_INT_MASK ); } +static inline struct bcm2835_rng_priv *to_rng_priv (struct hwrng *rng) +{ + return container_of(rng, struct bcm2835_rng_priv, rng); +} +static int bcm2835_rng_read (struct hwrng *rng,void *buf,size_t max,bool wait) { -void __iomem *rng_base = (void __iomem *)rng->priv; +struct bcm2835_rng_priv *priv =to_rng_priv (rng);u32 max_words = max /sizeof (u32);u32 num_words, count; -while ((__raw_readl (rng_base +RNG_STATUS ) >>24 ) ==0 ) { +while ((__raw_readl (priv->base +RNG_STATUS ) >>24 ) ==0 ) {if (!wait)return 0 ;cpu_relax (); } - num_words =readl (rng_base +RNG_STATUS ) >>24 ; + num_words =readl (priv->base +RNG_STATUS ) >>24 ;if (num_words > max_words) num_words = max_words;for (count =0 ; count < num_words; count++) - ((u32 *)buf)[count] =readl (rng_base +RNG_DATA ); + ((u32 *)buf)[count] =readl (priv->base +RNG_DATA );return num_words *sizeof (u32); } -static struct hwrng bcm2835_rng_ops = { - .name ="bcm2835" , - .read = bcm2835_rng_read, -}; -static const struct of_device_id bcm2835_rng_of_match[] = { { .compatible ="brcm,bcm2835-rng" }, { .compatible ="brcm,bcm-nsp-rng" , .data = nsp_rng_init},
@@ -80,19 +85,27 @@ static int bcm2835_rng_probe(struct platform_device *pdev)struct device_node *np = dev->of_node;void (*rng_setup)(void __iomem *base);const struct of_device_id *rng_id; -void __iomem *rng_base; +struct bcm2835_rng_priv *priv;struct resource *r;int err; + priv =devm_kzalloc (dev,sizeof (*priv),GFP_KERNEL ); +if (!priv) +return -ENOMEM ; + +platform_set_drvdata (pdev, priv); + r =platform_get_resource (pdev,IORESOURCE_MEM ,0 );/* map peripheral */ - rng_base =devm_ioremap_resource (dev, r); -if (IS_ERR (rng_base)) { + priv->base =devm_ioremap_resource (dev, r); +if (IS_ERR (priv->base)) {dev_err (dev,"failed to remap rng regs" ); -return PTR_ERR (rng_base); +return PTR_ERR (priv->base); } - bcm2835_rng_ops.priv = (unsigned long )rng_base; + + priv->rng.name ="bcm2835-rng" ; + priv->rng.read = bcm2835_rng_read; rng_id =of_match_node (bcm2835_rng_of_match, np);if (!rng_id)
@@ -101,14 +114,14 @@ static int bcm2835_rng_probe(struct platform_device *pdev)/* Check for rng init function, execute it */ rng_setup = rng_id->data;if (rng_setup) -rng_setup (rng_base); +rng_setup (priv->base);/* set warm-up count & enable */ -__raw_writel (RNG_WARMUP_COUNT , rng_base +RNG_STATUS ); -__raw_writel (RNG_RBGEN , rng_base +RNG_CTRL ); +__raw_writel (RNG_WARMUP_COUNT , priv->base +RNG_STATUS ); +__raw_writel (RNG_RBGEN , priv->base +RNG_CTRL );/* register driver */ - err =hwrng_register (&bcm2835_rng_ops); + err =hwrng_register (&priv->rng);if (err)dev_err (dev,"hwrng registration failed\n" );else
@@ -119,13 +132,13 @@ static int bcm2835_rng_probe(struct platform_device *pdev)static int bcm2835_rng_remove (struct platform_device *pdev) { -void __iomem *rng_base = (void __iomem *)bcm2835_rng_ops.priv; +struct bcm2835_rng_priv *priv =platform_get_drvdata (pdev);/* disable rng hardware */ -__raw_writel (0 , rng_base +RNG_CTRL ); +__raw_writel (0 , priv->base +RNG_CTRL );/* unregister driver */ -hwrng_unregister (&bcm2835_rng_ops); +hwrng_unregister (&priv->rng);return 0 ; }
Signature · 1 line
2.9.3
PATCH 3/12 hwrng: bcm2835-rng: Move enabling to hwrng::init
In reply to Florian FainelliWe should be moving the enabling of the HWRNG into a hwrng::init callback since we can be disabled and enabled every time a different hwrng is selected in the system.
--- drivers/char/hw_random/bcm2835-rng.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
drivers/char/hw_random/bcm2835-rng.c +12 -4
@@ -72,6 +72,17 @@ static int bcm2835_rng_read(struct hwrng *rng, void *buf, size_t max,return num_words *sizeof (u32); } +static int bcm2835_rng_init (struct hwrng *rng) +{ +struct bcm2835_rng_priv *priv =to_rng_priv (rng); + +/* set warm-up count & enable */ +__raw_writel (RNG_WARMUP_COUNT , priv->base +RNG_STATUS ); +__raw_writel (RNG_RBGEN , priv->base +RNG_CTRL ); + +return 0 ; +} +static const struct of_device_id bcm2835_rng_of_match[] = { { .compatible ="brcm,bcm2835-rng" }, { .compatible ="brcm,bcm-nsp-rng" , .data = nsp_rng_init},
@@ -105,6 +116,7 @@ static int bcm2835_rng_probe(struct platform_device *pdev) } priv->rng.name ="bcm2835-rng" ; + priv->rng.init = bcm2835_rng_init; priv->rng.read = bcm2835_rng_read; rng_id =of_match_node (bcm2835_rng_of_match, np);
@@ -116,10 +128,6 @@ static int bcm2835_rng_probe(struct platform_device *pdev)if (rng_setup)rng_setup (priv->base); -/* set warm-up count & enable */ -__raw_writel (RNG_WARMUP_COUNT , priv->base +RNG_STATUS ); -__raw_writel (RNG_RBGEN , priv->base +RNG_CTRL ); -/* register driver */ err =hwrng_register (&priv->rng);if (err)
Signature · 1 line
2.9.3
PATCH 4/12 hwrng: bcm2835-rng: Implementation cleanup callback
In reply to Florian FainelliWe should be disabling the RNG in a hwrng::cleanup callback if we are not longer the system selected RNG, not wait until the device driver is removed.
--- drivers/char/hw_random/bcm2835-rng.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/char/hw_random/bcm2835-rng.c +9 -3
@@ -83,6 +83,14 @@ static int bcm2835_rng_init(struct hwrng *rng)return 0 ; } +static void bcm2835_rng_cleanup (struct hwrng *rng) +{ +struct bcm2835_rng_priv *priv =to_rng_priv (rng); + +/* disable rng hardware */ +__raw_writel (0 , priv->base +RNG_CTRL ); +} +static const struct of_device_id bcm2835_rng_of_match[] = { { .compatible ="brcm,bcm2835-rng" }, { .compatible ="brcm,bcm-nsp-rng" , .data = nsp_rng_init},
@@ -118,6 +126,7 @@ static int bcm2835_rng_probe(struct platform_device *pdev) priv->rng.name ="bcm2835-rng" ; priv->rng.init = bcm2835_rng_init; priv->rng.read = bcm2835_rng_read; + priv->rng.cleanup = bcm2835_rng_cleanup; rng_id =of_match_node (bcm2835_rng_of_match, np);if (!rng_id)
@@ -142,9 +151,6 @@ static int bcm2835_rng_remove(struct platform_device *pdev) {struct bcm2835_rng_priv *priv =platform_get_drvdata (pdev); -/* disable rng hardware */ -__raw_writel (0 , priv->base +RNG_CTRL ); -/* unregister driver */ hwrng_unregister (&priv->rng);
Signature · 1 line
2.9.3
PATCH 5/12 hwrng: bcm2835-rng: Use device managed helpers
In reply to Florian FainelliNow that we have moved the RNG disabling into a hwrng::cleanup callback, we can use the device managed registration operation and remove our remove callback since it won't do anything necessary.
--- drivers/char/hw_random/bcm2835-rng.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-)
drivers/char/hw_random/bcm2835-rng.c +1 -12
@@ -138,7 +138,7 @@ static int bcm2835_rng_probe(struct platform_device *pdev)rng_setup (priv->base);/* register driver */ - err =hwrng_register (&priv->rng); + err =devm_hwrng_register (dev, &priv->rng);if (err)dev_err (dev,"hwrng registration failed\n" );else
@@ -147,16 +147,6 @@ static int bcm2835_rng_probe(struct platform_device *pdev)return err; } -static int bcm2835_rng_remove (struct platform_device *pdev) -{ -struct bcm2835_rng_priv *priv =platform_get_drvdata (pdev); - -/* unregister driver */ -hwrng_unregister (&priv->rng); - -return 0 ; -} -MODULE_DEVICE_TABLE (of, bcm2835_rng_of_match);static struct platform_driver bcm2835_rng_driver = {
@@ -165,7 +155,6 @@ static struct platform_driver bcm2835_rng_driver = { .of_match_table = bcm2835_rng_of_match, }, .probe = bcm2835_rng_probe, - .remove = bcm2835_rng_remove, };module_platform_driver (bcm2835_rng_driver);
Signature · 1 line
2.9.3
PATCH 6/12 hwrng: bcm2835-rng: Rework interrupt masking
In reply to Florian FainelliThe interrupt masking done for Northstart Plus and Northstar (BCM5301X) is moved from being a function pointer mapped to of_device_id::data into a proper part of the hwrng::init callback. While at it, we also make the of_data be a proper structure indicating the platform specifics, since the day we need to add a second type of platform information, we would have to do that anyway.
--- drivers/char/hw_random/bcm2835-rng.c | 39 +++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 16 deletions(-)
drivers/char/hw_random/bcm2835-rng.c +23 -16
@@ -32,18 +32,9 @@struct bcm2835_rng_priv {struct hwrng rng;void __iomem *base; +bool mask_interrupts; }; -static void __init nsp_rng_init (void __iomem *base) -{ -u32 val; - -/* mask the interrupt */ - val =readl (base +RNG_INT_MASK ); - val |=RNG_INT_OFF ; -writel (val, base +RNG_INT_MASK ); -} -static inline struct bcm2835_rng_priv *to_rng_priv (struct hwrng *rng) { return container_of(rng, struct bcm2835_rng_priv, rng);
@@ -75,6 +66,14 @@ static int bcm2835_rng_read(struct hwrng *rng, void *buf, size_t max,static int bcm2835_rng_init (struct hwrng *rng) {struct bcm2835_rng_priv *priv =to_rng_priv (rng); +u32 val; + +if (priv->mask_interrupts) { +/* mask the interrupt */ + val =readl (priv->base +RNG_INT_MASK ); + val |=RNG_INT_OFF ; +writel (val, priv->base +RNG_INT_MASK ); + }/* set warm-up count & enable */ __raw_writel (RNG_WARMUP_COUNT , priv->base +RNG_STATUS );
@@ -91,18 +90,26 @@ static void bcm2835_rng_cleanup(struct hwrng *rng)__raw_writel (0 , priv->base +RNG_CTRL ); } +struct bcm2835_rng_of_data { +bool mask_interrupts; +}; + +static const struct bcm2835_rng_of_data nsp_rng_of_data = { + .mask_interrupts = true, +}; +static const struct of_device_id bcm2835_rng_of_match[] = { { .compatible ="brcm,bcm2835-rng" }, - { .compatible ="brcm,bcm-nsp-rng" , .data = nsp_rng_init}, - { .compatible ="brcm,bcm5301x-rng" , .data = nsp_rng_init}, + { .compatible ="brcm,bcm-nsp-rng" , .data = &nsp_rng_of_data }, + { .compatible ="brcm,bcm5301x-rng" , .data = &nsp_rng_of_data }, {}, };static int bcm2835_rng_probe (struct platform_device *pdev) { +const struct bcm2835_rng_of_data *of_data;struct device *dev = &pdev->dev;struct device_node *np = dev->of_node; -void (*rng_setup)(void __iomem *base);const struct of_device_id *rng_id;struct bcm2835_rng_priv *priv;struct resource *r;
@@ -133,9 +140,9 @@ static int bcm2835_rng_probe(struct platform_device *pdev)return -EINVAL ;/* Check for rng init function, execute it */ - rng_setup = rng_id->data; -if (rng_setup) -rng_setup (priv->base); + of_data = rng_id->data; +if (of_data) + priv->mask_interrupts = of_data->mask_interrupts;/* register driver */ err =devm_hwrng_register (dev, &priv->rng);
Signature · 1 line
2.9.3
PATCH 7/12 hwrng: bcm2835-rng: Manage an optional clock
In reply to Florian FainelliOne of the last steps before bcm63xx-rng can be eliminated is to manage a clock during hwrng::init and hwrng::cleanup, so fetch it in the probe function, and manage it during these two steps when valid.
--- drivers/char/hw_random/bcm2835-rng.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
drivers/char/hw_random/bcm2835-rng.c +14 -0
@@ -15,6 +15,7 @@#include <linux/of_platform.h> #include <linux/platform_device.h> #include <linux/printk.h> +#include <linux/clk.h> #define RNG_CTRL 0x0#define RNG_STATUS 0x4
@@ -33,6 +34,7 @@ struct bcm2835_rng_priv {struct hwrng rng;void __iomem *base;bool mask_interrupts; +struct clk *clk; };static inline struct bcm2835_rng_priv *to_rng_priv (struct hwrng *rng)
@@ -67,6 +69,11 @@ static int bcm2835_rng_init(struct hwrng *rng) {struct bcm2835_rng_priv *priv =to_rng_priv (rng);u32 val; +int ret; + + ret =clk_prepare_enable (priv->clk); +if (ret) +return ret;if (priv->mask_interrupts) {/* mask the interrupt */
@@ -88,6 +95,8 @@ static void bcm2835_rng_cleanup(struct hwrng *rng)/* disable rng hardware */ __raw_writel (0 , priv->base +RNG_CTRL ); + +clk_disable_unprepare (priv->clk); }struct bcm2835_rng_of_data {
@@ -130,6 +139,11 @@ static int bcm2835_rng_probe(struct platform_device *pdev)return PTR_ERR (priv->base); } +/* Clock is optional on most platforms */ + priv->clk =devm_clk_get (dev,NULL ); +if (IS_ERR (priv->clk)) + priv->clk =NULL ; + priv->rng.name ="bcm2835-rng" ; priv->rng.init = bcm2835_rng_init; priv->rng.read = bcm2835_rng_read;
Signature · 1 line
2.9.3
PATCH 8/12 hwrng: bcm2835-rng: Abstract I/O accessors
In reply to Florian FainelliIn preparation for allowing BCM63xx to use this driver, we abstract I/O accessors such that we can easily change those later on.
--- drivers/char/hw_random/bcm2835-rng.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-)
drivers/char/hw_random/bcm2835-rng.c +19 -8
@@ -42,6 +42,17 @@ static inline struct bcm2835_rng_priv *to_rng_priv(struct hwrng *rng) return container_of(rng, struct bcm2835_rng_priv, rng); } +static inline u32 rng_readl (struct bcm2835_rng_priv *priv,u32 offset) +{ +return readl (priv->base + offset); +} + +static inline void rng_writel (struct bcm2835_rng_priv *priv,u32 val, +u32 offset) +{ +writel (val, priv->base + offset); +} +static int bcm2835_rng_read (struct hwrng *rng,void *buf,size_t max,bool wait) {
@@ -49,18 +60,18 @@ static int bcm2835_rng_read(struct hwrng *rng, void *buf, size_t max,u32 max_words = max /sizeof (u32);u32 num_words, count; -while ((__raw_readl (priv->base +RNG_STATUS ) >>24 ) ==0 ) { +while ((rng_readl (priv,RNG_STATUS ) >>24 ) ==0 ) {if (!wait)return 0 ;cpu_relax (); } - num_words =readl (priv->base +RNG_STATUS ) >>24 ; + num_words =rng_readl (priv,RNG_STATUS ) >>24 ;if (num_words > max_words) num_words = max_words;for (count =0 ; count < num_words; count++) - ((u32 *)buf)[count] =readl (priv->base +RNG_DATA ); + ((u32 *)buf)[count] =rng_readl (priv,RNG_DATA );return num_words *sizeof (u32); }
@@ -77,14 +88,14 @@ static int bcm2835_rng_init(struct hwrng *rng)if (priv->mask_interrupts) {/* mask the interrupt */ - val =readl (priv->base +RNG_INT_MASK ); + val =rng_readl (priv,RNG_INT_MASK ); val |=RNG_INT_OFF ; -writel (val, priv->base +RNG_INT_MASK ); +rng_writel (priv, val,RNG_INT_MASK ); }/* set warm-up count & enable */ -__raw_writel (RNG_WARMUP_COUNT , priv->base +RNG_STATUS ); -__raw_writel (RNG_RBGEN , priv->base +RNG_CTRL ); +rng_writel (priv,RNG_WARMUP_COUNT ,RNG_STATUS ); +rng_writel (priv,RNG_RBGEN ,RNG_CTRL );return 0 ; }
@@ -94,7 +105,7 @@ static void bcm2835_rng_cleanup(struct hwrng *rng)struct bcm2835_rng_priv *priv =to_rng_priv (rng);/* disable rng hardware */ -__raw_writel (0 , priv->base +RNG_CTRL ); +rng_writel (priv,0 ,RNG_CTRL );clk_disable_unprepare (priv->clk); }
Signature · 1 line
2.9.3
PATCH 9/12 hwrng: bcm2835-rng: Add Broadcom MIPS I/O accessors
In reply to Florian FainelliBroadcom MIPS HW is always strapped to match the system-wide endian such that all I/O access to this RNG block is done with the native CPU endian, account for that.
--- drivers/char/hw_random/bcm2835-rng.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/char/hw_random/bcm2835-rng.c +11 -2
@@ -44,13 +44,22 @@ static inline struct bcm2835_rng_priv *to_rng_priv(struct hwrng *rng)static inline u32 rng_readl (struct bcm2835_rng_priv *priv,u32 offset) { -return readl (priv->base + offset); +/* MIPS chips strapped for BE will automagically configure the +* peripheral registers for CPU-native byte order. +*/ +if (IS_ENABLED (CONFIG_MIPS ) &&IS_ENABLED (CONFIG_CPU_BIG_ENDIAN )) +return __raw_readl (priv->base + offset); +else +return readl (priv->base + offset); }static inline void rng_writel (struct bcm2835_rng_priv *priv,u32 val,u32 offset) { -writel (val, priv->base + offset); +if (IS_ENABLED (CONFIG_MIPS ) &&IS_ENABLED (CONFIG_CPU_BIG_ENDIAN )) +__raw_writel (val, priv->base + offset); +else +writel (val, priv->base + offset); } static int bcm2835_rng_read(struct hwrng *rng, void *buf, size_t max,
Signature · 1 line
2.9.3
PATCH 10/12 dt-bindings: rng: Incorporate brcm,bcm6368.txt binding
In reply to Florian FainelliSince the same block is used on BCM2835 and BCM6368, merge the bindings and remove the brcm,bcm6368.txt binding document.
--- .../devicetree/bindings/rng/brcm,bcm2835.txt | 22 +++++++++++++++++++--- .../devicetree/bindings/rng/brcm,bcm6368.txt | 17 ----------------- 2 files changed, 19 insertions(+), 20 deletions(-) delete mode 100644 Documentation/devicetree/bindings/rng/brcm,bcm6368.txt
Documentation/devicetree/bindings/rng/brcm,bcm2835.txt +19 -3
@@ -1,11 +1,19 @@ -BCM2835 Random number generator +BCM2835/6368 Random number generator Required properties: -- compatible : should be "brcm,bcm2835-rng" or "brcm,bcm-nsp-rng" or - "brcm,bcm5301x-rng" +- compatible : should be one of + "brcm,bcm2835-rng" + "brcm,bcm-nsp-rng" + "brcm,bcm5301x-rng" or + "brcm,bcm6368-rng" - reg : Specifies base physical address and size of the registers. +Optional properties: + +- clocks : phandle to clock-controller plus clock-specifier pair +- clock-names : "ipsec" as a clock name + Example: rng {
@@ -17,3 +25,11 @@ rng at 18033000 { compatible = "brcm,bcm-nsp-rng"; reg = <0x18033000 0x14>; }; + +random: rng at 10004180 { + compatible = "brcm,bcm6368-rng"; + reg = <0x10004180 0x14>; + + clocks = <&periph_clk 18>; + clock-names = "ipsec"; +};
Documentation/devicetree/bindings/rng/brcm,bcm6368.txt deleted +0 -17
@@ -1,17 +0,0 @@ -BCM6368 Random number generator - -Required properties: - -- compatible : should be "brcm,bcm6368-rng" -- reg : Specifies base physical address and size of the registers -- clocks : phandle to clock-controller plus clock-specifier pair -- clock-names : "ipsec" as a clock name - -Example: - random: rng at 10004180 { - compatible = "brcm,bcm6368-rng"; - reg = <0x10004180 0x14>; - - clocks = <&periph_clk 18>; - clock-names = "ipsec"; - };
Signature · 1 line
2.9.3
PATCH 11/12 hwrng: bcm2835-rng: Enable BCM2835 RNG to work on BCM63xx platforms
In reply to Florian FainelliWe have now incorporated all necessary functionality for the BCM63xx platforms to successfully migrate over bcm2835-rng, so add the final
bits: Kconfig selection and proper platform_device device type matching to keep the same platform device name for registration to work.
--- drivers/char/hw_random/Kconfig | 7 ++++--- drivers/char/hw_random/bcm2835-rng.c | 11 ++++++++++- 2 files changed, 14 insertions(+), 4 deletions(-)
drivers/char/hw_random/Kconfig +4 -3
@@ -87,12 +87,13 @@ config HW_RANDOM_BCM63XX If unusure, say Y. config HW_RANDOM_BCM2835 - tristate "Broadcom BCM2835 Random Number Generator support" - depends on ARCH_BCM2835 || ARCH_BCM_NSP || ARCH_BCM_5301X + tristate "Broadcom BCM2835/BCM63xx Random Number Generator support" + depends on ARCH_BCM2835 || ARCH_BCM_NSP || ARCH_BCM_5301X || \ + ARCH_BCM_63XX || BCM63XX || BMIPS_GENERIC default HW_RANDOM ---help--- This driver provides kernel-side support for the Random Number - Generator hardware found on the Broadcom BCM2835 SoCs. + Generator hardware found on the Broadcom BCM2835 and BCM63xx SoCs. To compile this driver as a module, choose M here: the module will be called bcm2835-rng
drivers/char/hw_random/bcm2835-rng.c +10 -1
@@ -131,6 +131,7 @@ static const struct of_device_id bcm2835_rng_of_match[] = { { .compatible = "brcm,bcm2835-rng"}, { .compatible = "brcm,bcm-nsp-rng", .data = &nsp_rng_of_data }, { .compatible = "brcm,bcm5301x-rng", .data = &nsp_rng_of_data }, + { .compatible = "brcm,bcm6368-rng"}, {}, };
@@ -164,7 +165,7 @@ static int bcm2835_rng_probe(struct platform_device *pdev)if (IS_ERR (priv->clk)) priv->clk =NULL ; - priv->rng.name ="bcm2835-rng" ; + priv->rng.name = pdev->id_entry->name; priv->rng.init = bcm2835_rng_init; priv->rng.read = bcm2835_rng_read; priv->rng.cleanup = bcm2835_rng_cleanup;
@@ -190,12 +191,20 @@ static int bcm2835_rng_probe(struct platform_device *pdev)MODULE_DEVICE_TABLE (of, bcm2835_rng_of_match); +static struct platform_device_id bcm2835_rng_devtype[] = { + { .name ="bcm2835-rng" }, + { .name ="bcm63xx-rng" }, + {/* sentinel */ } +}; +MODULE_DEVICE_TABLE (platform, bcm2835_rng_devtype); +static struct platform_driver bcm2835_rng_driver = { .driver = { .name ="bcm2835-rng" , .of_match_table = bcm2835_rng_of_match, }, .probe = bcm2835_rng_probe, + .id_table = bcm2835_rng_devtype, };module_platform_driver (bcm2835_rng_driver);
Signature · 1 line
2.9.3
PATCH 12/12 hwrng: bcm63xx-rng: Remove since bcm2835-rng takes over
In reply to Florian Fainellibcm2835-rng is now capable of supporting the BCM63xx hardware, so remove the driver which duplicates the same functionality.
--- drivers/char/hw_random/Kconfig | 13 --- drivers/char/hw_random/Makefile | 1 - drivers/char/hw_random/bcm63xx-rng.c | 154 ----------------------------------- 3 files changed, 168 deletions(-) delete mode 100644 drivers/char/hw_random/bcm63xx-rng.c
drivers/char/hw_random/Kconfig +0 -13
@@ -73,19 +73,6 @@ config HW_RANDOM_ATMEL If unsure, say Y. -config HW_RANDOM_BCM63XX - tristate "Broadcom BCM63xx Random Number Generator support" - depends on BCM63XX || BMIPS_GENERIC - default HW_RANDOM - ---help--- - This driver provides kernel-side support for the Random Number - Generator hardware found on the Broadcom BCM63xx SoCs. - - To compile this driver as a module, choose M here: the - module will be called bcm63xx-rng - - If unusure, say Y. - config HW_RANDOM_BCM2835 tristate "Broadcom BCM2835/BCM63xx Random Number Generator support" depends on ARCH_BCM2835 || ARCH_BCM_NSP || ARCH_BCM_5301X || \
drivers/char/hw_random/Makefile +0 -1
@@ -8,7 +8,6 @@ obj-$(CONFIG_HW_RANDOM_TIMERIOMEM) += timeriomem-rng.o obj-$(CONFIG_HW_RANDOM_INTEL) += intel-rng.o obj-$(CONFIG_HW_RANDOM_AMD) += amd-rng.o obj-$(CONFIG_HW_RANDOM_ATMEL) += atmel-rng.o -obj-$(CONFIG_HW_RANDOM_BCM63XX) += bcm63xx-rng.o obj-$(CONFIG_HW_RANDOM_GEODE) += geode-rng.o obj-$(CONFIG_HW_RANDOM_N2RNG) += n2-rng.o n2-rng-y := n2-drv.o n2-asm.o
drivers/char/hw_random/bcm63xx-rng.c deleted +0 -154
154 lines not on this page · raw message
Signature · 1 line
2.9.3
Hi Florian,
Quoted 10 lines
Florian Fainelli <[email protected]> hat am 2. November 2017 um 02:03 geschrieben:
Hi,
As it usually happens when there is a fair amount of HW IP block re-use, competing implementations show up. In that case the BCM2835 HWRNG driver and the BCM63xx RNG driver have exactly the same register offsets and this is indeed the same piece of HW.
Quoted 8 lines
This patch series first prepares the bcm2835-rng to be more future proof and support newer platforms, and the last part brings in what is necessary to migrate the bcm63xx-rng over to bcm2835-rng. Finally we delete bcm63xx-rng completely.
The reason why BCM2835 RNG was kept over BCM63xx RNG is because the former deals correctly with a warm up count and the number of words available in the FIFO size.
are these the same patches as in this branch [1]?
https://github.com/ffainelli/linux/commits/rng-consolidation
Regards
Stefan
Quoted 35 lines
Thanks!
Florian Fainelli (12):
hwrng: bcm2835-rng: Obtain base register via resource
hwrng: bcm2835-rng: Define a driver private context
hwrng: bcm2835-rng: Move enabling tohwrng::init
hwrng: bcm2835-rng: Implementation cleanup callback
hwrng: bcm2835-rng: Use device managed helpers
hwrng: bcm2835-rng: Rework interrupt masking
hwrng: bcm2835-rng: Manage an optional clock
hwrng: bcm2835-rng: Abstract I/O accessors
hwrng: bcm2835-rng: Add Broadcom MIPS I/O accessors
dt-bindings: rng: Incorporate brcm,bcm6368.txt binding
hwrng: bcm2835-rng: Enable BCM2835 RNG to work on BCM63xx platforms
hwrng: bcm63xx-rng: Remove since bcm2835-rng takes over.../devicetree/bindings/rng/brcm,bcm2835.txt | 22 ++- .../devicetree/bindings/rng/brcm,bcm6368.txt | 17 --- drivers/char/hw_random/Kconfig | 20 +-- drivers/char/hw_random/Makefile | 1 - drivers/char/hw_random/bcm2835-rng.c | 166 ++++++++++++++------- drivers/char/hw_random/bcm63xx-rng.c | 154 ------------------- 6 files changed, 139 insertions(+), 241 deletions(-) delete mode 100644 Documentation/devicetree/bindings/rng/brcm,bcm6368.txt delete mode 100644 drivers/char/hw_random/bcm63xx-rng.cSignature · 7 lines
2.9.3 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel at lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Hi Florian,
Quoted 10 lines
Florian Fainelli <[email protected]> hat am 2. November 2017 um 02:03 geschrieben:
Hi,
As it usually happens when there is a fair amount of HW IP block re-use, competing implementations show up. In that case the BCM2835 HWRNG driver and the BCM63xx RNG driver have exactly the same register offsets and this is indeed the same piece of HW.
Quoted 8 lines
This patch series first prepares the bcm2835-rng to be more future proof and support newer platforms, and the last part brings in what is necessary to migrate the bcm63xx-rng over to bcm2835-rng. Finally we delete bcm63xx-rng completely.
The reason why BCM2835 RNG was kept over BCM63xx RNG is because the former deals correctly with a warm up count and the number of words available in the FIFO size.
are these the same patches as in this branch [1]?
https://github.com/ffainelli/linux/commits/rng-consolidation
Regards
Stefan
Quoted 35 lines
Thanks!
Florian Fainelli (12):
hwrng: bcm2835-rng: Obtain base register via resource
hwrng: bcm2835-rng: Define a driver private context
hwrng: bcm2835-rng: Move enabling tohwrng::init
hwrng: bcm2835-rng: Implementation cleanup callback
hwrng: bcm2835-rng: Use device managed helpers
hwrng: bcm2835-rng: Rework interrupt masking
hwrng: bcm2835-rng: Manage an optional clock
hwrng: bcm2835-rng: Abstract I/O accessors
hwrng: bcm2835-rng: Add Broadcom MIPS I/O accessors
dt-bindings: rng: Incorporate brcm,bcm6368.txt binding
hwrng: bcm2835-rng: Enable BCM2835 RNG to work on BCM63xx platforms
hwrng: bcm63xx-rng: Remove since bcm2835-rng takes over.../devicetree/bindings/rng/brcm,bcm2835.txt | 22 ++- .../devicetree/bindings/rng/brcm,bcm6368.txt | 17 --- drivers/char/hw_random/Kconfig | 20 +-- drivers/char/hw_random/Makefile | 1 - drivers/char/hw_random/bcm2835-rng.c | 166 ++++++++++++++------- drivers/char/hw_random/bcm63xx-rng.c | 154 ------------------- 6 files changed, 139 insertions(+), 241 deletions(-) delete mode 100644 Documentation/devicetree/bindings/rng/brcm,bcm6368.txt delete mode 100644 drivers/char/hw_random/bcm63xx-rng.cSignature · 7 lines
2.9.3 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel at lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Hi Stefan,
Quoted 17 lines · Stefan Wahren
Hi Florian,
Quoted 15 lines
Florian Fainelli <[email protected]> hat am 2. November 2017 um 02:03 geschrieben:
Hi,
As it usually happens when there is a fair amount of HW IP block re-use, competing implementations show up. In that case the BCM2835 HWRNG driver and the BCM63xx RNG driver have exactly the same register offsets and this is indeed the same piece of HW.
This patch series first prepares the bcm2835-rng to be more future proof and support newer platforms, and the last part brings in what is necessary to migrate the bcm63xx-rng over to bcm2835-rng. Finally we delete bcm63xx-rng completely.
Quoted 7 lines
Quoted 3 lines
The reason why BCM2835 RNG was kept over BCM63xx RNG is because the former deals correctly with a warm up count and the number of words available in the FIFO size.
are these the same patches as in this branch [1]?
https://github.com/ffainelli/linux/commits/rng-consolidation
Yes, this branch contains these 12 patches.
Signature · 1 line
Florian
Re: [PATCH 12/12] hwrng: bcm63xx-rng: Remove since bcm2835-rng takes over
In reply to Florian FainelliQuoted 17 lines · Florian Fainelli
bcm2835-rng is now capable of supporting the BCM63xx hardware, so remove the driver which duplicates the same functionality.
Signed-off-by Florian Fainelli <[email protected]>--- drivers/char/hw_random/Kconfig | 13 --- drivers/char/hw_random/Makefile | 1 - drivers/char/hw_random/bcm63xx-rng.c | 154 ----------------------------------- 3 files changed, 168 deletions(-) delete mode 100644 drivers/char/hw_random/bcm63xx-rng.cdrivers/char/hw_random/bcm63xx-rng.c deleted +0
-0
drivers/char/hw_random/bcm63xx-rng.c line 69
Quoted 7 lines
drivers/char/hw_random/bcm63xx-rng.c deleted +0
-6-static int bcm63xx_rng_data_present (struct hwrng *rng,int wait) -{ -struct bcm63xx_rng_priv *priv =to_rng_priv (rng); - -return __raw_readl (priv->regs +RNG_STAT ) &RNG_AVAIL_MASK ; -}
It looks like this method isn't in the 2835 implementation. Should it
get ported over?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20171103/869b7075/attachment.sig>
Re: [PATCH 08/12] hwrng: bcm2835-rng: Abstract I/O accessors
In reply to Florian FainelliQuoted 31 lines · Florian Fainelli
In preparation for allowing BCM63xx to use this driver, we abstract I/O accessors such that we can easily change those later on.
Signed-off-by Florian Fainelli <[email protected]>--- drivers/char/hw_random/bcm2835-rng.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-)drivers/char/hw_random/bcm2835-rng.c +11
-0@@ -42,6 +42,17 @@ static inline struct bcm2835_rng_priv *to_rng_priv(struct hwrng *rng) return container_of(rng, struct bcm2835_rng_priv, rng); } +static inline u32 rng_readl (struct bcm2835_rng_priv *priv,u32 offset) +{ +return readl (priv->base + offset); +} + +static inline void rng_writel (struct bcm2835_rng_priv *priv,u32 val, +u32 offset) +{ +writel (val, priv->base + offset); +} +static int bcm2835_rng_read (struct hwrng *rng,void *buf,size_t max,bool wait) {
drivers/char/hw_random/bcm2835-rng.c static int bcm2835_rng_read(struct hwrng *rng, void *buf, size_t max, · line 67
Quoted 9 lines
drivers/char/hw_random/bcm2835-rng.c +1
-1@@ -49,18 +60,18 @@ static int bcm2835_rng_read(struct hwrng *rng, void *buf, size_t max,u32 max_words = max /sizeof (u32);u32 num_words, count; -while ((__raw_readl (priv->base +RNG_STATUS ) >>24 ) ==0 ) { +while ((rng_readl (priv,RNG_STATUS ) >>24 ) ==0 ) {if (!wait)return 0 ;cpu_relax (); }
What was the difference between the __raw_readl and readl that's now being done in the new call? Is it important?
drivers/char/hw_random/bcm2835-rng.c static int bcm2835_rng_init(struct hwrng *rng) · line 98
Quoted 5 lines
drivers/char/hw_random/bcm2835-rng.c +2
-2/* set warm-up count & enable */ -__raw_writel (RNG_WARMUP_COUNT , priv->base +RNG_STATUS ); -__raw_writel (RNG_RBGEN , priv->base +RNG_CTRL ); +rng_writel (priv,RNG_WARMUP_COUNT ,RNG_STATUS ); +rng_writel (priv,RNG_RBGEN ,RNG_CTRL );
Similar question.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20171103/0eba7ded/attachment.sig>
Re: [PATCH 12/12] hwrng: bcm63xx-rng: Remove since bcm2835-rng takes over
In reply to Eric AnholtQuoted 20 lines · Eric Anholt
Quoted 17 lines · Florian Fainelli
bcm2835-rng is now capable of supporting the BCM63xx hardware, so remove the driver which duplicates the same functionality.
Signed-off-by Florian Fainelli <[email protected]>--- drivers/char/hw_random/Kconfig | 13 --- drivers/char/hw_random/Makefile | 1 - drivers/char/hw_random/bcm63xx-rng.c | 154 ----------------------------------- 3 files changed, 168 deletions(-) delete mode 100644 drivers/char/hw_random/bcm63xx-rng.cdrivers/char/hw_random/bcm63xx-rng.c deleted +0
-0
Quoted 9 lines
drivers/char/hw_random/bcm63xx-rng.c line 69
Quoted 6 lines
drivers/char/hw_random/bcm63xx-rng.c deleted +0
-6-static int bcm63xx_rng_data_present (struct hwrng *rng,int wait) -{ -struct bcm63xx_rng_priv *priv =to_rng_priv (rng); - -return __raw_readl (priv->regs +RNG_STAT ) &RNG_AVAIL_MASK ; -}It looks like this method isn't in the 2835 implementation. Should it get ported over?
The read method already has something similar in that it busy loops until it gets some random words available, which is why I did not port it over.
Signature · 1 line
Florian
Re: [PATCH 08/12] hwrng: bcm2835-rng: Abstract I/O accessors
In reply to Eric AnholtQuoted 36 lines · Eric Anholt
Quoted 34 lines · Florian Fainelli
In preparation for allowing BCM63xx to use this driver, we abstract I/O accessors such that we can easily change those later on.
Signed-off-by Florian Fainelli <[email protected]>--- drivers/char/hw_random/bcm2835-rng.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-)drivers/char/hw_random/bcm2835-rng.c +11
-0@@ -42,6 +42,17 @@ static inline struct bcm2835_rng_priv *to_rng_priv(struct hwrng *rng) return container_of(rng, struct bcm2835_rng_priv, rng); } +static inline u32 rng_readl (struct bcm2835_rng_priv *priv,u32 offset) +{ +return readl (priv->base + offset); +} + +static inline void rng_writel (struct bcm2835_rng_priv *priv,u32 val, +u32 offset) +{ +writel (val, priv->base + offset); +} +static int bcm2835_rng_read (struct hwrng *rng,void *buf,size_t max,bool wait) {@@ -49,18 +60,18 @@ static int bcm2835_rng_read(struct hwrng *rng, void *buf, size_t max,u32 max_words = max /sizeof (u32);u32 num_words, count;
Quoted 9 lines
drivers/char/hw_random/bcm2835-rng.c static int bcm2835_rng_read(struct hwrng *rng, void *buf, size_t max, · line 67
Quoted 6 lines
drivers/char/hw_random/bcm2835-rng.c +1
-1-while ((__raw_readl (priv->base +RNG_STATUS ) >>24 ) ==0 ) { +while ((rng_readl (priv,RNG_STATUS ) >>24 ) ==0 ) {if (!wait)return 0 ;cpu_relax (); }What was the difference between the
__raw_readland readl that's now being done in the new call? Is it important?
readl() on ARM contains a memory barrier, which has therefore stronger ordering guarantees than __raw_readl() which does not.
In practice I don't think this makes a whole lot of difference in that the above loop does not even have a barrier outside of it to try to have any sort of ordering guarantee so it seems to me like this may be an oversight.
I took the liberty to use the stronger operation here because it seems to me like this is what is desired, or at least won't cause functional problems, and because I am not intimately familiar with the 2835 busing architecture. I know for a thing that the Broadcom STB and DSL busses (named GISB and UBUS respectively) do not require such barriers since they do not re-order transactions and are non-posted.
Quoted 8 lines
drivers/char/hw_random/bcm2835-rng.c static int bcm2835_rng_init(struct hwrng *rng) · line 98
Quoted 6 lines
drivers/char/hw_random/bcm2835-rng.c +2
-2/* set warm-up count & enable */ -__raw_writel (RNG_WARMUP_COUNT , priv->base +RNG_STATUS ); -__raw_writel (RNG_RBGEN , priv->base +RNG_CTRL ); +rng_writel (priv,RNG_WARMUP_COUNT ,RNG_STATUS ); +rng_writel (priv,RNG_RBGEN ,RNG_CTRL );Similar question.
And here we definitively are not in a hot-path so the more "ordered" variant is acceptable it seems.
Signature · 1 line
Florian
Re: [PATCH 07/12] hwrng: bcm2835-rng: Manage an optional clock
In reply to Florian FainelliHi Florian,
Quoted 54 lines
Florian Fainelli <[email protected]> hat am 2. November 2017 um 02:04 geschrieben:
One of the last steps before bcm63xx-rng can be eliminated is to manage a clock during
hwrng::initandhwrng::cleanup, so fetch it in the probe function, and manage it during these two steps when valid.Signed-off-by Florian Fainelli <[email protected]>--- drivers/char/hw_random/bcm2835-rng.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)drivers/char/hw_random/bcm2835-rng.c +9
-0@@ -15,6 +15,7 @@#include <linux/of_platform.h> #include <linux/platform_device.h> #include <linux/printk.h> +#include <linux/clk.h> #define RNG_CTRL 0x0#define RNG_STATUS 0x4@@ -33,6 +34,7 @@ struct bcm2835_rng_priv {struct hwrng rng;void __iomem *base;bool mask_interrupts; +struct clk *clk; };static inline struct bcm2835_rng_priv *to_rng_priv (struct hwrng *rng)@@ -67,6 +69,11 @@ static int bcm2835_rng_init(struct hwrng *rng) {struct bcm2835_rng_priv *priv =to_rng_priv (rng);u32 val; +int ret; + + ret =clk_prepare_enable (priv->clk); +if (ret) +return ret;if (priv->mask_interrupts) {/* mask the interrupt */ @@ -88,6 +95,8 @@ static void bcm2835_rng_cleanup(struct hwrng *rng)/* disable rng hardware */ __raw_writel (0 , priv->base +RNG_CTRL ); + +clk_disable_unprepare (priv->clk); }struct bcm2835_rng_of_data {
drivers/char/hw_random/bcm2835-rng.c static int bcm2835_rng_probe(struct platform_device *pdev) · line 145
Quoted 7 lines
drivers/char/hw_random/bcm2835-rng.c +4
-0@@ -130,6 +139,11 @@ static int bcm2835_rng_probe(struct platform_device *pdev)return PTR_ERR (priv->base); } +/* Clock is optional on most platforms */ + priv->clk =devm_clk_get (dev,NULL ); +if (IS_ERR (priv->clk)) + priv->clk =NULL ;
at least in case of EPROBE_DEFERED this isn't the expected behavior. Maybe we should better trigger on non-existing clock?
Quoted 7 lines
drivers/char/hw_random/bcm2835-rng.c +1
-0+ priv->rng.name ="bcm2835-rng" ; priv->rng.init = bcm2835_rng_init; priv->rng.read = bcm2835_rng_read;Signature · 1 line
2.9.3
Re: [PATCH 07/12] hwrng: bcm2835-rng: Manage an optional clock
Hi Stefan,
Quoted 59 lines · Stefan Wahren
Hi Florian,
Quoted 57 lines
Florian Fainelli <[email protected]> hat am 2. November 2017 um 02:04 geschrieben:
One of the last steps before bcm63xx-rng can be eliminated is to manage a clock during
hwrng::initandhwrng::cleanup, so fetch it in the probe function, and manage it during these two steps when valid.Signed-off-by Florian Fainelli <[email protected]>--- drivers/char/hw_random/bcm2835-rng.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)drivers/char/hw_random/bcm2835-rng.c +9
-0@@ -15,6 +15,7 @@#include <linux/of_platform.h> #include <linux/platform_device.h> #include <linux/printk.h> +#include <linux/clk.h> #define RNG_CTRL 0x0#define RNG_STATUS 0x4@@ -33,6 +34,7 @@ struct bcm2835_rng_priv {struct hwrng rng;void __iomem *base;bool mask_interrupts; +struct clk *clk; };static inline struct bcm2835_rng_priv *to_rng_priv (struct hwrng *rng)@@ -67,6 +69,11 @@ static int bcm2835_rng_init(struct hwrng *rng) {struct bcm2835_rng_priv *priv =to_rng_priv (rng);u32 val; +int ret; + + ret =clk_prepare_enable (priv->clk); +if (ret) +return ret;if (priv->mask_interrupts) {/* mask the interrupt */ @@ -88,6 +95,8 @@ static void bcm2835_rng_cleanup(struct hwrng *rng)/* disable rng hardware */ __raw_writel (0 , priv->base +RNG_CTRL ); + +clk_disable_unprepare (priv->clk); }struct bcm2835_rng_of_data {@@ -130,6 +139,11 @@ static int bcm2835_rng_probe(struct platform_device *pdev)return PTR_ERR (priv->base); }
Quoted 6 lines
drivers/char/hw_random/bcm2835-rng.c static int bcm2835_rng_probe(struct platform_device *pdev) · line 145
Quoted 4 lines
drivers/char/hw_random/bcm2835-rng.c +4
-0+/* Clock is optional on most platforms */ + priv->clk =devm_clk_get (dev,NULL ); +if (IS_ERR (priv->clk)) + priv->clk =NULL ;at least in case of
EPROBE_DEFEREDthis isn't the expected behavior. Maybe we should better trigger on non-existing clock?
Good point, so more like:
if (IS_ERR(priv->clk) && PTR_ERR(priv->clk) == -ENODEV)?
Signature · 1 line
Florian
Re: [PATCH 07/12] hwrng: bcm2835-rng: Manage an optional clock
Quoted 73 lines
Florian Fainelli <[email protected]> hat am 4. November 2017 um 18:59 geschrieben:
Hi Stefan,
Quoted 59 lines · Stefan Wahren
Hi Florian,
Quoted 57 lines
Florian Fainelli <[email protected]> hat am 2. November 2017 um 02:04 geschrieben:
One of the last steps before bcm63xx-rng can be eliminated is to manage a clock during
hwrng::initandhwrng::cleanup, so fetch it in the probe function, and manage it during these two steps when valid.Signed-off-by Florian Fainelli <[email protected]>--- drivers/char/hw_random/bcm2835-rng.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)drivers/char/hw_random/bcm2835-rng.c +9
-0@@ -15,6 +15,7 @@#include <linux/of_platform.h> #include <linux/platform_device.h> #include <linux/printk.h> +#include <linux/clk.h> #define RNG_CTRL 0x0#define RNG_STATUS 0x4@@ -33,6 +34,7 @@ struct bcm2835_rng_priv {struct hwrng rng;void __iomem *base;bool mask_interrupts; +struct clk *clk; };static inline struct bcm2835_rng_priv *to_rng_priv (struct hwrng *rng)@@ -67,6 +69,11 @@ static int bcm2835_rng_init(struct hwrng *rng) {struct bcm2835_rng_priv *priv =to_rng_priv (rng);u32 val; +int ret; + + ret =clk_prepare_enable (priv->clk); +if (ret) +return ret;if (priv->mask_interrupts) {/* mask the interrupt */ @@ -88,6 +95,8 @@ static void bcm2835_rng_cleanup(struct hwrng *rng)/* disable rng hardware */ __raw_writel (0 , priv->base +RNG_CTRL ); + +clk_disable_unprepare (priv->clk); }struct bcm2835_rng_of_data {@@ -130,6 +139,11 @@ static int bcm2835_rng_probe(struct platform_device *pdev)return PTR_ERR (priv->base); }Quoted 6 lines
drivers/char/hw_random/bcm2835-rng.c static int bcm2835_rng_probe(struct platform_device *pdev) · line 145
Quoted 4 lines
drivers/char/hw_random/bcm2835-rng.c +4
-0+/* Clock is optional on most platforms */ + priv->clk =devm_clk_get (dev,NULL ); +if (IS_ERR (priv->clk)) + priv->clk =NULL ;at least in case of
EPROBE_DEFEREDthis isn't the expected behavior. Maybe we should better trigger on non-existing clock?
Quoted 3 lines
Good point, so more like:
if (
IS_ERR(priv->clk)&&PTR_ERR(priv->clk)==-ENODEV)?
Unfortunately we need to return the error in all other cases. Please take a look at devm_usb_get_phy in dwc2 [1]. AFAIK we don't need to take care of ENXIO in our case.
http://elixir.free-electrons.com/linux/latest/source/drivers/usb/dwc2/platform.c#L247
Quoted 8 lines
Signature · 7 lines
-- Florian _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel at lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 11/12] hwrng: bcm2835-rng: Enable BCM2835 RNG to work on BCM63xx platforms
In reply to Florian FainelliHi Florian
Quoted 48 lines
Florian Fainelli <[email protected]> hat am 2. November 2017 um 02:04 geschrieben:
We have now incorporated all necessary functionality for the BCM63xx platforms to successfully migrate over bcm2835-rng, so add the final
bits:Kconfigselection and properplatform_devicedevice type matching to keep the same platform device name for registration to work.Signed-off-by Florian Fainelli <[email protected]>--- drivers/char/hw_random/Kconfig | 7 ++++--- drivers/char/hw_random/bcm2835-rng.c | 11 ++++++++++- 2 files changed, 14 insertions(+), 4 deletions(-)drivers/char/hw_random/Kconfig +4
-3@@ -87,12 +87,13 @@ config HW_RANDOM_BCM63XX If unusure, say Y. config HW_RANDOM_BCM2835 - tristate "Broadcom BCM2835 Random Number Generator support" - depends on ARCH_BCM2835 || ARCH_BCM_NSP || ARCH_BCM_5301X + tristate "Broadcom BCM2835/BCM63xx Random Number Generator support" + depends on ARCH_BCM2835 || ARCH_BCM_NSP || ARCH_BCM_5301X || \ + ARCH_BCM_63XX || BCM63XX || BMIPS_GENERIC default HW_RANDOM ---help--- This driver provides kernel-side support for the Random Number - Generator hardware found on the Broadcom BCM2835 SoCs. + Generator hardware found on the Broadcom BCM2835 and BCM63xx SoCs. To compile this driver as a module, choose M here: the module will be called bcm2835-rngdrivers/char/hw_random/bcm2835-rng.c +1
-0@@ -131,6 +131,7 @@ static const struct of_device_id bcm2835_rng_of_match[] = { { .compatible = "brcm,bcm2835-rng"}, { .compatible = "brcm,bcm-nsp-rng", .data = &nsp_rng_of_data }, { .compatible = "brcm,bcm5301x-rng", .data = &nsp_rng_of_data }, + { .compatible = "brcm,bcm6368-rng"}, {}, };
drivers/char/hw_random/bcm2835-rng.c static int bcm2835_rng_probe(struct platform_device *pdev) · line 168
Quoted 5 lines
drivers/char/hw_random/bcm2835-rng.c +1
-1@@ -164,7 +165,7 @@ static int bcm2835_rng_probe(struct platform_device *pdev)if (IS_ERR (priv->clk)) priv->clk =NULL ; - priv->rng.name ="bcm2835-rng" ; + priv->rng.name = pdev->id_entry->name;
this change breaks registration on bcm2835, because the name is NULL.
Regards
Stefan
Quoted 32 lines
drivers/char/hw_random/bcm2835-rng.c +8
-0priv->rng.init = bcm2835_rng_init; priv->rng.read = bcm2835_rng_read; priv->rng.cleanup = bcm2835_rng_cleanup;@@ -190,12 +191,20 @@ static int bcm2835_rng_probe(struct platform_device *pdev)MODULE_DEVICE_TABLE (of, bcm2835_rng_of_match); +static struct platform_device_id bcm2835_rng_devtype[] = { + { .name ="bcm2835-rng" }, + { .name ="bcm63xx-rng" }, + {/* sentinel */ } +}; +MODULE_DEVICE_TABLE (platform, bcm2835_rng_devtype); +static struct platform_driver bcm2835_rng_driver = { .driver = { .name ="bcm2835-rng" , .of_match_table = bcm2835_rng_of_match, }, .probe = bcm2835_rng_probe, + .id_table = bcm2835_rng_devtype, };module_platform_driver (bcm2835_rng_driver);Signature · 7 lines
2.9.3 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel at lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 07/12] hwrng: bcm2835-rng: Manage an optional clock
In reply to Stefan WahrenHi Florian
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
drivers/char/hw_random/bcm2835-rng.c static int bcm2835_rng_probe(struct platform_device *pdev) · line 145
Quoted 4 lines
drivers/char/hw_random/bcm2835-rng.c +4
-0+/* Clock is optional on most platforms */ + priv->clk =devm_clk_get (dev,NULL ); +if (IS_ERR (priv->clk)) + priv->clk =NULL ;at least in case of
EPROBE_DEFEREDthis isn't the expected behavior. Maybe we should better trigger on non-existing clock?
Quoted 8 lines
Quoted 3 lines
Good point, so more like:
if (
IS_ERR(priv->clk)&&PTR_ERR(priv->clk)==-ENODEV)?Unfortunately we need to return the error in all other cases. Please take a look at
devm_usb_get_phyin dwc2 [1]. AFAIK we don't need to take care of ENXIO in our case.
A few subsystems have a get_optional() call, e.g. devm_phy_optional_get(). It does not return an error when the phy is not supposed to exist, but in all other cases, it does.
Maybe consider adding devm_clk_get_optional()?
Andrew
Re: [PATCH 07/12] hwrng: bcm2835-rng: Manage an optional clock
Quoted 18 lines · Andrew Lunn
Hi Florian
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
drivers/char/hw_random/bcm2835-rng.c static int bcm2835_rng_probe(struct platform_device *pdev) · line 145
Quoted 4 lines
drivers/char/hw_random/bcm2835-rng.c +4
-0+/* Clock is optional on most platforms */ + priv->clk =devm_clk_get (dev,NULL ); +if (IS_ERR (priv->clk)) + priv->clk =NULL ;at least in case of
EPROBE_DEFEREDthis isn't the expected behavior. Maybe we should better trigger on non-existing clock?Quoted 8 lines
Quoted 3 lines
Good point, so more like:
if (
IS_ERR(priv->clk)&&PTR_ERR(priv->clk)==-ENODEV)?Unfortunately we need to return the error in all other cases. Please take a look at
devm_usb_get_phyin dwc2 [1]. AFAIK we don't need to take care of ENXIO in our case.
Quoted 5 lines
A few subsystems have a
get_optional()call, e.g.devm_phy_optional_get(). It does not return an error when the phy is not supposed to exist, but in all other cases, it does.Maybe consider adding
devm_clk_get_optional()?
The clk API outside of DT doesn't have knowledge of when it's "complete" to be able to determine whether the clock is not present or temporarily missing. I've already NAK'd this suggestion.
Signature · 3 lines
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line in suburbia: sync at 8.8Mbps down 630kbps up According to speedtest.net: 8.21Mbps down 510kbps up
Re: [PATCH 07/12] hwrng: bcm2835-rng: Manage an optional clock
Quoted 3 lines
The clk API outside of DT doesn't have knowledge of when it's "complete" to be able to determine whether the clock is not present or temporarily missing. I've already NAK'd this suggestion.
Hi Russell
O.K, yes, makes sense.
We do have of_clk_get_by_name() and of_clk_get(). Would optional variants of these be acceptable?
Andrew
Re: [PATCH 11/12] hwrng: bcm2835-rng: Enable BCM2835 RNG to work on BCM63xx platforms
In reply to Stefan WahrenQuoted 49 lines · Stefan Wahren
Hi Florian
Quoted 47 lines
Florian Fainelli <[email protected]> hat am 2. November 2017 um 02:04 geschrieben:
We have now incorporated all necessary functionality for the BCM63xx platforms to successfully migrate over bcm2835-rng, so add the final
bits:Kconfigselection and properplatform_devicedevice type matching to keep the same platform device name for registration to work.Signed-off-by Florian Fainelli <[email protected]>--- drivers/char/hw_random/Kconfig | 7 ++++--- drivers/char/hw_random/bcm2835-rng.c | 11 ++++++++++- 2 files changed, 14 insertions(+), 4 deletions(-)drivers/char/hw_random/Kconfig +4
-3@@ -87,12 +87,13 @@ config HW_RANDOM_BCM63XX If unusure, say Y. config HW_RANDOM_BCM2835 - tristate "Broadcom BCM2835 Random Number Generator support" - depends on ARCH_BCM2835 || ARCH_BCM_NSP || ARCH_BCM_5301X + tristate "Broadcom BCM2835/BCM63xx Random Number Generator support" + depends on ARCH_BCM2835 || ARCH_BCM_NSP || ARCH_BCM_5301X || \ + ARCH_BCM_63XX || BCM63XX || BMIPS_GENERIC default HW_RANDOM ---help--- This driver provides kernel-side support for the Random Number - Generator hardware found on the Broadcom BCM2835 SoCs. + Generator hardware found on the Broadcom BCM2835 and BCM63xx SoCs. To compile this driver as a module, choose M here: the module will be called bcm2835-rngdrivers/char/hw_random/bcm2835-rng.c +1
-0@@ -131,6 +131,7 @@ static const struct of_device_id bcm2835_rng_of_match[] = { { .compatible = "brcm,bcm2835-rng"}, { .compatible = "brcm,bcm-nsp-rng", .data = &nsp_rng_of_data }, { .compatible = "brcm,bcm5301x-rng", .data = &nsp_rng_of_data }, + { .compatible = "brcm,bcm6368-rng"}, {}, };
Quoted 8 lines
drivers/char/hw_random/bcm2835-rng.c static int bcm2835_rng_probe(struct platform_device *pdev) · line 168
Quoted 6 lines
drivers/char/hw_random/bcm2835-rng.c +1
-1@@ -164,7 +165,7 @@ static int bcm2835_rng_probe(struct platform_device *pdev)if (IS_ERR (priv->clk)) priv->clk =NULL ; - priv->rng.name ="bcm2835-rng" ; + priv->rng.name = pdev->id_entry->name;this change breaks registration on bcm2835, because the name is NULL.
OH right, I will fix that in v2, I am assuming that if you did something like this, things still work correctly for you on 2835:
if (!priv->id_entry->name)
priv->rng.name = "bcm2835-rng"; else priv->rng.name = priv->id_entry->name;
?
Quoted 36 lines
Regards
StefanQuoted 32 lines
drivers/char/hw_random/bcm2835-rng.c +8
-0priv->rng.init = bcm2835_rng_init; priv->rng.read = bcm2835_rng_read; priv->rng.cleanup = bcm2835_rng_cleanup;@@ -190,12 +191,20 @@ static int bcm2835_rng_probe(struct platform_device *pdev)MODULE_DEVICE_TABLE (of, bcm2835_rng_of_match); +static struct platform_device_id bcm2835_rng_devtype[] = { + { .name ="bcm2835-rng" }, + { .name ="bcm63xx-rng" }, + {/* sentinel */ } +}; +MODULE_DEVICE_TABLE (platform, bcm2835_rng_devtype); +static struct platform_driver bcm2835_rng_driver = { .driver = { .name ="bcm2835-rng" , .of_match_table = bcm2835_rng_of_match, }, .probe = bcm2835_rng_probe, + .id_table = bcm2835_rng_devtype, };module_platform_driver (bcm2835_rng_driver);Signature · 7 lines
2.9.3 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel at lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Signature · 1 line
Florian
Re: [PATCH 10/12] dt-bindings: rng: Incorporate brcm,bcm6368.txt binding
In reply to Florian FainelliQuoted 9 lines · Florian Fainelli
Since the same block is used on BCM2835 and BCM6368, merge the bindings and remove the brcm,bcm6368.txt binding document.
Signed-off-by Florian Fainelli <[email protected]>--- .../devicetree/bindings/rng/brcm,bcm2835.txt | 22 +++++++++++++++++++--- .../devicetree/bindings/rng/brcm,bcm6368.txt | 17 ----------------- 2 files changed, 19 insertions(+), 20 deletions(-) delete mode 100644 Documentation/devicetree/bindings/rng/brcm,bcm6368.txt
Re: [PATCH 11/12] hwrng: bcm2835-rng: Enable BCM2835 RNG to work on BCM63xx platforms
In reply to Florian FainelliQuoted 65 lines
Florian Fainelli <[email protected]> hat am 6. November 2017 um 21:16 geschrieben:
Quoted 49 lines · Stefan Wahren
Hi Florian
Quoted 47 lines
Florian Fainelli <[email protected]> hat am 2. November 2017 um 02:04 geschrieben:
We have now incorporated all necessary functionality for the BCM63xx platforms to successfully migrate over bcm2835-rng, so add the final
bits:Kconfigselection and properplatform_devicedevice type matching to keep the same platform device name for registration to work.Signed-off-by Florian Fainelli <[email protected]>--- drivers/char/hw_random/Kconfig | 7 ++++--- drivers/char/hw_random/bcm2835-rng.c | 11 ++++++++++- 2 files changed, 14 insertions(+), 4 deletions(-)drivers/char/hw_random/Kconfig +4
-3@@ -87,12 +87,13 @@ config HW_RANDOM_BCM63XX If unusure, say Y. config HW_RANDOM_BCM2835 - tristate "Broadcom BCM2835 Random Number Generator support" - depends on ARCH_BCM2835 || ARCH_BCM_NSP || ARCH_BCM_5301X + tristate "Broadcom BCM2835/BCM63xx Random Number Generator support" + depends on ARCH_BCM2835 || ARCH_BCM_NSP || ARCH_BCM_5301X || \ + ARCH_BCM_63XX || BCM63XX || BMIPS_GENERIC default HW_RANDOM ---help--- This driver provides kernel-side support for the Random Number - Generator hardware found on the Broadcom BCM2835 SoCs. + Generator hardware found on the Broadcom BCM2835 and BCM63xx SoCs. To compile this driver as a module, choose M here: the module will be called bcm2835-rngdrivers/char/hw_random/bcm2835-rng.c +1
-0@@ -131,6 +131,7 @@ static const struct of_device_id bcm2835_rng_of_match[] = { { .compatible = "brcm,bcm2835-rng"}, { .compatible = "brcm,bcm-nsp-rng", .data = &nsp_rng_of_data }, { .compatible = "brcm,bcm5301x-rng", .data = &nsp_rng_of_data }, + { .compatible = "brcm,bcm6368-rng"}, {}, };Quoted 8 lines
drivers/char/hw_random/bcm2835-rng.c static int bcm2835_rng_probe(struct platform_device *pdev) · line 168
Quoted 6 lines
drivers/char/hw_random/bcm2835-rng.c +1
-1@@ -164,7 +165,7 @@ static int bcm2835_rng_probe(struct platform_device *pdev)if (IS_ERR (priv->clk)) priv->clk =NULL ; - priv->rng.name ="bcm2835-rng" ; + priv->rng.name = pdev->id_entry->name;this change breaks registration on bcm2835, because the name is NULL.
OH right, I will fix that in v2, I am assuming that if you did something like this, things still work correctly for you on 2835:
Quoted 6 lines
if (!priv->id_entry->name)
priv->rng.name = "bcm2835-rng"; else priv->rng.name = priv->id_entry->name;?
I think that should work, but i'm not really happy about it. I prefer a more general solution. Looking at the other rng drivers shows the following pattern:
priv->rng.name = pdev->name;
I need to verify this on bcm2835.
Quoted 46 lines
Quoted 37 lines
Regards
StefanQuoted 32 lines
drivers/char/hw_random/bcm2835-rng.c +8
-0priv->rng.init = bcm2835_rng_init; priv->rng.read = bcm2835_rng_read; priv->rng.cleanup = bcm2835_rng_cleanup;@@ -190,12 +191,20 @@ static int bcm2835_rng_probe(struct platform_device *pdev)MODULE_DEVICE_TABLE (of, bcm2835_rng_of_match); +static struct platform_device_id bcm2835_rng_devtype[] = { + { .name ="bcm2835-rng" }, + { .name ="bcm63xx-rng" }, + {/* sentinel */ } +}; +MODULE_DEVICE_TABLE (platform, bcm2835_rng_devtype); +static struct platform_driver bcm2835_rng_driver = { .driver = { .name ="bcm2835-rng" , .of_match_table = bcm2835_rng_of_match, }, .probe = bcm2835_rng_probe, + .id_table = bcm2835_rng_devtype, };module_platform_driver (bcm2835_rng_driver);Signature · 7 lines
2.9.3 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel at lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernelSignature · 6 lines
Florian _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel at lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 11/12] hwrng: bcm2835-rng: Enable BCM2835 RNG to work on BCM63xx platforms
Quoted 74 lines
Stefan Wahren <[email protected]> hat am 7. November 2017 um 07:45 geschrieben:
Quoted 70 lines
Florian Fainelli <[email protected]> hat am 6. November 2017 um 21:16 geschrieben:
Quoted 49 lines · Stefan Wahren
Hi Florian
Quoted 47 lines
Florian Fainelli <[email protected]> hat am 2. November 2017 um 02:04 geschrieben:
We have now incorporated all necessary functionality for the BCM63xx platforms to successfully migrate over bcm2835-rng, so add the final
bits:Kconfigselection and properplatform_devicedevice type matching to keep the same platform device name for registration to work.Signed-off-by Florian Fainelli <[email protected]>--- drivers/char/hw_random/Kconfig | 7 ++++--- drivers/char/hw_random/bcm2835-rng.c | 11 ++++++++++- 2 files changed, 14 insertions(+), 4 deletions(-)drivers/char/hw_random/Kconfig +4
-3@@ -87,12 +87,13 @@ config HW_RANDOM_BCM63XX If unusure, say Y. config HW_RANDOM_BCM2835 - tristate "Broadcom BCM2835 Random Number Generator support" - depends on ARCH_BCM2835 || ARCH_BCM_NSP || ARCH_BCM_5301X + tristate "Broadcom BCM2835/BCM63xx Random Number Generator support" + depends on ARCH_BCM2835 || ARCH_BCM_NSP || ARCH_BCM_5301X || \ + ARCH_BCM_63XX || BCM63XX || BMIPS_GENERIC default HW_RANDOM ---help--- This driver provides kernel-side support for the Random Number - Generator hardware found on the Broadcom BCM2835 SoCs. + Generator hardware found on the Broadcom BCM2835 and BCM63xx SoCs. To compile this driver as a module, choose M here: the module will be called bcm2835-rngdrivers/char/hw_random/bcm2835-rng.c +1
-0@@ -131,6 +131,7 @@ static const struct of_device_id bcm2835_rng_of_match[] = { { .compatible = "brcm,bcm2835-rng"}, { .compatible = "brcm,bcm-nsp-rng", .data = &nsp_rng_of_data }, { .compatible = "brcm,bcm5301x-rng", .data = &nsp_rng_of_data }, + { .compatible = "brcm,bcm6368-rng"}, {}, };Quoted 8 lines
drivers/char/hw_random/bcm2835-rng.c static int bcm2835_rng_probe(struct platform_device *pdev) · line 168
Quoted 6 lines
drivers/char/hw_random/bcm2835-rng.c +1
-1@@ -164,7 +165,7 @@ static int bcm2835_rng_probe(struct platform_device *pdev)if (IS_ERR (priv->clk)) priv->clk =NULL ; - priv->rng.name ="bcm2835-rng" ; + priv->rng.name = pdev->id_entry->name;this change breaks registration on bcm2835, because the name is NULL.
OH right, I will fix that in v2, I am assuming that if you did something like this, things still work correctly for you on 2835:
if (!priv->id_entry->name)
priv->rng.name = "bcm2835-rng"; else priv->rng.name = priv->id_entry->name;
Quoted 7 lines
Quoted 1 line
?
I think that should work, but i'm not really happy about it. I prefer a more general solution. Looking at the other rng drivers shows the following pattern:
priv->rng.name=pdev->name;I need to verify this on bcm2835.
Okay pdev->name works for bcm2835