Lines Matching +full:bus +full:- +full:err

1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (C) 2009-2016 Cavium, Inc.
15 #include "mdio-cavium.h"
27 int err; in thunder_mdiobus_pci_probe() local
30 nexus = devm_kzalloc(&pdev->dev, sizeof(*nexus), GFP_KERNEL); in thunder_mdiobus_pci_probe()
32 return -ENOMEM; in thunder_mdiobus_pci_probe()
36 err = pcim_enable_device(pdev); in thunder_mdiobus_pci_probe()
37 if (err) { in thunder_mdiobus_pci_probe()
38 dev_err(&pdev->dev, "Failed to enable PCI device\n"); in thunder_mdiobus_pci_probe()
40 return err; in thunder_mdiobus_pci_probe()
43 err = pci_request_regions(pdev, KBUILD_MODNAME); in thunder_mdiobus_pci_probe()
44 if (err) { in thunder_mdiobus_pci_probe()
45 dev_err(&pdev->dev, "pci_request_regions failed\n"); in thunder_mdiobus_pci_probe()
49 nexus->bar0 = pcim_iomap(pdev, 0, pci_resource_len(pdev, 0)); in thunder_mdiobus_pci_probe()
50 if (!nexus->bar0) { in thunder_mdiobus_pci_probe()
51 err = -ENOMEM; in thunder_mdiobus_pci_probe()
56 device_for_each_child_node_scoped(&pdev->dev, fwn) { in thunder_mdiobus_pci_probe()
59 struct cavium_mdiobus *bus; in thunder_mdiobus_pci_probe() local
69 err = of_address_to_resource(node, 0, &r); in thunder_mdiobus_pci_probe()
70 if (err) { in thunder_mdiobus_pci_probe()
71 dev_err(&pdev->dev, in thunder_mdiobus_pci_probe()
77 mii_bus = devm_mdiobus_alloc_size(&pdev->dev, sizeof(*bus)); in thunder_mdiobus_pci_probe()
80 bus = mii_bus->priv; in thunder_mdiobus_pci_probe()
81 bus->mii_bus = mii_bus; in thunder_mdiobus_pci_probe()
83 nexus->buses[i] = bus; in thunder_mdiobus_pci_probe()
86 bus->register_base = nexus->bar0 + in thunder_mdiobus_pci_probe()
87 r.start - pci_resource_start(pdev, 0); in thunder_mdiobus_pci_probe()
91 oct_mdio_writeq(smi_en.u64, bus->register_base + SMI_EN); in thunder_mdiobus_pci_probe()
92 bus->mii_bus->name = KBUILD_MODNAME; in thunder_mdiobus_pci_probe()
93 snprintf(bus->mii_bus->id, MII_BUS_ID_SIZE, "%llx", r.start); in thunder_mdiobus_pci_probe()
94 bus->mii_bus->parent = &pdev->dev; in thunder_mdiobus_pci_probe()
95 bus->mii_bus->read = cavium_mdiobus_read_c22; in thunder_mdiobus_pci_probe()
96 bus->mii_bus->write = cavium_mdiobus_write_c22; in thunder_mdiobus_pci_probe()
97 bus->mii_bus->read_c45 = cavium_mdiobus_read_c45; in thunder_mdiobus_pci_probe()
98 bus->mii_bus->write_c45 = cavium_mdiobus_write_c45; in thunder_mdiobus_pci_probe()
100 err = of_mdiobus_register(bus->mii_bus, node); in thunder_mdiobus_pci_probe()
101 if (err) in thunder_mdiobus_pci_probe()
102 dev_err(&pdev->dev, "of_mdiobus_register failed\n"); in thunder_mdiobus_pci_probe()
104 dev_info(&pdev->dev, "Added bus at %llx\n", r.start); in thunder_mdiobus_pci_probe()
105 if (i >= ARRAY_SIZE(nexus->buses)) in thunder_mdiobus_pci_probe()
115 return err; in thunder_mdiobus_pci_probe()
123 for (i = 0; i < ARRAY_SIZE(nexus->buses); i++) { in thunder_mdiobus_pci_remove()
124 struct cavium_mdiobus *bus = nexus->buses[i]; in thunder_mdiobus_pci_remove() local
126 if (!bus) in thunder_mdiobus_pci_remove()
129 mdiobus_unregister(bus->mii_bus); in thunder_mdiobus_pci_remove()
130 oct_mdio_writeq(0, bus->register_base + SMI_EN); in thunder_mdiobus_pci_remove()
151 MODULE_DESCRIPTION("Cavium ThunderX MDIO bus driver");