Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 26238994 authored by Rafał Miłecki's avatar Rafał Miłecki Committed by Ralf Baechle
Browse files

MIPS: BCM47xx: Read board info for all bcma buses



Extra bcma buses may be totally different models, see following dump:
boardtype=0x0646
pci/1/1/boardtype=0x0545
pci/2/1/boardtype=0x62b
We need to detect them properly to allow drivers apply some board
specific hacks.

[ralf@linux-mips.org: folded in Rafal's fix.]

Signed-off-by: default avatarRafał Miłecki <zajec5@gmail.com>
Cc: linux-mips@linux-mips.org
Cc: Hauke Mehrtens <hauke@hauke-m.de>
Patchwork: https://patchwork.linux-mips.org/patch/10028/
Patchwork: https://patchwork.linux-mips.org/patch/10048/


Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
parent 6e122ac0
Loading
Loading
Loading
Loading
+0 −3
Original line number Original line Diff line number Diff line
@@ -206,9 +206,6 @@ void __init bcm47xx_bus_setup(void)
		err = bcma_host_soc_init(&bcm47xx_bus.bcma);
		err = bcma_host_soc_init(&bcm47xx_bus.bcma);
		if (err)
		if (err)
			panic("Failed to initialize BCMA bus (err %d)", err);
			panic("Failed to initialize BCMA bus (err %d)", err);

		bcm47xx_fill_bcma_boardinfo(&bcm47xx_bus.bcma.bus.boardinfo,
					    NULL);
	}
	}
#endif
#endif


+22 −22
Original line number Original line Diff line number Diff line
@@ -640,19 +640,6 @@ void bcm47xx_fill_ssb_boardinfo(struct ssb_boardinfo *boardinfo,
}
}
#endif
#endif


#ifdef CONFIG_BCM47XX_BCMA
void bcm47xx_fill_bcma_boardinfo(struct bcma_boardinfo *boardinfo,
				 const char *prefix)
{
	nvram_read_u16(prefix, NULL, "boardvendor", &boardinfo->vendor, 0,
		       true);
	if (!boardinfo->vendor)
		boardinfo->vendor = SSB_BOARDVENDOR_BCM;

	nvram_read_u16(prefix, NULL, "boardtype", &boardinfo->type, 0, true);
}
#endif

#if defined(CONFIG_BCM47XX_SSB)
#if defined(CONFIG_BCM47XX_SSB)
static int bcm47xx_get_sprom_ssb(struct ssb_bus *bus, struct ssb_sprom *out)
static int bcm47xx_get_sprom_ssb(struct ssb_bus *bus, struct ssb_sprom *out)
{
{
@@ -707,33 +694,46 @@ static void bcm47xx_sprom_apply_prefix_alias(char *prefix, size_t prefix_size)


static int bcm47xx_get_sprom_bcma(struct bcma_bus *bus, struct ssb_sprom *out)
static int bcm47xx_get_sprom_bcma(struct bcma_bus *bus, struct ssb_sprom *out)
{
{
	char prefix[10];
	struct bcma_boardinfo *binfo = &bus->boardinfo;
	struct bcma_device *core;
	struct bcma_device *core;
	char buf[10];
	char *prefix;
	bool fallback = false;


	switch (bus->hosttype) {
	switch (bus->hosttype) {
	case BCMA_HOSTTYPE_PCI:
	case BCMA_HOSTTYPE_PCI:
		memset(out, 0, sizeof(struct ssb_sprom));
		memset(out, 0, sizeof(struct ssb_sprom));
		snprintf(prefix, sizeof(prefix), "pci/%u/%u/",
		snprintf(buf, sizeof(buf), "pci/%u/%u/",
			 bus->host_pci->bus->number + 1,
			 bus->host_pci->bus->number + 1,
			 PCI_SLOT(bus->host_pci->devfn));
			 PCI_SLOT(bus->host_pci->devfn));
		bcm47xx_sprom_apply_prefix_alias(prefix, sizeof(prefix));
		bcm47xx_sprom_apply_prefix_alias(buf, sizeof(buf));
		bcm47xx_fill_sprom(out, prefix, false);
		prefix = buf;
		return 0;
		break;
	case BCMA_HOSTTYPE_SOC:
	case BCMA_HOSTTYPE_SOC:
		memset(out, 0, sizeof(struct ssb_sprom));
		memset(out, 0, sizeof(struct ssb_sprom));
		core = bcma_find_core(bus, BCMA_CORE_80211);
		core = bcma_find_core(bus, BCMA_CORE_80211);
		if (core) {
		if (core) {
			snprintf(prefix, sizeof(prefix), "sb/%u/",
			snprintf(buf, sizeof(buf), "sb/%u/",
				 core->core_index);
				 core->core_index);
			bcm47xx_fill_sprom(out, prefix, true);
			prefix = buf;
			fallback = true;
		} else {
		} else {
			bcm47xx_fill_sprom(out, NULL, false);
			prefix = NULL;
		}
		}
		return 0;
		break;
	default:
	default:
		pr_warn("Unable to fill SPROM for given bustype.\n");
		pr_warn("Unable to fill SPROM for given bustype.\n");
		return -EINVAL;
		return -EINVAL;
	}
	}

	nvram_read_u16(prefix, NULL, "boardvendor", &binfo->vendor, 0, true);
	if (!binfo->vendor)
		binfo->vendor = SSB_BOARDVENDOR_BCM;
	nvram_read_u16(prefix, NULL, "boardtype", &binfo->type, 0, true);

	bcm47xx_fill_sprom(out, prefix, fallback);

	return 0;
}
}
#endif
#endif


+0 −4
Original line number Original line Diff line number Diff line
@@ -52,10 +52,6 @@ void bcm47xx_fill_sprom(struct ssb_sprom *sprom, const char *prefix,
void bcm47xx_fill_ssb_boardinfo(struct ssb_boardinfo *boardinfo,
void bcm47xx_fill_ssb_boardinfo(struct ssb_boardinfo *boardinfo,
				const char *prefix);
				const char *prefix);
#endif
#endif
#ifdef CONFIG_BCM47XX_BCMA
void bcm47xx_fill_bcma_boardinfo(struct bcma_boardinfo *boardinfo,
				 const char *prefix);
#endif


void bcm47xx_set_system_type(u16 chip_id);
void bcm47xx_set_system_type(u16 chip_id);