Lines Matching full:bus
20 * struct sfp_bus - internal representation of a sfp bus
124 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
136 int sfp_parse_port(struct sfp_bus *bus, const struct sfp_eeprom_id *id, in sfp_parse_port() argument
175 dev_warn(bus->sfp_dev, "SFP: unknown connector id 0x%02x\n", in sfp_parse_port()
199 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
205 bool sfp_may_have_phy(struct sfp_bus *bus, const struct sfp_eeprom_id *id) in sfp_may_have_phy() argument
226 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
233 void sfp_parse_support(struct sfp_bus *bus, const struct sfp_eeprom_id *id, in sfp_parse_support() argument
335 dev_warn(bus->sfp_dev, in sfp_parse_support()
362 if (bus->sfp_quirk) in sfp_parse_support()
363 bus->sfp_quirk->modes(id, modes); in sfp_parse_support()
375 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
381 phy_interface_t sfp_select_interface(struct sfp_bus *bus, in sfp_select_interface() argument
402 dev_warn(bus->sfp_dev, "Unable to ascertain link mode\n"); in sfp_select_interface()
411 static const struct sfp_upstream_ops *sfp_get_upstream_ops(struct sfp_bus *bus) in sfp_get_upstream_ops() argument
413 return bus->registered ? bus->upstream_ops : NULL; in sfp_get_upstream_ops()
449 struct sfp_bus *bus = container_of(kref, struct sfp_bus, kref); in sfp_bus_release() local
451 list_del(&bus->node); in sfp_bus_release()
453 kfree(bus); in sfp_bus_release()
458 * @bus: the &struct sfp_bus found via sfp_bus_find_fwnode()
463 void sfp_bus_put(struct sfp_bus *bus) in sfp_bus_put() argument
465 if (bus) in sfp_bus_put()
466 kref_put_mutex(&bus->kref, sfp_bus_release, &sfp_mutex); in sfp_bus_put()
470 static int sfp_register_bus(struct sfp_bus *bus) in sfp_register_bus() argument
472 const struct sfp_upstream_ops *ops = bus->upstream_ops; in sfp_register_bus()
477 ops->link_down(bus->upstream); in sfp_register_bus()
478 if (ops->connect_phy && bus->phydev) { in sfp_register_bus()
479 ret = ops->connect_phy(bus->upstream, bus->phydev); in sfp_register_bus()
484 bus->registered = true; in sfp_register_bus()
485 bus->socket_ops->attach(bus->sfp); in sfp_register_bus()
486 if (bus->started) in sfp_register_bus()
487 bus->socket_ops->start(bus->sfp); in sfp_register_bus()
488 bus->upstream_ops->attach(bus->upstream, bus); in sfp_register_bus()
492 static void sfp_unregister_bus(struct sfp_bus *bus) in sfp_unregister_bus() argument
494 const struct sfp_upstream_ops *ops = bus->upstream_ops; in sfp_unregister_bus()
496 if (bus->registered) { in sfp_unregister_bus()
497 bus->upstream_ops->detach(bus->upstream, bus); in sfp_unregister_bus()
498 if (bus->started) in sfp_unregister_bus()
499 bus->socket_ops->stop(bus->sfp); in sfp_unregister_bus()
500 bus->socket_ops->detach(bus->sfp); in sfp_unregister_bus()
501 if (bus->phydev && ops && ops->disconnect_phy) in sfp_unregister_bus()
502 ops->disconnect_phy(bus->upstream); in sfp_unregister_bus()
504 bus->registered = false; in sfp_unregister_bus()
509 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
513 * the sfp bus specified by @bus.
517 int sfp_get_module_info(struct sfp_bus *bus, struct ethtool_modinfo *modinfo) in sfp_get_module_info() argument
519 return bus->socket_ops->module_info(bus->sfp, modinfo); in sfp_get_module_info()
525 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
534 int sfp_get_module_eeprom(struct sfp_bus *bus, struct ethtool_eeprom *ee, in sfp_get_module_eeprom() argument
537 return bus->socket_ops->module_eeprom(bus->sfp, ee, data); in sfp_get_module_eeprom()
543 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
550 void sfp_upstream_start(struct sfp_bus *bus) in sfp_upstream_start() argument
552 if (bus->registered) in sfp_upstream_start()
553 bus->socket_ops->start(bus->sfp); in sfp_upstream_start()
554 bus->started = true; in sfp_upstream_start()
560 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
567 void sfp_upstream_stop(struct sfp_bus *bus) in sfp_upstream_stop() argument
569 if (bus->registered) in sfp_upstream_stop()
570 bus->socket_ops->stop(bus->sfp); in sfp_upstream_stop()
571 bus->started = false; in sfp_upstream_stop()
575 static void sfp_upstream_clear(struct sfp_bus *bus) in sfp_upstream_clear() argument
577 bus->upstream_ops = NULL; in sfp_upstream_clear()
578 bus->upstream = NULL; in sfp_upstream_clear()
582 * sfp_bus_find_fwnode() - parse and locate the SFP bus from fwnode
585 * Parse the parent device's firmware node for a SFP bus, and locate
596 * - %-ENOMEM if we failed to allocate the bus.
602 struct sfp_bus *bus; in sfp_bus_find_fwnode() local
612 bus = sfp_bus_get(ref.fwnode); in sfp_bus_find_fwnode()
614 if (!bus) in sfp_bus_find_fwnode()
617 return bus; in sfp_bus_find_fwnode()
623 * @bus: the &struct sfp_bus found via sfp_bus_find_fwnode()
627 * Add upstream driver for the SFP bus, and if the bus is complete, register
628 * the SFP bus using sfp_register_upstream(). This takes a reference on the
629 * bus, so it is safe to put the bus after this call.
638 * - %-ENOMEM if we failed to allocate the bus.
641 int sfp_bus_add_upstream(struct sfp_bus *bus, void *upstream, in sfp_bus_add_upstream() argument
646 /* If no bus, return success */ in sfp_bus_add_upstream()
647 if (!bus) in sfp_bus_add_upstream()
651 kref_get(&bus->kref); in sfp_bus_add_upstream()
652 bus->upstream_ops = ops; in sfp_bus_add_upstream()
653 bus->upstream = upstream; in sfp_bus_add_upstream()
655 if (bus->sfp) { in sfp_bus_add_upstream()
656 ret = sfp_register_bus(bus); in sfp_bus_add_upstream()
658 sfp_upstream_clear(bus); in sfp_bus_add_upstream()
665 sfp_bus_put(bus); in sfp_bus_add_upstream()
672 * sfp_bus_del_upstream() - Delete a sfp bus
673 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
676 * module. @bus should have been added by sfp_bus_add_upstream().
678 void sfp_bus_del_upstream(struct sfp_bus *bus) in sfp_bus_del_upstream() argument
680 if (bus) { in sfp_bus_del_upstream()
682 if (bus->sfp) in sfp_bus_del_upstream()
683 sfp_unregister_bus(bus); in sfp_bus_del_upstream()
684 sfp_upstream_clear(bus); in sfp_bus_del_upstream()
687 sfp_bus_put(bus); in sfp_bus_del_upstream()
693 int sfp_add_phy(struct sfp_bus *bus, struct phy_device *phydev) in sfp_add_phy() argument
695 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); in sfp_add_phy()
699 ret = ops->connect_phy(bus->upstream, phydev); in sfp_add_phy()
702 bus->phydev = phydev; in sfp_add_phy()
708 void sfp_remove_phy(struct sfp_bus *bus) in sfp_remove_phy() argument
710 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); in sfp_remove_phy()
713 ops->disconnect_phy(bus->upstream); in sfp_remove_phy()
714 bus->phydev = NULL; in sfp_remove_phy()
718 void sfp_link_up(struct sfp_bus *bus) in sfp_link_up() argument
720 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); in sfp_link_up()
723 ops->link_up(bus->upstream); in sfp_link_up()
727 void sfp_link_down(struct sfp_bus *bus) in sfp_link_down() argument
729 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); in sfp_link_down()
732 ops->link_down(bus->upstream); in sfp_link_down()
736 int sfp_module_insert(struct sfp_bus *bus, const struct sfp_eeprom_id *id) in sfp_module_insert() argument
738 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); in sfp_module_insert()
741 bus->sfp_quirk = sfp_lookup_quirk(id); in sfp_module_insert()
744 ret = ops->module_insert(bus->upstream, id); in sfp_module_insert()
750 void sfp_module_remove(struct sfp_bus *bus) in sfp_module_remove() argument
752 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); in sfp_module_remove()
755 ops->module_remove(bus->upstream); in sfp_module_remove()
757 bus->sfp_quirk = NULL; in sfp_module_remove()
761 int sfp_module_start(struct sfp_bus *bus) in sfp_module_start() argument
763 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); in sfp_module_start()
767 ret = ops->module_start(bus->upstream); in sfp_module_start()
773 void sfp_module_stop(struct sfp_bus *bus) in sfp_module_stop() argument
775 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); in sfp_module_stop()
778 ops->module_stop(bus->upstream); in sfp_module_stop()
782 static void sfp_socket_clear(struct sfp_bus *bus) in sfp_socket_clear() argument
784 bus->sfp_dev = NULL; in sfp_socket_clear()
785 bus->sfp = NULL; in sfp_socket_clear()
786 bus->socket_ops = NULL; in sfp_socket_clear()
792 struct sfp_bus *bus = sfp_bus_get(dev->fwnode); in sfp_register_socket() local
795 if (bus) { in sfp_register_socket()
797 bus->sfp_dev = dev; in sfp_register_socket()
798 bus->sfp = sfp; in sfp_register_socket()
799 bus->socket_ops = ops; in sfp_register_socket()
801 if (bus->upstream_ops) { in sfp_register_socket()
802 ret = sfp_register_bus(bus); in sfp_register_socket()
804 sfp_socket_clear(bus); in sfp_register_socket()
810 sfp_bus_put(bus); in sfp_register_socket()
811 bus = NULL; in sfp_register_socket()
814 return bus; in sfp_register_socket()
818 void sfp_unregister_socket(struct sfp_bus *bus) in sfp_unregister_socket() argument
821 if (bus->upstream_ops) in sfp_unregister_socket()
822 sfp_unregister_bus(bus); in sfp_unregister_socket()
823 sfp_socket_clear(bus); in sfp_unregister_socket()
826 sfp_bus_put(bus); in sfp_unregister_socket()