aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/bcm47xx
diff options
context:
space:
mode:
Diffstat (limited to 'arch/mips/bcm47xx')
-rw-r--r--arch/mips/bcm47xx/setup.c19
-rw-r--r--arch/mips/bcm47xx/sprom.c46
2 files changed, 40 insertions, 25 deletions
diff --git a/arch/mips/bcm47xx/setup.c b/arch/mips/bcm47xx/setup.c
index 17503a05938e..6d38948f0f1e 100644
--- a/arch/mips/bcm47xx/setup.c
+++ b/arch/mips/bcm47xx/setup.c
@@ -105,11 +105,28 @@ static int bcm47xx_get_invariants(struct ssb_bus *bus,
105 struct ssb_init_invariants *iv) 105 struct ssb_init_invariants *iv)
106{ 106{
107 char buf[20]; 107 char buf[20];
108 int len, err;
108 109
109 /* Fill boardinfo structure */ 110 /* Fill boardinfo structure */
110 memset(&iv->boardinfo, 0 , sizeof(struct ssb_boardinfo)); 111 memset(&iv->boardinfo, 0 , sizeof(struct ssb_boardinfo));
111 112
112 bcm47xx_fill_ssb_boardinfo(&iv->boardinfo, NULL); 113 len = bcm47xx_nvram_getenv("boardvendor", buf, sizeof(buf));
114 if (len > 0) {
115 err = kstrtou16(strim(buf), 0, &iv->boardinfo.vendor);
116 if (err)
117 pr_warn("Couldn't parse nvram board vendor entry with value \"%s\"\n",
118 buf);
119 }
120 if (!iv->boardinfo.vendor)
121 iv->boardinfo.vendor = SSB_BOARDVENDOR_BCM;
122
123 len = bcm47xx_nvram_getenv("boardtype", buf, sizeof(buf));
124 if (len > 0) {
125 err = kstrtou16(strim(buf), 0, &iv->boardinfo.type);
126 if (err)
127 pr_warn("Couldn't parse nvram board type entry with value \"%s\"\n",
128 buf);
129 }
113 130
114 memset(&iv->sprom, 0, sizeof(struct ssb_sprom)); 131 memset(&iv->sprom, 0, sizeof(struct ssb_sprom));
115 bcm47xx_fill_sprom(&iv->sprom, NULL, false); 132 bcm47xx_fill_sprom(&iv->sprom, NULL, false);
diff --git a/arch/mips/bcm47xx/sprom.c b/arch/mips/bcm47xx/sprom.c
index 2d5c7a7f24bb..a7e569c7968e 100644
--- a/arch/mips/bcm47xx/sprom.c
+++ b/arch/mips/bcm47xx/sprom.c
@@ -60,9 +60,9 @@ static int get_nvram_var(const char *prefix, const char *postfix,
60} 60}
61 61
62#define NVRAM_READ_VAL(type) \ 62#define NVRAM_READ_VAL(type) \
63static void nvram_read_ ## type (const char *prefix, \ 63static void nvram_read_ ## type(const char *prefix, \
64 const char *postfix, const char *name, \ 64 const char *postfix, const char *name, \
65 type *val, type allset, bool fallback) \ 65 type *val, type allset, bool fallback) \
66{ \ 66{ \
67 char buf[100]; \ 67 char buf[100]; \
68 int err; \ 68 int err; \
@@ -422,7 +422,10 @@ static void bcm47xx_fill_sprom_path_r4589(struct ssb_sprom *sprom,
422 int i; 422 int i;
423 423
424 for (i = 0; i < ARRAY_SIZE(sprom->core_pwr_info); i++) { 424 for (i = 0; i < ARRAY_SIZE(sprom->core_pwr_info); i++) {
425 struct ssb_sprom_core_pwr_info *pwr_info = &sprom->core_pwr_info[i]; 425 struct ssb_sprom_core_pwr_info *pwr_info;
426
427 pwr_info = &sprom->core_pwr_info[i];
428
426 snprintf(postfix, sizeof(postfix), "%i", i); 429 snprintf(postfix, sizeof(postfix), "%i", i);
427 nvram_read_u8(prefix, postfix, "maxp2ga", 430 nvram_read_u8(prefix, postfix, "maxp2ga",
428 &pwr_info->maxpwr_2g, 0, fallback); 431 &pwr_info->maxpwr_2g, 0, fallback);
@@ -470,7 +473,10 @@ static void bcm47xx_fill_sprom_path_r45(struct ssb_sprom *sprom,
470 int i; 473 int i;
471 474
472 for (i = 0; i < ARRAY_SIZE(sprom->core_pwr_info); i++) { 475 for (i = 0; i < ARRAY_SIZE(sprom->core_pwr_info); i++) {
473 struct ssb_sprom_core_pwr_info *pwr_info = &sprom->core_pwr_info[i]; 476 struct ssb_sprom_core_pwr_info *pwr_info;
477
478 pwr_info = &sprom->core_pwr_info[i];
479
474 snprintf(postfix, sizeof(postfix), "%i", i); 480 snprintf(postfix, sizeof(postfix), "%i", i);
475 nvram_read_u16(prefix, postfix, "pa2gw3a", 481 nvram_read_u16(prefix, postfix, "pa2gw3a",
476 &pwr_info->pa_2g[3], 0, fallback); 482 &pwr_info->pa_2g[3], 0, fallback);
@@ -535,10 +541,11 @@ static void bcm47xx_fill_sprom_ethernet(struct ssb_sprom *sprom,
535 nvram_read_macaddr(prefix, "il0macaddr", sprom->il0mac, fallback); 541 nvram_read_macaddr(prefix, "il0macaddr", sprom->il0mac, fallback);
536 542
537 /* The address prefix 00:90:4C is used by Broadcom in their initial 543 /* The address prefix 00:90:4C is used by Broadcom in their initial
538 configuration. When a mac address with the prefix 00:90:4C is used 544 * configuration. When a mac address with the prefix 00:90:4C is used
539 all devices from the same series are sharing the same mac address. 545 * all devices from the same series are sharing the same mac address.
540 To prevent mac address collisions we replace them with a mac address 546 * To prevent mac address collisions we replace them with a mac address
541 based on the base address. */ 547 * based on the base address.
548 */
542 if (!bcm47xx_is_valid_mac(sprom->il0mac)) { 549 if (!bcm47xx_is_valid_mac(sprom->il0mac)) {
543 u8 mac[6]; 550 u8 mac[6];
544 551
@@ -592,32 +599,23 @@ void bcm47xx_fill_sprom(struct ssb_sprom *sprom, const char *prefix,
592 bcm47xx_sprom_fill_auto(sprom, prefix, fallback); 599 bcm47xx_sprom_fill_auto(sprom, prefix, fallback);
593} 600}
594 601
595#ifdef CONFIG_BCM47XX_SSB
596void bcm47xx_fill_ssb_boardinfo(struct ssb_boardinfo *boardinfo,
597 const char *prefix)
598{
599 nvram_read_u16(prefix, NULL, "boardvendor", &boardinfo->vendor, 0,
600 true);
601 if (!boardinfo->vendor)
602 boardinfo->vendor = SSB_BOARDVENDOR_BCM;
603
604 nvram_read_u16(prefix, NULL, "boardtype", &boardinfo->type, 0, true);
605}
606#endif
607
608#if defined(CONFIG_BCM47XX_SSB) 602#if defined(CONFIG_BCM47XX_SSB)
609static int bcm47xx_get_sprom_ssb(struct ssb_bus *bus, struct ssb_sprom *out) 603static int bcm47xx_get_sprom_ssb(struct ssb_bus *bus, struct ssb_sprom *out)
610{ 604{
611 char prefix[10]; 605 char prefix[10];
612 606
613 if (bus->bustype == SSB_BUSTYPE_PCI) { 607 switch (bus->bustype) {
608 case SSB_BUSTYPE_SSB:
609 bcm47xx_fill_sprom(out, NULL, false);
610 return 0;
611 case SSB_BUSTYPE_PCI:
614 memset(out, 0, sizeof(struct ssb_sprom)); 612 memset(out, 0, sizeof(struct ssb_sprom));
615 snprintf(prefix, sizeof(prefix), "pci/%u/%u/", 613 snprintf(prefix, sizeof(prefix), "pci/%u/%u/",
616 bus->host_pci->bus->number + 1, 614 bus->host_pci->bus->number + 1,
617 PCI_SLOT(bus->host_pci->devfn)); 615 PCI_SLOT(bus->host_pci->devfn));
618 bcm47xx_fill_sprom(out, prefix, false); 616 bcm47xx_fill_sprom(out, prefix, false);
619 return 0; 617 return 0;
620 } else { 618 default:
621 pr_warn("Unable to fill SPROM for given bustype.\n"); 619 pr_warn("Unable to fill SPROM for given bustype.\n");
622 return -EINVAL; 620 return -EINVAL;
623 } 621 }