summaryrefslogtreecommitdiffstats
path: root/firmware/target/arm/s5l8702/ipod6g/lcd-6g.c
blob: 0f74787b45601cbab7d3d212f2666341d5af6910 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
/***************************************************************************
 *             __________               __   ___.
 *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
 *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
 *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
 *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
 *                     \/            \/     \/    \/            \/
 * $Id: lcd-nano2g.c 28868 2010-12-21 06:59:17Z Buschel $
 *
 * Copyright (C) 2009 by Dave Chapman
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
 * KIND, either express or implied.
 *
 ****************************************************************************/
#include <stdlib.h>
#include <stdint.h>

#include "config.h"

#include "s5l87xx.h"
#include "lcd-s5l8702.h"


#if defined(HAVE_LCD_SLEEP) || defined(HAVE_LCD_SHUTDOWN)
/* powersave sequences */

static const uint8_t lcd_sleep_seq_01[] =
{
    CMD,   0x28,  0,    /* Display Off */
    SLEEP, 5,           /* 50 ms */
    CMD,   0x10,  0,    /* Sleep In */
    SLEEP, 5,           /* 50 ms */
    END
};

static const uint16_t lcd_deepstandby_seq_23[] =
{
    /* Display Off */
    MREG16(1),  0x007, 0x0172,
    MREG16(1),  0x030, 0x03ff,
    SLEEP16(9),
    MREG16(1),  0x007, 0x0120,
    MREG16(1),  0x030, 0x0000,
    MREG16(1),  0x100, 0x0780,
    MREG16(1),  0x007, 0x0000,

    /* power supply off */
    MREG16(1),  0x101, 0x0260,
    MREG16(1),  0x102, 0x00a9,
    SLEEP16(3),
    MREG16(1),  0x100, 0x0700,

    /* Deep Standby Mode */
    MREG16(1),  0x100, 0x0704,
    SLEEP16(5),
    END
};
#endif /* HAVE_LCD_SLEEP || HAVE_LCD_SHUTDOWN */

#ifdef HAVE_LCD_SLEEP
/* awake sequences */

static const uint8_t lcd_awake_seq_01[] =
{
    CMD,   0x11,  0,    /* Sleep Out */
    SLEEP, 6,           /* 60 ms */
    CMD,   0x29,  0,    /* Display On */
    END
};
#endif

// XXX: ili9340 DS: pag.168 B7H -> Entry Mode Set, DSTB -> enter this mode and tell how to exit

#if defined(HAVE_LCD_SLEEP) || defined(BOOTLOADER)
/* init sequences */

static const uint16_t lcd_init_seq_23[] =
{
#ifdef HAVE_LCD_SLEEP
    /* release from deep standby mode (ili9320 DS s12.3) */
    CMD16,      0x000,  /* NOP */
    DELAY16(20),        /* 1024 usecs */
    CMD16,      0x000,
    DELAY16(20),
    CMD16,      0x000,
    DELAY16(20),
    CMD16,      0x000,
    DELAY16(20),
    CMD16,      0x000,
    DELAY16(20),
    CMD16,      0x000,
    DELAY16(20),
#endif

    /* Display settings */
    MREG16(1),  0x008, 0x0808,
    MREG16(7),  0x010, 0x0013, 0x0300, 0x0101, 0x0a03, 0x0a0e, 0x0a19, 0x2402,
    MREG16(1),  0x018, 0x0001,
    MREG16(1),  0x090, 0x0021,

    /* Gamma settings */
    MREG16(14), 0x300, 0x0307, 0x0003, 0x0402, 0x0303, 0x0300, 0x0407, 0x1c04,
                       0x0307, 0x0003, 0x0402, 0x0303, 0x0300, 0x0407, 0x1c04,
    MREG16(14), 0x310, 0x0707, 0x0407, 0x0306, 0x0303, 0x0300, 0x0407, 0x1c01,
                       0x0707, 0x0407, 0x0306, 0x0303, 0x0300, 0x0407, 0x1c01,
    MREG16(14), 0x320, 0x0206, 0x0102, 0x0404, 0x0303, 0x0300, 0x0407, 0x1c1f,
                       0x0206, 0x0102, 0x0404, 0x0303, 0x0300, 0x0407, 0x1c1f,

    /* GRAM and Base Imagen settings (ili9326 DS) */
    MREG16(2),  0x400, 0x001d, 0x0001,
    MREG16(1),  0x205, 0x0060,

    /* Power settings */
    MREG16(1),  0x007, 0x0001,
    MREG16(1),  0x031, 0x0071,
    MREG16(1),  0x110, 0x0001,
    MREG16(6),  0x100, 0x17b0, 0x0220, 0x00bd, 0x1500, 0x0103, 0x0105,

    /* Display On */
    MREG16(1),  0x007, 0x0021,
    MREG16(1),  0x001, 0x0110,
    MREG16(1),  0x003, 0x0230,
    MREG16(1),  0x002, 0x0500,
    MREG16(1),  0x007, 0x0031,
    MREG16(1),  0x030, 0x0007,
    SLEEP16(3),
    MREG16(1),  0x030, 0x03ff,
    SLEEP16(6),
    MREG16(1),  0x007, 0x0072,
    SLEEP16(15),
    MREG16(1),  0x007, 0x0173,
    END
};

#ifdef BOOTLOADER
static const uint8_t lcd_init_seq_0[] =
{
    CMD,   0x11,  0,        /* Sleep Out */
    SLEEP, 3,               /* 30 ms */
    CMD,   0x35,  1, 0x00,  /* Tearing Effect Line On */
    CMD,   0x3a,  1, 0x06,  /* Pixel Format Set */
    CMD,   0x36,  1, 0x00,  /* Memory Access Control */

    CMD,   0x13,  0,        /* Normal Mode On */
    CMD,   0x29,  0,        /* Display On */
    END
};

