Lines Matching full:lcd

3  *  LCD/Backlight Driver for Sharp Zaurus Handhelds (various models)
10 * Converted to SPI device based LCD/Backlight device driver
20 #include <linux/lcd.h>
99 static int corgi_ssp_lcdtg_send(struct corgi_lcd *lcd, int reg, uint8_t val);
110 static void lcdtg_ssp_i2c_send(struct corgi_lcd *lcd, uint8_t data) in lcdtg_ssp_i2c_send() argument
112 corgi_ssp_lcdtg_send(lcd, POWERREG0_ADRS, data); in lcdtg_ssp_i2c_send()
116 static void lcdtg_i2c_send_bit(struct corgi_lcd *lcd, uint8_t data) in lcdtg_i2c_send_bit() argument
118 lcdtg_ssp_i2c_send(lcd, data); in lcdtg_i2c_send_bit()
119 lcdtg_ssp_i2c_send(lcd, data | POWER0_COM_DCLK); in lcdtg_i2c_send_bit()
120 lcdtg_ssp_i2c_send(lcd, data); in lcdtg_i2c_send_bit()
123 static void lcdtg_i2c_send_start(struct corgi_lcd *lcd, uint8_t base) in lcdtg_i2c_send_start() argument
125 lcdtg_ssp_i2c_send(lcd, base | POWER0_COM_DCLK | POWER0_COM_DOUT); in lcdtg_i2c_send_start()
126 lcdtg_ssp_i2c_send(lcd, base | POWER0_COM_DCLK); in lcdtg_i2c_send_start()
127 lcdtg_ssp_i2c_send(lcd, base); in lcdtg_i2c_send_start()
130 static void lcdtg_i2c_send_stop(struct corgi_lcd *lcd, uint8_t base) in lcdtg_i2c_send_stop() argument
132 lcdtg_ssp_i2c_send(lcd, base); in lcdtg_i2c_send_stop()
133 lcdtg_ssp_i2c_send(lcd, base | POWER0_COM_DCLK); in lcdtg_i2c_send_stop()
134 lcdtg_ssp_i2c_send(lcd, base | POWER0_COM_DCLK | POWER0_COM_DOUT); in lcdtg_i2c_send_stop()
137 static void lcdtg_i2c_send_byte(struct corgi_lcd *lcd, in lcdtg_i2c_send_byte() argument
144 lcdtg_i2c_send_bit(lcd, base | POWER0_COM_DOUT); in lcdtg_i2c_send_byte()
146 lcdtg_i2c_send_bit(lcd, base); in lcdtg_i2c_send_byte()
151 static void lcdtg_i2c_wait_ack(struct corgi_lcd *lcd, uint8_t base) in lcdtg_i2c_wait_ack() argument
153 lcdtg_i2c_send_bit(lcd, base); in lcdtg_i2c_wait_ack()
156 static void lcdtg_set_common_voltage(struct corgi_lcd *lcd, in lcdtg_set_common_voltage() argument
160 lcdtg_i2c_send_start(lcd, base_data); in lcdtg_set_common_voltage()
161 lcdtg_i2c_send_byte(lcd, base_data, 0x9c); in lcdtg_set_common_voltage()
162 lcdtg_i2c_wait_ack(lcd, base_data); in lcdtg_set_common_voltage()
163 lcdtg_i2c_send_byte(lcd, base_data, 0x00); in lcdtg_set_common_voltage()
164 lcdtg_i2c_wait_ack(lcd, base_data); in lcdtg_set_common_voltage()
165 lcdtg_i2c_send_byte(lcd, base_data, data); in lcdtg_set_common_voltage()
166 lcdtg_i2c_wait_ack(lcd, base_data); in lcdtg_set_common_voltage()
167 lcdtg_i2c_send_stop(lcd, base_data); in lcdtg_set_common_voltage()
170 static int corgi_ssp_lcdtg_send(struct corgi_lcd *lcd, int adrs, uint8_t data) in corgi_ssp_lcdtg_send() argument
176 .tx_buf = lcd->buf, in corgi_ssp_lcdtg_send()
179 lcd->buf[0] = ((adrs & 0x07) << 5) | (data & 0x1f); in corgi_ssp_lcdtg_send()
183 return spi_sync(lcd->spi_dev, &msg); in corgi_ssp_lcdtg_send()
187 static void lcdtg_set_phadadj(struct corgi_lcd *lcd, int mode) in lcdtg_set_phadadj() argument
205 corgi_ssp_lcdtg_send(lcd, PHACTRL_ADRS, adj); in lcdtg_set_phadadj()
208 static void corgi_lcd_power_on(struct corgi_lcd *lcd) in corgi_lcd_power_on() argument
213 corgi_ssp_lcdtg_send(lcd, PICTRL_ADRS, in corgi_lcd_power_on()
218 corgi_ssp_lcdtg_send(lcd, POWERREG0_ADRS, in corgi_lcd_power_on()
222 corgi_ssp_lcdtg_send(lcd, POWERREG1_ADRS, in corgi_lcd_power_on()
226 corgi_ssp_lcdtg_send(lcd, POWERREG1_ADRS, in corgi_lcd_power_on()
231 corgi_ssp_lcdtg_send(lcd, POWERREG0_ADRS, in corgi_lcd_power_on()
237 corgi_ssp_lcdtg_send(lcd, PICTRL_ADRS, in corgi_lcd_power_on()
245 lcdtg_set_common_voltage(lcd, POWER0_DAC_ON | POWER0_COM_OFF | in corgi_lcd_power_on()
249 corgi_ssp_lcdtg_send(lcd, POWERREG0_ADRS, in corgi_lcd_power_on()
254 corgi_ssp_lcdtg_send(lcd, POWERREG1_ADRS, in corgi_lcd_power_on()
259 corgi_ssp_lcdtg_send(lcd, PICTRL_ADRS, PICTRL_INIT_STATE); in corgi_lcd_power_on()
262 corgi_ssp_lcdtg_send(lcd, POWERREG0_ADRS, in corgi_lcd_power_on()
267 corgi_ssp_lcdtg_send(lcd, POWERREG1_ADRS, in corgi_lcd_power_on()
271 corgi_ssp_lcdtg_send(lcd, PICTRL_ADRS, 0); in corgi_lcd_power_on()
274 lcdtg_set_phadadj(lcd, lcd->mode); in corgi_lcd_power_on()
277 corgi_ssp_lcdtg_send(lcd, POLCTRL_ADRS, in corgi_lcd_power_on()
283 switch (lcd->mode) { in corgi_lcd_power_on()
285 corgi_ssp_lcdtg_send(lcd, RESCTL_ADRS, RESCTL_VGA); in corgi_lcd_power_on()
289 corgi_ssp_lcdtg_send(lcd, RESCTL_ADRS, RESCTL_QVGA); in corgi_lcd_power_on()
294 static void corgi_lcd_power_off(struct corgi_lcd *lcd) in corgi_lcd_power_off() argument
300 corgi_ssp_lcdtg_send(lcd, POWERREG1_ADRS, in corgi_lcd_power_off()
304 corgi_ssp_lcdtg_send(lcd, PICTRL_ADRS, PICTRL_COM_SIGNAL_OFF); in corgi_lcd_power_off()
305 corgi_ssp_lcdtg_send(lcd, POWERREG0_ADRS, in corgi_lcd_power_off()
309 lcdtg_set_common_voltage(lcd, POWER0_DAC_ON | POWER0_COM_OFF | in corgi_lcd_power_off()
313 corgi_ssp_lcdtg_send(lcd, POWERREG1_ADRS, in corgi_lcd_power_off()
317 corgi_ssp_lcdtg_send(lcd, POWERREG0_ADRS, in corgi_lcd_power_off()
321 corgi_ssp_lcdtg_send(lcd, PICTRL_ADRS, in corgi_lcd_power_off()
326 corgi_ssp_lcdtg_send(lcd, POWERREG0_ADRS, in corgi_lcd_power_off()
330 corgi_ssp_lcdtg_send(lcd, POWERREG1_ADRS, in corgi_lcd_power_off()
336 struct corgi_lcd *lcd = lcd_get_data(ld); in corgi_lcd_set_mode() local
342 if (lcd->mode == mode) in corgi_lcd_set_mode()
345 lcdtg_set_phadadj(lcd, mode); in corgi_lcd_set_mode()
349 corgi_ssp_lcdtg_send(lcd, RESCTL_ADRS, RESCTL_VGA); in corgi_lcd_set_mode()
353 corgi_ssp_lcdtg_send(lcd, RESCTL_ADRS, RESCTL_QVGA); in corgi_lcd_set_mode()
357 lcd->mode = mode; in corgi_lcd_set_mode()
363 struct corgi_lcd *lcd = lcd_get_data(ld); in corgi_lcd_set_power() local
365 if (POWER_IS_ON(power) && !POWER_IS_ON(lcd->power)) in corgi_lcd_set_power()
366 corgi_lcd_power_on(lcd); in corgi_lcd_set_power()
368 if (!POWER_IS_ON(power) && POWER_IS_ON(lcd->power)) in corgi_lcd_set_power()
369 corgi_lcd_power_off(lcd); in corgi_lcd_set_power()
371 lcd->power = power; in corgi_lcd_set_power()
377 struct corgi_lcd *lcd = lcd_get_data(ld); in corgi_lcd_get_power() local
379 return lcd->power; in corgi_lcd_get_power()
390 struct corgi_lcd *lcd = bl_get_data(bd); in corgi_bl_get_intensity() local
392 return lcd->intensity; in corgi_bl_get_intensity()
395 static int corgi_bl_set_intensity(struct corgi_lcd *lcd, int intensity) in corgi_bl_set_intensity() argument
402 corgi_ssp_lcdtg_send(lcd, DUTYCTRL_ADRS, intensity); in corgi_bl_set_intensity()
407 if (lcd->backlight_cont) in corgi_bl_set_intensity()
408 gpiod_set_value_cansleep(lcd->backlight_cont, cont); in corgi_bl_set_intensity()
410 if (lcd->backlight_on) in corgi_bl_set_intensity()
411 gpiod_set_value_cansleep(lcd->backlight_on, intensity); in corgi_bl_set_intensity()
413 if (lcd->kick_battery) in corgi_bl_set_intensity()
414 lcd->kick_battery(); in corgi_bl_set_intensity()
416 lcd->intensity = intensity; in corgi_bl_set_intensity()
422 struct corgi_lcd *lcd = bl_get_data(bd); in corgi_bl_update_status() local
428 if ((corgibl_flags & CORGIBL_BATTLOW) && intensity > lcd->limit_mask) in corgi_bl_update_status()
429 intensity = lcd->limit_mask; in corgi_bl_update_status()
431 return corgi_bl_set_intensity(lcd, intensity); in corgi_bl_update_status()
453 struct corgi_lcd *lcd = dev_get_drvdata(dev); in corgi_lcd_suspend() local
456 corgi_bl_set_intensity(lcd, 0); in corgi_lcd_suspend()
457 corgi_lcd_set_power(lcd->lcd_dev, FB_BLANK_POWERDOWN); in corgi_lcd_suspend()
463 struct corgi_lcd *lcd = dev_get_drvdata(dev); in corgi_lcd_resume() local
466 corgi_lcd_set_power(lcd->lcd_dev, FB_BLANK_UNBLANK); in corgi_lcd_resume()
467 backlight_update_status(lcd->bl_dev); in corgi_lcd_resume()
474 static int setup_gpio_backlight(struct corgi_lcd *lcd, in setup_gpio_backlight() argument
477 struct spi_device *spi = lcd->spi_dev; in setup_gpio_backlight()
479 lcd->backlight_on = devm_gpiod_get_optional(&spi->dev, in setup_gpio_backlight()
481 if (IS_ERR(lcd->backlight_on)) in setup_gpio_backlight()
482 return PTR_ERR(lcd->backlight_on); in setup_gpio_backlight()
484 lcd->backlight_cont = devm_gpiod_get_optional(&spi->dev, "BL_CONT", in setup_gpio_backlight()
486 if (IS_ERR(lcd->backlight_cont)) in setup_gpio_backlight()
487 return PTR_ERR(lcd->backlight_cont); in setup_gpio_backlight()
496 struct corgi_lcd *lcd; in corgi_lcd_probe() local
504 lcd = devm_kzalloc(&spi->dev, sizeof(struct corgi_lcd), GFP_KERNEL); in corgi_lcd_probe()
505 if (!lcd) in corgi_lcd_probe()
508 lcd->spi_dev = spi; in corgi_lcd_probe()
510 lcd->lcd_dev = devm_lcd_device_register(&spi->dev, "corgi_lcd", in corgi_lcd_probe()
511 &spi->dev, lcd, &corgi_lcd_ops); in corgi_lcd_probe()
512 if (IS_ERR(lcd->lcd_dev)) in corgi_lcd_probe()
513 return PTR_ERR(lcd->lcd_dev); in corgi_lcd_probe()
515 lcd->power = FB_BLANK_POWERDOWN; in corgi_lcd_probe()
516 lcd->mode = (pdata) ? pdata->init_mode : CORGI_LCD_MODE_VGA; in corgi_lcd_probe()
521 lcd->bl_dev = devm_backlight_device_register(&spi->dev, "corgi_bl", in corgi_lcd_probe()
522 &spi->dev, lcd, &corgi_bl_ops, in corgi_lcd_probe()
524 if (IS_ERR(lcd->bl_dev)) in corgi_lcd_probe()
525 return PTR_ERR(lcd->bl_dev); in corgi_lcd_probe()
527 lcd->bl_dev->props.brightness = pdata->default_intensity; in corgi_lcd_probe()
528 lcd->bl_dev->props.power = FB_BLANK_UNBLANK; in corgi_lcd_probe()
530 ret = setup_gpio_backlight(lcd, pdata); in corgi_lcd_probe()
534 lcd->kick_battery = pdata->kick_battery; in corgi_lcd_probe()
536 spi_set_drvdata(spi, lcd); in corgi_lcd_probe()
537 corgi_lcd_set_power(lcd->lcd_dev, FB_BLANK_UNBLANK); in corgi_lcd_probe()
538 backlight_update_status(lcd->bl_dev); in corgi_lcd_probe()
540 lcd->limit_mask = pdata->limit_mask; in corgi_lcd_probe()
541 the_corgi_lcd = lcd; in corgi_lcd_probe()
547 struct corgi_lcd *lcd = spi_get_drvdata(spi); in corgi_lcd_remove() local
549 lcd->bl_dev->props.power = FB_BLANK_UNBLANK; in corgi_lcd_remove()
550 lcd->bl_dev->props.brightness = 0; in corgi_lcd_remove()
551 backlight_update_status(lcd->bl_dev); in corgi_lcd_remove()
552 corgi_lcd_set_power(lcd->lcd_dev, FB_BLANK_POWERDOWN); in corgi_lcd_remove()
557 .name = "corgi-lcd",
566 MODULE_DESCRIPTION("LCD and backlight driver for SHARP C7x0/Cxx00");
569 MODULE_ALIAS("spi:corgi-lcd");