aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/bcm53xx/files/drivers
diff options
context:
space:
mode:
authorRafał Miłecki <zajec5@gmail.com>2015-02-16 16:13:23 +0000
committerRafał Miłecki <zajec5@gmail.com>2015-02-16 16:13:23 +0000
commit44253d311f4e5d22c1bb1b5882431e36e5c44f3a (patch)
tree3961abc98e15ed24560f3f61a312ce20ba65ae45 /target/linux/bcm53xx/files/drivers
parent4c98253648c0b4a364dce28d69f04219bc8bc4d9 (diff)
downloadupstream-44253d311f4e5d22c1bb1b5882431e36e5c44f3a.tar.gz
upstream-44253d311f4e5d22c1bb1b5882431e36e5c44f3a.tar.bz2
upstream-44253d311f4e5d22c1bb1b5882431e36e5c44f3a.zip
bcm53xx: sprom: extract for PCI host
Signed-off-by: Rafał Miłecki <zajec5@gmail.com> SVN-Revision: 44464
Diffstat (limited to 'target/linux/bcm53xx/files/drivers')
-rw-r--r--target/linux/bcm53xx/files/drivers/misc/bcm47xx-sprom.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/target/linux/bcm53xx/files/drivers/misc/bcm47xx-sprom.c b/target/linux/bcm53xx/files/drivers/misc/bcm47xx-sprom.c
index 6b3ab96749..a82728df91 100644
--- a/target/linux/bcm53xx/files/drivers/misc/bcm47xx-sprom.c
+++ b/target/linux/bcm53xx/files/drivers/misc/bcm47xx-sprom.c
@@ -644,6 +644,30 @@ static int bcm47xx_sprom_getenv(const struct bcm47xx_sprom_fill *fill,
/* FIXME: This should not be static, but some callback argument */
static struct platform_device *sprom_pdev = NULL;
+static char prefix[20];
+
+static void bcm47xx_sprom_apply_prefix_alias(char *prefix, size_t prefix_len)
+{
+ size_t needle_len = strlen(prefix) - 1;
+ char nvram_var[10];
+ char buf[20];
+ int i;
+
+ if (needle_len <= 0 || prefix[needle_len] != '/')
+ return;
+
+ for (i = 0; i < 3; i++) {
+ if (snprintf(nvram_var, sizeof(nvram_var), "devpath%d", i) <= 0)
+ continue;
+ if (bcm47xx_nvram_getenv(nvram_var, buf, sizeof(buf)) < 0)
+ continue;
+ if (strlen(buf) == needle_len && !strncmp(buf, prefix, needle_len)) {
+ snprintf(prefix, prefix_len, "%d:", i);
+ return;
+ }
+ }
+}
+
/*
* This function has to be called in a very precise moment. It has to be done:
* 1) After bcma registers flash cores, so we can read NVRAM.
@@ -674,6 +698,13 @@ static int bcm47xx_sprom_init(struct bcma_bus *bus, struct ssb_sprom *out)
return -ENOMEM;
switch (bus->hosttype) {
+ case BCMA_HOSTTYPE_PCI:
+ snprintf(prefix, sizeof(prefix), "pci/%u/%u/",
+ pci_domain_nr(bus->host_pci->bus) + 1,
+ bus->host_pci->bus->number);
+ bcm47xx_sprom_apply_prefix_alias(prefix, sizeof(prefix));
+ fill.prefix = prefix;
+ break;
case BCMA_HOSTTYPE_SOC:
fill.prefix = of_get_property(np, "prefix", NULL);
break;