18 #include <linux/module.h>
19 #include <linux/kernel.h>
27 #include <linux/slab.h>
30 #define POWER_IS_ON(pwr) ((pwr) <= FB_BLANK_NORMAL)
33 #define RESCTL_ADRS 0x00
34 #define PHACTRL_ADRS 0x01
35 #define DUTYCTRL_ADRS 0x02
36 #define POWERREG0_ADRS 0x03
37 #define POWERREG1_ADRS 0x04
38 #define GPOR3_ADRS 0x05
39 #define PICTRL_ADRS 0x06
40 #define POLCTRL_ADRS 0x07
43 #define RESCTL_QVGA 0x01
44 #define RESCTL_VGA 0x00
46 #define POWER1_VW_ON 0x01
47 #define POWER1_GVSS_ON 0x02
48 #define POWER1_VDD_ON 0x04
50 #define POWER1_VW_OFF 0x00
51 #define POWER1_GVSS_OFF 0x00
52 #define POWER1_VDD_OFF 0x00
54 #define POWER0_COM_DCLK 0x01
55 #define POWER0_COM_DOUT 0x02
56 #define POWER0_DAC_ON 0x04
57 #define POWER0_COM_ON 0x08
58 #define POWER0_VCC5_ON 0x10
60 #define POWER0_DAC_OFF 0x00
61 #define POWER0_COM_OFF 0x00
62 #define POWER0_VCC5_OFF 0x00
64 #define PICTRL_INIT_STATE 0x01
65 #define PICTRL_INIOFF 0x02
66 #define PICTRL_POWER_DOWN 0x04
67 #define PICTRL_COM_SIGNAL_OFF 0x08
68 #define PICTRL_DAC_SIGNAL_OFF 0x10
70 #define POLCTRL_SYNC_POL_FALL 0x01
71 #define POLCTRL_EN_POL_FALL 0x02
72 #define POLCTRL_DATA_POL_FALL 0x04
73 #define POLCTRL_SYNC_ACT_H 0x08
74 #define POLCTRL_EN_ACT_L 0x10
76 #define POLCTRL_SYNC_POL_RISE 0x00
77 #define POLCTRL_EN_POL_RISE 0x00
78 #define POLCTRL_DATA_POL_RISE 0x00
79 #define POLCTRL_SYNC_ACT_L 0x00
80 #define POLCTRL_EN_ACT_H 0x00
82 #define PHACTRL_PHASE_MANUAL 0x01
83 #define DEFAULT_PHAD_QVGA (9)
84 #define DEFAULT_COMADJ (125)
107 static unsigned long corgibl_flags;
108 #define CORGIBL_SUSPENDED 0x01
109 #define CORGIBL_BATTLOW 0x02
123 lcdtg_ssp_i2c_send(lcd, data);
125 lcdtg_ssp_i2c_send(lcd, data);
132 lcdtg_ssp_i2c_send(lcd, base);
137 lcdtg_ssp_i2c_send(lcd, base);
146 for (i = 0; i < 8; i++) {
150 lcdtg_i2c_send_bit(lcd, base);
157 lcdtg_i2c_send_bit(lcd, base);
160 static void lcdtg_set_common_voltage(
struct corgi_lcd *lcd,
164 lcdtg_i2c_send_start(lcd, base_data);
165 lcdtg_i2c_send_byte(lcd, base_data, 0x9c);
166 lcdtg_i2c_wait_ack(lcd, base_data);
167 lcdtg_i2c_send_byte(lcd, base_data, 0x00);
168 lcdtg_i2c_wait_ack(lcd, base_data);
169 lcdtg_i2c_send_byte(lcd, base_data, data);
170 lcdtg_i2c_wait_ack(lcd, base_data);
171 lcdtg_i2c_send_stop(lcd, base_data);
174 static int corgi_ssp_lcdtg_send(
struct corgi_lcd *lcd,
int adrs,
uint8_t data)
183 lcd->
buf[0] = ((adrs & 0x07) << 5) | (data & 0x1f);
184 spi_message_init(&
msg);
185 spi_message_add_tail(&xfer, &
msg);
191 static void lcdtg_set_phadadj(
struct corgi_lcd *lcd,
int mode)
212 static void corgi_lcd_power_on(
struct corgi_lcd *lcd)
278 lcdtg_set_phadadj(lcd, lcd->
mode);
298 static void corgi_lcd_power_off(
struct corgi_lcd *lcd)
343 if (m->
xres == 640 || m->
xres == 480)
346 if (lcd->
mode == mode)
349 lcdtg_set_phadadj(lcd, mode);
370 corgi_lcd_power_on(lcd);
373 corgi_lcd_power_off(lcd);
379 static int corgi_lcd_get_power(
struct lcd_device *ld)
386 static struct lcd_ops corgi_lcd_ops = {
387 .get_power = corgi_lcd_get_power,
388 .set_power = corgi_lcd_set_power,
389 .set_mode = corgi_lcd_set_mode,
403 if (intensity > 0x10)
427 int intensity = bd->
props.brightness;
441 return corgi_bl_set_intensity(lcd, intensity);
451 backlight_update_status(the_corgi_lcd->
bl_dev);
456 .get_brightness = corgi_bl_get_intensity,
457 .update_status = corgi_bl_update_status,
466 corgi_bl_set_intensity(lcd, 0);
475 corgibl_flags &= ~CORGIBL_SUSPENDED;
477 backlight_update_status(lcd->
bl_dev);
481 #define corgi_lcd_suspend NULL
482 #define corgi_lcd_resume NULL
485 static int setup_gpio_backlight(
struct corgi_lcd *lcd,
498 dev_err(&spi->
dev,
"failed to request GPIO%d for "
511 dev_err(&spi->
dev,
"failed to request GPIO%d for "
540 dev_err(&spi->
dev,
"platform data not available\n");
546 dev_err(&spi->
dev,
"failed to allocate memory\n");
553 lcd, &corgi_lcd_ops);
564 &corgi_bl_ops, &props);
565 if (IS_ERR(lcd->
bl_dev)) {
566 ret = PTR_ERR(lcd->
bl_dev);
567 goto err_unregister_lcd;
572 ret = setup_gpio_backlight(lcd, pdata);
574 goto err_unregister_bl;
580 backlight_update_status(lcd->
bl_dev);
598 lcd->
bl_dev->props.brightness = 0;
599 backlight_update_status(lcd->
bl_dev);
613 .probe = corgi_lcd_probe,