aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/brcm63xx/patches-3.18/362-MIPS-BCM63XX-also-register-a-fallback-sprom-for-bcma.patch
blob: 6475f9fa242ecbdce9bf8704c98f6aec760e85d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
From 03feb9db77fba3eef3d83e17a87a56979659b248 Mon Sep 17 00:00:00 2001
From: Jonas Gorski <jogo@openwrt.org>
Date: Tue, 29 Jul 2014 22:48:26 +0200
Subject: [PATCH 07/10] MIPS: BCM63XX: also register a fallback sprom for bcma

Similar to SSB, register a fallback sprom handler for BCMA.

Signed-off-by: Jonas Gorski <jogo@openwrt.org>
---
 arch/mips/bcm63xx/boards/Kconfig |  1 +
 arch/mips/bcm63xx/sprom.c        | 40 +++++++++++++++++++++++++++++++++++-----
 2 files changed, 36 insertions(+), 5 deletions(-)

--- a/arch/mips/bcm63xx/boards/Kconfig
+++ b/arch/mips/bcm63xx/boards/Kconfig
@@ -4,6 +4,7 @@ menu "Board support"
 config BOARD_BCM963XX
        bool "Generic Broadcom 963xx boards"
 	select SSB
+	select BCMA
 	default y
        help
 
--- a/arch/mips/bcm63xx/sprom.c
+++ b/arch/mips/bcm63xx/sprom.c
@@ -12,6 +12,7 @@
 #include <linux/string.h>
 #include <linux/platform_device.h>
 #include <linux/ssb/ssb.h>
+#include <linux/bcma/bcma.h>
 #include <bcm63xx_fallback_sprom.h>
 #include <board_bcm963xx.h>
 
@@ -21,7 +22,7 @@
  * Register a sane SPROMv2 to make the on-board
  * bcm4318 WLAN work
  */
-#ifdef CONFIG_SSB_PCIHOST
+#if defined(CONFIG_SSB_PCIHOST) || defined(CONFIG_BCMA_HOST_PCI)
 static __initconst struct ssb_sprom bcm63xx_default_sprom = {
 	.revision		= 0x02,
 	.board_rev		= 0x17,
@@ -43,7 +44,7 @@ static __initconst struct ssb_sprom bcm6
 	.boardflags_hi		= 0x0000,
 };
 
-
+#if defined (CONFIG_SSB_PCIHOST)
 static __initconst u16 bcm4306_sprom[] = {
 	0x4001, 0x0000, 0x0453, 0x14e4, 0x4320, 0x8000, 0x0002, 0x0002,
 	0x1000, 0x1800, 0x0000, 0x0000, 0xffff, 0xffff, 0xffff, 0xffff,
@@ -158,10 +159,12 @@ static __initconst u16 bcm43222_sprom[]
 	0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
 	0xffff, 0xffff, 0xffff, 0x0008,
 };
+#endif /* CONFIG_SSB_PCIHOST */
 
 static struct ssb_sprom bcm63xx_sprom;
 
-int bcm63xx_get_fallback_sprom(struct ssb_bus *bus, struct ssb_sprom *out)
+#if defined(CONFIG_SSB_PCIHOST)
+int bcm63xx_get_fallback_ssb_sprom(struct ssb_bus *bus, struct ssb_sprom *out)
 {
 	if (bus->bustype == SSB_BUSTYPE_PCI) {
 		memcpy(out, &bcm63xx_sprom, sizeof(struct ssb_sprom));
@@ -171,6 +174,20 @@ int bcm63xx_get_fallback_sprom(struct ss
 		return -EINVAL;
 	}
 }
+#endif
+
+#if defined(CONFIG_BCMA_HOST_PCI)
+int bcm63xx_get_fallback_bcma_sprom(struct bcma_bus *bus, struct ssb_sprom *out)
+{
+	if (bus->hosttype == BCMA_HOSTTYPE_PCI) {
+		memcpy(out, &bcm63xx_sprom, sizeof(struct ssb_sprom));
+		return 0;
+	} else {
+		printk(KERN_ERR PFX "unable to fill SPROM for given bustype.\n");
+		return -EINVAL;
+	}
+}
+#endif
 
 /* FIXME: use lib_sprom after submission upstream */
 
@@ -654,10 +671,11 @@ int __init bcm63xx_register_fallback_spr
 {
 	int ret = 0;
 
-#ifdef CONFIG_SSB_PCIHOST
+#if defined(CONFIG_SSB_PCIHOST) || defined(CONFIG_BCMA_HOST_PCI)
 	u16 size = 0;
 
 	switch (data->type) {
+#if defined(CONFIG_SSB_PCIHOST)
 	case SPROM_BCM4306:
 		memcpy(&template_sprom, &bcm4306_sprom, sizeof(bcm4306_sprom));
 		size = ARRAY_SIZE(bcm4306_sprom);
@@ -678,6 +696,7 @@ int __init bcm63xx_register_fallback_spr
 		memcpy(&template_sprom, &bcm43222_sprom, sizeof(bcm43222_sprom));
 		size = ARRAY_SIZE(bcm43222_sprom);
 		break;
+#endif
 	case SPROM_DEFAULT:
 		memcpy(&bcm63xx_sprom, &bcm63xx_default_sprom,
 		       sizeof(bcm63xx_sprom));
@@ -692,8 +711,19 @@ int __init bcm63xx_register_fallback_spr
 	memcpy(bcm63xx_sprom.il0mac, data->mac_addr, ETH_ALEN);
 	memcpy(bcm63xx_sprom.et0mac, data->mac_addr, ETH_ALEN);
 	memcpy(bcm63xx_sprom.et1mac, data->mac_addr, ETH_ALEN);
+#endif /* defined(CONFIG_SSB_PCIHOST) || defined(CONFIG_BCMA_HOST_PCI) */
+
+#if defined(CONFIG_SSB_PCIHOST)
+	ret = ssb_arch_register_fallback_sprom(&bcm63xx_get_fallback_ssb_sprom);
+	if (ret)
+		return ret;
+
+#endif
 
-	ret = ssb_arch_register_fallback_sprom(&bcm63xx_get_fallback_sprom);
+#if defined(CONFIG_BCMA_HOST_PCI)
+	ret = bcma_arch_register_fallback_sprom(bcm63xx_get_fallback_bcma_sprom);
+	if (ret)
+		return ret;
 #endif
 	return ret;
 }