brcm63xx: rename target to bcm63xx
[openwrt/openwrt.git] / target / linux / bcm63xx / patches-4.14 / 362-MIPS-BCM63XX-also-register-a-fallback-sprom-for-bcma.patch
1 From 03feb9db77fba3eef3d83e17a87a56979659b248 Mon Sep 17 00:00:00 2001
2 From: Jonas Gorski <jogo@openwrt.org>
3 Date: Tue, 29 Jul 2014 22:48:26 +0200
4 Subject: [PATCH 07/10] MIPS: BCM63XX: also register a fallback sprom for bcma
5
6 Similar to SSB, register a fallback sprom handler for BCMA.
7
8 Signed-off-by: Jonas Gorski <jogo@openwrt.org>
9 ---
10 arch/mips/bcm63xx/boards/Kconfig | 1 +
11 arch/mips/bcm63xx/sprom.c | 40 +++++++++++++++++++++++++++++++++++-----
12 2 files changed, 36 insertions(+), 5 deletions(-)
13
14 --- a/arch/mips/bcm63xx/boards/Kconfig
15 +++ b/arch/mips/bcm63xx/boards/Kconfig
16 @@ -5,6 +5,7 @@ menu "Board support"
17 config BOARD_BCM963XX
18 bool "Generic Broadcom 963xx boards"
19 select SSB
20 + select BCMA
21 default y
22 help
23
24 --- a/arch/mips/bcm63xx/sprom.c
25 +++ b/arch/mips/bcm63xx/sprom.c
26 @@ -12,6 +12,7 @@
27 #include <linux/string.h>
28 #include <linux/platform_device.h>
29 #include <linux/ssb/ssb.h>
30 +#include <linux/bcma/bcma.h>
31 #include <bcm63xx_fallback_sprom.h>
32 #include <board_bcm963xx.h>
33
34 @@ -21,7 +22,7 @@
35 * Register a sane SPROMv2 to make the on-board
36 * bcm4318 WLAN work
37 */
38 -#ifdef CONFIG_SSB_PCIHOST
39 +#if defined(CONFIG_SSB_PCIHOST) || defined(CONFIG_BCMA_HOST_PCI)
40 static __initconst struct ssb_sprom bcm63xx_default_sprom = {
41 .revision = 0x02,
42 .board_rev = 0x17,
43 @@ -43,7 +44,7 @@ static __initconst struct ssb_sprom bcm6
44 .boardflags_hi = 0x0000,
45 };
46
47 -
48 +#if defined (CONFIG_SSB_PCIHOST)
49 static __initconst u16 bcm4306_sprom[] = {
50 0x4001, 0x0000, 0x0453, 0x14e4, 0x4320, 0x8000, 0x0002, 0x0002,
51 0x1000, 0x1800, 0x0000, 0x0000, 0xffff, 0xffff, 0xffff, 0xffff,
52 @@ -158,10 +159,12 @@ static __initconst u16 bcm43222_sprom[]
53 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
54 0xffff, 0xffff, 0xffff, 0x0008,
55 };
56 +#endif /* CONFIG_SSB_PCIHOST */
57
58 static struct ssb_sprom bcm63xx_sprom;
59
60 -int bcm63xx_get_fallback_sprom(struct ssb_bus *bus, struct ssb_sprom *out)
61 +#if defined(CONFIG_SSB_PCIHOST)
62 +int bcm63xx_get_fallback_ssb_sprom(struct ssb_bus *bus, struct ssb_sprom *out)
63 {
64 if (bus->bustype == SSB_BUSTYPE_PCI) {
65 memcpy(out, &bcm63xx_sprom, sizeof(struct ssb_sprom));
66 @@ -171,6 +174,20 @@ int bcm63xx_get_fallback_sprom(struct ss
67 return -EINVAL;
68 }
69 }
70 +#endif
71 +
72 +#if defined(CONFIG_BCMA_HOST_PCI)
73 +int bcm63xx_get_fallback_bcma_sprom(struct bcma_bus *bus, struct ssb_sprom *out)
74 +{
75 + if (bus->hosttype == BCMA_HOSTTYPE_PCI) {
76 + memcpy(out, &bcm63xx_sprom, sizeof(struct ssb_sprom));
77 + return 0;
78 + } else {
79 + printk(KERN_ERR PFX "unable to fill SPROM for given bustype.\n");
80 + return -EINVAL;
81 + }
82 +}
83 +#endif
84
85 /* FIXME: use lib_sprom after submission upstream */
86
87 @@ -654,10 +671,11 @@ int __init bcm63xx_register_fallback_spr
88 {
89 int ret = 0;
90
91 -#ifdef CONFIG_SSB_PCIHOST
92 +#if defined(CONFIG_SSB_PCIHOST) || defined(CONFIG_BCMA_HOST_PCI)
93 u16 size = 0;
94
95 switch (data->type) {
96 +#if defined(CONFIG_SSB_PCIHOST)
97 case SPROM_BCM4306:
98 memcpy(&template_sprom, &bcm4306_sprom, sizeof(bcm4306_sprom));
99 size = ARRAY_SIZE(bcm4306_sprom);
100 @@ -678,6 +696,7 @@ int __init bcm63xx_register_fallback_spr
101 memcpy(&template_sprom, &bcm43222_sprom, sizeof(bcm43222_sprom));
102 size = ARRAY_SIZE(bcm43222_sprom);
103 break;
104 +#endif
105 case SPROM_DEFAULT:
106 memcpy(&bcm63xx_sprom, &bcm63xx_default_sprom,
107 sizeof(bcm63xx_sprom));
108 @@ -692,8 +711,19 @@ int __init bcm63xx_register_fallback_spr
109 memcpy(bcm63xx_sprom.il0mac, data->mac_addr, ETH_ALEN);
110 memcpy(bcm63xx_sprom.et0mac, data->mac_addr, ETH_ALEN);
111 memcpy(bcm63xx_sprom.et1mac, data->mac_addr, ETH_ALEN);
112 +#endif /* defined(CONFIG_SSB_PCIHOST) || defined(CONFIG_BCMA_HOST_PCI) */
113 +
114 +#if defined(CONFIG_SSB_PCIHOST)
115 + ret = ssb_arch_register_fallback_sprom(&bcm63xx_get_fallback_ssb_sprom);
116 + if (ret)
117 + return ret;
118 +
119 +#endif
120
121 - ret = ssb_arch_register_fallback_sprom(&bcm63xx_get_fallback_sprom);
122 +#if defined(CONFIG_BCMA_HOST_PCI)
123 + ret = bcma_arch_register_fallback_sprom(bcm63xx_get_fallback_bcma_sprom);
124 + if (ret)
125 + return ret;
126 #endif
127 return ret;
128 }