adm8668: drop 3.14
[openwrt/svn-archive/archive.git] / target / linux / brcm47xx / patches-3.14 / 157-MIPS-BCM47XX-Move-SPROM-fallback-code-into-sprom.c.patch
1 From a59da8fb3b2a1f2df5f871464e43cd5b6ca6ceb1 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
3 Date: Tue, 28 Oct 2014 12:52:02 +0100
4 Subject: [PATCH 157/158] MIPS: BCM47XX: Move SPROM fallback code into sprom.c
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 This is some general cleanup as well as preparing sprom.c to become a
10 standalone driver. We will need this for bcm53xx ARM arch support.
11
12 Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
13 Acked-by: Hauke Mehrtens <hauke@hauke-m.de>
14 Cc: linux-mips@linux-mips.org
15 Patchwork: https://patchwork.linux-mips.org/patch/8232/
16 Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
17 ---
18 arch/mips/bcm47xx/bcm47xx_private.h | 3 ++
19 arch/mips/bcm47xx/setup.c | 58 ++-----------------------------
20 arch/mips/bcm47xx/sprom.c | 68 +++++++++++++++++++++++++++++++++++++
21 3 files changed, 73 insertions(+), 56 deletions(-)
22
23 diff --git a/arch/mips/bcm47xx/bcm47xx_private.h b/arch/mips/bcm47xx/bcm47xx_private.h
24 index f1cc9d0..12a112d 100644
25 --- a/arch/mips/bcm47xx/bcm47xx_private.h
26 +++ b/arch/mips/bcm47xx/bcm47xx_private.h
27 @@ -6,6 +6,9 @@
28 /* prom.c */
29 void __init bcm47xx_prom_highmem_init(void);
30
31 +/* sprom.c */
32 +void bcm47xx_sprom_register_fallbacks(void);
33 +
34 /* buttons.c */
35 int __init bcm47xx_buttons_register(void);
36
37 diff --git a/arch/mips/bcm47xx/setup.c b/arch/mips/bcm47xx/setup.c
38 index c00585d..444c65a 100644
39 --- a/arch/mips/bcm47xx/setup.c
40 +++ b/arch/mips/bcm47xx/setup.c
41 @@ -102,23 +102,6 @@ static void bcm47xx_machine_halt(void)
42 }
43
44 #ifdef CONFIG_BCM47XX_SSB
45 -static int bcm47xx_get_sprom_ssb(struct ssb_bus *bus, struct ssb_sprom *out)
46 -{
47 - char prefix[10];
48 -
49 - if (bus->bustype == SSB_BUSTYPE_PCI) {
50 - memset(out, 0, sizeof(struct ssb_sprom));
51 - snprintf(prefix, sizeof(prefix), "pci/%u/%u/",
52 - bus->host_pci->bus->number + 1,
53 - PCI_SLOT(bus->host_pci->devfn));
54 - bcm47xx_fill_sprom(out, prefix, false);
55 - return 0;
56 - } else {
57 - printk(KERN_WARNING "bcm47xx: unable to fill SPROM for given bustype.\n");
58 - return -EINVAL;
59 - }
60 -}
61 -
62 static int bcm47xx_get_invariants(struct ssb_bus *bus,
63 struct ssb_init_invariants *iv)
64 {
65 @@ -144,11 +127,6 @@ static void __init bcm47xx_register_ssb(void)
66 char buf[100];
67 struct ssb_mipscore *mcore;
68
69 - err = ssb_arch_register_fallback_sprom(&bcm47xx_get_sprom_ssb);
70 - if (err)
71 - printk(KERN_WARNING "bcm47xx: someone else already registered"
72 - " a ssb SPROM callback handler (err %d)\n", err);
73 -
74 err = ssb_bus_ssbbus_register(&(bcm47xx_bus.ssb), SSB_ENUM_BASE,
75 bcm47xx_get_invariants);
76 if (err)
77 @@ -171,44 +149,10 @@ static void __init bcm47xx_register_ssb(void)
78 #endif
79
80 #ifdef CONFIG_BCM47XX_BCMA
81 -static int bcm47xx_get_sprom_bcma(struct bcma_bus *bus, struct ssb_sprom *out)
82 -{
83 - char prefix[10];
84 - struct bcma_device *core;
85 -
86 - switch (bus->hosttype) {
87 - case BCMA_HOSTTYPE_PCI:
88 - memset(out, 0, sizeof(struct ssb_sprom));
89 - snprintf(prefix, sizeof(prefix), "pci/%u/%u/",
90 - bus->host_pci->bus->number + 1,
91 - PCI_SLOT(bus->host_pci->devfn));
92 - bcm47xx_fill_sprom(out, prefix, false);
93 - return 0;
94 - case BCMA_HOSTTYPE_SOC:
95 - memset(out, 0, sizeof(struct ssb_sprom));
96 - core = bcma_find_core(bus, BCMA_CORE_80211);
97 - if (core) {
98 - snprintf(prefix, sizeof(prefix), "sb/%u/",
99 - core->core_index);
100 - bcm47xx_fill_sprom(out, prefix, true);
101 - } else {
102 - bcm47xx_fill_sprom(out, NULL, false);
103 - }
104 - return 0;
105 - default:
106 - pr_warn("bcm47xx: unable to fill SPROM for given bustype.\n");
107 - return -EINVAL;
108 - }
109 -}
110 -
111 static void __init bcm47xx_register_bcma(void)
112 {
113 int err;
114
115 - err = bcma_arch_register_fallback_sprom(&bcm47xx_get_sprom_bcma);
116 - if (err)
117 - pr_warn("bcm47xx: someone else already registered a bcma SPROM callback handler (err %d)\n", err);
118 -
119 err = bcma_host_soc_register(&bcm47xx_bus.bcma);
120 if (err)
121 panic("Failed to register BCMA bus (err %d)", err);
122 @@ -229,6 +173,7 @@ void __init plat_mem_setup(void)
123 printk(KERN_INFO "bcm47xx: using bcma bus\n");
124 #ifdef CONFIG_BCM47XX_BCMA
125 bcm47xx_bus_type = BCM47XX_BUS_TYPE_BCMA;
126 + bcm47xx_sprom_register_fallbacks();
127 bcm47xx_register_bcma();
128 bcm47xx_set_system_type(bcm47xx_bus.bcma.bus.chipinfo.id);
129 #ifdef CONFIG_HIGHMEM
130 @@ -239,6 +184,7 @@ void __init plat_mem_setup(void)
131 printk(KERN_INFO "bcm47xx: using ssb bus\n");
132 #ifdef CONFIG_BCM47XX_SSB
133 bcm47xx_bus_type = BCM47XX_BUS_TYPE_SSB;
134 + bcm47xx_sprom_register_fallbacks();
135 bcm47xx_register_ssb();
136 bcm47xx_set_system_type(bcm47xx_bus.ssb.chip_id);
137 #endif
138 diff --git a/arch/mips/bcm47xx/sprom.c b/arch/mips/bcm47xx/sprom.c
139 index 41226b6..e772e77 100644
140 --- a/arch/mips/bcm47xx/sprom.c
141 +++ b/arch/mips/bcm47xx/sprom.c
142 @@ -801,3 +801,71 @@ void bcm47xx_fill_bcma_boardinfo(struct bcma_boardinfo *boardinfo,
143 nvram_read_u16(prefix, NULL, "boardtype", &boardinfo->type, 0, true);
144 }
145 #endif
146 +
147 +#if defined(CONFIG_BCM47XX_SSB)
148 +static int bcm47xx_get_sprom_ssb(struct ssb_bus *bus, struct ssb_sprom *out)
149 +{
150 + char prefix[10];
151 +
152 + if (bus->bustype == SSB_BUSTYPE_PCI) {
153 + memset(out, 0, sizeof(struct ssb_sprom));
154 + snprintf(prefix, sizeof(prefix), "pci/%u/%u/",
155 + bus->host_pci->bus->number + 1,
156 + PCI_SLOT(bus->host_pci->devfn));
157 + bcm47xx_fill_sprom(out, prefix, false);
158 + return 0;
159 + } else {
160 + pr_warn("bcm47xx: unable to fill SPROM for given bustype.\n");
161 + return -EINVAL;
162 + }
163 +}
164 +#endif
165 +
166 +#if defined(CONFIG_BCM47XX_BCMA)
167 +static int bcm47xx_get_sprom_bcma(struct bcma_bus *bus, struct ssb_sprom *out)
168 +{
169 + char prefix[10];
170 + struct bcma_device *core;
171 +
172 + switch (bus->hosttype) {
173 + case BCMA_HOSTTYPE_PCI:
174 + memset(out, 0, sizeof(struct ssb_sprom));
175 + snprintf(prefix, sizeof(prefix), "pci/%u/%u/",
176 + bus->host_pci->bus->number + 1,
177 + PCI_SLOT(bus->host_pci->devfn));
178 + bcm47xx_fill_sprom(out, prefix, false);
179 + return 0;
180 + case BCMA_HOSTTYPE_SOC:
181 + memset(out, 0, sizeof(struct ssb_sprom));
182 + core = bcma_find_core(bus, BCMA_CORE_80211);
183 + if (core) {
184 + snprintf(prefix, sizeof(prefix), "sb/%u/",
185 + core->core_index);
186 + bcm47xx_fill_sprom(out, prefix, true);
187 + } else {
188 + bcm47xx_fill_sprom(out, NULL, false);
189 + }
190 + return 0;
191 + default:
192 + pr_warn("bcm47xx: unable to fill SPROM for given bustype.\n");
193 + return -EINVAL;
194 + }
195 +}
196 +#endif
197 +
198 +/*
199 + * On bcm47xx we need to register SPROM fallback handler very early, so we can't
200 + * use anything like platform device / driver for this.
201 + */
202 +void bcm47xx_sprom_register_fallbacks(void)
203 +{
204 +#if defined(CONFIG_BCM47XX_SSB)
205 + if (ssb_arch_register_fallback_sprom(&bcm47xx_get_sprom_ssb))
206 + pr_warn("Failed to registered ssb SPROM handler\n");
207 +#endif
208 +
209 +#if defined(CONFIG_BCM47XX_BCMA)
210 + if (bcma_arch_register_fallback_sprom(&bcm47xx_get_sprom_bcma))
211 + pr_warn("Failed to registered bcma SPROM handler\n");
212 +#endif
213 +}
214 --
215 1.8.4.5
216