mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	ssb: pick SoC invariants code from MIPS BCM47xx arch
There is code in ssb fetching "invariants" that is basically a set of board specific data. Every host requires its own implementation of reading function. In ssb we have support for PCI, PCMCIA & SDIO. For some (historical?) reason code reading "invariants" for SoC was placed in arch code and provided by a callback. This is not needed nowadays, so lets move that into ssb. This way we keep all "invariants" functions in a single module making code cleaner. Signed-off-by: Rafał Miłecki <zajec5@gmail.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
This commit is contained in:
		
							parent
							
								
									d0ca990067
								
							
						
					
					
						commit
						541c9a84cd
					
				
					 6 changed files with 47 additions and 49 deletions
				
			
		| 
						 | 
				
			
			@ -101,50 +101,13 @@ static void bcm47xx_machine_halt(void)
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
#ifdef CONFIG_BCM47XX_SSB
 | 
			
		||||
static int bcm47xx_get_invariants(struct ssb_bus *bus,
 | 
			
		||||
				  struct ssb_init_invariants *iv)
 | 
			
		||||
{
 | 
			
		||||
	char buf[20];
 | 
			
		||||
	int len, err;
 | 
			
		||||
 | 
			
		||||
	/* Fill boardinfo structure */
 | 
			
		||||
	memset(&iv->boardinfo, 0 , sizeof(struct ssb_boardinfo));
 | 
			
		||||
 | 
			
		||||
	len = bcm47xx_nvram_getenv("boardvendor", buf, sizeof(buf));
 | 
			
		||||
	if (len > 0) {
 | 
			
		||||
		err = kstrtou16(strim(buf), 0, &iv->boardinfo.vendor);
 | 
			
		||||
		if (err)
 | 
			
		||||
			pr_warn("Couldn't parse nvram board vendor entry with value \"%s\"\n",
 | 
			
		||||
				buf);
 | 
			
		||||
	}
 | 
			
		||||
	if (!iv->boardinfo.vendor)
 | 
			
		||||
		iv->boardinfo.vendor = SSB_BOARDVENDOR_BCM;
 | 
			
		||||
 | 
			
		||||
	len = bcm47xx_nvram_getenv("boardtype", buf, sizeof(buf));
 | 
			
		||||
	if (len > 0) {
 | 
			
		||||
		err = kstrtou16(strim(buf), 0, &iv->boardinfo.type);
 | 
			
		||||
		if (err)
 | 
			
		||||
			pr_warn("Couldn't parse nvram board type entry with value \"%s\"\n",
 | 
			
		||||
				buf);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	memset(&iv->sprom, 0, sizeof(struct ssb_sprom));
 | 
			
		||||
	bcm47xx_fill_sprom(&iv->sprom, NULL, false);
 | 
			
		||||
 | 
			
		||||
	if (bcm47xx_nvram_getenv("cardbus", buf, sizeof(buf)) >= 0)
 | 
			
		||||
		iv->has_cardbus_slot = !!simple_strtoul(buf, NULL, 10);
 | 
			
		||||
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void __init bcm47xx_register_ssb(void)
 | 
			
		||||
{
 | 
			
		||||
	int err;
 | 
			
		||||
	char buf[100];
 | 
			
		||||
	struct ssb_mipscore *mcore;
 | 
			
		||||
 | 
			
		||||
	err = ssb_bus_ssbbus_register(&bcm47xx_bus.ssb, SSB_ENUM_BASE,
 | 
			
		||||
				      bcm47xx_get_invariants);
 | 
			
		||||
	err = ssb_bus_host_soc_register(&bcm47xx_bus.ssb, SSB_ENUM_BASE);
 | 
			
		||||
	if (err)
 | 
			
		||||
		panic("Failed to initialize SSB bus (err %d)", err);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -82,7 +82,7 @@ config SSB_SDIOHOST
 | 
			
		|||
 | 
			
		||||
config SSB_HOST_SOC
 | 
			
		||||
	bool "Support for SSB bus on SoC"
 | 
			
		||||
	depends on SSB
 | 
			
		||||
	depends on SSB && BCM47XX_NVRAM
 | 
			
		||||
	help
 | 
			
		||||
	  Host interface for a SSB directly mapped into memory. This is
 | 
			
		||||
	  for some Broadcom SoCs from the BCM47xx and BCM53xx lines.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -8,6 +8,7 @@
 | 
			
		|||
 * Licensed under the GNU/GPL. See COPYING for details.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include <linux/bcm47xx_nvram.h>
 | 
			
		||||
#include <linux/ssb/ssb.h>
 | 
			
		||||
 | 
			
		||||
#include "ssb_private.h"
 | 
			
		||||
| 
						 | 
				
			
			@ -171,3 +172,39 @@ const struct ssb_bus_ops ssb_host_soc_ops = {
 | 
			
		|||
	.block_write	= ssb_host_soc_block_write,
 | 
			
		||||
#endif
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
int ssb_host_soc_get_invariants(struct ssb_bus *bus,
 | 
			
		||||
				struct ssb_init_invariants *iv)
 | 
			
		||||
{
 | 
			
		||||
	char buf[20];
 | 
			
		||||
	int len, err;
 | 
			
		||||
 | 
			
		||||
	/* Fill boardinfo structure */
 | 
			
		||||
	memset(&iv->boardinfo, 0, sizeof(struct ssb_boardinfo));
 | 
			
		||||
 | 
			
		||||
	len = bcm47xx_nvram_getenv("boardvendor", buf, sizeof(buf));
 | 
			
		||||
	if (len > 0) {
 | 
			
		||||
		err = kstrtou16(strim(buf), 0, &iv->boardinfo.vendor);
 | 
			
		||||
		if (err)
 | 
			
		||||
			pr_warn("Couldn't parse nvram board vendor entry with value \"%s\"\n",
 | 
			
		||||
				buf);
 | 
			
		||||
	}
 | 
			
		||||
	if (!iv->boardinfo.vendor)
 | 
			
		||||
		iv->boardinfo.vendor = SSB_BOARDVENDOR_BCM;
 | 
			
		||||
 | 
			
		||||
	len = bcm47xx_nvram_getenv("boardtype", buf, sizeof(buf));
 | 
			
		||||
	if (len > 0) {
 | 
			
		||||
		err = kstrtou16(strim(buf), 0, &iv->boardinfo.type);
 | 
			
		||||
		if (err)
 | 
			
		||||
			pr_warn("Couldn't parse nvram board type entry with value \"%s\"\n",
 | 
			
		||||
				buf);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	memset(&iv->sprom, 0, sizeof(struct ssb_sprom));
 | 
			
		||||
	ssb_fill_sprom_with_fallback(bus, &iv->sprom);
 | 
			
		||||
 | 
			
		||||
	if (bcm47xx_nvram_getenv("cardbus", buf, sizeof(buf)) >= 0)
 | 
			
		||||
		iv->has_cardbus_slot = !!simple_strtoul(buf, NULL, 10);
 | 
			
		||||
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -762,15 +762,14 @@ EXPORT_SYMBOL(ssb_bus_sdiobus_register);
 | 
			
		|||
#endif /* CONFIG_SSB_PCMCIAHOST */
 | 
			
		||||
 | 
			
		||||
#ifdef CONFIG_SSB_HOST_SOC
 | 
			
		||||
int ssb_bus_ssbbus_register(struct ssb_bus *bus, unsigned long baseaddr,
 | 
			
		||||
			    ssb_invariants_func_t get_invariants)
 | 
			
		||||
int ssb_bus_host_soc_register(struct ssb_bus *bus, unsigned long baseaddr)
 | 
			
		||||
{
 | 
			
		||||
	int err;
 | 
			
		||||
 | 
			
		||||
	bus->bustype = SSB_BUSTYPE_SSB;
 | 
			
		||||
	bus->ops = &ssb_host_soc_ops;
 | 
			
		||||
 | 
			
		||||
	err = ssb_bus_register(bus, get_invariants, baseaddr);
 | 
			
		||||
	err = ssb_bus_register(bus, ssb_host_soc_get_invariants, baseaddr);
 | 
			
		||||
	if (!err) {
 | 
			
		||||
		ssb_info("Sonics Silicon Backplane found at address 0x%08lX\n",
 | 
			
		||||
			 baseaddr);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -163,6 +163,9 @@ static inline int ssb_sdio_init(struct ssb_bus *bus)
 | 
			
		|||
 | 
			
		||||
#ifdef CONFIG_SSB_HOST_SOC
 | 
			
		||||
extern const struct ssb_bus_ops ssb_host_soc_ops;
 | 
			
		||||
 | 
			
		||||
extern int ssb_host_soc_get_invariants(struct ssb_bus *bus,
 | 
			
		||||
				       struct ssb_init_invariants *iv);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/* scan.c */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -524,13 +524,9 @@ struct ssb_init_invariants {
 | 
			
		|||
typedef int (*ssb_invariants_func_t)(struct ssb_bus *bus,
 | 
			
		||||
				     struct ssb_init_invariants *iv);
 | 
			
		||||
 | 
			
		||||
/* Register a SSB system bus. get_invariants() is called after the
 | 
			
		||||
 * basic system devices are initialized.
 | 
			
		||||
 * The invariants are usually fetched from some NVRAM.
 | 
			
		||||
 * Put the invariants into the struct pointed to by iv. */
 | 
			
		||||
extern int ssb_bus_ssbbus_register(struct ssb_bus *bus,
 | 
			
		||||
				   unsigned long baseaddr,
 | 
			
		||||
				   ssb_invariants_func_t get_invariants);
 | 
			
		||||
/* Register SoC bus. */
 | 
			
		||||
extern int ssb_bus_host_soc_register(struct ssb_bus *bus,
 | 
			
		||||
				     unsigned long baseaddr);
 | 
			
		||||
#ifdef CONFIG_SSB_PCIHOST
 | 
			
		||||
extern int ssb_bus_pcibus_register(struct ssb_bus *bus,
 | 
			
		||||
				   struct pci_dev *host_pci);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue