33 #define MDFLD_DSI_READ_MAX_COUNT 5000
58 static const char *
const dsi_errors[] = {
62 "RX Escape Mode Entry Error",
63 "RX LP TX Sync Error",
64 "RX HS Receive Timeout Error",
65 "RX False Control Error",
66 "RX ECC Single Bit Error",
67 "RX ECC Multibit Error",
69 "RX DSI Data Type Not Recognised",
70 "RX DSI VC ID Invalid",
71 "TX False Control Error",
72 "TX ECC Single Bit Error",
73 "TX ECC Multibit Error",
75 "TX DSI Data Type Not Recognised",
76 "TX DSI VC ID invalid",
82 "Turn Around ACK Timeout",
84 "RX Invalid TX Length",
86 "HS Generic Write FIFO Full",
87 "LP Generic Write FIFO Full",
88 "Generic Read Data Avail"
89 "Special Packet Sent",
101 if ((mask &
REG_READ(gen_fifo_stat_reg)) == mask)
105 DRM_ERROR(
"fifo is NOT empty 0x%08x\n",
REG_READ(gen_fifo_stat_reg));
111 return wait_for_gen_fifo_empty(sender, (
BIT(2) |
BIT(10) |
BIT(18) |
117 return wait_for_gen_fifo_empty(sender, (
BIT(10) |
BIT(26)));
122 return wait_for_gen_fifo_empty(sender, (
BIT(2) |
BIT(18)));
130 dev_dbg(sender->
dev->dev,
"Handling error 0x%08x\n", mask);
147 dev_dbg(sender->dev->dev,
"No Action required\n");
154 dev_dbg(sender->dev->dev,
"No Action required\n");
162 dev_dbg(sender->dev->dev,
"High/Low contention detected\n");
167 wait_for_all_fifos_empty(sender);
170 dev_dbg(sender->dev->dev,
"No Action required\n");
183 dev_dbg(sender->dev->dev,
"HS Gen fifo full\n");
185 wait_for_hs_fifos_empty(sender);
188 dev_dbg(sender->dev->dev,
"LP Gen fifo full\n");
190 wait_for_lp_fifos_empty(sender);
195 dev_dbg(sender->dev->dev,
"No Action required\n");
201 "Cannot clean interrupt 0x%08x\n", mask);
214 intr_stat =
REG_READ(intr_stat_reg);
216 for (i = 0; i < 32; i++) {
217 mask = (0x00000001
UL) << i;
218 if (intr_stat & mask) {
219 dev_dbg(sender->
dev->dev,
"[DSI]: %s\n", dsi_errors[i]);
220 err = handle_dsi_error(sender, mask);
222 DRM_ERROR(
"Cannot handle error\n");
234 u8 virtual_channel = 0;
255 u8 *
data,
int len,
bool hs)
263 u8 virtual_channel = 0;
279 for (i = 0; i < len / 4; i++) {
285 REG_WRITE(data_reg, b4 << 24 | b3 << 16 | b2 << 8 | b1);
290 b1 = 0; b2 = 0; b3 = 0;
307 REG_WRITE(data_reg, b3 << 16 | b2 << 8 | b1);
384 u8 *data,
u16 len,
bool hs)
389 ret = dsi_error_handler(sender);
391 DRM_ERROR(
"Error handling failed\n");
397 DRM_ERROR(
"sender is busy\n");
401 ret = send_pkg_prepare(sender, data_type, data, len);
403 DRM_ERROR(
"send_pkg_prepare error\n");
417 ret = send_short_pkg(sender, data_type, data[0], data[1], hs);
421 ret = send_long_pkg(sender, data_type, data, len, hs);
425 send_pkg_done(sender, data_type, data, len);
437 if (!sender || !data || !len) {
438 DRM_ERROR(
"Invalid parameters\n");
444 spin_unlock_irqrestore(&sender->
lock, flags);
450 u8 param,
u8 param_num,
bool hs)
457 DRM_ERROR(
"Invalid parameter\n");
472 send_pkg(sender, data_type, data,
sizeof(data), hs);
473 spin_unlock_irqrestore(&sender->
lock, flags);
485 if (!sender || param_num > 2) {
486 DRM_ERROR(
"Invalid parameter\n");
509 send_pkg(sender, data_type, data,
sizeof(data), hs);
510 spin_unlock_irqrestore(&sender->
lock, flags);
520 if (!sender || !data || !len) {
521 DRM_ERROR(
"Invalid parameters\n");
527 spin_unlock_irqrestore(&sender->
lock, flags);
533 u8 *data,
u16 len,
u32 *data_out,
u16 len_out,
bool hs)
541 if (!sender || !data_out || !len_out) {
542 DRM_ERROR(
"Invalid parameters\n");
557 DRM_ERROR(
"Can NOT clean read data valid interrupt\n");
560 send_pkg(sender, data_type, data, len, hs);
569 spin_unlock_irqrestore(&sender->
lock, flags);
581 for (i = 0; i < len_out; i++)
582 *(data_out + i) =
REG_READ(gen_data_reg);
584 spin_unlock_irqrestore(&sender->
lock, flags);
590 u32 *data,
u16 len,
bool hs)
592 if (!sender || !data || !len) {
593 DRM_ERROR(
"Invalid parameters\n");
606 mdfld_dsi_get_config(dsi_connector);
612 if (!dsi_connector) {
613 DRM_ERROR(
"Invalid parameter\n");
619 if (!pkg_sender || IS_ERR(pkg_sender)) {
623 DRM_ERROR(
"Create DSI pkg sender failed\n");
626 dsi_connector->
pkg_sender = (
void *)pkg_sender;
681 if (!sender || IS_ERR(sender))