23 #include <linux/wait.h>
30 #include <linux/kernel.h>
33 #include <linux/module.h>
37 #define SLEEPMSEC 0x1000
39 #define DEFMASK 0xFF00
40 #define COMMAND_ONLY 0xFE
41 #define DATA_ONLY 0xFF
43 #define MIN_BRIGHTNESS 0
44 #define MAX_BRIGHTNESS 10
46 #define POWER_IS_ON(pwr) ((pwr) <= FB_BLANK_NORMAL)
60 static const unsigned short SEQ_PANEL_CONDITION_SET[] = {
79 static const unsigned short SEQ_DISPLAY_CONDITION_SET[] = {
93 static const unsigned short SEQ_GAMMA_SETTING[] = {
122 static const unsigned short SEQ_ETC_CONDITION_SET[] = {
321 static const unsigned short SEQ_ACL_ON[] = {
328 static const unsigned short SEQ_ACL_OFF[] = {
335 static const unsigned short SEQ_ELVSS_ON[] = {
342 static const unsigned short SEQ_ELVSS_OFF[] = {
349 static const unsigned short SEQ_STAND_BY_OFF[] = {
355 static const unsigned short SEQ_STAND_BY_ON[] = {
361 static const unsigned short SEQ_DISPLAY_ON[] = {
378 buf[0] = (addr << 8) | data;
380 spi_message_init(&
msg);
381 spi_message_add_tail(&xfer, &
msg);
392 ret = s6e63m0_spi_write_byte(lcd, 0x0, address);
394 ret = s6e63m0_spi_write_byte(lcd, 0x1, command);
399 static int s6e63m0_panel_send_sequence(
struct s6e63m0 *lcd,
400 const unsigned short *wbuf)
406 ret = s6e63m0_spi_write(lcd, wbuf[
i], wbuf[i+1]);
417 static int _s6e63m0_gamma_ctl(
struct s6e63m0 *lcd,
const unsigned int *
gamma)
423 ret = s6e63m0_spi_write(lcd, 0xfa, 0x00);
425 dev_err(lcd->
dev,
"failed to disable gamma table updating.\n");
430 ret = s6e63m0_spi_write(lcd,
DATA_ONLY, gamma[i]);
432 dev_err(lcd->
dev,
"failed to set gamma table.\n");
438 ret = s6e63m0_spi_write(lcd, 0xfa, 0x01);
440 dev_err(lcd->
dev,
"failed to update gamma table.\n");
446 static int s6e63m0_gamma_ctl(
struct s6e63m0 *lcd,
int gamma)
450 ret = _s6e63m0_gamma_ctl(lcd,
gamma_table.gamma_22_table[gamma]);
456 static int s6e63m0_ldi_init(
struct s6e63m0 *lcd)
459 const unsigned short *init_seq[] = {
460 SEQ_PANEL_CONDITION_SET,
461 SEQ_DISPLAY_CONDITION_SET,
463 SEQ_ETC_CONDITION_SET,
469 ret = s6e63m0_panel_send_sequence(lcd, init_seq[i]);
477 static int s6e63m0_ldi_enable(
struct s6e63m0 *lcd)
480 const unsigned short *enable_seq[] = {
485 for (i = 0; i <
ARRAY_SIZE(enable_seq); i++) {
486 ret = s6e63m0_panel_send_sequence(lcd, enable_seq[i]);
494 static int s6e63m0_ldi_disable(
struct s6e63m0 *lcd)
498 ret = s6e63m0_panel_send_sequence(lcd, SEQ_STAND_BY_ON);
503 static int s6e63m0_power_on(
struct s6e63m0 *lcd)
511 dev_err(lcd->
dev,
"platform data is NULL.\n");
517 dev_err(lcd->
dev,
"backlight device is NULL.\n");
537 ret = s6e63m0_ldi_init(lcd);
539 dev_err(lcd->
dev,
"failed to initialize ldi.\n");
543 ret = s6e63m0_ldi_enable(lcd);
550 ret = s6e63m0_gamma_ctl(lcd, bd->
props.brightness);
552 dev_err(lcd->
dev,
"lcd gamma setting failed.\n");
559 static int s6e63m0_power_off(
struct s6e63m0 *lcd)
566 dev_err(lcd->
dev,
"platform data is NULL.\n");
570 ret = s6e63m0_ldi_disable(lcd);
587 static int s6e63m0_power(
struct s6e63m0 *lcd,
int power)
592 ret = s6e63m0_power_on(lcd);
594 ret = s6e63m0_power_off(lcd);
602 static int s6e63m0_set_power(
struct lcd_device *
ld,
int power)
604 struct s6e63m0 *lcd = lcd_get_data(ld);
608 dev_err(lcd->
dev,
"power value should be 0, 1 or 4.\n");
612 return s6e63m0_power(lcd, power);
615 static int s6e63m0_get_power(
struct lcd_device *ld)
617 struct s6e63m0 *lcd = lcd_get_data(ld);
624 return bd->
props.brightness;
630 struct s6e63m0 *lcd = bl_get_data(bd);
634 dev_err(&bd->
dev,
"lcd brightness should be %d to %d.\n",
639 ret = s6e63m0_gamma_ctl(lcd, bd->
props.brightness);
641 dev_err(&bd->
dev,
"lcd brightness setting failed.\n");
648 static struct lcd_ops s6e63m0_lcd_ops = {
649 .set_power = s6e63m0_set_power,
650 .get_power = s6e63m0_get_power,
654 .get_brightness = s6e63m0_get_brightness,
655 .update_status = s6e63m0_set_brightness,
678 dev_info(dev,
"gamma mode could be 0:2.2, 1:1.9 or 2:1.7)n");
685 static ssize_t s6e63m0_sysfs_store_gamma_mode(
struct device *dev,
687 const char *buf,
size_t len)
699 brightness = bd->
props.brightness;
703 _s6e63m0_gamma_ctl(lcd,
gamma_table.gamma_22_table[brightness]);
706 _s6e63m0_gamma_ctl(lcd,
gamma_table.gamma_19_table[brightness]);
709 _s6e63m0_gamma_ctl(lcd,
gamma_table.gamma_17_table[brightness]);
712 dev_info(dev,
"gamma mode could be 0:2.2, 1:1.9 or 2:1.7\n");
713 _s6e63m0_gamma_ctl(lcd,
gamma_table.gamma_22_table[brightness]);
720 s6e63m0_sysfs_show_gamma_mode, s6e63m0_sysfs_store_gamma_mode);
722 static ssize_t s6e63m0_sysfs_show_gamma_table(
struct device *dev,
734 s6e63m0_sysfs_show_gamma_table,
NULL);
758 lcd->dev = &spi->
dev;
762 dev_err(&spi->
dev,
"platform data is NULL.\n");
777 &s6e63m0_backlight_ops, &props);
780 goto out_lcd_unregister;
790 lcd->gamma_table_count =
795 dev_err(&(spi->
dev),
"failed to add sysfs entries\n");
799 dev_err(&(spi->
dev),
"failed to add sysfs entries\n");
805 if (!lcd->lcd_pd->lcd_enabled) {
819 dev_info(&spi->
dev,
"s6e63m0 panel driver has been probed.\n");
841 #if defined(CONFIG_PM)
842 static unsigned int before_power;
851 before_power = lcd->
power;
875 dev_dbg(&spi->
dev,
"before_power = %d\n", before_power);
877 ret = s6e63m0_power(lcd, before_power);
882 #define s6e63m0_suspend NULL
883 #define s6e63m0_resume NULL
887 static void s6e63m0_shutdown(
struct spi_device *spi)
899 .probe = s6e63m0_probe,
901 .shutdown = s6e63m0_shutdown,