18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Broadcom specific AMBA 38c2ecf20Sopenharmony_ci * PCI Host 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Licensed under the GNU/GPL. See COPYING for details. 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#include "bcma_private.h" 98c2ecf20Sopenharmony_ci#include <linux/slab.h> 108c2ecf20Sopenharmony_ci#include <linux/bcma/bcma.h> 118c2ecf20Sopenharmony_ci#include <linux/pci.h> 128c2ecf20Sopenharmony_ci#include <linux/module.h> 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_cistatic void bcma_host_pci_switch_core(struct bcma_device *core) 158c2ecf20Sopenharmony_ci{ 168c2ecf20Sopenharmony_ci int win2 = core->bus->host_is_pcie2 ? 178c2ecf20Sopenharmony_ci BCMA_PCIE2_BAR0_WIN2 : BCMA_PCI_BAR0_WIN2; 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci pci_write_config_dword(core->bus->host_pci, BCMA_PCI_BAR0_WIN, 208c2ecf20Sopenharmony_ci core->addr); 218c2ecf20Sopenharmony_ci pci_write_config_dword(core->bus->host_pci, win2, core->wrap); 228c2ecf20Sopenharmony_ci core->bus->mapped_core = core; 238c2ecf20Sopenharmony_ci bcma_debug(core->bus, "Switched to core: 0x%X\n", core->id.id); 248c2ecf20Sopenharmony_ci} 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci/* Provides access to the requested core. Returns base offset that has to be 278c2ecf20Sopenharmony_ci * used. It makes use of fixed windows when possible. */ 288c2ecf20Sopenharmony_cistatic u16 bcma_host_pci_provide_access_to_core(struct bcma_device *core) 298c2ecf20Sopenharmony_ci{ 308c2ecf20Sopenharmony_ci switch (core->id.id) { 318c2ecf20Sopenharmony_ci case BCMA_CORE_CHIPCOMMON: 328c2ecf20Sopenharmony_ci return 3 * BCMA_CORE_SIZE; 338c2ecf20Sopenharmony_ci case BCMA_CORE_PCIE: 348c2ecf20Sopenharmony_ci return 2 * BCMA_CORE_SIZE; 358c2ecf20Sopenharmony_ci } 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci if (core->bus->mapped_core != core) 388c2ecf20Sopenharmony_ci bcma_host_pci_switch_core(core); 398c2ecf20Sopenharmony_ci return 0; 408c2ecf20Sopenharmony_ci} 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_cistatic u8 bcma_host_pci_read8(struct bcma_device *core, u16 offset) 438c2ecf20Sopenharmony_ci{ 448c2ecf20Sopenharmony_ci offset += bcma_host_pci_provide_access_to_core(core); 458c2ecf20Sopenharmony_ci return ioread8(core->bus->mmio + offset); 468c2ecf20Sopenharmony_ci} 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_cistatic u16 bcma_host_pci_read16(struct bcma_device *core, u16 offset) 498c2ecf20Sopenharmony_ci{ 508c2ecf20Sopenharmony_ci offset += bcma_host_pci_provide_access_to_core(core); 518c2ecf20Sopenharmony_ci return ioread16(core->bus->mmio + offset); 528c2ecf20Sopenharmony_ci} 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_cistatic u32 bcma_host_pci_read32(struct bcma_device *core, u16 offset) 558c2ecf20Sopenharmony_ci{ 568c2ecf20Sopenharmony_ci offset += bcma_host_pci_provide_access_to_core(core); 578c2ecf20Sopenharmony_ci return ioread32(core->bus->mmio + offset); 588c2ecf20Sopenharmony_ci} 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_cistatic void bcma_host_pci_write8(struct bcma_device *core, u16 offset, 618c2ecf20Sopenharmony_ci u8 value) 628c2ecf20Sopenharmony_ci{ 638c2ecf20Sopenharmony_ci offset += bcma_host_pci_provide_access_to_core(core); 648c2ecf20Sopenharmony_ci iowrite8(value, core->bus->mmio + offset); 658c2ecf20Sopenharmony_ci} 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_cistatic void bcma_host_pci_write16(struct bcma_device *core, u16 offset, 688c2ecf20Sopenharmony_ci u16 value) 698c2ecf20Sopenharmony_ci{ 708c2ecf20Sopenharmony_ci offset += bcma_host_pci_provide_access_to_core(core); 718c2ecf20Sopenharmony_ci iowrite16(value, core->bus->mmio + offset); 728c2ecf20Sopenharmony_ci} 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_cistatic void bcma_host_pci_write32(struct bcma_device *core, u16 offset, 758c2ecf20Sopenharmony_ci u32 value) 768c2ecf20Sopenharmony_ci{ 778c2ecf20Sopenharmony_ci offset += bcma_host_pci_provide_access_to_core(core); 788c2ecf20Sopenharmony_ci iowrite32(value, core->bus->mmio + offset); 798c2ecf20Sopenharmony_ci} 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_ci#ifdef CONFIG_BCMA_BLOCKIO 828c2ecf20Sopenharmony_cistatic void bcma_host_pci_block_read(struct bcma_device *core, void *buffer, 838c2ecf20Sopenharmony_ci size_t count, u16 offset, u8 reg_width) 848c2ecf20Sopenharmony_ci{ 858c2ecf20Sopenharmony_ci void __iomem *addr = core->bus->mmio + offset; 868c2ecf20Sopenharmony_ci if (core->bus->mapped_core != core) 878c2ecf20Sopenharmony_ci bcma_host_pci_switch_core(core); 888c2ecf20Sopenharmony_ci switch (reg_width) { 898c2ecf20Sopenharmony_ci case sizeof(u8): 908c2ecf20Sopenharmony_ci ioread8_rep(addr, buffer, count); 918c2ecf20Sopenharmony_ci break; 928c2ecf20Sopenharmony_ci case sizeof(u16): 938c2ecf20Sopenharmony_ci WARN_ON(count & 1); 948c2ecf20Sopenharmony_ci ioread16_rep(addr, buffer, count >> 1); 958c2ecf20Sopenharmony_ci break; 968c2ecf20Sopenharmony_ci case sizeof(u32): 978c2ecf20Sopenharmony_ci WARN_ON(count & 3); 988c2ecf20Sopenharmony_ci ioread32_rep(addr, buffer, count >> 2); 998c2ecf20Sopenharmony_ci break; 1008c2ecf20Sopenharmony_ci default: 1018c2ecf20Sopenharmony_ci WARN_ON(1); 1028c2ecf20Sopenharmony_ci } 1038c2ecf20Sopenharmony_ci} 1048c2ecf20Sopenharmony_ci 1058c2ecf20Sopenharmony_cistatic void bcma_host_pci_block_write(struct bcma_device *core, 1068c2ecf20Sopenharmony_ci const void *buffer, size_t count, 1078c2ecf20Sopenharmony_ci u16 offset, u8 reg_width) 1088c2ecf20Sopenharmony_ci{ 1098c2ecf20Sopenharmony_ci void __iomem *addr = core->bus->mmio + offset; 1108c2ecf20Sopenharmony_ci if (core->bus->mapped_core != core) 1118c2ecf20Sopenharmony_ci bcma_host_pci_switch_core(core); 1128c2ecf20Sopenharmony_ci switch (reg_width) { 1138c2ecf20Sopenharmony_ci case sizeof(u8): 1148c2ecf20Sopenharmony_ci iowrite8_rep(addr, buffer, count); 1158c2ecf20Sopenharmony_ci break; 1168c2ecf20Sopenharmony_ci case sizeof(u16): 1178c2ecf20Sopenharmony_ci WARN_ON(count & 1); 1188c2ecf20Sopenharmony_ci iowrite16_rep(addr, buffer, count >> 1); 1198c2ecf20Sopenharmony_ci break; 1208c2ecf20Sopenharmony_ci case sizeof(u32): 1218c2ecf20Sopenharmony_ci WARN_ON(count & 3); 1228c2ecf20Sopenharmony_ci iowrite32_rep(addr, buffer, count >> 2); 1238c2ecf20Sopenharmony_ci break; 1248c2ecf20Sopenharmony_ci default: 1258c2ecf20Sopenharmony_ci WARN_ON(1); 1268c2ecf20Sopenharmony_ci } 1278c2ecf20Sopenharmony_ci} 1288c2ecf20Sopenharmony_ci#endif 1298c2ecf20Sopenharmony_ci 1308c2ecf20Sopenharmony_cistatic u32 bcma_host_pci_aread32(struct bcma_device *core, u16 offset) 1318c2ecf20Sopenharmony_ci{ 1328c2ecf20Sopenharmony_ci if (core->bus->mapped_core != core) 1338c2ecf20Sopenharmony_ci bcma_host_pci_switch_core(core); 1348c2ecf20Sopenharmony_ci return ioread32(core->bus->mmio + (1 * BCMA_CORE_SIZE) + offset); 1358c2ecf20Sopenharmony_ci} 1368c2ecf20Sopenharmony_ci 1378c2ecf20Sopenharmony_cistatic void bcma_host_pci_awrite32(struct bcma_device *core, u16 offset, 1388c2ecf20Sopenharmony_ci u32 value) 1398c2ecf20Sopenharmony_ci{ 1408c2ecf20Sopenharmony_ci if (core->bus->mapped_core != core) 1418c2ecf20Sopenharmony_ci bcma_host_pci_switch_core(core); 1428c2ecf20Sopenharmony_ci iowrite32(value, core->bus->mmio + (1 * BCMA_CORE_SIZE) + offset); 1438c2ecf20Sopenharmony_ci} 1448c2ecf20Sopenharmony_ci 1458c2ecf20Sopenharmony_cistatic const struct bcma_host_ops bcma_host_pci_ops = { 1468c2ecf20Sopenharmony_ci .read8 = bcma_host_pci_read8, 1478c2ecf20Sopenharmony_ci .read16 = bcma_host_pci_read16, 1488c2ecf20Sopenharmony_ci .read32 = bcma_host_pci_read32, 1498c2ecf20Sopenharmony_ci .write8 = bcma_host_pci_write8, 1508c2ecf20Sopenharmony_ci .write16 = bcma_host_pci_write16, 1518c2ecf20Sopenharmony_ci .write32 = bcma_host_pci_write32, 1528c2ecf20Sopenharmony_ci#ifdef CONFIG_BCMA_BLOCKIO 1538c2ecf20Sopenharmony_ci .block_read = bcma_host_pci_block_read, 1548c2ecf20Sopenharmony_ci .block_write = bcma_host_pci_block_write, 1558c2ecf20Sopenharmony_ci#endif 1568c2ecf20Sopenharmony_ci .aread32 = bcma_host_pci_aread32, 1578c2ecf20Sopenharmony_ci .awrite32 = bcma_host_pci_awrite32, 1588c2ecf20Sopenharmony_ci}; 1598c2ecf20Sopenharmony_ci 1608c2ecf20Sopenharmony_cistatic int bcma_host_pci_probe(struct pci_dev *dev, 1618c2ecf20Sopenharmony_ci const struct pci_device_id *id) 1628c2ecf20Sopenharmony_ci{ 1638c2ecf20Sopenharmony_ci struct bcma_bus *bus; 1648c2ecf20Sopenharmony_ci int err = -ENOMEM; 1658c2ecf20Sopenharmony_ci const char *name; 1668c2ecf20Sopenharmony_ci u32 val; 1678c2ecf20Sopenharmony_ci 1688c2ecf20Sopenharmony_ci /* Alloc */ 1698c2ecf20Sopenharmony_ci bus = kzalloc(sizeof(*bus), GFP_KERNEL); 1708c2ecf20Sopenharmony_ci if (!bus) 1718c2ecf20Sopenharmony_ci goto out; 1728c2ecf20Sopenharmony_ci 1738c2ecf20Sopenharmony_ci /* Basic PCI configuration */ 1748c2ecf20Sopenharmony_ci err = pci_enable_device(dev); 1758c2ecf20Sopenharmony_ci if (err) 1768c2ecf20Sopenharmony_ci goto err_kfree_bus; 1778c2ecf20Sopenharmony_ci 1788c2ecf20Sopenharmony_ci name = dev_name(&dev->dev); 1798c2ecf20Sopenharmony_ci if (dev->driver && dev->driver->name) 1808c2ecf20Sopenharmony_ci name = dev->driver->name; 1818c2ecf20Sopenharmony_ci err = pci_request_regions(dev, name); 1828c2ecf20Sopenharmony_ci if (err) 1838c2ecf20Sopenharmony_ci goto err_pci_disable; 1848c2ecf20Sopenharmony_ci pci_set_master(dev); 1858c2ecf20Sopenharmony_ci 1868c2ecf20Sopenharmony_ci /* Disable the RETRY_TIMEOUT register (0x41) to keep 1878c2ecf20Sopenharmony_ci * PCI Tx retries from interfering with C3 CPU state */ 1888c2ecf20Sopenharmony_ci pci_read_config_dword(dev, 0x40, &val); 1898c2ecf20Sopenharmony_ci if ((val & 0x0000ff00) != 0) 1908c2ecf20Sopenharmony_ci pci_write_config_dword(dev, 0x40, val & 0xffff00ff); 1918c2ecf20Sopenharmony_ci 1928c2ecf20Sopenharmony_ci /* SSB needed additional powering up, do we have any AMBA PCI cards? */ 1938c2ecf20Sopenharmony_ci if (!pci_is_pcie(dev)) { 1948c2ecf20Sopenharmony_ci bcma_err(bus, "PCI card detected, they are not supported.\n"); 1958c2ecf20Sopenharmony_ci err = -ENXIO; 1968c2ecf20Sopenharmony_ci goto err_pci_release_regions; 1978c2ecf20Sopenharmony_ci } 1988c2ecf20Sopenharmony_ci 1998c2ecf20Sopenharmony_ci bus->dev = &dev->dev; 2008c2ecf20Sopenharmony_ci 2018c2ecf20Sopenharmony_ci /* Map MMIO */ 2028c2ecf20Sopenharmony_ci err = -ENOMEM; 2038c2ecf20Sopenharmony_ci bus->mmio = pci_iomap(dev, 0, ~0UL); 2048c2ecf20Sopenharmony_ci if (!bus->mmio) 2058c2ecf20Sopenharmony_ci goto err_pci_release_regions; 2068c2ecf20Sopenharmony_ci 2078c2ecf20Sopenharmony_ci /* Host specific */ 2088c2ecf20Sopenharmony_ci bus->host_pci = dev; 2098c2ecf20Sopenharmony_ci bus->hosttype = BCMA_HOSTTYPE_PCI; 2108c2ecf20Sopenharmony_ci bus->ops = &bcma_host_pci_ops; 2118c2ecf20Sopenharmony_ci 2128c2ecf20Sopenharmony_ci bus->boardinfo.vendor = bus->host_pci->subsystem_vendor; 2138c2ecf20Sopenharmony_ci bus->boardinfo.type = bus->host_pci->subsystem_device; 2148c2ecf20Sopenharmony_ci 2158c2ecf20Sopenharmony_ci /* Initialize struct, detect chip */ 2168c2ecf20Sopenharmony_ci bcma_init_bus(bus); 2178c2ecf20Sopenharmony_ci 2188c2ecf20Sopenharmony_ci /* Scan bus to find out generation of PCIe core */ 2198c2ecf20Sopenharmony_ci err = bcma_bus_scan(bus); 2208c2ecf20Sopenharmony_ci if (err) 2218c2ecf20Sopenharmony_ci goto err_pci_unmap_mmio; 2228c2ecf20Sopenharmony_ci 2238c2ecf20Sopenharmony_ci if (bcma_find_core(bus, BCMA_CORE_PCIE2)) 2248c2ecf20Sopenharmony_ci bus->host_is_pcie2 = true; 2258c2ecf20Sopenharmony_ci 2268c2ecf20Sopenharmony_ci /* Register */ 2278c2ecf20Sopenharmony_ci err = bcma_bus_register(bus); 2288c2ecf20Sopenharmony_ci if (err) 2298c2ecf20Sopenharmony_ci goto err_unregister_cores; 2308c2ecf20Sopenharmony_ci 2318c2ecf20Sopenharmony_ci pci_set_drvdata(dev, bus); 2328c2ecf20Sopenharmony_ci 2338c2ecf20Sopenharmony_ciout: 2348c2ecf20Sopenharmony_ci return err; 2358c2ecf20Sopenharmony_ci 2368c2ecf20Sopenharmony_cierr_unregister_cores: 2378c2ecf20Sopenharmony_ci bcma_unregister_cores(bus); 2388c2ecf20Sopenharmony_cierr_pci_unmap_mmio: 2398c2ecf20Sopenharmony_ci pci_iounmap(dev, bus->mmio); 2408c2ecf20Sopenharmony_cierr_pci_release_regions: 2418c2ecf20Sopenharmony_ci pci_release_regions(dev); 2428c2ecf20Sopenharmony_cierr_pci_disable: 2438c2ecf20Sopenharmony_ci pci_disable_device(dev); 2448c2ecf20Sopenharmony_cierr_kfree_bus: 2458c2ecf20Sopenharmony_ci kfree(bus); 2468c2ecf20Sopenharmony_ci return err; 2478c2ecf20Sopenharmony_ci} 2488c2ecf20Sopenharmony_ci 2498c2ecf20Sopenharmony_cistatic void bcma_host_pci_remove(struct pci_dev *dev) 2508c2ecf20Sopenharmony_ci{ 2518c2ecf20Sopenharmony_ci struct bcma_bus *bus = pci_get_drvdata(dev); 2528c2ecf20Sopenharmony_ci 2538c2ecf20Sopenharmony_ci bcma_bus_unregister(bus); 2548c2ecf20Sopenharmony_ci pci_iounmap(dev, bus->mmio); 2558c2ecf20Sopenharmony_ci pci_release_regions(dev); 2568c2ecf20Sopenharmony_ci pci_disable_device(dev); 2578c2ecf20Sopenharmony_ci kfree(bus); 2588c2ecf20Sopenharmony_ci} 2598c2ecf20Sopenharmony_ci 2608c2ecf20Sopenharmony_ci#ifdef CONFIG_PM_SLEEP 2618c2ecf20Sopenharmony_cistatic int bcma_host_pci_suspend(struct device *dev) 2628c2ecf20Sopenharmony_ci{ 2638c2ecf20Sopenharmony_ci struct bcma_bus *bus = dev_get_drvdata(dev); 2648c2ecf20Sopenharmony_ci 2658c2ecf20Sopenharmony_ci bus->mapped_core = NULL; 2668c2ecf20Sopenharmony_ci 2678c2ecf20Sopenharmony_ci return bcma_bus_suspend(bus); 2688c2ecf20Sopenharmony_ci} 2698c2ecf20Sopenharmony_ci 2708c2ecf20Sopenharmony_cistatic int bcma_host_pci_resume(struct device *dev) 2718c2ecf20Sopenharmony_ci{ 2728c2ecf20Sopenharmony_ci struct bcma_bus *bus = dev_get_drvdata(dev); 2738c2ecf20Sopenharmony_ci 2748c2ecf20Sopenharmony_ci return bcma_bus_resume(bus); 2758c2ecf20Sopenharmony_ci} 2768c2ecf20Sopenharmony_ci 2778c2ecf20Sopenharmony_cistatic SIMPLE_DEV_PM_OPS(bcma_pm_ops, bcma_host_pci_suspend, 2788c2ecf20Sopenharmony_ci bcma_host_pci_resume); 2798c2ecf20Sopenharmony_ci#define BCMA_PM_OPS (&bcma_pm_ops) 2808c2ecf20Sopenharmony_ci 2818c2ecf20Sopenharmony_ci#else /* CONFIG_PM_SLEEP */ 2828c2ecf20Sopenharmony_ci 2838c2ecf20Sopenharmony_ci#define BCMA_PM_OPS NULL 2848c2ecf20Sopenharmony_ci 2858c2ecf20Sopenharmony_ci#endif /* CONFIG_PM_SLEEP */ 2868c2ecf20Sopenharmony_ci 2878c2ecf20Sopenharmony_cistatic const struct pci_device_id bcma_pci_bridge_tbl[] = { 2888c2ecf20Sopenharmony_ci { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x0576) }, 2898c2ecf20Sopenharmony_ci { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4313) }, 2908c2ecf20Sopenharmony_ci { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 43224) }, /* 0xa8d8 */ 2918c2ecf20Sopenharmony_ci { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4331) }, 2928c2ecf20Sopenharmony_ci { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4353) }, 2938c2ecf20Sopenharmony_ci { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4357) }, 2948c2ecf20Sopenharmony_ci { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4358) }, 2958c2ecf20Sopenharmony_ci { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4359) }, 2968c2ecf20Sopenharmony_ci { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4360) }, 2978c2ecf20Sopenharmony_ci { PCI_DEVICE_SUB(PCI_VENDOR_ID_BROADCOM, 0x4365, PCI_VENDOR_ID_DELL, 0x0016) }, 2988c2ecf20Sopenharmony_ci { PCI_DEVICE_SUB(PCI_VENDOR_ID_BROADCOM, 0x4365, PCI_VENDOR_ID_DELL, 0x0018) }, 2998c2ecf20Sopenharmony_ci { PCI_DEVICE_SUB(PCI_VENDOR_ID_BROADCOM, 0x4365, PCI_VENDOR_ID_FOXCONN, 0xe092) }, 3008c2ecf20Sopenharmony_ci { PCI_DEVICE_SUB(PCI_VENDOR_ID_BROADCOM, 0x4365, PCI_VENDOR_ID_HP, 0x804a) }, 3018c2ecf20Sopenharmony_ci { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x43a0) }, 3028c2ecf20Sopenharmony_ci { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x43a9) }, 3038c2ecf20Sopenharmony_ci { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x43aa) }, 3048c2ecf20Sopenharmony_ci { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x43b1) }, 3058c2ecf20Sopenharmony_ci { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4727) }, 3068c2ecf20Sopenharmony_ci { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 43227) }, /* 0xa8db, BCM43217 (sic!) */ 3078c2ecf20Sopenharmony_ci { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 43228) }, /* 0xa8dc */ 3088c2ecf20Sopenharmony_ci { 0, }, 3098c2ecf20Sopenharmony_ci}; 3108c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(pci, bcma_pci_bridge_tbl); 3118c2ecf20Sopenharmony_ci 3128c2ecf20Sopenharmony_cistatic struct pci_driver bcma_pci_bridge_driver = { 3138c2ecf20Sopenharmony_ci .name = "bcma-pci-bridge", 3148c2ecf20Sopenharmony_ci .id_table = bcma_pci_bridge_tbl, 3158c2ecf20Sopenharmony_ci .probe = bcma_host_pci_probe, 3168c2ecf20Sopenharmony_ci .remove = bcma_host_pci_remove, 3178c2ecf20Sopenharmony_ci .driver.pm = BCMA_PM_OPS, 3188c2ecf20Sopenharmony_ci}; 3198c2ecf20Sopenharmony_ci 3208c2ecf20Sopenharmony_ciint __init bcma_host_pci_init(void) 3218c2ecf20Sopenharmony_ci{ 3228c2ecf20Sopenharmony_ci return pci_register_driver(&bcma_pci_bridge_driver); 3238c2ecf20Sopenharmony_ci} 3248c2ecf20Sopenharmony_ci 3258c2ecf20Sopenharmony_civoid __exit bcma_host_pci_exit(void) 3268c2ecf20Sopenharmony_ci{ 3278c2ecf20Sopenharmony_ci pci_unregister_driver(&bcma_pci_bridge_driver); 3288c2ecf20Sopenharmony_ci} 3298c2ecf20Sopenharmony_ci 3308c2ecf20Sopenharmony_ci/************************************************** 3318c2ecf20Sopenharmony_ci * Runtime ops for drivers. 3328c2ecf20Sopenharmony_ci **************************************************/ 3338c2ecf20Sopenharmony_ci 3348c2ecf20Sopenharmony_ci/* See also pcicore_up */ 3358c2ecf20Sopenharmony_civoid bcma_host_pci_up(struct bcma_bus *bus) 3368c2ecf20Sopenharmony_ci{ 3378c2ecf20Sopenharmony_ci if (bus->hosttype != BCMA_HOSTTYPE_PCI) 3388c2ecf20Sopenharmony_ci return; 3398c2ecf20Sopenharmony_ci 3408c2ecf20Sopenharmony_ci if (bus->host_is_pcie2) 3418c2ecf20Sopenharmony_ci bcma_core_pcie2_up(&bus->drv_pcie2); 3428c2ecf20Sopenharmony_ci else 3438c2ecf20Sopenharmony_ci bcma_core_pci_up(&bus->drv_pci[0]); 3448c2ecf20Sopenharmony_ci} 3458c2ecf20Sopenharmony_ciEXPORT_SYMBOL_GPL(bcma_host_pci_up); 3468c2ecf20Sopenharmony_ci 3478c2ecf20Sopenharmony_ci/* See also pcicore_down */ 3488c2ecf20Sopenharmony_civoid bcma_host_pci_down(struct bcma_bus *bus) 3498c2ecf20Sopenharmony_ci{ 3508c2ecf20Sopenharmony_ci if (bus->hosttype != BCMA_HOSTTYPE_PCI) 3518c2ecf20Sopenharmony_ci return; 3528c2ecf20Sopenharmony_ci 3538c2ecf20Sopenharmony_ci if (!bus->host_is_pcie2) 3548c2ecf20Sopenharmony_ci bcma_core_pci_down(&bus->drv_pci[0]); 3558c2ecf20Sopenharmony_ci} 3568c2ecf20Sopenharmony_ciEXPORT_SYMBOL_GPL(bcma_host_pci_down); 3578c2ecf20Sopenharmony_ci 3588c2ecf20Sopenharmony_ci/* See also si_pci_setup */ 3598c2ecf20Sopenharmony_ciint bcma_host_pci_irq_ctl(struct bcma_bus *bus, struct bcma_device *core, 3608c2ecf20Sopenharmony_ci bool enable) 3618c2ecf20Sopenharmony_ci{ 3628c2ecf20Sopenharmony_ci struct pci_dev *pdev; 3638c2ecf20Sopenharmony_ci u32 coremask, tmp; 3648c2ecf20Sopenharmony_ci int err = 0; 3658c2ecf20Sopenharmony_ci 3668c2ecf20Sopenharmony_ci if (bus->hosttype != BCMA_HOSTTYPE_PCI) { 3678c2ecf20Sopenharmony_ci /* This bcma device is not on a PCI host-bus. So the IRQs are 3688c2ecf20Sopenharmony_ci * not routed through the PCI core. 3698c2ecf20Sopenharmony_ci * So we must not enable routing through the PCI core. */ 3708c2ecf20Sopenharmony_ci goto out; 3718c2ecf20Sopenharmony_ci } 3728c2ecf20Sopenharmony_ci 3738c2ecf20Sopenharmony_ci pdev = bus->host_pci; 3748c2ecf20Sopenharmony_ci 3758c2ecf20Sopenharmony_ci err = pci_read_config_dword(pdev, BCMA_PCI_IRQMASK, &tmp); 3768c2ecf20Sopenharmony_ci if (err) 3778c2ecf20Sopenharmony_ci goto out; 3788c2ecf20Sopenharmony_ci 3798c2ecf20Sopenharmony_ci coremask = BIT(core->core_index) << 8; 3808c2ecf20Sopenharmony_ci if (enable) 3818c2ecf20Sopenharmony_ci tmp |= coremask; 3828c2ecf20Sopenharmony_ci else 3838c2ecf20Sopenharmony_ci tmp &= ~coremask; 3848c2ecf20Sopenharmony_ci 3858c2ecf20Sopenharmony_ci err = pci_write_config_dword(pdev, BCMA_PCI_IRQMASK, tmp); 3868c2ecf20Sopenharmony_ci 3878c2ecf20Sopenharmony_ciout: 3888c2ecf20Sopenharmony_ci return err; 3898c2ecf20Sopenharmony_ci} 3908c2ecf20Sopenharmony_ciEXPORT_SYMBOL_GPL(bcma_host_pci_irq_ctl); 391