Lines Matching refs:dbi
105 static bool mipi_dbi_command_is_read(struct mipi_dbi *dbi, u8 cmd)
109 if (!dbi->read_commands)
113 if (!dbi->read_commands[i])
115 if (cmd == dbi->read_commands[i])
124 * @dbi: MIPI DBI structure
133 int mipi_dbi_command_read(struct mipi_dbi *dbi, u8 cmd, u8 *val)
135 if (!dbi->read_commands)
138 if (!mipi_dbi_command_is_read(dbi, cmd))
141 return mipi_dbi_command_buf(dbi, cmd, val, 1);
147 * @dbi: MIPI DBI structure
155 int mipi_dbi_command_buf(struct mipi_dbi *dbi, u8 cmd, u8 *data, size_t len)
165 mutex_lock(&dbi->cmdlock);
166 ret = dbi->command(dbi, cmdbuf, data, len);
167 mutex_unlock(&dbi->cmdlock);
176 int mipi_dbi_command_stackbuf(struct mipi_dbi *dbi, u8 cmd, const u8 *data,
186 ret = mipi_dbi_command_buf(dbi, cmd, buf, len);
262 struct mipi_dbi *dbi = &dbidev->dbi;
269 mipi_dbi_command(dbi, MIPI_DCS_SET_COLUMN_ADDRESS, (xs >> 8) & 0xff,
271 mipi_dbi_command(dbi, MIPI_DCS_SET_PAGE_ADDRESS, (ys >> 8) & 0xff,
282 struct mipi_dbi *dbi = &dbidev->dbi;
283 bool swap = dbi->swap_bytes;
293 if (!dbi->dc || !full || swap ||
312 ret = mipi_dbi_command_buf(dbi, MIPI_DCS_WRITE_MEMORY_START, tr, len);
413 struct mipi_dbi *dbi = &dbidev->dbi;
427 mipi_dbi_command_buf(dbi, MIPI_DCS_WRITE_MEMORY_START,
626 if (!dbidev->dbi.command)
665 dbidev->dbi.write_memory_bpw = 8;
706 * @dbi: MIPI DBI structure
710 void mipi_dbi_hw_reset(struct mipi_dbi *dbi)
712 if (!dbi->reset)
715 gpiod_set_value_cansleep(dbi->reset, 0);
717 gpiod_set_value_cansleep(dbi->reset, 1);
724 * @dbi: MIPI DBI structure
734 bool mipi_dbi_display_is_on(struct mipi_dbi *dbi)
738 if (mipi_dbi_command_read(dbi, MIPI_DCS_GET_POWER_MODE, &val))
757 struct mipi_dbi *dbi = &dbidev->dbi;
778 if (cond && mipi_dbi_display_is_on(dbi))
781 mipi_dbi_hw_reset(dbi);
782 ret = mipi_dbi_command(dbi, MIPI_DCS_SOFT_RESET);
797 if (dbi->reset)
877 static int mipi_dbi_spi1e_transfer(struct mipi_dbi *dbi, int dc,
882 size_t chunk, max_chunk = dbi->tx_buf9_len;
883 struct spi_device *spi = dbi->spi;
885 .tx_buf = dbi->tx_buf9,
905 dst = dbi->tx_buf9;
925 dst = dbi->tx_buf9;
995 static int mipi_dbi_spi1_transfer(struct mipi_dbi *dbi, int dc,
999 struct spi_device *spi = dbi->spi;
1011 return mipi_dbi_spi1e_transfer(dbi, dc, buf, len, bpw);
1014 max_chunk = dbi->tx_buf9_len;
1015 dst16 = dbi->tx_buf9;
1058 static int mipi_dbi_typec1_command_read(struct mipi_dbi *dbi, u8 *cmd,
1061 struct spi_device *spi = dbi->spi;
1068 .tx_buf = dbi->tx_buf9,
1099 dst16 = dbi->tx_buf9;
1111 static int mipi_dbi_typec1_command(struct mipi_dbi *dbi, u8 *cmd,
1117 if (mipi_dbi_command_is_read(dbi, *cmd))
1118 return mipi_dbi_typec1_command_read(dbi, cmd, parameters, num);
1122 ret = mipi_dbi_spi1_transfer(dbi, 0, cmd, 1, 8);
1127 bpw = dbi->write_memory_bpw;
1129 return mipi_dbi_spi1_transfer(dbi, 1, parameters, num, bpw);
1134 static int mipi_dbi_typec3_command_read(struct mipi_dbi *dbi, u8 *cmd,
1137 struct spi_device *spi = dbi->spi;
1176 gpiod_set_value_cansleep(dbi->dc, 0);
1201 static int mipi_dbi_typec3_command(struct mipi_dbi *dbi, u8 *cmd,
1204 struct spi_device *spi = dbi->spi;
1209 if (mipi_dbi_command_is_read(dbi, *cmd))
1210 return mipi_dbi_typec3_command_read(dbi, cmd, par, num);
1215 gpiod_set_value_cansleep(dbi->dc, 0);
1223 bpw = dbi->write_memory_bpw;
1226 gpiod_set_value_cansleep(dbi->dc, 1);
1237 * @dbi: MIPI DBI structure to initialize
1268 int mipi_dbi_spi_init(struct spi_device *spi, struct mipi_dbi *dbi,
1292 dbi->spi = spi;
1293 dbi->read_commands = mipi_dbi_dcs_read_commands;
1294 dbi->write_memory_bpw = 16;
1297 dbi->command = mipi_dbi_typec3_command;
1298 dbi->dc = dc;
1300 dbi->write_memory_bpw = 8;
1301 dbi->swap_bytes = true;
1304 dbi->command = mipi_dbi_typec1_command;
1305 dbi->tx_buf9_len = SZ_16K;
1306 dbi->tx_buf9 = devm_kmalloc(dev, dbi->tx_buf9_len, GFP_KERNEL);
1307 if (!dbi->tx_buf9)
1311 mutex_init(&dbi->cmdlock);
1425 ret = mipi_dbi_command_buf(&dbidev->dbi, cmd, parameters, i);
1438 struct mipi_dbi *dbi = &dbidev->dbi;
1447 if (!mipi_dbi_command_is_read(dbi, cmd))
1467 ret = mipi_dbi_command_buf(dbi, cmd, val, len);
1510 if (dbidev->dbi.read_commands)