summaryrefslogtreecommitdiff
path: root/firmware/target/mips/ingenic_jz47xx/onda_vx767/lcd-ondavx767.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/mips/ingenic_jz47xx/onda_vx767/lcd-ondavx767.c')
-rw-r--r--firmware/target/mips/ingenic_jz47xx/onda_vx767/lcd-ondavx767.c195
1 files changed, 195 insertions, 0 deletions
diff --git a/firmware/target/mips/ingenic_jz47xx/onda_vx767/lcd-ondavx767.c b/firmware/target/mips/ingenic_jz47xx/onda_vx767/lcd-ondavx767.c
new file mode 100644
index 0000000000..63d1736ebe
--- /dev/null
+++ b/firmware/target/mips/ingenic_jz47xx/onda_vx767/lcd-ondavx767.c
@@ -0,0 +1,195 @@
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#define PIN_UNK_N (32*2+19)
29
30#define my__gpio_as_lcd_16bit() \
31do { \
32 REG_GPIO_PXFUNS(2) = 0x0014ffff; \
33 REG_GPIO_PXSELC(2) = 0x0014ffff; \
34 REG_GPIO_PXPES(2) = 0x0014ffff; \
35} while (0)
36
37
38#define SLEEP(x) for(i=0; i<x; i++) asm("nop"); asm("nop");
39#define DELAY SLEEP(700000);
40static void _display_pin_init(void)
41{
42 int i;
43 my__gpio_as_lcd_16bit();
44 __gpio_as_output(PIN_UNK_N);
45 __gpio_set_pin(PIN_UNK_N);
46 __gpio_as_output(PIN_CS_N);
47 __gpio_as_output(PIN_RESET_N);
48 DELAY; /* delay_ms(10); */
49
50 __gpio_clear_pin(PIN_CS_N);
51 DELAY; /* delay_ms(10); */
52
53 __gpio_set_pin(PIN_RESET_N);
54 DELAY; /* delay_ms(10); */
55 __gpio_clear_pin(PIN_RESET_N);
56 DELAY; /* delay_ms(10); */
57 __gpio_set_pin(PIN_RESET_N);
58 DELAY; /* delay_ms(10); */
59}
60
61#define WAIT_ON_SLCD while(REG_SLCD_STATE & SLCD_STATE_BUSY);
62#define SLCD_SET_DATA(x) WAIT_ON_SLCD; REG_SLCD_DATA = (x) | SLCD_DATA_RS_DATA;
63#define SLCD_SET_COMMAND(x) WAIT_ON_SLCD; REG_SLCD_DATA = (x) | SLCD_DATA_RS_COMMAND;
64#define SLCD_SEND_COMMAND(cmd,val) SLCD_SET_COMMAND(cmd); __gpio_set_pin(PIN_UNK_N); SLCD_SET_DATA(val); __gpio_clear_pin(PIN_UNK_N);
65static void _display_init(void)
66{
67 int i;
68
69 SLCD_SEND_COMMAND(0xE3, 0x8);
70 SLCD_SEND_COMMAND(0xE4, 0x1411);
71 SLCD_SEND_COMMAND(0xE5, 0x8000);
72 SLCD_SEND_COMMAND(0x0, 0x1);
73 DELAY; /* delay_ms(10); */
74
75 SLCD_SEND_COMMAND(0x1, 0x100);
76 SLCD_SEND_COMMAND(0x2, 0x400);
77 SLCD_SEND_COMMAND(0x3, 0x1028);
78 SLCD_SEND_COMMAND(0x4, 0);
79 SLCD_SEND_COMMAND(0x8, 0x202);
80 SLCD_SEND_COMMAND(0x9, 0);
81 SLCD_SEND_COMMAND(0xA, 0);
82 SLCD_SEND_COMMAND(0xC, 0);
83 SLCD_SEND_COMMAND(0xD, 0);
84 SLCD_SEND_COMMAND(0xF, 0);
85 SLCD_SEND_COMMAND(0x10, 0);
86 SLCD_SEND_COMMAND(0x11, 0x7);
87 SLCD_SEND_COMMAND(0x12, 0);
88 SLCD_SEND_COMMAND(0x13, 0);
89 SLCD_SEND_COMMAND(0x10, 0x17B0);
90 SLCD_SEND_COMMAND(0x11, 0x4);
91 SLCD_SEND_COMMAND(0x12, 0x13C);
92 SLCD_SEND_COMMAND(0x13, 0x1B00);
93 SLCD_SEND_COMMAND(0x29, 0x16);
94 SLCD_SEND_COMMAND(0x20, 0);
95 SLCD_SEND_COMMAND(0x21, 0);
96 SLCD_SEND_COMMAND(0x2B, 0x20);
97 SLCD_SEND_COMMAND(0x30, 0);
98 SLCD_SEND_COMMAND(0x31, 0x403);
99 SLCD_SEND_COMMAND(0x32, 0x400);
100 SLCD_SEND_COMMAND(0x35, 0x5);
101 SLCD_SEND_COMMAND(0x36, 0x6);
102 SLCD_SEND_COMMAND(0x37, 0x606);
103 SLCD_SEND_COMMAND(0x38, 0x106);
104 SLCD_SEND_COMMAND(0x39, 0x7);
105 SLCD_SEND_COMMAND(0x3C, 0x700);
106 SLCD_SEND_COMMAND(0x3D, 0x707);
107 SLCD_SEND_COMMAND(0x50, 0);
108 SLCD_SEND_COMMAND(0x51, 239);
109 SLCD_SEND_COMMAND(0x52, 0);
110 SLCD_SEND_COMMAND(0x53, 319);
111 SLCD_SEND_COMMAND(0x60, 0x2700);
112 SLCD_SEND_COMMAND(0x61, 0x1);
113 SLCD_SEND_COMMAND(0x6A, 0);
114 SLCD_SEND_COMMAND(0x80, 0);
115 SLCD_SEND_COMMAND(0x81, 0);
116 SLCD_SEND_COMMAND(0x82, 0);
117 SLCD_SEND_COMMAND(0x83, 0);
118 SLCD_SEND_COMMAND(0x84, 0);
119 SLCD_SEND_COMMAND(0x85, 0);
120 SLCD_SEND_COMMAND(0x90, 0x10);
121 SLCD_SEND_COMMAND(0x92, 0);
122 SLCD_SEND_COMMAND(0x93, 0x3);
123 SLCD_SEND_COMMAND(0x95, 0x110);
124 SLCD_SEND_COMMAND(0x97, 0);
125 SLCD_SEND_COMMAND(0x98, 0);
126 SLCD_SEND_COMMAND(0x7, 0x173);
127
128 SLCD_SET_COMMAND(0x22);
129 __gpio_set_pin(PIN_UNK_N);
130}
131
132static void _display_on(void)
133{
134}
135
136static void _display_off(void)
137{
138}
139
140static void _set_lcd_bus(void)
141{
142 REG_LCD_CFG &= ~LCD_CFG_LCDPIN_MASK;
143 REG_LCD_CFG |= LCD_CFG_LCDPIN_SLCD;
144
145 REG_SLCD_CFG = (SLCD_CFG_BURST_4_WORD | SLCD_CFG_DWIDTH_18 | SLCD_CFG_CWIDTH_18BIT
146 | SLCD_CFG_CS_ACTIVE_LOW | SLCD_CFG_RS_CMD_LOW | SLCD_CFG_CLK_ACTIVE_FALLING
147 | SLCD_CFG_TYPE_PARALLEL);
148
149 REG_SLCD_CTRL = SLCD_CTRL_DMA_EN;
150}
151
152static void _set_lcd_clock(void)
153{
154 unsigned int val;
155 int pll_div;
156
157 __cpm_stop_lcd();
158 pll_div = ( REG_CPM_CPCCR & CPM_CPCCR_PCS ); /* clock source, 0:pllout/2 1: pllout */
159 pll_div = pll_div ? 1 : 2 ;
160 val = ( __cpm_get_pllout()/pll_div ) / 336000000;
161 val--;
162 if ( val > 0x1ff )
163 val = 0x1ff; /* CPM_LPCDR is too large, set it to 0x1ff */
164 __cpm_set_pixdiv(val);
165 __cpm_start_lcd();
166}
167
168void lcd_init_controller(void)
169{
170 int i;
171 _display_pin_init();
172 _set_lcd_bus();
173 _set_lcd_clock();
174 SLEEP(1000);
175 _display_init();
176}
177
178void lcd_set_target(short x, short y, short width, short height)
179{
180 SLCD_SEND_COMMAND(0x50, y);
181 SLCD_SEND_COMMAND(0x51, y+height-1);
182 SLCD_SEND_COMMAND(0x52, x);
183 SLCD_SEND_COMMAND(0x53, x+width-1);
184 /* TODO */
185}
186
187void lcd_on(void)
188{
189 _display_on();
190}
191
192void lcd_off(void)
193{
194 _display_off();
195}