2 * LCD: LG4573, TFT 4.3", 480x800, RGB24
3 * LCD initialization via SPI
5 * SPDX-License-Identifier: GPL-2.0
12 #define PWR_ON_DELAY_MSECS 120
14 static int lb043wv_spi_write_u16(struct spi_slave *spi, u16 val)
16 unsigned long flags = SPI_XFER_BEGIN;
17 unsigned short buf16 = htons(val);
20 flags |= SPI_XFER_END;
22 ret = spi_xfer(spi, 16, &buf16, NULL, flags);
24 debug("%s: Failed to send: %d\n", __func__, ret);
29 static void lb043wv_spi_write_u16_array(struct spi_slave *spi, u16 *buff,
34 for (i = 0; i < size; i++)
35 lb043wv_spi_write_u16(spi, buff[i]);
38 static void lb043wv_display_mode_settings(struct spi_slave *spi)
40 static u16 display_mode_settings[] = {
75 debug("transfer display mode settings\n");
76 lb043wv_spi_write_u16_array(spi, display_mode_settings,
77 ARRAY_SIZE(display_mode_settings));
80 static void lb043wv_power_settings(struct spi_slave *spi)
82 static u16 power_settings[] = {
106 debug("transfer power settings\n");
107 lb043wv_spi_write_u16_array(spi, power_settings,
108 ARRAY_SIZE(power_settings));
111 static void lb043wv_gamma_settings(struct spi_slave *spi)
113 static u16 gamma_settings[] = {
176 debug("transfer gamma settings\n");
177 lb043wv_spi_write_u16_array(spi, gamma_settings,
178 ARRAY_SIZE(gamma_settings));
181 static void lb043wv_display_on(struct spi_slave *spi)
183 static u16 sleep_out = 0x7011;
184 static u16 display_on = 0x7029;
186 lb043wv_spi_write_u16(spi, sleep_out);
187 mdelay(PWR_ON_DELAY_MSECS);
188 lb043wv_spi_write_u16(spi, display_on);
191 int lg4573_spi_startup(unsigned int bus, unsigned int cs,
192 unsigned int max_hz, unsigned int spi_mode)
194 struct spi_slave *spi;
197 spi = spi_setup_slave(bus, cs, max_hz, spi_mode);
199 debug("%s: Failed to set up slave\n", __func__);
203 ret = spi_claim_bus(spi);
205 debug("%s: Failed to claim SPI bus: %d\n", __func__, ret);
209 lb043wv_display_mode_settings(spi);
210 lb043wv_power_settings(spi);
211 lb043wv_gamma_settings(spi);
213 lb043wv_display_on(spi);
220 static int do_lgset(cmd_tbl_t *cmdtp, int flag, int argc,
223 lg4573_spi_startup(0, 0, 10000000, SPI_MODE_0);
228 lgset, 2, 1, do_lgset,