kernel: add bcma patches sent upstream but not pushed yet
[openwrt/staging/mkresin.git] / target / linux / generic / patches-3.14 / 026-bcma-sent.patch
1 --- a/arch/mips/bcm47xx/setup.c
2 +++ b/arch/mips/bcm47xx/setup.c
3 @@ -202,6 +202,10 @@ static void __init bcm47xx_register_bcma
4
5 err = bcma_host_soc_register(&bcm47xx_bus.bcma);
6 if (err)
7 + panic("Failed to register BCMA bus (err %d)", err);
8 +
9 + err = bcma_host_soc_init(&bcm47xx_bus.bcma);
10 + if (err)
11 panic("Failed to initialize BCMA bus (err %d)", err);
12
13 bcm47xx_fill_bcma_boardinfo(&bcm47xx_bus.bcma.bus.boardinfo, NULL);
14 --- a/drivers/bcma/host_pci.c
15 +++ b/drivers/bcma/host_pci.c
16 @@ -208,6 +208,9 @@ static int bcma_host_pci_probe(struct pc
17 bus->boardinfo.vendor = bus->host_pci->subsystem_vendor;
18 bus->boardinfo.type = bus->host_pci->subsystem_device;
19
20 + /* Initialize struct, detect chip */
21 + bcma_init_bus(bus);
22 +
23 /* Register */
24 err = bcma_bus_register(bus);
25 if (err)
26 @@ -282,6 +285,7 @@ static const struct pci_device_id bcma_p
27 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x43a9) },
28 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x43aa) },
29 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4727) },
30 + { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 43227) }, /* 0xA8DB */
31 { 0, },
32 };
33 MODULE_DEVICE_TABLE(pci, bcma_pci_bridge_tbl);
34 --- a/drivers/bcma/host_soc.c
35 +++ b/drivers/bcma/host_soc.c
36 @@ -165,7 +165,6 @@ static const struct bcma_host_ops bcma_h
37 int __init bcma_host_soc_register(struct bcma_soc *soc)
38 {
39 struct bcma_bus *bus = &soc->bus;
40 - int err;
41
42 /* iomap only first core. We have to read some register on this core
43 * to scan the bus.
44 @@ -178,7 +177,18 @@ int __init bcma_host_soc_register(struct
45 bus->hosttype = BCMA_HOSTTYPE_SOC;
46 bus->ops = &bcma_host_soc_ops;
47
48 - /* Register */
49 + /* Initialize struct, detect chip */
50 + bcma_init_bus(bus);
51 +
52 + return 0;
53 +}
54 +
55 +int __init bcma_host_soc_init(struct bcma_soc *soc)
56 +{
57 + struct bcma_bus *bus = &soc->bus;
58 + int err;
59 +
60 + /* Scan bus and initialize it */
61 err = bcma_bus_early_register(bus, &soc->core_cc, &soc->core_mips);
62 if (err)
63 iounmap(bus->mmio);
64 --- a/drivers/bcma/main.c
65 +++ b/drivers/bcma/main.c
66 @@ -120,10 +120,53 @@ static void bcma_release_core_dev(struct
67 kfree(core);
68 }
69
70 -static int bcma_register_cores(struct bcma_bus *bus)
71 +static bool bcma_is_core_needed_early(u16 core_id)
72 +{
73 + switch (core_id) {
74 + case BCMA_CORE_NS_NAND:
75 + case BCMA_CORE_NS_QSPI:
76 + return true;
77 + }
78 +
79 + return false;
80 +}
81 +
82 +static void bcma_register_core(struct bcma_bus *bus, struct bcma_device *core)
83 +{
84 + int err;
85 +
86 + core->dev.release = bcma_release_core_dev;
87 + core->dev.bus = &bcma_bus_type;
88 + dev_set_name(&core->dev, "bcma%d:%d", bus->num, core->core_index);
89 +
90 + switch (bus->hosttype) {
91 + case BCMA_HOSTTYPE_PCI:
92 + core->dev.parent = &bus->host_pci->dev;
93 + core->dma_dev = &bus->host_pci->dev;
94 + core->irq = bus->host_pci->irq;
95 + break;
96 + case BCMA_HOSTTYPE_SOC:
97 + core->dev.dma_mask = &core->dev.coherent_dma_mask;
98 + core->dma_dev = &core->dev;
99 + break;
100 + case BCMA_HOSTTYPE_SDIO:
101 + break;
102 + }
103 +
104 + err = device_register(&core->dev);
105 + if (err) {
106 + bcma_err(bus, "Could not register dev for core 0x%03X\n",
107 + core->id.id);
108 + put_device(&core->dev);
109 + return;
110 + }
111 + core->dev_registered = true;
112 +}
113 +
114 +static int bcma_register_devices(struct bcma_bus *bus)
115 {
116 struct bcma_device *core;
117 - int err, dev_id = 0;
118 + int err;
119
120 list_for_each_entry(core, &bus->cores, list) {
121 /* We support that cores ourself */
122 @@ -138,39 +181,16 @@ static int bcma_register_cores(struct bc
123 continue;
124 }
125
126 + /* Early cores were already registered */
127 + if (bcma_is_core_needed_early(core->id.id))
128 + continue;
129 +
130 /* Only first GMAC core on BCM4706 is connected and working */
131 if (core->id.id == BCMA_CORE_4706_MAC_GBIT &&
132 core->core_unit > 0)
133 continue;
134
135 - core->dev.release = bcma_release_core_dev;
136 - core->dev.bus = &bcma_bus_type;
137 - dev_set_name(&core->dev, "bcma%d:%d", bus->num, dev_id);
138 -
139 - switch (bus->hosttype) {
140 - case BCMA_HOSTTYPE_PCI:
141 - core->dev.parent = &bus->host_pci->dev;
142 - core->dma_dev = &bus->host_pci->dev;
143 - core->irq = bus->host_pci->irq;
144 - break;
145 - case BCMA_HOSTTYPE_SOC:
146 - core->dev.dma_mask = &core->dev.coherent_dma_mask;
147 - core->dma_dev = &core->dev;
148 - break;
149 - case BCMA_HOSTTYPE_SDIO:
150 - break;
151 - }
152 -
153 - err = device_register(&core->dev);
154 - if (err) {
155 - bcma_err(bus,
156 - "Could not register dev for core 0x%03X\n",
157 - core->id.id);
158 - put_device(&core->dev);
159 - continue;
160 - }
161 - core->dev_registered = true;
162 - dev_id++;
163 + bcma_register_core(bus, core);
164 }
165
166 #ifdef CONFIG_BCMA_DRIVER_MIPS
167 @@ -247,6 +267,12 @@ int bcma_bus_register(struct bcma_bus *b
168 bcma_core_chipcommon_early_init(&bus->drv_cc);
169 }
170
171 + /* Cores providing flash access go before SPROM init */
172 + list_for_each_entry(core, &bus->cores, list) {
173 + if (bcma_is_core_needed_early(core->id.id))
174 + bcma_register_core(bus, core);
175 + }
176 +
177 /* Try to get SPROM */
178 err = bcma_sprom_get(bus);
179 if (err == -ENOENT) {
180 @@ -297,7 +323,7 @@ int bcma_bus_register(struct bcma_bus *b
181 }
182
183 /* Register found cores */
184 - bcma_register_cores(bus);
185 + bcma_register_devices(bus);
186
187 bcma_info(bus, "Bus registered\n");
188
189 @@ -334,8 +360,6 @@ int __init bcma_bus_early_register(struc
190 struct bcma_device *core;
191 struct bcma_device_id match;
192
193 - bcma_init_bus(bus);
194 -
195 match.manuf = BCMA_MANUF_BCM;
196 match.id = bcma_cc_core_id(bus);
197 match.class = BCMA_CL_SIM;
198 --- a/drivers/bcma/scan.c
199 +++ b/drivers/bcma/scan.c
200 @@ -438,9 +438,6 @@ void bcma_init_bus(struct bcma_bus *bus)
201 s32 tmp;
202 struct bcma_chipinfo *chipinfo = &(bus->chipinfo);
203
204 - if (bus->init_done)
205 - return;
206 -
207 INIT_LIST_HEAD(&bus->cores);
208 bus->nr_cores = 0;
209
210 @@ -452,8 +449,6 @@ void bcma_init_bus(struct bcma_bus *bus)
211 chipinfo->pkg = (tmp & BCMA_CC_ID_PKG) >> BCMA_CC_ID_PKG_SHIFT;
212 bcma_info(bus, "Found chip with id 0x%04X, rev 0x%02X and package 0x%02X\n",
213 chipinfo->id, chipinfo->rev, chipinfo->pkg);
214 -
215 - bus->init_done = true;
216 }
217
218 int bcma_bus_scan(struct bcma_bus *bus)
219 @@ -463,8 +458,6 @@ int bcma_bus_scan(struct bcma_bus *bus)
220
221 int err, core_num = 0;
222
223 - bcma_init_bus(bus);
224 -
225 erombase = bcma_scan_read32(bus, 0, BCMA_CC_EROM);
226 if (bus->hosttype == BCMA_HOSTTYPE_SOC) {
227 eromptr = ioremap_nocache(erombase, BCMA_CORE_SIZE);
228 --- a/include/linux/bcma/bcma.h
229 +++ b/include/linux/bcma/bcma.h
230 @@ -332,7 +332,6 @@ struct bcma_bus {
231 struct bcma_device *mapped_core;
232 struct list_head cores;
233 u8 nr_cores;
234 - u8 init_done:1;
235 u8 num;
236
237 struct bcma_drv_cc drv_cc;
238 --- a/include/linux/bcma/bcma_soc.h
239 +++ b/include/linux/bcma/bcma_soc.h
240 @@ -10,6 +10,7 @@ struct bcma_soc {
241 };
242
243 int __init bcma_host_soc_register(struct bcma_soc *soc);
244 +int __init bcma_host_soc_init(struct bcma_soc *soc);
245
246 int bcma_bus_register(struct bcma_bus *bus);
247