#include <linux/slab.h>
#include <linux/errno.h>
#include <linux/delay.h>
#include <linux/pm_runtime.h>
#include <linux/platform_data/x86/apple.h>
#include "tb.h"
#include "tb_regs.h"
#include "tunnel.h"
#define TB_TIMEOUT …
#define TB_RELEASE_BW_TIMEOUT …
#define TB_ASYM_MIN …
#define TB_ASYM_THRESHOLD …
#define MAX_GROUPS …
static unsigned int asym_threshold = …;
module_param_named(asym_threshold, asym_threshold, uint, 0444);
MODULE_PARM_DESC(…) …;
struct tb_cm { … };
static inline struct tb *tcm_to_tb(struct tb_cm *tcm)
{ … }
struct tb_hotplug_event { … };
static void tb_handle_hotplug(struct work_struct *work);
static void tb_queue_hotplug(struct tb *tb, u64 route, u8 port, bool unplug)
{ … }
static void tb_add_dp_resources(struct tb_switch *sw)
{ … }
static void tb_remove_dp_resources(struct tb_switch *sw)
{ … }
static void tb_discover_dp_resource(struct tb *tb, struct tb_port *port)
{ … }
static void tb_discover_dp_resources(struct tb *tb)
{ … }
static int tb_enable_clx(struct tb_switch *sw)
{ … }
static bool tb_disable_clx(struct tb_switch *sw)
{ … }
static int tb_increase_switch_tmu_accuracy(struct device *dev, void *data)
{ … }
static void tb_increase_tmu_accuracy(struct tb_tunnel *tunnel)
{ … }
static int tb_enable_tmu(struct tb_switch *sw)
{ … }
static void tb_switch_discover_tunnels(struct tb_switch *sw,
struct list_head *list,
bool alloc_hopids)
{ … }
static int tb_port_configure_xdomain(struct tb_port *port, struct tb_xdomain *xd)
{ … }
static void tb_port_unconfigure_xdomain(struct tb_port *port)
{ … }
static void tb_scan_xdomain(struct tb_port *port)
{ … }
static struct tb_port *tb_find_unused_port(struct tb_switch *sw,
enum tb_port_type type)
{ … }
static struct tb_port *tb_find_usb3_down(struct tb_switch *sw,
const struct tb_port *port)
{ … }
static struct tb_tunnel *tb_find_tunnel(struct tb *tb, enum tb_tunnel_type type,
struct tb_port *src_port,
struct tb_port *dst_port)
{ … }
static struct tb_tunnel *tb_find_first_usb3_tunnel(struct tb *tb,
struct tb_port *src_port,
struct tb_port *dst_port)
{ … }
static int tb_consumed_usb3_pcie_bandwidth(struct tb *tb,
struct tb_port *src_port,
struct tb_port *dst_port,
struct tb_port *port,
int *consumed_up,
int *consumed_down)
{ … }
static int tb_consumed_dp_bandwidth(struct tb *tb,
struct tb_port *src_port,
struct tb_port *dst_port,
struct tb_port *port,
int *consumed_up,
int *consumed_down)
{ … }
static bool tb_asym_supported(struct tb_port *src_port, struct tb_port *dst_port,
struct tb_port *port)
{ … }
static int tb_maximum_bandwidth(struct tb *tb, struct tb_port *src_port,
struct tb_port *dst_port, struct tb_port *port,
int *max_up, int *max_down, bool include_asym)
{ … }
static int tb_available_bandwidth(struct tb *tb, struct tb_port *src_port,
struct tb_port *dst_port, int *available_up,
int *available_down, bool include_asym)
{ … }
static int tb_release_unused_usb3_bandwidth(struct tb *tb,
struct tb_port *src_port,
struct tb_port *dst_port)
{ … }
static void tb_reclaim_usb3_bandwidth(struct tb *tb, struct tb_port *src_port,
struct tb_port *dst_port)
{ … }
static int tb_tunnel_usb3(struct tb *tb, struct tb_switch *sw)
{ … }
static int tb_create_usb3_tunnels(struct tb_switch *sw)
{ … }
static int tb_configure_asym(struct tb *tb, struct tb_port *src_port,
struct tb_port *dst_port, int requested_up,
int requested_down)
{ … }
static int tb_configure_sym(struct tb *tb, struct tb_port *src_port,
struct tb_port *dst_port, bool keep_asym)
{ … }
static void tb_configure_link(struct tb_port *down, struct tb_port *up,
struct tb_switch *sw)
{ … }
static void tb_scan_port(struct tb_port *port);
static void tb_scan_switch(struct tb_switch *sw)
{ … }
static void tb_scan_port(struct tb_port *port)
{ … }
static void
tb_recalc_estimated_bandwidth_for_group(struct tb_bandwidth_group *group)
{ … }
static void tb_recalc_estimated_bandwidth(struct tb *tb)
{ … }
static bool __release_group_bandwidth(struct tb_bandwidth_group *group)
{ … }
static void __configure_group_sym(struct tb_bandwidth_group *group)
{ … }
static void tb_bandwidth_group_release_work(struct work_struct *work)
{ … }
static void tb_init_bandwidth_groups(struct tb_cm *tcm)
{ … }
static void tb_bandwidth_group_attach_port(struct tb_bandwidth_group *group,
struct tb_port *in)
{ … }
static struct tb_bandwidth_group *tb_find_free_bandwidth_group(struct tb_cm *tcm)
{ … }
static struct tb_bandwidth_group *
tb_attach_bandwidth_group(struct tb_cm *tcm, struct tb_port *in,
struct tb_port *out)
{ … }
static void tb_discover_bandwidth_group(struct tb_cm *tcm, struct tb_port *in,
struct tb_port *out)
{ … }
static void tb_detach_bandwidth_group(struct tb_port *in)
{ … }
static void tb_discover_tunnels(struct tb *tb)
{ … }
static void tb_deactivate_and_free_tunnel(struct tb_tunnel *tunnel)
{ … }
static void tb_free_invalid_tunnels(struct tb *tb)
{ … }
static void tb_free_unplugged_children(struct tb_switch *sw)
{ … }
static struct tb_port *tb_find_pcie_down(struct tb_switch *sw,
const struct tb_port *port)
{ … }
static struct tb_port *tb_find_dp_out(struct tb *tb, struct tb_port *in)
{ … }
static bool tb_tunnel_one_dp(struct tb *tb, struct tb_port *in,
struct tb_port *out)
{ … }
static void tb_tunnel_dp(struct tb *tb)
{ … }
static void tb_enter_redrive(struct tb_port *port)
{ … }
static void tb_exit_redrive(struct tb_port *port)
{ … }
static void tb_dp_resource_unavailable(struct tb *tb, struct tb_port *port)
{ … }
static void tb_dp_resource_available(struct tb *tb, struct tb_port *port)
{ … }
static void tb_disconnect_and_release_dp(struct tb *tb)
{ … }
static int tb_disconnect_pci(struct tb *tb, struct tb_switch *sw)
{ … }
static int tb_tunnel_pci(struct tb *tb, struct tb_switch *sw)
{ … }
static int tb_approve_xdomain_paths(struct tb *tb, struct tb_xdomain *xd,
int transmit_path, int transmit_ring,
int receive_path, int receive_ring)
{ … }
static void __tb_disconnect_xdomain_paths(struct tb *tb, struct tb_xdomain *xd,
int transmit_path, int transmit_ring,
int receive_path, int receive_ring)
{ … }
static int tb_disconnect_xdomain_paths(struct tb *tb, struct tb_xdomain *xd,
int transmit_path, int transmit_ring,
int receive_path, int receive_ring)
{ … }
static void tb_handle_hotplug(struct work_struct *work)
{ … }
static int tb_alloc_dp_bandwidth(struct tb_tunnel *tunnel, int *requested_up,
int *requested_down)
{ … }
static void tb_handle_dp_bandwidth_request(struct work_struct *work)
{ … }
static void tb_queue_dp_bandwidth_request(struct tb *tb, u64 route, u8 port)
{ … }
static void tb_handle_notification(struct tb *tb, u64 route,
const struct cfg_error_pkg *error)
{ … }
static void tb_handle_event(struct tb *tb, enum tb_cfg_pkg_type type,
const void *buf, size_t size)
{ … }
static void tb_stop(struct tb *tb)
{ … }
static void tb_deinit(struct tb *tb)
{ … }
static int tb_scan_finalize_switch(struct device *dev, void *data)
{ … }
static int tb_start(struct tb *tb, bool reset)
{ … }
static int tb_suspend_noirq(struct tb *tb)
{ … }
static void tb_restore_children(struct tb_switch *sw)
{ … }
static int tb_resume_noirq(struct tb *tb)
{ … }
static int tb_free_unplugged_xdomains(struct tb_switch *sw)
{ … }
static int tb_freeze_noirq(struct tb *tb)
{ … }
static int tb_thaw_noirq(struct tb *tb)
{ … }
static void tb_complete(struct tb *tb)
{ … }
static int tb_runtime_suspend(struct tb *tb)
{ … }
static void tb_remove_work(struct work_struct *work)
{ … }
static int tb_runtime_resume(struct tb *tb)
{ … }
static const struct tb_cm_ops tb_cm_ops = …;
static bool tb_apple_add_links(struct tb_nhi *nhi)
{ … }
struct tb *tb_probe(struct tb_nhi *nhi)
{ … }