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
341 dev_warn(bus->sfp_dev, in sfp_parse_support()
373 if (bus->sfp_quirk) in sfp_parse_support()
374 bus->sfp_quirk->modes(id, modes); in sfp_parse_support()
386 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
392 phy_interface_t sfp_select_interface(struct sfp_bus *bus, in sfp_select_interface() argument
424 dev_warn(bus->sfp_dev, "Unable to ascertain link mode\n"); in sfp_select_interface()
433 static const struct sfp_upstream_ops *sfp_get_upstream_ops(struct sfp_bus *bus) in sfp_get_upstream_ops() argument
435 return bus->registered ? bus->upstream_ops : NULL; in sfp_get_upstream_ops()
471 struct sfp_bus *bus = container_of(kref, struct sfp_bus, kref); in sfp_bus_release() local
473 list_del(&bus->node); in sfp_bus_release()
475 kfree(bus); in sfp_bus_release()
480 * @bus: the &struct sfp_bus found via sfp_bus_find_fwnode()
485 void sfp_bus_put(struct sfp_bus *bus) in sfp_bus_put() argument
487 if (bus) in sfp_bus_put()
488 kref_put_mutex(&bus->kref, sfp_bus_release, &sfp_mutex); in sfp_bus_put()
492 static int sfp_register_bus(struct sfp_bus *bus) in sfp_register_bus() argument
494 const struct sfp_upstream_ops *ops = bus->upstream_ops; in sfp_register_bus()
499 ops->link_down(bus->upstream); in sfp_register_bus()
500 if (ops->connect_phy && bus->phydev) { in sfp_register_bus()
501 ret = ops->connect_phy(bus->upstream, bus->phydev); in sfp_register_bus()
506 bus->registered = true; in sfp_register_bus()
507 bus->socket_ops->attach(bus->sfp); in sfp_register_bus()
508 if (bus->started) in sfp_register_bus()
509 bus->socket_ops->start(bus->sfp); in sfp_register_bus()
510 bus->upstream_ops->attach(bus->upstream, bus); in sfp_register_bus()
514 static void sfp_unregister_bus(struct sfp_bus *bus) in sfp_unregister_bus() argument
516 const struct sfp_upstream_ops *ops = bus->upstream_ops; in sfp_unregister_bus()
518 if (bus->registered) { in sfp_unregister_bus()
519 bus->upstream_ops->detach(bus->upstream, bus); in sfp_unregister_bus()
520 if (bus->started) in sfp_unregister_bus()
521 bus->socket_ops->stop(bus->sfp); in sfp_unregister_bus()
522 bus->socket_ops->detach(bus->sfp); in sfp_unregister_bus()
523 if (bus->phydev && ops && ops->disconnect_phy) in sfp_unregister_bus()
524 ops->disconnect_phy(bus->upstream); in sfp_unregister_bus()
526 bus->registered = false; in sfp_unregister_bus()
531 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
535 * the sfp bus specified by @bus.
539 int sfp_get_module_info(struct sfp_bus *bus, struct ethtool_modinfo *modinfo) in sfp_get_module_info() argument
541 return bus->socket_ops->module_info(bus->sfp, modinfo); in sfp_get_module_info()
547 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
556 int sfp_get_module_eeprom(struct sfp_bus *bus, struct ethtool_eeprom *ee, in sfp_get_module_eeprom() argument
559 return bus->socket_ops->module_eeprom(bus->sfp, ee, data); in sfp_get_module_eeprom()
565 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
575 int sfp_get_module_eeprom_by_page(struct sfp_bus *bus, in sfp_get_module_eeprom_by_page() argument
579 return bus->socket_ops->module_eeprom_by_page(bus->sfp, page, extack); in sfp_get_module_eeprom_by_page()
585 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
592 void sfp_upstream_start(struct sfp_bus *bus) in sfp_upstream_start() argument
594 if (bus->registered) in sfp_upstream_start()
595 bus->socket_ops->start(bus->sfp); in sfp_upstream_start()
596 bus->started = true; in sfp_upstream_start()
602 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
609 void sfp_upstream_stop(struct sfp_bus *bus) in sfp_upstream_stop() argument
611 if (bus->registered) in sfp_upstream_stop()
612 bus->socket_ops->stop(bus->sfp); in sfp_upstream_stop()
613 bus->started = false; in sfp_upstream_stop()
617 static void sfp_upstream_clear(struct sfp_bus *bus) in sfp_upstream_clear() argument
619 bus->upstream_ops = NULL; in sfp_upstream_clear()
620 bus->upstream = NULL; in sfp_upstream_clear()
624 * sfp_bus_find_fwnode() - parse and locate the SFP bus from fwnode
627 * Parse the parent device's firmware node for a SFP bus, and locate
638 * - %-ENOMEM if we failed to allocate the bus.
644 struct sfp_bus *bus; in sfp_bus_find_fwnode() local
654 bus = sfp_bus_get(ref.fwnode); in sfp_bus_find_fwnode()
656 if (!bus) in sfp_bus_find_fwnode()
659 return bus; in sfp_bus_find_fwnode()
665 * @bus: the &struct sfp_bus found via sfp_bus_find_fwnode()
669 * Add upstream driver for the SFP bus, and if the bus is complete, register
670 * the SFP bus using sfp_register_upstream(). This takes a reference on the
671 * bus, so it is safe to put the bus after this call.
680 * - %-ENOMEM if we failed to allocate the bus.
683 int sfp_bus_add_upstream(struct sfp_bus *bus, void *upstream, in sfp_bus_add_upstream() argument
688 /* If no bus, return success */ in sfp_bus_add_upstream()
689 if (!bus) in sfp_bus_add_upstream()
693 kref_get(&bus->kref); in sfp_bus_add_upstream()
694 bus->upstream_ops = ops; in sfp_bus_add_upstream()
695 bus->upstream = upstream; in sfp_bus_add_upstream()
697 if (bus->sfp) { in sfp_bus_add_upstream()
698 ret = sfp_register_bus(bus); in sfp_bus_add_upstream()
700 sfp_upstream_clear(bus); in sfp_bus_add_upstream()
707 sfp_bus_put(bus); in sfp_bus_add_upstream()
714 * sfp_bus_del_upstream() - Delete a sfp bus
715 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
718 * module. @bus should have been added by sfp_bus_add_upstream().
720 void sfp_bus_del_upstream(struct sfp_bus *bus) in sfp_bus_del_upstream() argument
722 if (bus) { in sfp_bus_del_upstream()
724 if (bus->sfp) in sfp_bus_del_upstream()
725 sfp_unregister_bus(bus); in sfp_bus_del_upstream()
726 sfp_upstream_clear(bus); in sfp_bus_del_upstream()
729 sfp_bus_put(bus); in sfp_bus_del_upstream()
735 int sfp_add_phy(struct sfp_bus *bus, struct phy_device *phydev) in sfp_add_phy() argument
737 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); in sfp_add_phy()
741 ret = ops->connect_phy(bus->upstream, phydev); in sfp_add_phy()
744 bus->phydev = phydev; in sfp_add_phy()
750 void sfp_remove_phy(struct sfp_bus *bus) in sfp_remove_phy() argument
752 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); in sfp_remove_phy()
755 ops->disconnect_phy(bus->upstream); in sfp_remove_phy()
756 bus->phydev = NULL; in sfp_remove_phy()
760 void sfp_link_up(struct sfp_bus *bus) in sfp_link_up() argument
762 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); in sfp_link_up()
765 ops->link_up(bus->upstream); in sfp_link_up()
769 void sfp_link_down(struct sfp_bus *bus) in sfp_link_down() argument
771 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); in sfp_link_down()
774 ops->link_down(bus->upstream); in sfp_link_down()
778 int sfp_module_insert(struct sfp_bus *bus, const struct sfp_eeprom_id *id) in sfp_module_insert() argument
780 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); in sfp_module_insert()
783 bus->sfp_quirk = sfp_lookup_quirk(id); in sfp_module_insert()
786 ret = ops->module_insert(bus->upstream, id); in sfp_module_insert()
792 void sfp_module_remove(struct sfp_bus *bus) in sfp_module_remove() argument
794 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); in sfp_module_remove()
797 ops->module_remove(bus->upstream); in sfp_module_remove()
799 bus->sfp_quirk = NULL; in sfp_module_remove()
803 int sfp_module_start(struct sfp_bus *bus) in sfp_module_start() argument
805 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); in sfp_module_start()
809 ret = ops->module_start(bus->upstream); in sfp_module_start()
815 void sfp_module_stop(struct sfp_bus *bus) in sfp_module_stop() argument
817 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); in sfp_module_stop()
820 ops->module_stop(bus->upstream); in sfp_module_stop()
824 static void sfp_socket_clear(struct sfp_bus *bus) in sfp_socket_clear() argument
826 bus->sfp_dev = NULL; in sfp_socket_clear()
827 bus->sfp = NULL; in sfp_socket_clear()
828 bus->socket_ops = NULL; in sfp_socket_clear()
834 struct sfp_bus *bus = sfp_bus_get(dev->fwnode); in sfp_register_socket() local
837 if (bus) { in sfp_register_socket()
839 bus->sfp_dev = dev; in sfp_register_socket()
840 bus->sfp = sfp; in sfp_register_socket()
841 bus->socket_ops = ops; in sfp_register_socket()
843 if (bus->upstream_ops) { in sfp_register_socket()
844 ret = sfp_register_bus(bus); in sfp_register_socket()
846 sfp_socket_clear(bus); in sfp_register_socket()
852 sfp_bus_put(bus); in sfp_register_socket()
853 bus = NULL; in sfp_register_socket()
856 return bus; in sfp_register_socket()
860 void sfp_unregister_socket(struct sfp_bus *bus) in sfp_unregister_socket() argument
863 if (bus->upstream_ops) in sfp_unregister_socket()
864 sfp_unregister_bus(bus); in sfp_unregister_socket()
865 sfp_socket_clear(bus); in sfp_unregister_socket()
868 sfp_bus_put(bus); in sfp_unregister_socket()