static const uint8_t lcd_init_seq_1[] =
{
    CMD,   0xb0, 21, 0x3a, 0x3a, 0x80, 0x80, 0x0a, 0x0a, 0x0a, 0x0a,
                     0x0a, 0x0a, 0x0a, 0x0a, 0x3c, 0x30, 0x0f, 0x00,
                     0x01, 0x54, 0x06, 0x66, 0x66,
    CMD,   0xb8,  1, 0xd8,
    CMD,   0xb1, 30, 0x14, 0x59, 0x00, 0x15, 0x57, 0x27, 0x04, 0x85,
                     0x14, 0x59, 0x00, 0x15, 0x57, 0x27, 0x04, 0x85,
                     0x14, 0x09, 0x15, 0x57, 0x27, 0x04, 0x05,
                     0x14, 0x09, 0x15, 0x57, 0x27, 0x04, 0x05,
    CMD,   0xd2,  1, 0x01,

    /* Gamma settings */
    CMD,   0xe0, 13, 0x00, 0x00, 0x00, 0x05, 0x0b, 0x12, 0x16, 0x1f,
                     0x25, 0x22, 0x24, 0x29, 0x1c,
    CMD,   0xe1, 13, 0x08, 0x01, 0x01, 0x06, 0x0b, 0x11, 0x15, 0x1f,
                     0x27, 0x26, 0x29, 0x2f, 0x1e,
    CMD,   0xe2, 13, 0x07, 0x01, 0x01, 0x05, 0x09, 0x0f, 0x13, 0x1e,
                     0x26, 0x25, 0x28, 0x2e, 0x1e,
    CMD,   0xe3, 13, 0x00, 0x00, 0x00, 0x05, 0x0b, 0x12, 0x16, 0x1f,
                     0x25, 0x22, 0x24, 0x29, 0x1c,
    CMD,   0xe4, 13, 0x08, 0x01, 0x01, 0x06, 0x0b, 0x11, 0x15, 0x1f,
                     0x27, 0x26, 0x29, 0x2f, 0x1e,
    CMD,   0xe5, 13, 0x07, 0x01, 0x01, 0x05, 0x09, 0x0f, 0x13, 0x1e,
                     0x26, 0x25, 0x28, 0x2e, 0x1e,

    CMD,   0x3a,  1, 0x06,  /* Pixel Format Set */
    CMD,   0xc2,  1, 0x00,  /* Power Control */
    CMD,   0x35,  1, 0x00,  /* Tearing Effect Line On */

    CMD,   0x11,  0,        /* Sleep Out */
    SLEEP, 6,               /* 60 ms */
    CMD,   0x13,  0,        /* Normal Mode On */
    CMD,   0x29,  0,        /* Display On */
    END
};
#endif /* BOOTLOADER */
#endif /* HAVE_LCD_SLEEP || BOOTLOADER */


static struct lcd_info_rec lcd_info_list[] =
{
    [0] = {
        .lcd_type   = 0,
        .mpuiface   = LCD_MPUIFACE_PAR18,
        .cmdset     = LCD_CMDSET_8BIT,
    #if defined(HAVE_LCD_SLEEP) || defined(HAVE_LCD_SHUTDOWN)
        .seq_sleep  = (void*) lcd_sleep_seq_01,
    #endif
    #ifdef HAVE_LCD_SLEEP
        .seq_awake  = (void*) lcd_awake_seq_01,
    #endif
    #ifdef BOOTLOADER
        .seq_init   = (void*) lcd_init_seq_0,
    #endif
    },

    [1] = {
        .lcd_type   = 1,
        .mpuiface   = LCD_MPUIFACE_PAR18,
        .cmdset     = LCD_CMDSET_8BIT,
    #if defined(HAVE_LCD_SLEEP) || defined(HAVE_LCD_SHUTDOWN)
        .seq_sleep  = (void*) lcd_sleep_seq_01,
    #endif
    #ifdef HAVE_LCD_SLEEP
        .seq_awake  = (void*) lcd_awake_seq_01,
    #endif
    #ifdef BOOTLOADER
        .seq_init   = (void*) lcd_init_seq_1,
    #endif
    },

    [2] = {
        .lcd_type   = 2,
        .mpuiface   = LCD_MPUIFACE_PAR18,
        .cmdset     = LCD_CMDSET_16BIT,
    #if defined(HAVE_LCD_SLEEP) || defined(HAVE_LCD_SHUTDOWN)
        .seq_sleep  = (void*) lcd_deepstandby_seq_23,
    #endif
    #ifdef HAVE_LCD_SLEEP
        .seq_awake  = (void*) lcd_init_seq_23,
    #endif
    #ifdef BOOTLOADER
        .seq_init   = (void*) lcd_init_seq_23,
    #endif
    },

    [3] = {
        .lcd_type   = 3,
        .mpuiface   = LCD_MPUIFACE_PAR18,
        .cmdset     = LCD_CMDSET_16BIT,
    #if defined(HAVE_LCD_SLEEP) || defined(HAVE_LCD_SHUTDOWN)
        .seq_sleep  = (void*) lcd_deepstandby_seq_23,
    #endif
    #ifdef HAVE_LCD_SLEEP
        .seq_awake  = (void*) lcd_init_seq_23,
    #endif
    #ifdef BOOTLOADER
        .seq_init   = (void*) lcd_init_seq_23,
    #endif
    },
};

struct lcd_info_rec* lcd_target_get_info(void)
{
    return &lcd_info_list[(PDAT6 & 0x30) >> 4];
}