Lines Matching full:bus

14  * struct sfp_bus - internal representation of a sfp bus
37 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
49 int sfp_parse_port(struct sfp_bus *bus, const struct sfp_eeprom_id *id, in sfp_parse_port() argument
88 dev_warn(bus->sfp_dev, "SFP: unknown connector id 0x%02x\n", in sfp_parse_port()
112 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
118 bool sfp_may_have_phy(struct sfp_bus *bus, const struct sfp_eeprom_id *id) in sfp_may_have_phy() argument
139 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
148 void sfp_parse_support(struct sfp_bus *bus, const struct sfp_eeprom_id *id, in sfp_parse_support() argument
298 dev_warn(bus->sfp_dev, in sfp_parse_support()
342 if (bus->sfp_quirk && bus->sfp_quirk->modes) in sfp_parse_support()
343 bus->sfp_quirk->modes(id, modes, interfaces); in sfp_parse_support()
351 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
357 phy_interface_t sfp_select_interface(struct sfp_bus *bus, in sfp_select_interface() argument
390 dev_warn(bus->sfp_dev, "Unable to ascertain link mode\n"); in sfp_select_interface()
399 static const struct sfp_upstream_ops *sfp_get_upstream_ops(struct sfp_bus *bus) in sfp_get_upstream_ops() argument
401 return bus->registered ? bus->upstream_ops : NULL; in sfp_get_upstream_ops()
437 struct sfp_bus *bus = container_of(kref, struct sfp_bus, kref); in sfp_bus_release() local
439 list_del(&bus->node); in sfp_bus_release()
441 kfree(bus); in sfp_bus_release()
446 * @bus: the &struct sfp_bus found via sfp_bus_find_fwnode()
451 void sfp_bus_put(struct sfp_bus *bus) in sfp_bus_put() argument
453 if (bus) in sfp_bus_put()
454 kref_put_mutex(&bus->kref, sfp_bus_release, &sfp_mutex); in sfp_bus_put()
458 static int sfp_register_bus(struct sfp_bus *bus) in sfp_register_bus() argument
460 const struct sfp_upstream_ops *ops = bus->upstream_ops; in sfp_register_bus()
465 ops->link_down(bus->upstream); in sfp_register_bus()
466 if (ops->connect_phy && bus->phydev) { in sfp_register_bus()
467 ret = ops->connect_phy(bus->upstream, bus->phydev); in sfp_register_bus()
472 bus->registered = true; in sfp_register_bus()
473 bus->socket_ops->attach(bus->sfp); in sfp_register_bus()
474 if (bus->started) in sfp_register_bus()
475 bus->socket_ops->start(bus->sfp); in sfp_register_bus()
476 bus->upstream_ops->attach(bus->upstream, bus); in sfp_register_bus()
480 static void sfp_unregister_bus(struct sfp_bus *bus) in sfp_unregister_bus() argument
482 const struct sfp_upstream_ops *ops = bus->upstream_ops; in sfp_unregister_bus()
484 if (bus->registered) { in sfp_unregister_bus()
485 bus->upstream_ops->detach(bus->upstream, bus); in sfp_unregister_bus()
486 if (bus->started) in sfp_unregister_bus()
487 bus->socket_ops->stop(bus->sfp); in sfp_unregister_bus()
488 bus->socket_ops->detach(bus->sfp); in sfp_unregister_bus()
489 if (bus->phydev && ops && ops->disconnect_phy) in sfp_unregister_bus()
490 ops->disconnect_phy(bus->upstream, bus->phydev); in sfp_unregister_bus()
492 bus->registered = false; in sfp_unregister_bus()
497 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
501 * the sfp bus specified by @bus.
505 int sfp_get_module_info(struct sfp_bus *bus, struct ethtool_modinfo *modinfo) in sfp_get_module_info() argument
507 return bus->socket_ops->module_info(bus->sfp, modinfo); in sfp_get_module_info()
513 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
522 int sfp_get_module_eeprom(struct sfp_bus *bus, struct ethtool_eeprom *ee, in sfp_get_module_eeprom() argument
525 return bus->socket_ops->module_eeprom(bus->sfp, ee, data); in sfp_get_module_eeprom()
531 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
541 int sfp_get_module_eeprom_by_page(struct sfp_bus *bus, in sfp_get_module_eeprom_by_page() argument
545 return bus->socket_ops->module_eeprom_by_page(bus->sfp, page, extack); in sfp_get_module_eeprom_by_page()
551 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
558 void sfp_upstream_start(struct sfp_bus *bus) in sfp_upstream_start() argument
560 if (bus->registered) in sfp_upstream_start()
561 bus->socket_ops->start(bus->sfp); in sfp_upstream_start()
562 bus->started = true; in sfp_upstream_start()
568 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
575 void sfp_upstream_stop(struct sfp_bus *bus) in sfp_upstream_stop() argument
577 if (bus->registered) in sfp_upstream_stop()
578 bus->socket_ops->stop(bus->sfp); in sfp_upstream_stop()
579 bus->started = false; in sfp_upstream_stop()
583 static void sfp_upstream_clear(struct sfp_bus *bus) in sfp_upstream_clear() argument
585 bus->upstream_ops = NULL; in sfp_upstream_clear()
586 bus->upstream = NULL; in sfp_upstream_clear()
591 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
602 void sfp_upstream_set_signal_rate(struct sfp_bus *bus, unsigned int rate_kbd) in sfp_upstream_set_signal_rate() argument
604 if (bus->registered) in sfp_upstream_set_signal_rate()
605 bus->socket_ops->set_signal_rate(bus->sfp, rate_kbd); in sfp_upstream_set_signal_rate()
610 * sfp_bus_find_fwnode() - parse and locate the SFP bus from fwnode
613 * Parse the parent device's firmware node for a SFP bus, and locate
624 * - %-ENOMEM if we failed to allocate the bus.
630 struct sfp_bus *bus; in sfp_bus_find_fwnode() local
645 bus = sfp_bus_get(ref.fwnode); in sfp_bus_find_fwnode()
647 if (!bus) in sfp_bus_find_fwnode()
650 return bus; in sfp_bus_find_fwnode()
656 * @bus: the &struct sfp_bus found via sfp_bus_find_fwnode()
660 * Add upstream driver for the SFP bus, and if the bus is complete, register
661 * the SFP bus using sfp_register_upstream(). This takes a reference on the
662 * bus, so it is safe to put the bus after this call.
671 * - %-ENOMEM if we failed to allocate the bus.
674 int sfp_bus_add_upstream(struct sfp_bus *bus, void *upstream, in sfp_bus_add_upstream() argument
679 /* If no bus, return success */ in sfp_bus_add_upstream()
680 if (!bus) in sfp_bus_add_upstream()
684 kref_get(&bus->kref); in sfp_bus_add_upstream()
685 bus->upstream_ops = ops; in sfp_bus_add_upstream()
686 bus->upstream = upstream; in sfp_bus_add_upstream()
688 if (bus->sfp) { in sfp_bus_add_upstream()
689 ret = sfp_register_bus(bus); in sfp_bus_add_upstream()
691 sfp_upstream_clear(bus); in sfp_bus_add_upstream()
698 sfp_bus_put(bus); in sfp_bus_add_upstream()
705 * sfp_bus_del_upstream() - Delete a sfp bus
706 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
709 * module. @bus should have been added by sfp_bus_add_upstream().
711 void sfp_bus_del_upstream(struct sfp_bus *bus) in sfp_bus_del_upstream() argument
713 if (bus) { in sfp_bus_del_upstream()
715 if (bus->sfp) in sfp_bus_del_upstream()
716 sfp_unregister_bus(bus); in sfp_bus_del_upstream()
717 sfp_upstream_clear(bus); in sfp_bus_del_upstream()
720 sfp_bus_put(bus); in sfp_bus_del_upstream()
727 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
729 * Gets the SFP device's name, if @bus has a registered socket. Callers must
734 * - %NULL if no device was registered on @bus
736 const char *sfp_get_name(struct sfp_bus *bus) in sfp_get_name() argument
740 if (bus->sfp_dev) in sfp_get_name()
741 return dev_name(bus->sfp_dev); in sfp_get_name()
748 int sfp_add_phy(struct sfp_bus *bus, struct phy_device *phydev) in sfp_add_phy() argument
750 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); in sfp_add_phy()
754 ret = ops->connect_phy(bus->upstream, phydev); in sfp_add_phy()
757 bus->phydev = phydev; in sfp_add_phy()
763 void sfp_remove_phy(struct sfp_bus *bus) in sfp_remove_phy() argument
765 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); in sfp_remove_phy()
768 ops->disconnect_phy(bus->upstream, bus->phydev); in sfp_remove_phy()
769 bus->phydev = NULL; in sfp_remove_phy()
773 void sfp_link_up(struct sfp_bus *bus) in sfp_link_up() argument
775 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); in sfp_link_up()
778 ops->link_up(bus->upstream); in sfp_link_up()
782 void sfp_link_down(struct sfp_bus *bus) in sfp_link_down() argument
784 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); in sfp_link_down()
787 ops->link_down(bus->upstream); in sfp_link_down()
791 int sfp_module_insert(struct sfp_bus *bus, const struct sfp_eeprom_id *id, in sfp_module_insert() argument
794 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); in sfp_module_insert()
797 bus->sfp_quirk = quirk; in sfp_module_insert()
800 ret = ops->module_insert(bus->upstream, id); in sfp_module_insert()
806 void sfp_module_remove(struct sfp_bus *bus) in sfp_module_remove() argument
808 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); in sfp_module_remove()
811 ops->module_remove(bus->upstream); in sfp_module_remove()
813 bus->sfp_quirk = NULL; in sfp_module_remove()
817 int sfp_module_start(struct sfp_bus *bus) in sfp_module_start() argument
819 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); in sfp_module_start()
823 ret = ops->module_start(bus->upstream); in sfp_module_start()
829 void sfp_module_stop(struct sfp_bus *bus) in sfp_module_stop() argument
831 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); in sfp_module_stop()
834 ops->module_stop(bus->upstream); in sfp_module_stop()
838 static void sfp_socket_clear(struct sfp_bus *bus) in sfp_socket_clear() argument
840 bus->sfp_dev = NULL; in sfp_socket_clear()
841 bus->sfp = NULL; in sfp_socket_clear()
842 bus->socket_ops = NULL; in sfp_socket_clear()
848 struct sfp_bus *bus = sfp_bus_get(dev->fwnode); in sfp_register_socket() local
851 if (bus) { in sfp_register_socket()
853 bus->sfp_dev = dev; in sfp_register_socket()
854 bus->sfp = sfp; in sfp_register_socket()
855 bus->socket_ops = ops; in sfp_register_socket()
857 if (bus->upstream_ops) { in sfp_register_socket()
858 ret = sfp_register_bus(bus); in sfp_register_socket()
860 sfp_socket_clear(bus); in sfp_register_socket()
866 sfp_bus_put(bus); in sfp_register_socket()
867 bus = NULL; in sfp_register_socket()
870 return bus; in sfp_register_socket()
874 void sfp_unregister_socket(struct sfp_bus *bus) in sfp_unregister_socket() argument
877 if (bus->upstream_ops) in sfp_unregister_socket()
878 sfp_unregister_bus(bus); in sfp_unregister_socket()
879 sfp_socket_clear(bus); in sfp_unregister_socket()
882 sfp_bus_put(bus); in sfp_unregister_socket()