|
@@ -12,6 +12,31 @@
|
|
|
#include "dp_debug.h"
|
|
|
|
|
|
#define DP_AUX_ENUM_STR(x) #x
|
|
|
+#define DP_AUX_IPC_NUM_PAGES 10
|
|
|
+
|
|
|
+#define DP_AUX_DEBUG(dp_aux, fmt, ...) \
|
|
|
+ do { \
|
|
|
+ if (dp_aux) \
|
|
|
+ ipc_log_string(dp_aux->ipc_log_context, "[d][%-4d]"fmt,\
|
|
|
+ current->pid, ##__VA_ARGS__); \
|
|
|
+ DP_DEBUG_V(fmt, ##__VA_ARGS__); \
|
|
|
+ } while (0)
|
|
|
+
|
|
|
+#define DP_AUX_WARN(dp_aux, fmt, ...) \
|
|
|
+ do { \
|
|
|
+ if (dp_aux) \
|
|
|
+ ipc_log_string(dp_aux->ipc_log_context, "[w][%-4d]"fmt,\
|
|
|
+ current->pid, ##__VA_ARGS__); \
|
|
|
+ DP_WARN_V(fmt, ##__VA_ARGS__); \
|
|
|
+ } while (0)
|
|
|
+
|
|
|
+#define DP_AUX_ERR(dp_aux, fmt, ...) \
|
|
|
+ do { \
|
|
|
+ if (dp_aux) \
|
|
|
+ ipc_log_string(dp_aux->ipc_log_context, "[e][%-4d]"fmt,\
|
|
|
+ current->pid, ##__VA_ARGS__); \
|
|
|
+ DP_ERR_V(fmt, ##__VA_ARGS__); \
|
|
|
+ } while (0)
|
|
|
|
|
|
enum {
|
|
|
DP_AUX_DATA_INDEX_WRITE = BIT(31),
|
|
@@ -57,10 +82,11 @@ static void dp_aux_hex_dump(struct drm_dp_aux *drm_aux,
|
|
|
u8 linebuf[64];
|
|
|
struct dp_aux_private *aux = container_of(drm_aux,
|
|
|
struct dp_aux_private, drm_aux);
|
|
|
+ struct dp_aux *dp_aux = &aux->dp_aux;
|
|
|
|
|
|
snprintf(prefix, sizeof(prefix), "%s %s %4xh(%2zu): ",
|
|
|
- aux->native ? "NAT" : "I2C",
|
|
|
- aux->read ? "RD" : "WR",
|
|
|
+ (msg->request & DP_AUX_I2C_MOT) ? "I2C" : "NAT",
|
|
|
+ (msg->request & DP_AUX_I2C_READ) ? "RD" : "WR",
|
|
|
msg->address, msg->size);
|
|
|
|
|
|
for (i = 0; i < msg->size; i += rowsize) {
|
|
@@ -70,7 +96,10 @@ static void dp_aux_hex_dump(struct drm_dp_aux *drm_aux,
|
|
|
hex_dump_to_buffer(msg->buffer + i, linelen, rowsize, 1,
|
|
|
linebuf, sizeof(linebuf), false);
|
|
|
|
|
|
- DP_DEBUG("%s%s\n", prefix, linebuf);
|
|
|
+ if (msg->size == 1 && msg->address == 0)
|
|
|
+ DP_DEBUG_V("%s%s\n", prefix, linebuf);
|
|
|
+ else
|
|
|
+ DP_AUX_DEBUG(dp_aux, "%s%s\n", prefix, linebuf);
|
|
|
}
|
|
|
}
|
|
|
#else
|
|
@@ -107,6 +136,7 @@ static u32 dp_aux_write(struct dp_aux_private *aux,
|
|
|
u8 *msgdata = msg->buffer;
|
|
|
int const aux_cmd_fifo_len = 128;
|
|
|
int i = 0;
|
|
|
+ struct dp_aux *dp_aux = &aux->dp_aux;
|
|
|
|
|
|
if (aux->read)
|
|
|
len = 4;
|
|
@@ -118,7 +148,7 @@ static u32 dp_aux_write(struct dp_aux_private *aux,
|
|
|
* limit buf length to 128 bytes here
|
|
|
*/
|
|
|
if (len > aux_cmd_fifo_len) {
|
|
|
- DP_ERR("buf len error\n");
|
|
|
+ DP_AUX_ERR(dp_aux, "buf len error\n");
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
@@ -166,18 +196,19 @@ static int dp_aux_cmd_fifo_tx(struct dp_aux_private *aux,
|
|
|
{
|
|
|
u32 ret = 0, len = 0, timeout;
|
|
|
int const aux_timeout_ms = HZ/4;
|
|
|
+ struct dp_aux *dp_aux = &aux->dp_aux;
|
|
|
|
|
|
reinit_completion(&aux->comp);
|
|
|
|
|
|
len = dp_aux_write(aux, msg);
|
|
|
if (len == 0) {
|
|
|
- DP_ERR("DP AUX write failed\n");
|
|
|
+ DP_AUX_ERR(dp_aux, "DP AUX write failed\n");
|
|
|
return -EINVAL;
|
|
|
}
|
|
|
|
|
|
timeout = wait_for_completion_timeout(&aux->comp, aux_timeout_ms);
|
|
|
if (!timeout) {
|
|
|
- DP_ERR("aux %s timeout\n", (aux->read ? "read" : "write"));
|
|
|
+ DP_AUX_ERR(dp_aux, "aux %s timeout\n", (aux->read ? "read" : "write"));
|
|
|
return -ETIMEDOUT;
|
|
|
}
|
|
|
|
|
@@ -200,6 +231,7 @@ static void dp_aux_cmd_fifo_rx(struct dp_aux_private *aux,
|
|
|
u8 *dp;
|
|
|
u32 i, actual_i;
|
|
|
u32 len = msg->size;
|
|
|
+ struct dp_aux *dp_aux = &aux->dp_aux;
|
|
|
|
|
|
aux->catalog->clear_trans(aux->catalog, true);
|
|
|
|
|
@@ -221,7 +253,7 @@ static void dp_aux_cmd_fifo_rx(struct dp_aux_private *aux,
|
|
|
|
|
|
actual_i = (data >> 16) & 0xFF;
|
|
|
if (i != actual_i)
|
|
|
- DP_WARN("Index mismatch: expected %d, found %d\n",
|
|
|
+ DP_AUX_WARN(dp_aux, "Index mismatch: expected %d, found %d\n",
|
|
|
i, actual_i);
|
|
|
}
|
|
|
}
|
|
@@ -280,7 +312,7 @@ static void dp_aux_isr(struct dp_aux *dp_aux)
|
|
|
struct dp_aux_private *aux;
|
|
|
|
|
|
if (!dp_aux) {
|
|
|
- DP_ERR("invalid input\n");
|
|
|
+ DP_AUX_ERR(dp_aux, "invalid input\n");
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -302,7 +334,7 @@ static void dp_aux_reconfig(struct dp_aux *dp_aux)
|
|
|
struct dp_aux_private *aux;
|
|
|
|
|
|
if (!dp_aux) {
|
|
|
- DP_ERR("invalid input\n");
|
|
|
+ DP_AUX_ERR(dp_aux, "invalid input\n");
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -318,7 +350,7 @@ static void dp_aux_abort_transaction(struct dp_aux *dp_aux, bool abort)
|
|
|
struct dp_aux_private *aux;
|
|
|
|
|
|
if (!dp_aux) {
|
|
|
- DP_ERR("invalid input\n");
|
|
|
+ DP_AUX_ERR(dp_aux, "invalid input\n");
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -427,6 +459,7 @@ static int dp_aux_transfer_ready(struct dp_aux_private *aux,
|
|
|
int ret = 0;
|
|
|
int const aux_cmd_native_max = 16;
|
|
|
int const aux_cmd_i2c_max = 128;
|
|
|
+ struct dp_aux *dp_aux = &aux->dp_aux;
|
|
|
|
|
|
if (atomic_read(&aux->aborted)) {
|
|
|
ret = -ETIMEDOUT;
|
|
@@ -445,7 +478,7 @@ static int dp_aux_transfer_ready(struct dp_aux_private *aux,
|
|
|
/* msg sanity check */
|
|
|
if ((aux->native && (msg->size > aux_cmd_native_max)) ||
|
|
|
(msg->size > aux_cmd_i2c_max)) {
|
|
|
- DP_ERR("%s: invalid msg: size(%zu), request(%x)\n",
|
|
|
+ DP_AUX_ERR(dp_aux, "%s: invalid msg: size(%zu), request(%x)\n",
|
|
|
__func__, msg->size, msg->request);
|
|
|
ret = -EINVAL;
|
|
|
goto error;
|
|
@@ -550,6 +583,7 @@ static ssize_t dp_aux_bridge_transfer(struct drm_dp_aux *drm_aux,
|
|
|
size = aux->aux_bridge->transfer(aux->aux_bridge,
|
|
|
drm_aux, msg);
|
|
|
aux->bridge_in_transfer = false;
|
|
|
+ dp_aux_hex_dump(drm_aux, msg);
|
|
|
}
|
|
|
|
|
|
return size;
|
|
@@ -581,6 +615,7 @@ static ssize_t dp_aux_transfer_debug(struct drm_dp_aux *drm_aux,
|
|
|
size = aux->sim_bridge->transfer(aux->sim_bridge,
|
|
|
drm_aux, msg);
|
|
|
aux->sim_in_transfer = false;
|
|
|
+ dp_aux_hex_dump(drm_aux, msg);
|
|
|
}
|
|
|
end:
|
|
|
return size;
|
|
@@ -599,7 +634,7 @@ static void dp_aux_init(struct dp_aux *dp_aux, struct dp_aux_cfg *aux_cfg)
|
|
|
struct dp_aux_private *aux;
|
|
|
|
|
|
if (!dp_aux || !aux_cfg) {
|
|
|
- DP_ERR("invalid input\n");
|
|
|
+ DP_AUX_ERR(dp_aux, "invalid input\n");
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -608,6 +643,10 @@ static void dp_aux_init(struct dp_aux *dp_aux, struct dp_aux_cfg *aux_cfg)
|
|
|
if (aux->enabled)
|
|
|
return;
|
|
|
|
|
|
+ dp_aux->ipc_log_context = ipc_log_context_create(DP_AUX_IPC_NUM_PAGES, "drm_dp_aux", 0);
|
|
|
+ if (!dp_aux->ipc_log_context)
|
|
|
+ DP_AUX_WARN(dp_aux, "Error in creating dp_aux_ipc_log context\n");
|
|
|
+
|
|
|
dp_aux_reset_phy_config_indices(aux_cfg);
|
|
|
aux->catalog->setup(aux->catalog, aux_cfg);
|
|
|
aux->catalog->reset(aux->catalog);
|
|
@@ -622,7 +661,7 @@ static void dp_aux_deinit(struct dp_aux *dp_aux)
|
|
|
struct dp_aux_private *aux;
|
|
|
|
|
|
if (!dp_aux) {
|
|
|
- DP_ERR("invalid input\n");
|
|
|
+ DP_AUX_ERR(dp_aux, "invalid input\n");
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -631,6 +670,11 @@ static void dp_aux_deinit(struct dp_aux *dp_aux)
|
|
|
if (!aux->enabled)
|
|
|
return;
|
|
|
|
|
|
+ if (dp_aux->ipc_log_context) {
|
|
|
+ ipc_log_context_destroy(dp_aux->ipc_log_context);
|
|
|
+ dp_aux->ipc_log_context = NULL;
|
|
|
+ }
|
|
|
+
|
|
|
atomic_set(&aux->aborted, 1);
|
|
|
aux->catalog->enable(aux->catalog, false);
|
|
|
aux->enabled = false;
|
|
@@ -642,7 +686,7 @@ static int dp_aux_register(struct dp_aux *dp_aux, struct drm_device *drm_dev)
|
|
|
int ret = 0;
|
|
|
|
|
|
if (!dp_aux) {
|
|
|
- DP_ERR("invalid input\n");
|
|
|
+ DP_AUX_ERR(dp_aux, "invalid input\n");
|
|
|
ret = -EINVAL;
|
|
|
goto exit;
|
|
|
}
|
|
@@ -658,7 +702,7 @@ static int dp_aux_register(struct dp_aux *dp_aux, struct drm_device *drm_dev)
|
|
|
atomic_set(&aux->aborted, 1);
|
|
|
ret = drm_dp_aux_register(&aux->drm_aux);
|
|
|
if (ret) {
|
|
|
- DP_ERR("%s: failed to register drm aux: %d\n", __func__, ret);
|
|
|
+ DP_AUX_ERR(dp_aux, "%s: failed to register drm aux: %d\n", __func__, ret);
|
|
|
goto exit;
|
|
|
}
|
|
|
dp_aux->drm_aux = &aux->drm_aux;
|
|
@@ -675,7 +719,7 @@ static void dp_aux_deregister(struct dp_aux *dp_aux)
|
|
|
struct dp_aux_private *aux;
|
|
|
|
|
|
if (!dp_aux) {
|
|
|
- DP_ERR("invalid input\n");
|
|
|
+ DP_AUX_ERR(dp_aux, "invalid input\n");
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -689,7 +733,7 @@ static void dp_aux_set_sim_mode(struct dp_aux *dp_aux,
|
|
|
struct dp_aux_private *aux;
|
|
|
|
|
|
if (!dp_aux) {
|
|
|
- DP_ERR("invalid input\n");
|
|
|
+ DP_AUX_ERR(dp_aux, "invalid input\n");
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -719,7 +763,7 @@ static int dp_aux_configure_aux_switch(struct dp_aux *dp_aux,
|
|
|
enum fsa_function event = FSA_USBC_DISPLAYPORT_DISCONNECTED;
|
|
|
|
|
|
if (!dp_aux) {
|
|
|
- DP_ERR("invalid input\n");
|
|
|
+ DP_AUX_ERR(dp_aux, "invalid input\n");
|
|
|
rc = -EINVAL;
|
|
|
goto end;
|
|
|
}
|
|
@@ -727,7 +771,7 @@ static int dp_aux_configure_aux_switch(struct dp_aux *dp_aux,
|
|
|
aux = container_of(dp_aux, struct dp_aux_private, dp_aux);
|
|
|
|
|
|
if (!aux->aux_switch_node) {
|
|
|
- DP_DEBUG("undefined fsa4480 handle\n");
|
|
|
+ DP_AUX_DEBUG(dp_aux, "undefined fsa4480 handle\n");
|
|
|
rc = -EINVAL;
|
|
|
goto end;
|
|
|
}
|
|
@@ -741,18 +785,18 @@ static int dp_aux_configure_aux_switch(struct dp_aux *dp_aux,
|
|
|
event = FSA_USBC_ORIENTATION_CC2;
|
|
|
break;
|
|
|
default:
|
|
|
- DP_ERR("invalid orientation\n");
|
|
|
+ DP_AUX_ERR(dp_aux, "invalid orientation\n");
|
|
|
rc = -EINVAL;
|
|
|
goto end;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- DP_DEBUG("enable=%d, orientation=%d, event=%d\n",
|
|
|
+ DP_AUX_DEBUG(dp_aux, "enable=%d, orientation=%d, event=%d\n",
|
|
|
enable, orientation, event);
|
|
|
|
|
|
rc = fsa4480_switch_event(aux->aux_switch_node, event);
|
|
|
if (rc)
|
|
|
- DP_ERR("failed to configure fsa4480 i2c device (%d)\n", rc);
|
|
|
+ DP_AUX_ERR(dp_aux, "failed to configure fsa4480 i2c device (%d)\n", rc);
|
|
|
end:
|
|
|
return rc;
|
|
|
}
|
|
@@ -763,10 +807,10 @@ struct dp_aux *dp_aux_get(struct device *dev, struct dp_catalog_aux *catalog,
|
|
|
{
|
|
|
int rc = 0;
|
|
|
struct dp_aux_private *aux;
|
|
|
- struct dp_aux *dp_aux;
|
|
|
+ struct dp_aux *dp_aux = NULL;
|
|
|
|
|
|
if (!catalog || !parser) {
|
|
|
- DP_ERR("invalid input\n");
|
|
|
+ DP_AUX_ERR(dp_aux, "invalid input\n");
|
|
|
rc = -ENODEV;
|
|
|
goto error;
|
|
|
}
|