diff options
Diffstat (limited to 'arch/mips/bcm47xx/sprom.c')
-rw-r--r-- | arch/mips/bcm47xx/sprom.c | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/arch/mips/bcm47xx/sprom.c b/arch/mips/bcm47xx/sprom.c index 41226b68de3d..2eff7fe99c6b 100644 --- a/arch/mips/bcm47xx/sprom.c +++ b/arch/mips/bcm47xx/sprom.c | |||
@@ -136,6 +136,20 @@ static void nvram_read_leddc(const char *prefix, const char *name, | |||
136 | *leddc_off_time = (val >> 16) & 0xff; | 136 | *leddc_off_time = (val >> 16) & 0xff; |
137 | } | 137 | } |
138 | 138 | ||
139 | static void bcm47xx_nvram_parse_macaddr(char *buf, u8 macaddr[6]) | ||
140 | { | ||
141 | if (strchr(buf, ':')) | ||
142 | sscanf(buf, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &macaddr[0], | ||
143 | &macaddr[1], &macaddr[2], &macaddr[3], &macaddr[4], | ||
144 | &macaddr[5]); | ||
145 | else if (strchr(buf, '-')) | ||
146 | sscanf(buf, "%hhx-%hhx-%hhx-%hhx-%hhx-%hhx", &macaddr[0], | ||
147 | &macaddr[1], &macaddr[2], &macaddr[3], &macaddr[4], | ||
148 | &macaddr[5]); | ||
149 | else | ||
150 | pr_warn("Can not parse mac address: %s\n", buf); | ||
151 | } | ||
152 | |||
139 | static void nvram_read_macaddr(const char *prefix, const char *name, | 153 | static void nvram_read_macaddr(const char *prefix, const char *name, |
140 | u8 val[6], bool fallback) | 154 | u8 val[6], bool fallback) |
141 | { | 155 | { |
@@ -801,3 +815,71 @@ void bcm47xx_fill_bcma_boardinfo(struct bcma_boardinfo *boardinfo, | |||
801 | nvram_read_u16(prefix, NULL, "boardtype", &boardinfo->type, 0, true); | 815 | nvram_read_u16(prefix, NULL, "boardtype", &boardinfo->type, 0, true); |
802 | } | 816 | } |
803 | #endif | 817 | #endif |
818 | |||
819 | #if defined(CONFIG_BCM47XX_SSB) | ||
820 | static int bcm47xx_get_sprom_ssb(struct ssb_bus *bus, struct ssb_sprom *out) | ||
821 | { | ||
822 | char prefix[10]; | ||
823 | |||
824 | if (bus->bustype == SSB_BUSTYPE_PCI) { | ||
825 | memset(out, 0, sizeof(struct ssb_sprom)); | ||
826 | snprintf(prefix, sizeof(prefix), "pci/%u/%u/", | ||
827 | bus->host_pci->bus->number + 1, | ||
828 | PCI_SLOT(bus->host_pci->devfn)); | ||
829 | bcm47xx_fill_sprom(out, prefix, false); | ||
830 | return 0; | ||
831 | } else { | ||
832 | pr_warn("bcm47xx: unable to fill SPROM for given bustype.\n"); | ||
833 | return -EINVAL; | ||
834 | } | ||
835 | } | ||
836 | #endif | ||
837 | |||
838 | #if defined(CONFIG_BCM47XX_BCMA) | ||
839 | static int bcm47xx_get_sprom_bcma(struct bcma_bus *bus, struct ssb_sprom *out) | ||
840 | { | ||
841 | char prefix[10]; | ||
842 | struct bcma_device *core; | ||
843 | |||
844 | switch (bus->hosttype) { | ||
845 | case BCMA_HOSTTYPE_PCI: | ||
846 | memset(out, 0, sizeof(struct ssb_sprom)); | ||
847 | snprintf(prefix, sizeof(prefix), "pci/%u/%u/", | ||
848 | bus->host_pci->bus->number + 1, | ||
849 | PCI_SLOT(bus->host_pci->devfn)); | ||
850 | bcm47xx_fill_sprom(out, prefix, false); | ||
851 | return 0; | ||
852 | case BCMA_HOSTTYPE_SOC: | ||
853 | memset(out, 0, sizeof(struct ssb_sprom)); | ||
854 | core = bcma_find_core(bus, BCMA_CORE_80211); | ||
855 | if (core) { | ||
856 | snprintf(prefix, sizeof(prefix), "sb/%u/", | ||
857 | core->core_index); | ||
858 | bcm47xx_fill_sprom(out, prefix, true); | ||
859 | } else { | ||
860 | bcm47xx_fill_sprom(out, NULL, false); | ||
861 | } | ||
862 | return 0; | ||
863 | default: | ||
864 | pr_warn("bcm47xx: unable to fill SPROM for given bustype.\n"); | ||
865 | return -EINVAL; | ||
866 | } | ||
867 | } | ||
868 | #endif | ||
869 | |||
870 | /* | ||
871 | * On bcm47xx we need to register SPROM fallback handler very early, so we can't | ||
872 | * use anything like platform device / driver for this. | ||
873 | */ | ||
874 | void bcm47xx_sprom_register_fallbacks(void) | ||
875 | { | ||
876 | #if defined(CONFIG_BCM47XX_SSB) | ||
877 | if (ssb_arch_register_fallback_sprom(&bcm47xx_get_sprom_ssb)) | ||
878 | pr_warn("Failed to registered ssb SPROM handler\n"); | ||
879 | #endif | ||
880 | |||
881 | #if defined(CONFIG_BCM47XX_BCMA) | ||
882 | if (bcma_arch_register_fallback_sprom(&bcm47xx_get_sprom_bcma)) | ||
883 | pr_warn("Failed to registered bcma SPROM handler\n"); | ||
884 | #endif | ||
885 | } | ||