Lines Matching full:lcd
74 static int td043mtea1_write(struct td043mtea1_panel *lcd, u8 addr, u8 value) in td043mtea1_write() argument
91 ret = spi_sync(lcd->spi, &msg); in td043mtea1_write()
93 dev_warn(&lcd->spi->dev, "failed to write to LCD reg (%d)\n", in td043mtea1_write()
99 static void td043mtea1_write_gamma(struct td043mtea1_panel *lcd) in td043mtea1_write_gamma() argument
101 const u16 *gamma = lcd->gamma; in td043mtea1_write_gamma()
108 td043mtea1_write(lcd, 0x11, val); in td043mtea1_write_gamma()
112 td043mtea1_write(lcd, 0x12, val); in td043mtea1_write_gamma()
116 td043mtea1_write(lcd, 0x13, val); in td043mtea1_write_gamma()
120 td043mtea1_write(lcd, 0x14 + i, gamma[i] & 0xff); in td043mtea1_write_gamma()
123 static int td043mtea1_write_mirror(struct td043mtea1_panel *lcd) in td043mtea1_write_mirror() argument
127 if (lcd->vmirror) in td043mtea1_write_mirror()
130 return td043mtea1_write(lcd, 4, reg4); in td043mtea1_write_mirror()
133 static int td043mtea1_power_on(struct td043mtea1_panel *lcd) in td043mtea1_power_on() argument
137 if (lcd->powered_on) in td043mtea1_power_on()
140 ret = regulator_enable(lcd->vcc_reg); in td043mtea1_power_on()
147 gpiod_set_value(lcd->reset_gpio, 0); in td043mtea1_power_on()
149 td043mtea1_write(lcd, 2, TPO_R02_MODE(lcd->mode) | TPO_R02_NCLK_RISING); in td043mtea1_power_on()
150 td043mtea1_write(lcd, 3, TPO_R03_VAL_NORMAL); in td043mtea1_power_on()
151 td043mtea1_write(lcd, 0x20, 0xf0); in td043mtea1_power_on()
152 td043mtea1_write(lcd, 0x21, 0xf0); in td043mtea1_power_on()
153 td043mtea1_write_mirror(lcd); in td043mtea1_power_on()
154 td043mtea1_write_gamma(lcd); in td043mtea1_power_on()
156 lcd->powered_on = true; in td043mtea1_power_on()
161 static void td043mtea1_power_off(struct td043mtea1_panel *lcd) in td043mtea1_power_off() argument
163 if (!lcd->powered_on) in td043mtea1_power_off()
166 td043mtea1_write(lcd, 3, TPO_R03_VAL_STANDBY | TPO_R03_EN_PWM); in td043mtea1_power_off()
168 gpiod_set_value(lcd->reset_gpio, 1); in td043mtea1_power_off()
173 td043mtea1_write(lcd, 3, TPO_R03_VAL_STANDBY); in td043mtea1_power_off()
175 regulator_disable(lcd->vcc_reg); in td043mtea1_power_off()
177 lcd->powered_on = false; in td043mtea1_power_off()
187 struct td043mtea1_panel *lcd = dev_get_drvdata(dev); in vmirror_show() local
189 return sysfs_emit(buf, "%d\n", lcd->vmirror); in vmirror_show()
195 struct td043mtea1_panel *lcd = dev_get_drvdata(dev); in vmirror_store() local
203 lcd->vmirror = !!val; in vmirror_store()
205 ret = td043mtea1_write_mirror(lcd); in vmirror_store()
215 struct td043mtea1_panel *lcd = dev_get_drvdata(dev); in mode_show() local
217 return sysfs_emit(buf, "%d\n", lcd->mode); in mode_show()
223 struct td043mtea1_panel *lcd = dev_get_drvdata(dev); in mode_store() local
231 lcd->mode = val; in mode_store()
234 td043mtea1_write(lcd, 2, val); in mode_store()
242 struct td043mtea1_panel *lcd = dev_get_drvdata(dev); in gamma_show() local
247 for (i = 0; i < ARRAY_SIZE(lcd->gamma); i++) { in gamma_show()
249 lcd->gamma[i]); in gamma_show()
262 struct td043mtea1_panel *lcd = dev_get_drvdata(dev); in gamma_store() local
274 lcd->gamma[i] = g[i]; in gamma_store()
276 td043mtea1_write_gamma(lcd); in gamma_store()
302 struct td043mtea1_panel *lcd = to_td043mtea1_device(panel); in td043mtea1_unprepare() local
304 if (!lcd->spi_suspended) in td043mtea1_unprepare()
305 td043mtea1_power_off(lcd); in td043mtea1_unprepare()
312 struct td043mtea1_panel *lcd = to_td043mtea1_device(panel); in td043mtea1_prepare() local
317 * yet, so we'll program the LCD from SPI PM resume callback. in td043mtea1_prepare()
319 if (lcd->spi_suspended) in td043mtea1_prepare()
322 ret = td043mtea1_power_on(lcd); in td043mtea1_prepare()
324 dev_err(&lcd->spi->dev, "%s: power on failed (%d)\n", in td043mtea1_prepare()
387 struct td043mtea1_panel *lcd = dev_get_drvdata(dev); in td043mtea1_suspend() local
389 if (lcd->powered_on) { in td043mtea1_suspend()
390 td043mtea1_power_off(lcd); in td043mtea1_suspend()
391 lcd->powered_on = true; in td043mtea1_suspend()
394 lcd->spi_suspended = true; in td043mtea1_suspend()
401 struct td043mtea1_panel *lcd = dev_get_drvdata(dev); in td043mtea1_resume() local
404 lcd->spi_suspended = false; in td043mtea1_resume()
406 if (lcd->powered_on) { in td043mtea1_resume()
407 lcd->powered_on = false; in td043mtea1_resume()
408 ret = td043mtea1_power_on(lcd); in td043mtea1_resume()
421 struct td043mtea1_panel *lcd; in td043mtea1_probe() local
424 lcd = devm_kzalloc(&spi->dev, sizeof(*lcd), GFP_KERNEL); in td043mtea1_probe()
425 if (lcd == NULL) in td043mtea1_probe()
428 spi_set_drvdata(spi, lcd); in td043mtea1_probe()
429 lcd->spi = spi; in td043mtea1_probe()
430 lcd->mode = TPO_R02_MODE_800x480; in td043mtea1_probe()
431 memcpy(lcd->gamma, td043mtea1_def_gamma, sizeof(lcd->gamma)); in td043mtea1_probe()
433 lcd->vcc_reg = devm_regulator_get(&spi->dev, "vcc"); in td043mtea1_probe()
434 if (IS_ERR(lcd->vcc_reg)) in td043mtea1_probe()
435 return dev_err_probe(&spi->dev, PTR_ERR(lcd->vcc_reg), in td043mtea1_probe()
438 lcd->reset_gpio = devm_gpiod_get(&spi->dev, "reset", GPIOD_OUT_HIGH); in td043mtea1_probe()
439 if (IS_ERR(lcd->reset_gpio)) in td043mtea1_probe()
440 return dev_err_probe(&spi->dev, PTR_ERR(lcd->reset_gpio), in td043mtea1_probe()
458 drm_panel_init(&lcd->panel, &lcd->spi->dev, &td043mtea1_funcs, in td043mtea1_probe()
461 drm_panel_add(&lcd->panel); in td043mtea1_probe()
468 struct td043mtea1_panel *lcd = spi_get_drvdata(spi); in td043mtea1_remove() local
470 drm_panel_remove(&lcd->panel); in td043mtea1_remove()
471 drm_panel_disable(&lcd->panel); in td043mtea1_remove()
472 drm_panel_unprepare(&lcd->panel); in td043mtea1_remove()