Source
216
216
unsigned int mips_irq;
217
217
218
218
switch (bus->hosttype) {
219
219
case BCMA_HOSTTYPE_PCI:
220
220
return bus->host_pci->irq;
221
221
case BCMA_HOSTTYPE_SOC:
222
222
if (bus->drv_mips.core && num == 0) {
223
223
mips_irq = bcma_core_mips_irq(core);
224
224
return mips_irq <= 4 ? mips_irq + 2 : 0;
225
225
}
226
-
if (bus->host_pdev)
227
-
return bcma_of_get_irq(&bus->host_pdev->dev, core, num);
226
+
if (bus->dev)
227
+
return bcma_of_get_irq(bus->dev, core, num);
228
228
return 0;
229
229
case BCMA_HOSTTYPE_SDIO:
230
230
return 0;
231
231
}
232
232
233
233
return 0;
234
234
}
235
235
EXPORT_SYMBOL(bcma_core_irq);
236
236
237
237
void bcma_prepare_core(struct bcma_bus *bus, struct bcma_device *core)
238
238
{
239
239
core->dev.release = bcma_release_core_dev;
240
240
core->dev.bus = &bcma_bus_type;
241
241
dev_set_name(&core->dev, "bcma%d:%d", bus->num, core->core_index);
242
-
core->dev.parent = bcma_bus_get_host_dev(bus);
243
-
if (core->dev.parent)
244
-
bcma_of_fill_device(core->dev.parent, core);
242
+
core->dev.parent = bus->dev;
243
+
if (bus->dev)
244
+
bcma_of_fill_device(bus->dev, core);
245
245
246
246
switch (bus->hosttype) {
247
247
case BCMA_HOSTTYPE_PCI:
248
-
core->dma_dev = &bus->host_pci->dev;
248
+
core->dma_dev = bus->dev;
249
249
core->irq = bus->host_pci->irq;
250
250
break;
251
251
case BCMA_HOSTTYPE_SOC:
252
-
if (IS_ENABLED(CONFIG_OF) && bus->host_pdev) {
253
-
core->dma_dev = &bus->host_pdev->dev;
252
+
if (IS_ENABLED(CONFIG_OF) && bus->dev) {
253
+
core->dma_dev = bus->dev;
254
254
} else {
255
255
core->dev.dma_mask = &core->dev.coherent_dma_mask;
256
256
core->dma_dev = &core->dev;
257
257
}
258
258
break;
259
259
case BCMA_HOSTTYPE_SDIO:
260
260
break;
261
261
}
262
262
}
263
263
264
-
struct device *bcma_bus_get_host_dev(struct bcma_bus *bus)
265
-
{
266
-
switch (bus->hosttype) {
267
-
case BCMA_HOSTTYPE_PCI:
268
-
if (bus->host_pci)
269
-
return &bus->host_pci->dev;
270
-
else
271
-
return NULL;
272
-
case BCMA_HOSTTYPE_SOC:
273
-
if (bus->host_pdev)
274
-
return &bus->host_pdev->dev;
275
-
else
276
-
return NULL;
277
-
case BCMA_HOSTTYPE_SDIO:
278
-
if (bus->host_sdio)
279
-
return &bus->host_sdio->dev;
280
-
else
281
-
return NULL;
282
-
}
283
-
return NULL;
284
-
}
285
-
286
264
void bcma_init_bus(struct bcma_bus *bus)
287
265
{
288
266
mutex_lock(&bcma_buses_mutex);
289
267
bus->num = bcma_bus_next_num++;
290
268
mutex_unlock(&bcma_buses_mutex);
291
269
292
270
INIT_LIST_HEAD(&bus->cores);
293
271
bus->nr_cores = 0;
294
272
295
273
bcma_detect_chip(bus);
395
373
list_for_each_entry_safe(core, tmp, &bus->cores, list) {
396
374
list_del(&core->list);
397
375
kfree(core);
398
376
}
399
377
}
400
378
401
379
int bcma_bus_register(struct bcma_bus *bus)
402
380
{
403
381
int err;
404
382
struct bcma_device *core;
405
-
struct device *dev;
406
383
407
384
/* Scan for devices (cores) */
408
385
err = bcma_bus_scan(bus);
409
386
if (err) {
410
387
bcma_err(bus, "Failed to scan: %d\n", err);
411
388
return err;
412
389
}
413
390
414
391
/* Early init CC core */
415
392
core = bcma_find_core(bus, bcma_cc_core_id(bus));
418
395
bcma_core_chipcommon_early_init(&bus->drv_cc);
419
396
}
420
397
421
398
/* Early init PCIE core */
422
399
core = bcma_find_core(bus, BCMA_CORE_PCIE);
423
400
if (core) {
424
401
bus->drv_pci[0].core = core;
425
402
bcma_core_pci_early_init(&bus->drv_pci[0]);
426
403
}
427
404
428
-
dev = bcma_bus_get_host_dev(bus);
429
-
if (dev) {
430
-
of_platform_default_populate(dev->of_node, NULL, dev);
431
-
}
405
+
if (bus->dev)
406
+
of_platform_default_populate(bus->dev->of_node, NULL, bus->dev);
432
407
433
408
/* Cores providing flash access go before SPROM init */
434
409
list_for_each_entry(core, &bus->cores, list) {
435
410
if (bcma_is_core_needed_early(core->id.id))
436
411
bcma_register_core(bus, core);
437
412
}
438
413
439
414
/* Try to get SPROM */
440
415
err = bcma_sprom_get(bus);
441
416
if (err == -ENOENT) {