1 From bd9106f5907080b467026bdaaea979fac8c7badb Mon Sep 17 00:00:00 2001
2 From: Hauke Mehrtens <hauke@hauke-m.de>
3 Date: Sun, 4 May 2014 14:34:31 +0200
4 Subject: [PATCH 06/17] bcma: get sprom from devicetree
6 This patch make it possible to device an sprom provider in device tree
7 and get the sprom from this driver. Every time there is such a provider
8 it gets asked for a sprom.
10 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
12 drivers/bcma/sprom.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++-
13 1 file changed, 50 insertions(+), 1 deletion(-)
15 --- a/drivers/bcma/sprom.c
16 +++ b/drivers/bcma/sprom.c
19 #include <linux/dma-mapping.h>
20 #include <linux/slab.h>
21 +#include <linux/of.h>
22 +#include <linux/of_platform.h>
24 static int(*get_fallback_sprom)(struct bcma_bus *dev, struct ssb_sprom *out);
26 @@ -46,6 +48,46 @@ int bcma_arch_register_fallback_sprom(in
31 +static int bcma_fill_sprom_with_dt(struct bcma_bus *bus,
32 + struct ssb_sprom *out)
34 + const __be32 *handle;
35 + struct device_node *sprom_node;
36 + struct platform_device *sprom_dev;
37 + struct ssb_sprom *sprom;
39 + if (!bus->host_pdev || !bus->host_pdev->dev.of_node)
42 + handle = of_get_property(bus->host_pdev->dev.of_node, "sprom", NULL);
46 + sprom_node = of_find_node_by_phandle(be32_to_cpup(handle));
50 + sprom_dev = of_find_device_by_node(sprom_node);
54 + sprom = platform_get_drvdata(sprom_dev);
58 + memcpy(out, sprom, sizeof(*out));
63 +static int bcma_fill_sprom_with_dt(struct bcma_bus *bus,
64 + struct ssb_sprom *out)
70 static int bcma_fill_sprom_with_fallback(struct bcma_bus *bus,
71 struct ssb_sprom *out)
73 @@ -580,7 +622,14 @@ int bcma_sprom_get(struct bcma_bus *bus)
75 size_t sprom_sizes[] = { SSB_SPROMSIZE_WORDS_R4,
76 SSB_SPROMSIZE_WORDS_R10, };
80 + err = bcma_fill_sprom_with_dt(bus, &bus->sprom);
82 + bcma_info(bus, "Found sprom from device tree provider\n");
87 if (!bus->drv_cc.core)