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
389 dev_warn(bus->sfp_dev, "Unable to ascertain link mode\n"); in sfp_select_interface()
398 static const struct sfp_upstream_ops *sfp_get_upstream_ops(struct sfp_bus *bus) in sfp_get_upstream_ops() argument
400 return bus->registered ? bus->upstream_ops : NULL; in sfp_get_upstream_ops()
436 struct sfp_bus *bus = container_of(kref, struct sfp_bus, kref); in sfp_bus_release() local
438 list_del(&bus->node); in sfp_bus_release()
440 kfree(bus); in sfp_bus_release()
445 * @bus: the &struct sfp_bus found via sfp_bus_find_fwnode()
450 void sfp_bus_put(struct sfp_bus *bus) in sfp_bus_put() argument
452 if (bus) in sfp_bus_put()
453 kref_put_mutex(&bus->kref, sfp_bus_release, &sfp_mutex); in sfp_bus_put()
457 static int sfp_register_bus(struct sfp_bus *bus) in sfp_register_bus() argument
459 const struct sfp_upstream_ops *ops = bus->upstream_ops; in sfp_register_bus()
464 ops->link_down(bus->upstream); in sfp_register_bus()
465 if (ops->connect_phy && bus->phydev) { in sfp_register_bus()
466 ret = ops->connect_phy(bus->upstream, bus->phydev); in sfp_register_bus()
471 bus->registered = true; in sfp_register_bus()
472 bus->socket_ops->attach(bus->sfp); in sfp_register_bus()
473 if (bus->started) in sfp_register_bus()
474 bus->socket_ops->start(bus->sfp); in sfp_register_bus()
475 bus->upstream_ops->attach(bus->upstream, bus); in sfp_register_bus()
479 static void sfp_unregister_bus(struct sfp_bus *bus) in sfp_unregister_bus() argument
481 const struct sfp_upstream_ops *ops = bus->upstream_ops; in sfp_unregister_bus()
483 if (bus->registered) { in sfp_unregister_bus()
484 bus->upstream_ops->detach(bus->upstream, bus); in sfp_unregister_bus()
485 if (bus->started) in sfp_unregister_bus()
486 bus->socket_ops->stop(bus->sfp); in sfp_unregister_bus()
487 bus->socket_ops->detach(bus->sfp); in sfp_unregister_bus()
488 if (bus->phydev && ops && ops->disconnect_phy) in sfp_unregister_bus()
489 ops->disconnect_phy(bus->upstream); in sfp_unregister_bus()
491 bus->registered = false; in sfp_unregister_bus()
496 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
500 * the sfp bus specified by @bus.
504 int sfp_get_module_info(struct sfp_bus *bus, struct ethtool_modinfo *modinfo) in sfp_get_module_info() argument
506 return bus->socket_ops->module_info(bus->sfp, modinfo); in sfp_get_module_info()
512 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
521 int sfp_get_module_eeprom(struct sfp_bus *bus, struct ethtool_eeprom *ee, in sfp_get_module_eeprom() argument
524 return bus->socket_ops->module_eeprom(bus->sfp, ee, data); in sfp_get_module_eeprom()
530 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
540 int sfp_get_module_eeprom_by_page(struct sfp_bus *bus, in sfp_get_module_eeprom_by_page() argument
544 return bus->socket_ops->module_eeprom_by_page(bus->sfp, page, extack); in sfp_get_module_eeprom_by_page()
550 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
557 void sfp_upstream_start(struct sfp_bus *bus) in sfp_upstream_start() argument
559 if (bus->registered) in sfp_upstream_start()
560 bus->socket_ops->start(bus->sfp); in sfp_upstream_start()
561 bus->started = true; in sfp_upstream_start()
567 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
574 void sfp_upstream_stop(struct sfp_bus *bus) in sfp_upstream_stop() argument
576 if (bus->registered) in sfp_upstream_stop()
577 bus->socket_ops->stop(bus->sfp); in sfp_upstream_stop()
578 bus->started = false; in sfp_upstream_stop()
582 static void sfp_upstream_clear(struct sfp_bus *bus) in sfp_upstream_clear() argument
584 bus->upstream_ops = NULL; in sfp_upstream_clear()
585 bus->upstream = NULL; in sfp_upstream_clear()
590 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
601 void sfp_upstream_set_signal_rate(struct sfp_bus *bus, unsigned int rate_kbd) in sfp_upstream_set_signal_rate() argument
603 if (bus->registered) in sfp_upstream_set_signal_rate()
604 bus->socket_ops->set_signal_rate(bus->sfp, rate_kbd); in sfp_upstream_set_signal_rate()
609 * sfp_bus_find_fwnode() - parse and locate the SFP bus from fwnode
612 * Parse the parent device's firmware node for a SFP bus, and locate
623 * - %-ENOMEM if we failed to allocate the bus.
629 struct sfp_bus *bus; in sfp_bus_find_fwnode() local
644 bus = sfp_bus_get(ref.fwnode); in sfp_bus_find_fwnode()
646 if (!bus) in sfp_bus_find_fwnode()
649 return bus; in sfp_bus_find_fwnode()
655 * @bus: the &struct sfp_bus found via sfp_bus_find_fwnode()
659 * Add upstream driver for the SFP bus, and if the bus is complete, register
660 * the SFP bus using sfp_register_upstream(). This takes a reference on the
661 * bus, so it is safe to put the bus after this call.
670 * - %-ENOMEM if we failed to allocate the bus.
673 int sfp_bus_add_upstream(struct sfp_bus *bus, void *upstream, in sfp_bus_add_upstream() argument
678 /* If no bus, return success */ in sfp_bus_add_upstream()
679 if (!bus) in sfp_bus_add_upstream()
683 kref_get(&bus->kref); in sfp_bus_add_upstream()
684 bus->upstream_ops = ops; in sfp_bus_add_upstream()
685 bus->upstream = upstream; in sfp_bus_add_upstream()
687 if (bus->sfp) { in sfp_bus_add_upstream()
688 ret = sfp_register_bus(bus); in sfp_bus_add_upstream()
690 sfp_upstream_clear(bus); in sfp_bus_add_upstream()
697 sfp_bus_put(bus); in sfp_bus_add_upstream()
704 * sfp_bus_del_upstream() - Delete a sfp bus
705 * @bus: a pointer to the &struct sfp_bus structure for the sfp module
708 * module. @bus should have been added by sfp_bus_add_upstream().
710 void sfp_bus_del_upstream(struct sfp_bus *bus) in sfp_bus_del_upstream() argument
712 if (bus) { in sfp_bus_del_upstream()
714 if (bus->sfp) in sfp_bus_del_upstream()
715 sfp_unregister_bus(bus); in sfp_bus_del_upstream()
716 sfp_upstream_clear(bus); in sfp_bus_del_upstream()
719 sfp_bus_put(bus); in sfp_bus_del_upstream()
725 int sfp_add_phy(struct sfp_bus *bus, struct phy_device *phydev) in sfp_add_phy() argument
727 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); in sfp_add_phy()
731 ret = ops->connect_phy(bus->upstream, phydev); in sfp_add_phy()
734 bus->phydev = phydev; in sfp_add_phy()
740 void sfp_remove_phy(struct sfp_bus *bus) in sfp_remove_phy() argument
742 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); in sfp_remove_phy()
745 ops->disconnect_phy(bus->upstream); in sfp_remove_phy()
746 bus->phydev = NULL; in sfp_remove_phy()
750 void sfp_link_up(struct sfp_bus *bus) in sfp_link_up() argument
752 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); in sfp_link_up()
755 ops->link_up(bus->upstream); in sfp_link_up()
759 void sfp_link_down(struct sfp_bus *bus) in sfp_link_down() argument
761 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); in sfp_link_down()
764 ops->link_down(bus->upstream); in sfp_link_down()
768 int sfp_module_insert(struct sfp_bus *bus, const struct sfp_eeprom_id *id, in sfp_module_insert() argument
771 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); in sfp_module_insert()
774 bus->sfp_quirk = quirk; in sfp_module_insert()
777 ret = ops->module_insert(bus->upstream, id); in sfp_module_insert()
783 void sfp_module_remove(struct sfp_bus *bus) in sfp_module_remove() argument
785 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); in sfp_module_remove()
788 ops->module_remove(bus->upstream); in sfp_module_remove()
790 bus->sfp_quirk = NULL; in sfp_module_remove()
794 int sfp_module_start(struct sfp_bus *bus) in sfp_module_start() argument
796 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); in sfp_module_start()
800 ret = ops->module_start(bus->upstream); in sfp_module_start()
806 void sfp_module_stop(struct sfp_bus *bus) in sfp_module_stop() argument
808 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); in sfp_module_stop()
811 ops->module_stop(bus->upstream); in sfp_module_stop()
815 static void sfp_socket_clear(struct sfp_bus *bus) in sfp_socket_clear() argument
817 bus->sfp_dev = NULL; in sfp_socket_clear()
818 bus->sfp = NULL; in sfp_socket_clear()
819 bus->socket_ops = NULL; in sfp_socket_clear()
825 struct sfp_bus *bus = sfp_bus_get(dev->fwnode); in sfp_register_socket() local
828 if (bus) { in sfp_register_socket()
830 bus->sfp_dev = dev; in sfp_register_socket()
831 bus->sfp = sfp; in sfp_register_socket()
832 bus->socket_ops = ops; in sfp_register_socket()
834 if (bus->upstream_ops) { in sfp_register_socket()
835 ret = sfp_register_bus(bus); in sfp_register_socket()
837 sfp_socket_clear(bus); in sfp_register_socket()
843 sfp_bus_put(bus); in sfp_register_socket()
844 bus = NULL; in sfp_register_socket()
847 return bus; in sfp_register_socket()
851 void sfp_unregister_socket(struct sfp_bus *bus) in sfp_unregister_socket() argument
854 if (bus->upstream_ops) in sfp_unregister_socket()
855 sfp_unregister_bus(bus); in sfp_unregister_socket()
856 sfp_socket_clear(bus); in sfp_unregister_socket()
859 sfp_bus_put(bus); in sfp_unregister_socket()