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"
28 int err; in thunder_mdiobus_pci_probe() local
31 nexus = devm_kzalloc(&pdev->dev, sizeof(*nexus), GFP_KERNEL); in thunder_mdiobus_pci_probe()
33 return -ENOMEM; in thunder_mdiobus_pci_probe()
37 err = pcim_enable_device(pdev); in thunder_mdiobus_pci_probe()
38 if (err) { in thunder_mdiobus_pci_probe()
39 dev_err(&pdev->dev, "Failed to enable PCI device\n"); in thunder_mdiobus_pci_probe()
41 return err; in thunder_mdiobus_pci_probe()
44 err = pci_request_regions(pdev, KBUILD_MODNAME); in thunder_mdiobus_pci_probe()
45 if (err) { in thunder_mdiobus_pci_probe()
46 dev_err(&pdev->dev, "pci_request_regions failed\n"); in thunder_mdiobus_pci_probe()
50 nexus->bar0 = pcim_iomap(pdev, 0, pci_resource_len(pdev, 0)); in thunder_mdiobus_pci_probe()
51 if (!nexus->bar0) { in thunder_mdiobus_pci_probe()
52 err = -ENOMEM; in thunder_mdiobus_pci_probe()
57 device_for_each_child_node(&pdev->dev, fwn) { in thunder_mdiobus_pci_probe()
60 struct cavium_mdiobus *bus; in thunder_mdiobus_pci_probe() local
70 err = of_address_to_resource(node, 0, &r); in thunder_mdiobus_pci_probe()
71 if (err) { in thunder_mdiobus_pci_probe()
72 dev_err(&pdev->dev, in thunder_mdiobus_pci_probe()
78 mii_bus = devm_mdiobus_alloc_size(&pdev->dev, sizeof(*bus)); in thunder_mdiobus_pci_probe()
81 bus = mii_bus->priv; in thunder_mdiobus_pci_probe()
82 bus->mii_bus = mii_bus; in thunder_mdiobus_pci_probe()
84 nexus->buses[i] = bus; in thunder_mdiobus_pci_probe()
87 bus->register_base = nexus->bar0 + in thunder_mdiobus_pci_probe()
88 r.start - pci_resource_start(pdev, 0); in thunder_mdiobus_pci_probe()
92 oct_mdio_writeq(smi_en.u64, bus->register_base + SMI_EN); in thunder_mdiobus_pci_probe()
93 bus->mii_bus->name = KBUILD_MODNAME; in thunder_mdiobus_pci_probe()
94 snprintf(bus->mii_bus->id, MII_BUS_ID_SIZE, "%llx", r.start); in thunder_mdiobus_pci_probe()
95 bus->mii_bus->parent = &pdev->dev; in thunder_mdiobus_pci_probe()
96 bus->mii_bus->read = cavium_mdiobus_read_c22; in thunder_mdiobus_pci_probe()
97 bus->mii_bus->write = cavium_mdiobus_write_c22; in thunder_mdiobus_pci_probe()
98 bus->mii_bus->read_c45 = cavium_mdiobus_read_c45; in thunder_mdiobus_pci_probe()
99 bus->mii_bus->write_c45 = cavium_mdiobus_write_c45; in thunder_mdiobus_pci_probe()
101 err = of_mdiobus_register(bus->mii_bus, node); in thunder_mdiobus_pci_probe()
102 if (err) in thunder_mdiobus_pci_probe()
103 dev_err(&pdev->dev, "of_mdiobus_register failed\n"); in thunder_mdiobus_pci_probe()
105 dev_info(&pdev->dev, "Added bus at %llx\n", r.start); in thunder_mdiobus_pci_probe()
106 if (i >= ARRAY_SIZE(nexus->buses)) in thunder_mdiobus_pci_probe()
117 return err; in thunder_mdiobus_pci_probe()
125 for (i = 0; i < ARRAY_SIZE(nexus->buses); i++) { in thunder_mdiobus_pci_remove()
126 struct cavium_mdiobus *bus = nexus->buses[i]; in thunder_mdiobus_pci_remove() local
128 if (!bus) in thunder_mdiobus_pci_remove()
131 mdiobus_unregister(bus->mii_bus); in thunder_mdiobus_pci_remove()
132 oct_mdio_writeq(0, bus->register_base + SMI_EN); in thunder_mdiobus_pci_remove()
153 MODULE_DESCRIPTION("Cavium ThunderX MDIO bus driver");