1 // SPDX-License-Identifier: GPL-2.0
3 * LCD: LG4573, TFT 4.3", 480x800, RGB24
4 * LCD initialization via SPI
11 #define PWR_ON_DELAY_MSECS 120
13 static int lb043wv_spi_write_u16(struct spi_slave *spi, u16 val)
15 unsigned long flags = SPI_XFER_BEGIN;
16 unsigned short buf16 = htons(val);
19 flags |= SPI_XFER_END;
21 ret = spi_xfer(spi, 16, &buf16, NULL, flags);
23 debug("%s: Failed to send: %d\n", __func__, ret);
28 static void lb043wv_spi_write_u16_array(struct spi_slave *spi, u16 *buff,
33 for (i = 0; i < size; i++)
34 lb043wv_spi_write_u16(spi, buff[i]);
37 static void lb043wv_display_mode_settings(struct spi_slave *spi)
39 static u16 display_mode_settings[] = {
74 debug("transfer display mode settings\n");
75 lb043wv_spi_write_u16_array(spi, display_mode_settings,
76 ARRAY_SIZE(display_mode_settings));
79 static void lb043wv_power_settings(struct spi_slave *spi)
81 static u16 power_settings[] = {
105 debug("transfer power settings\n");
106 lb043wv_spi_write_u16_array(spi, power_settings,
107 ARRAY_SIZE(power_settings));
110 static void lb043wv_gamma_settings(struct spi_slave *spi)
112 static u16 gamma_settings[] = {
175 debug("transfer gamma settings\n");
176 lb043wv_spi_write_u16_array(spi, gamma_settings,
177 ARRAY_SIZE(gamma_settings));
180 static void lb043wv_display_on(struct spi_slave *spi)
182 static u16 sleep_out = 0x7011;
183 static u16 display_on = 0x7029;
185 lb043wv_spi_write_u16(spi, sleep_out);
186 mdelay(PWR_ON_DELAY_MSECS);
187 lb043wv_spi_write_u16(spi, display_on);
190 int lg4573_spi_startup(unsigned int bus, unsigned int cs,
191 unsigned int max_hz, unsigned int spi_mode)
193 struct spi_slave *spi;
196 spi = spi_setup_slave(bus, cs, max_hz, spi_mode);
198 debug("%s: Failed to set up slave\n", __func__);
202 ret = spi_claim_bus(spi);
204 debug("%s: Failed to claim SPI bus: %d\n", __func__, ret);
208 lb043wv_display_mode_settings(spi);
209 lb043wv_power_settings(spi);
210 lb043wv_gamma_settings(spi);
212 lb043wv_display_on(spi);
219 static int do_lgset(cmd_tbl_t *cmdtp, int flag, int argc,
222 lg4573_spi_startup(CONFIG_LG4573_BUS, CONFIG_LG4573_CS, 10000000,
228 lgset, 2, 1, do_lgset,