18 #include <linux/kernel.h>
19 #include <linux/module.h>
33 static void reset_lcd_module(
void)
43 static unsigned long adjust_reg18(
unsigned short data)
45 unsigned long tmp1, tmp2;
47 tmp1 = (data<<1 | 0x00000001) & 0x000001FF;
48 tmp2 = (data<<2 | 0x00000200) & 0x0003FE00;
52 static void write_reg(
void *sys_ops_handle,
54 unsigned short reg,
unsigned short data)
56 sys_ops->
write_index(sys_ops_handle, adjust_reg18(reg << 8 | data));
61 unsigned short reg,
unsigned short data)
63 sys_ops->
write_index(sys_ops_handle, adjust_reg18(reg));
64 sys_ops->
write_data(sys_ops_handle, adjust_reg18(data));
67 static unsigned long read_reg16(
void *sys_ops_handle,
73 sys_ops->
write_index(sys_ops_handle, adjust_reg18(reg));
74 data = sys_ops->
read_data(sys_ops_handle);
75 return ((data >> 1) & 0xff) | ((data >> 2) & 0xff00);
78 static void migor_lcd_qvga_seq(
void *sys_ops_handle,
80 unsigned short const *data,
int no_data)
84 for (i = 0; i < no_data; i += 2)
85 write_reg16(sys_ops_handle, sys_ops, data[i], data[i + 1]);
88 static const unsigned short sync_data[] = {
89 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
92 static const unsigned short magic0_data[] = {
93 0x0060, 0x2700, 0x0008, 0x0808, 0x0090, 0x001A, 0x0007, 0x0001,
94 0x0017, 0x0001, 0x0019, 0x0000, 0x0010, 0x17B0, 0x0011, 0x0116,
95 0x0012, 0x0198, 0x0013, 0x1400, 0x0029, 0x000C, 0x0012, 0x01B8,
98 static const unsigned short magic1_data[] = {
99 0x0030, 0x0307, 0x0031, 0x0303, 0x0032, 0x0603, 0x0033, 0x0202,
100 0x0034, 0x0202, 0x0035, 0x0202, 0x0036, 0x1F1F, 0x0037, 0x0303,
101 0x0038, 0x0303, 0x0039, 0x0603, 0x003A, 0x0202, 0x003B, 0x0102,
102 0x003C, 0x0204, 0x003D, 0x0000, 0x0001, 0x0100, 0x0002, 0x0300,
103 0x0003, 0x5028, 0x0020, 0x00ef, 0x0021, 0x0000, 0x0004, 0x0000,
104 0x0009, 0x0000, 0x000A, 0x0008, 0x000C, 0x0000, 0x000D, 0x0000,
108 static const unsigned short magic2_data[] = {
109 0x0061, 0x0001, 0x0092, 0x0100, 0x0093, 0x0001, 0x0007, 0x0021,
112 static const unsigned short magic3_data[] = {
113 0x0010, 0x16B0, 0x0011, 0x0111, 0x0007, 0x0061,
118 unsigned long xres = 320;
119 unsigned long yres = 240;
123 migor_lcd_qvga_seq(sohandle, so, sync_data,
ARRAY_SIZE(sync_data));
128 pr_info(
"Migo-R QVGA LCD Module detected.\n");
130 migor_lcd_qvga_seq(sohandle, so, sync_data,
ARRAY_SIZE(sync_data));
134 migor_lcd_qvga_seq(sohandle, so, magic0_data,
ARRAY_SIZE(magic0_data));
137 migor_lcd_qvga_seq(sohandle, so, magic1_data,
ARRAY_SIZE(magic1_data));
138 write_reg16(sohandle, so, 0x0050, 0xef - (yres - 1));
143 migor_lcd_qvga_seq(sohandle, so, magic2_data,
ARRAY_SIZE(magic2_data));
146 migor_lcd_qvga_seq(sohandle, so, magic3_data,
ARRAY_SIZE(magic3_data));
154 for (k = 0; k < (xres * 256); k++)