2 * Thunderbolt Cactus Ridge driver - control channel and configuration commands
4 * Copyright (c) 2014 Andreas Noever <andreas.noever@gmail.com>
15 typedef void (*hotplug_cb
)(void *data
, u64 route
, u8 port
, bool unplug
);
17 struct tb_ctl
*tb_ctl_alloc(struct tb_nhi
*nhi
, hotplug_cb cb
, void *cb_data
);
18 void tb_ctl_start(struct tb_ctl
*ctl
);
19 void tb_ctl_stop(struct tb_ctl
*ctl
);
20 void tb_ctl_free(struct tb_ctl
*ctl
);
22 /* configuration commands */
24 #define TB_CFG_DEFAULT_TIMEOUT 5000 /* msec */
34 TB_CFG_ERROR_PORT_NOT_CONNECTED
= 0,
35 TB_CFG_ERROR_INVALID_CONFIG_SPACE
= 2,
36 TB_CFG_ERROR_NO_SUCH_PORT
= 4,
37 TB_CFG_ERROR_ACK_PLUG_EVENT
= 7, /* send as reply to TB_CFG_PKG_EVENT */
38 TB_CFG_ERROR_LOOP
= 8,
41 struct tb_cfg_result
{
44 * If err = 1 then this is the port that send the
46 * If err = 0 and if this was a cfg_read/write then
47 * this is the the upstream port of the responding
49 * Otherwise the field is set to zero.
51 int err
; /* negative errors, 0 for success, 1 for tb errors */
52 enum tb_cfg_error tb_error
; /* valid if err == 1 */
56 int tb_cfg_error(struct tb_ctl
*ctl
, u64 route
, u32 port
,
57 enum tb_cfg_error error
);
58 struct tb_cfg_result
tb_cfg_reset(struct tb_ctl
*ctl
, u64 route
,
60 struct tb_cfg_result
tb_cfg_read_raw(struct tb_ctl
*ctl
, void *buffer
,
62 enum tb_cfg_space space
, u32 offset
,
63 u32 length
, int timeout_msec
);
64 struct tb_cfg_result
tb_cfg_write_raw(struct tb_ctl
*ctl
, void *buffer
,
66 enum tb_cfg_space space
, u32 offset
,
67 u32 length
, int timeout_msec
);
68 int tb_cfg_read(struct tb_ctl
*ctl
, void *buffer
, u64 route
, u32 port
,
69 enum tb_cfg_space space
, u32 offset
, u32 length
);
70 int tb_cfg_write(struct tb_ctl
*ctl
, void *buffer
, u64 route
, u32 port
,
71 enum tb_cfg_space space
, u32 offset
, u32 length
);
72 int tb_cfg_get_upstream_port(struct tb_ctl
*ctl
, u64 route
);