summaryrefslogtreecommitdiff
path: root/firmware/target/mips/ingenic_jz47xx/onda_vx747/lcd-onda_vx747.c
diff options
context:
space:
mode:
authorMaurus Cuelenaere <mcuelenaere@gmail.com>2008-07-14 15:03:10 +0000
committerMaurus Cuelenaere <mcuelenaere@gmail.com>2008-07-14 15:03:10 +0000
commit0709f0a5c60b5525ff98708887f5f1e5b0b570c2 (patch)
tree849fd125aa7b217228d584212d2930d8259ff5d8 /firmware/target/mips/ingenic_jz47xx/onda_vx747/lcd-onda_vx747.c
parent4f199817488708ba60724accb6ce76886f855af8 (diff)
downloadrockbox-0709f0a5c60b5525ff98708887f5f1e5b0b570c2.tar.gz
rockbox-0709f0a5c60b5525ff98708887f5f1e5b0b570c2.zip
Add preliminary support for the Onda VX747 (MIPS target)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18032 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/mips/ingenic_jz47xx/onda_vx747/lcd-onda_vx747.c')
-rwxr-xr-xfirmware/target/mips/ingenic_jz47xx/onda_vx747/lcd-onda_vx747.c201
1 files changed, 201 insertions, 0 deletions
diff --git a/firmware/target/mips/ingenic_jz47xx/onda_vx747/lcd-onda_vx747.c b/firmware/target/mips/ingenic_jz47xx/onda_vx747/lcd-onda_vx747.c
new file mode 100755
index 0000000000..d46cee6884
--- /dev/null
+++ b/firmware/target/mips/ingenic_jz47xx/onda_vx747/lcd-onda_vx747.c
@@ -0,0 +1,201 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 by Maurus Cuelenaere
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include "config.h"
23#include "jz4740.h"
24#include "lcd-target.h"
25
26#define PIN_CS_N (32*1+17) /* Chip select */
27#define PIN_RESET_N (32*1+18) /* Reset */
28
29#define my__gpio_as_lcd_16bit() \
30do { \
31 REG_GPIO_PXFUNS(2) = 0x001cffff; \
32 REG_GPIO_PXSELC(2) = 0x001cffff; \
33 REG_GPIO_PXPES(2) = 0x001cffff; \
34} while (0)
35
36
37#define SLEEP(x) for(i=0; i<x; i++) asm("nop"); asm("nop");
38#define DELAY SLEEP(700000);
39static void _display_pin_init(void)
40{
41 int i;
42 my__gpio_as_lcd_16bit();
43 __gpio_as_output(PIN_CS_N);
44 __gpio_as_output(PIN_RESET_N);
45 __gpio_clear_pin(PIN_CS_N);
46
47 __gpio_set_pin(PIN_RESET_N);
48 DELAY;
49 __gpio_clear_pin(PIN_RESET_N);
50 DELAY;
51 __gpio_set_pin(PIN_RESET_N);
52 DELAY;
53}
54
55#define WAIT_ON_SLCD while(REG_SLCD_STATE & SLCD_STATE_BUSY);
56#define SLCD_SET_DATA(x) WAIT_ON_SLCD; REG_SLCD_DATA = (x) | SLCD_DATA_RS_DATA;
57#define SLCD_SET_COMMAND(x) WAIT_ON_SLCD; REG_SLCD_DATA = (x) | SLCD_DATA_RS_COMMAND;
58#define SLCD_SEND_COMMAND(cmd,val) SLCD_SET_COMMAND(cmd); SLCD_SET_DATA(val);
59static void _display_on(void)
60{
61 int i;
62
63 SLCD_SEND_COMMAND(0x600, 1);
64 SLEEP(700000);
65 SLCD_SEND_COMMAND(0x600, 0);
66 SLEEP(700000);
67 SLCD_SEND_COMMAND(0x606, 0);
68
69 SLCD_SEND_COMMAND(1, 0x100);
70 SLCD_SEND_COMMAND(2, 0x100);
71 SLCD_SEND_COMMAND(3, 0x1028);
72 SLCD_SEND_COMMAND(8, 0x503);
73 SLCD_SEND_COMMAND(9, 1);
74 SLCD_SEND_COMMAND(0xB, 0x10);
75 SLCD_SEND_COMMAND(0xC, 0);
76 SLCD_SEND_COMMAND(0xF, 0);
77 SLCD_SEND_COMMAND(7, 1);
78 SLCD_SEND_COMMAND(0x10, 0x12);
79 SLCD_SEND_COMMAND(0x11, 0x202);
80 SLCD_SEND_COMMAND(0x12, 0x300);
81 SLCD_SEND_COMMAND(0x20, 0x21e);
82 SLCD_SEND_COMMAND(0x21, 0x202);
83 SLCD_SEND_COMMAND(0x22, 0x100);
84 SLCD_SEND_COMMAND(0x90, 0x8000);
85 SLCD_SEND_COMMAND(0x100, 0x16b0);
86 SLCD_SEND_COMMAND(0x101, 0x147);
87 SLCD_SEND_COMMAND(0x102, 0x1bd);
88 SLCD_SEND_COMMAND(0x103, 0x2f00);
89 SLCD_SEND_COMMAND(0x107, 0);
90 SLCD_SEND_COMMAND(0x110, 1);
91 SLCD_SEND_COMMAND(0x200, 0); /* set cursor at x_start */
92 SLCD_SEND_COMMAND(0x201, 0); /* set cursor at y_start */
93 SLCD_SEND_COMMAND(0x210, 0); /* y_start*/
94 SLCD_SEND_COMMAND(0x211, 239); /* y_end */
95 SLCD_SEND_COMMAND(0x212, 0); /* x_start */
96 SLCD_SEND_COMMAND(0x213, 399); /* x_end */
97 SLCD_SEND_COMMAND(0x280, 0);
98 SLCD_SEND_COMMAND(0x281, 6);
99 SLCD_SEND_COMMAND(0x282, 0);
100 SLCD_SEND_COMMAND(0x300, 0x101);
101 SLCD_SEND_COMMAND(0x301, 0xb27);
102 SLCD_SEND_COMMAND(0x302, 0x132a);
103 SLCD_SEND_COMMAND(0x303, 0x2a13);
104 SLCD_SEND_COMMAND(0x304, 0x270b);
105 SLCD_SEND_COMMAND(0x305, 0x101);
106 SLCD_SEND_COMMAND(0x306, 0x1205);
107 SLCD_SEND_COMMAND(0x307, 0x512);
108 SLCD_SEND_COMMAND(0x308, 5);
109 SLCD_SEND_COMMAND(0x309, 3);
110 SLCD_SEND_COMMAND(0x30a, 0xf04);
111 SLCD_SEND_COMMAND(0x30b, 0xf00);
112 SLCD_SEND_COMMAND(0x30c, 0xf);
113 SLCD_SEND_COMMAND(0x30d, 0x40f);
114 SLCD_SEND_COMMAND(0x30e, 0x300);
115 SLCD_SEND_COMMAND(0x30f, 0x500);
116 SLCD_SEND_COMMAND(0x400, 0x3100);
117 SLCD_SEND_COMMAND(0x401, 1);
118 SLCD_SEND_COMMAND(0x404, 0);
119 SLCD_SEND_COMMAND(0x500, 0);
120 SLCD_SEND_COMMAND(0x501, 0);
121 SLCD_SEND_COMMAND(0x502, 0);
122 SLCD_SEND_COMMAND(0x503, 0);
123 SLCD_SEND_COMMAND(0x504, 0);
124 SLCD_SEND_COMMAND(0x505, 0);
125 SLCD_SEND_COMMAND(0x606, 0);
126 SLCD_SEND_COMMAND(0x6f0, 0);
127 SLCD_SEND_COMMAND(0x7f0, 0x5420);
128 SLCD_SEND_COMMAND(0x7f3, 0x288a);
129 SLCD_SEND_COMMAND(0x7f4, 0x22);
130 SLCD_SEND_COMMAND(0x7f5, 1);
131 SLCD_SEND_COMMAND(0x7f0, 0);
132
133 SLCD_SEND_COMMAND(7, 0x173);
134 SLEEP(3500000);
135 SLCD_SEND_COMMAND(7, 0x171);
136 SLEEP(3500000);
137 SLCD_SEND_COMMAND(7, 0x173);
138 SLEEP(3500000);
139}
140
141static void _set_lcd_bus(void)
142{
143 REG_LCD_CFG &= ~LCD_CFG_LCDPIN_MASK;
144 REG_LCD_CFG |= LCD_CFG_LCDPIN_SLCD;
145
146 REG_SLCD_CFG = (SLCD_CFG_BURST_8_WORD | SLCD_CFG_DWIDTH_16 | SLCD_CFG_CWIDTH_16BIT
147 | SLCD_CFG_CS_ACTIVE_LOW | SLCD_CFG_RS_CMD_LOW | SLCD_CFG_CLK_ACTIVE_FALLING
148 | SLCD_CFG_TYPE_PARALLEL);
149
150 REG_SLCD_CTRL = SLCD_CTRL_DMA_EN;
151}
152
153static void _set_lcd_clock(void)
154{
155 unsigned int val;
156 int pll_div;
157
158 __cpm_stop_lcd();
159 pll_div = ( REG_CPM_CPCCR & CPM_CPCCR_PCS ); /* clock source,0:pllout/2 1: pllout */
160 pll_div = pll_div ? 1 : 2 ;
161 val = ( __cpm_get_pllout()/pll_div ) / 336000000;
162 val--;
163 if ( val > 0x1ff )
164 {
165 //printf("CPM_LPCDR too large, set it to 0x1ff\n");
166 val = 0x1ff;
167 }
168 __cpm_set_pixdiv(val);
169 __cpm_start_lcd();
170}
171
172void lcd_init_controller(void)
173{
174 int i;
175 _display_pin_init();
176 _set_lcd_bus();
177 _set_lcd_clock();
178 SLEEP(1000);
179 _display_on();
180}
181
182void lcd_set_target(short x, short y, short width, short height)
183{
184 SLCD_SEND_COMMAND(0x210, y); /* y_start */
185 SLCD_SEND_COMMAND(0x211, y+height); /* y_end */
186 SLCD_SEND_COMMAND(0x212, x); /* x_start */
187 SLCD_SEND_COMMAND(0x213, x+width); /* x_end */
188 SLCD_SEND_COMMAND(0x200, x); /* set cursor at x_start */
189 SLCD_SEND_COMMAND(0x201, y); /* set cursor at y_start */
190 SLCD_SET_COMMAND(0x202); /* write data? */
191}
192
193void lcd_on(void)
194{
195 _display_on();
196}
197
198void lcd_off(void)
199{
200 return;
201}