diff options
Diffstat (limited to 'firmware/target/mips/ingenic_jz47xx')
-rw-r--r-- | firmware/target/mips/ingenic_jz47xx/lcd-target.h (renamed from firmware/target/mips/ingenic_jz47xx/onda_vx747/lcd-target.h) | 0 | ||||
-rw-r--r-- | firmware/target/mips/ingenic_jz47xx/onda_vx767/adc-target.h | 28 | ||||
-rw-r--r-- | firmware/target/mips/ingenic_jz47xx/onda_vx767/backlight-ondavx767.c | 80 | ||||
-rw-r--r-- | firmware/target/mips/ingenic_jz47xx/onda_vx767/backlight-target.h | 37 | ||||
-rw-r--r-- | firmware/target/mips/ingenic_jz47xx/onda_vx767/button-ondavx767.c | 70 | ||||
-rw-r--r-- | firmware/target/mips/ingenic_jz47xx/onda_vx767/button-target.h | 54 | ||||
-rw-r--r-- | firmware/target/mips/ingenic_jz47xx/onda_vx767/lcd-ondavx767.c | 195 | ||||
-rw-r--r-- | firmware/target/mips/ingenic_jz47xx/system-jz4740.c | 122 |
8 files changed, 536 insertions, 50 deletions
diff --git a/firmware/target/mips/ingenic_jz47xx/onda_vx747/lcd-target.h b/firmware/target/mips/ingenic_jz47xx/lcd-target.h index e643608d56..e643608d56 100644 --- a/firmware/target/mips/ingenic_jz47xx/onda_vx747/lcd-target.h +++ b/firmware/target/mips/ingenic_jz47xx/lcd-target.h | |||
diff --git a/firmware/target/mips/ingenic_jz47xx/onda_vx767/adc-target.h b/firmware/target/mips/ingenic_jz47xx/onda_vx767/adc-target.h new file mode 100644 index 0000000000..e74f008a3e --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/onda_vx767/adc-target.h | |||
@@ -0,0 +1,28 @@ | |||
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 | #ifndef _ADC_TARGET_H_ | ||
22 | #define _ADC_TARGET_H_ | ||
23 | |||
24 | #define NUM_ADC_CHANNELS 4 | ||
25 | |||
26 | #define ADC_BUTTONS 0 | ||
27 | |||
28 | #endif /* _ADC_TARGET_H_ */ | ||
diff --git a/firmware/target/mips/ingenic_jz47xx/onda_vx767/backlight-ondavx767.c b/firmware/target/mips/ingenic_jz47xx/onda_vx767/backlight-ondavx767.c new file mode 100644 index 0000000000..9deab7712a --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/onda_vx767/backlight-ondavx767.c | |||
@@ -0,0 +1,80 @@ | |||
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 "backlight-target.h" | ||
25 | |||
26 | #define GPIO_PWM 123 | ||
27 | #define PWM_CHN 7 | ||
28 | #define PWM_FULL 101 | ||
29 | |||
30 | static void set_backlight(int unk, int val) | ||
31 | { | ||
32 | if(val == 0) | ||
33 | __gpio_as_pwm7(); | ||
34 | else | ||
35 | { | ||
36 | REG_TCU_TCSR(7) |= 2; | ||
37 | REG_TCU_TCSR(7) &= ~0x100; | ||
38 | int tmp; | ||
39 | tmp = (unk/2 + __cpm_get_rtcclk()) / unk; | ||
40 | if(tmp > 0xFFFF) | ||
41 | tmp = 0xFFFF; | ||
42 | |||
43 | __tcu_set_half_data(7, (tmp * unk * 1374389535) >> 5); | ||
44 | __tcu_set_full_data(7, tmp); | ||
45 | |||
46 | REG_TCU_TSCR = (1 << 7); | ||
47 | REG_TCU_TESR = (1 << 7); | ||
48 | |||
49 | __tcu_enable_pwm_output(7); | ||
50 | } | ||
51 | __tcu_set_count(7, 0); | ||
52 | } | ||
53 | |||
54 | bool _backlight_init(void) | ||
55 | { | ||
56 | __gpio_as_pwm7(); | ||
57 | |||
58 | __tcu_stop_counter(7); | ||
59 | __tcu_disable_pwm_output(7); | ||
60 | |||
61 | set_backlight(300, 7); | ||
62 | |||
63 | return true; | ||
64 | } | ||
65 | void _backlight_on(void) | ||
66 | { | ||
67 | set_backlight(300, 7); | ||
68 | } | ||
69 | void _backlight_off(void) | ||
70 | { | ||
71 | set_backlight(300, 0); | ||
72 | } | ||
73 | |||
74 | #ifdef HAVE_BACKLIGHT_BRIGHTNESS | ||
75 | void _backlight_set_brightness(int brightness) | ||
76 | { | ||
77 | (void)brightness; | ||
78 | return; | ||
79 | } | ||
80 | #endif | ||
diff --git a/firmware/target/mips/ingenic_jz47xx/onda_vx767/backlight-target.h b/firmware/target/mips/ingenic_jz47xx/onda_vx767/backlight-target.h new file mode 100644 index 0000000000..4170f96cc0 --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/onda_vx767/backlight-target.h | |||
@@ -0,0 +1,37 @@ | |||
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 | #ifndef BACKLIGHT_TARGET_H | ||
22 | #define BACKLIGHT_TARGET_H | ||
23 | |||
24 | #ifdef BOOTLOADER | ||
25 | #define BACKLIGHT_DRIVER_CLOSE | ||
26 | /* Force the whole driver to be built */ | ||
27 | #define BACKLIGHT_FULL_INIT | ||
28 | #endif | ||
29 | |||
30 | #include <stdbool.h> | ||
31 | |||
32 | bool _backlight_init(void); | ||
33 | void _backlight_on(void); | ||
34 | void _backlight_off(void); | ||
35 | void _backlight_set_brightness(int brightness); | ||
36 | |||
37 | #endif /* BACKLIGHT_TARGET_H */ | ||
diff --git a/firmware/target/mips/ingenic_jz47xx/onda_vx767/button-ondavx767.c b/firmware/target/mips/ingenic_jz47xx/onda_vx767/button-ondavx767.c new file mode 100644 index 0000000000..8b033a1bee --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/onda_vx767/button-ondavx767.c | |||
@@ -0,0 +1,70 @@ | |||
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 "system.h" | ||
24 | #include "jz4740.h" | ||
25 | #include "button-target.h" | ||
26 | |||
27 | #define BTN_VOL_DOWN (1 << 27) | ||
28 | #define BTN_VOL_UP (1 << 0) | ||
29 | #define BTN_MENU (1 << 1) | ||
30 | #define BTN_OFF (1 << 29) | ||
31 | #define BTN_HOLD (1 << 16) | ||
32 | #define BTN_MASK (BTN_VOL_DOWN | BTN_VOL_UP \ | ||
33 | | BTN_MENU | BTN_OFF ) | ||
34 | |||
35 | bool button_hold(void) | ||
36 | { | ||
37 | return (~REG_GPIO_PXPIN(3) & BTN_HOLD ? 1 : 0); | ||
38 | } | ||
39 | |||
40 | void button_init_device(void) | ||
41 | { | ||
42 | __gpio_port_as_input(3, 29); | ||
43 | __gpio_port_as_input(3, 27); | ||
44 | __gpio_port_as_input(3, 16); | ||
45 | __gpio_port_as_input(3, 1); | ||
46 | __gpio_port_as_input(3, 0); | ||
47 | } | ||
48 | |||
49 | int button_read_device(void) | ||
50 | { | ||
51 | if(button_hold()) | ||
52 | return 0; | ||
53 | |||
54 | unsigned int key = ~(__gpio_get_port(3)); | ||
55 | int ret = 0; | ||
56 | |||
57 | if(key & BTN_MASK) | ||
58 | { | ||
59 | if(key & BTN_VOL_DOWN) | ||
60 | ret |= BUTTON_VOL_DOWN; | ||
61 | if(key & BTN_VOL_UP) | ||
62 | ret |= BUTTON_VOL_UP; | ||
63 | if(key & BTN_MENU) | ||
64 | ret |= BUTTON_MENU; | ||
65 | if(key & BTN_OFF) | ||
66 | ret |= BUTTON_POWER; | ||
67 | } | ||
68 | |||
69 | return ret; | ||
70 | } | ||
diff --git a/firmware/target/mips/ingenic_jz47xx/onda_vx767/button-target.h b/firmware/target/mips/ingenic_jz47xx/onda_vx767/button-target.h new file mode 100644 index 0000000000..32325d1423 --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/onda_vx767/button-target.h | |||
@@ -0,0 +1,54 @@ | |||
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 | #ifndef BUTTON_TARGET_H | ||
22 | #define BUTTON_TARGET_H | ||
23 | |||
24 | #include <stdbool.h> | ||
25 | #include "config.h" | ||
26 | |||
27 | #define HAS_BUTTON_HOLD | ||
28 | |||
29 | bool button_hold(void); | ||
30 | void button_init_device(void); | ||
31 | int button_read_device(void); | ||
32 | |||
33 | /* Main unit's buttons */ | ||
34 | #define BUTTON_POWER 0x00000001 | ||
35 | #define BUTTON_VOL_UP 0x00000002 | ||
36 | #define BUTTON_VOL_DOWN 0x00000004 | ||
37 | #define BUTTON_MENU 0x00000008 | ||
38 | |||
39 | /* Compatibility hacks for flipping. Needs a somewhat better fix. */ | ||
40 | #define BUTTON_LEFT 0 | ||
41 | #define BUTTON_RIGHT 0 | ||
42 | #define BUTTON_UP 0 | ||
43 | #define BUTTON_DOWN 0 | ||
44 | |||
45 | #define BUTTON_MAIN (BUTTON_POWER | BUTTON_VOL_UP | BUTTON_VOL_DOWN | BUTTON_MENU) | ||
46 | |||
47 | /* No remote */ | ||
48 | #define BUTTON_REMOTE 0 | ||
49 | |||
50 | /* Software power-off */ | ||
51 | #define POWEROFF_BUTTON BUTTON_POWER | ||
52 | #define POWEROFF_COUNT 10 | ||
53 | |||
54 | #endif /* BUTTON_TARGET_H */ | ||
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() \ | ||
31 | do { \ | ||
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); | ||
40 | static 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); | ||
65 | static 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 | |||
132 | static void _display_on(void) | ||
133 | { | ||
134 | } | ||
135 | |||
136 | static void _display_off(void) | ||
137 | { | ||
138 | } | ||
139 | |||
140 | static 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 | |||
152 | static 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 | |||
168 | void 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 | |||
178 | void 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 | |||
187 | void lcd_on(void) | ||
188 | { | ||
189 | _display_on(); | ||
190 | } | ||
191 | |||
192 | void lcd_off(void) | ||
193 | { | ||
194 | _display_off(); | ||
195 | } | ||
diff --git a/firmware/target/mips/ingenic_jz47xx/system-jz4740.c b/firmware/target/mips/ingenic_jz47xx/system-jz4740.c index 8f1c3f5c1a..61be6c60de 100644 --- a/firmware/target/mips/ingenic_jz47xx/system-jz4740.c +++ b/firmware/target/mips/ingenic_jz47xx/system-jz4740.c | |||
@@ -555,21 +555,7 @@ void dma_cache_wback_inv(unsigned long addr, unsigned long size) | |||
555 | } | 555 | } |
556 | } | 556 | } |
557 | 557 | ||
558 | extern int main(void); | 558 | #define BARRIER \ |
559 | extern void except_common_entry(void); | ||
560 | |||
561 | #define mtc0_tlbw_hazard() \ | ||
562 | __asm__ __volatile__( \ | ||
563 | " .set noreorder \n" \ | ||
564 | " nop \n" \ | ||
565 | " nop \n" \ | ||
566 | " nop \n" \ | ||
567 | " nop \n" \ | ||
568 | " nop \n" \ | ||
569 | " nop \n" \ | ||
570 | " .set reorder \n"); | ||
571 | |||
572 | #define tlbw_use_hazard() \ | ||
573 | __asm__ __volatile__( \ | 559 | __asm__ __volatile__( \ |
574 | " .set noreorder \n" \ | 560 | " .set noreorder \n" \ |
575 | " nop \n" \ | 561 | " nop \n" \ |
@@ -580,10 +566,13 @@ extern void except_common_entry(void); | |||
580 | " nop \n" \ | 566 | " nop \n" \ |
581 | " .set reorder \n"); | 567 | " .set reorder \n"); |
582 | 568 | ||
583 | 569 | #define DEFAULT_PAGE_SHIFT PL_4K | |
584 | #define PAGE_SHIFT PL_4K | 570 | #define DEFAULT_PAGE_MASK PM_4K |
585 | #define PM_DEFAULT_MASK PM_4K | 571 | #define UNIQUE_ENTRYHI(idx, ps) (A_K0BASE + ((idx) << (ps + 1))) |
586 | #define UNIQUE_ENTRYHI(idx) (A_K0BASE + ((idx) << (PAGE_SHIFT + 1))) | 572 | #define ASID_MASK M_EntryHiASID |
573 | #define VPN2_SHIFT S_EntryHiVPN2 | ||
574 | #define PFN_SHIFT S_EntryLoPFN | ||
575 | #define PFN_MASK 0xffffff | ||
587 | static void local_flush_tlb_all(void) | 576 | static void local_flush_tlb_all(void) |
588 | { | 577 | { |
589 | unsigned long old_ctx; | 578 | unsigned long old_ctx; |
@@ -594,59 +583,92 @@ static void local_flush_tlb_all(void) | |||
594 | old_ctx = read_c0_entryhi(); | 583 | old_ctx = read_c0_entryhi(); |
595 | write_c0_entrylo0(0); | 584 | write_c0_entrylo0(0); |
596 | write_c0_entrylo1(0); | 585 | write_c0_entrylo1(0); |
586 | BARRIER; | ||
597 | 587 | ||
598 | /* Blast 'em all away. */ | 588 | /* Blast 'em all away. */ |
599 | for(entry = read_c0_wired(); entry < 32; entry++) | 589 | for(entry = 0; entry < 32; entry++) |
600 | { | 590 | { |
601 | /* Make sure all entries differ. */ | 591 | /* Make sure all entries differ. */ |
602 | write_c0_entryhi(UNIQUE_ENTRYHI(entry)); | 592 | write_c0_entryhi(UNIQUE_ENTRYHI(entry, DEFAULT_PAGE_SHIFT)); |
603 | write_c0_index(entry); | 593 | write_c0_index(entry); |
604 | mtc0_tlbw_hazard(); | 594 | BARRIER; |
605 | tlb_write_indexed(); | 595 | tlb_write_indexed(); |
606 | } | 596 | } |
607 | tlbw_use_hazard(); | 597 | BARRIER; |
608 | write_c0_entryhi(old_ctx); | 598 | write_c0_entryhi(old_ctx); |
609 | 599 | ||
610 | restore_irq(old_irq); | 600 | restore_irq(old_irq); |
611 | } | 601 | } |
612 | 602 | ||
603 | static void add_wired_entry(unsigned long entrylo0, unsigned long entrylo1, | ||
604 | unsigned long entryhi, unsigned long pagemask) | ||
605 | { | ||
606 | unsigned long wired; | ||
607 | unsigned long old_pagemask; | ||
608 | unsigned long old_ctx; | ||
609 | unsigned int old_irq = disable_irq_save(); | ||
610 | |||
611 | old_ctx = read_c0_entryhi() & ASID_MASK; | ||
612 | old_pagemask = read_c0_pagemask(); | ||
613 | wired = read_c0_wired(); | ||
614 | write_c0_wired(wired + 1); | ||
615 | write_c0_index(wired); | ||
616 | BARRIER; | ||
617 | write_c0_pagemask(pagemask); | ||
618 | write_c0_entryhi(entryhi); | ||
619 | write_c0_entrylo0(entrylo0); | ||
620 | write_c0_entrylo1(entrylo1); | ||
621 | BARRIER; | ||
622 | tlb_write_indexed(); | ||
623 | BARRIER; | ||
624 | |||
625 | write_c0_entryhi(old_ctx); | ||
626 | BARRIER; | ||
627 | write_c0_pagemask(old_pagemask); | ||
628 | local_flush_tlb_all(); | ||
629 | restore_irq(old_irq); | ||
630 | } | ||
631 | |||
632 | static void map_address(unsigned long virtual, unsigned long physical, unsigned long length) | ||
633 | { | ||
634 | unsigned long entry0 = (physical & PFN_MASK) << PFN_SHIFT; | ||
635 | unsigned long entry1 = ((physical+length) & PFN_MASK) << PFN_SHIFT; | ||
636 | unsigned long entryhi = virtual & ~VPN2_SHIFT; | ||
637 | |||
638 | entry0 |= (M_EntryLoG | M_EntryLoV | (K_CacheAttrC << S_EntryLoC) ); | ||
639 | entry1 |= (M_EntryLoG | M_EntryLoV | (K_CacheAttrC << S_EntryLoC) ); | ||
640 | |||
641 | add_wired_entry(entry0, entry1, entryhi, DEFAULT_PAGE_MASK); | ||
642 | } | ||
643 | |||
613 | 644 | ||
614 | static void tlb_init(void) | 645 | static void tlb_init(void) |
615 | { | 646 | { |
616 | write_c0_pagemask(PM_DEFAULT_MASK); | 647 | write_c0_pagemask(DEFAULT_PAGE_MASK); |
617 | write_c0_wired(0); | 648 | write_c0_wired(0); |
618 | write_c0_framemask(0); | 649 | write_c0_framemask(0); |
619 | 650 | ||
620 | local_flush_tlb_all(); | 651 | local_flush_tlb_all(); |
652 | /* | ||
653 | map_address(0x80000000, 0x80000000, 0x4000); | ||
654 | map_address(0x80004000, 0x80004000, MEM * 0x100000); | ||
655 | */ | ||
621 | } | 656 | } |
622 | 657 | ||
623 | static void tlb_refill_handler(void) | 658 | void tlb_refill_handler(void) |
624 | { | 659 | { |
625 | #if 1 | 660 | panicf("TLB refill handler! [0x%x] [0x%lx]", read_c0_badvaddr(), read_c0_epc()); |
626 | panicf("TLB refill handler! [0x%x] [0x%x]", read_c0_badvaddr(), read_c0_epc()); | ||
627 | #else | ||
628 | __asm__ __volatile__( | ||
629 | "mfc0 k0, C0_BADVADDR\n" | ||
630 | "lui k1, pgdc\n" | ||
631 | "lw k1, pgdc>>16(k0)\n" | ||
632 | "srl k0, k0, 22\n" | ||
633 | "sll k0, k0, 2\n" | ||
634 | "addu k1, k1, k0\n" | ||
635 | "mfc0 k0, C0_CONTEXT\n" | ||
636 | "lw k1, 0(k1)\n" | ||
637 | "andi k0, k0, 0xFFC\n" | ||
638 | "addu k1, k1, k0\n" | ||
639 | "lw k0, 0(k1)\n" | ||
640 | "nop\n" | ||
641 | "mtc0 k0, C0_ENTRYLO0\n" | ||
642 | "mfc0 k1, C0_EPC\n" | ||
643 | "tlbwr\n" | ||
644 | "jr k1\n" | ||
645 | "rfe\n" | ||
646 | ); | ||
647 | #endif | ||
648 | } | 661 | } |
649 | 662 | ||
663 | static void tlb_call_refill(void) | ||
664 | { | ||
665 | asm("la $8, tlb_refill_handler \n" | ||
666 | "jr $8 \n"); | ||
667 | } | ||
668 | |||
669 | extern int main(void); | ||
670 | extern void except_common_entry(void); | ||
671 | |||
650 | void system_main(void) | 672 | void system_main(void) |
651 | { | 673 | { |
652 | int i; | 674 | int i; |
@@ -657,7 +679,7 @@ void system_main(void) | |||
657 | * 0x180 - Exception/Interrupt handler | 679 | * 0x180 - Exception/Interrupt handler |
658 | * 0x200 - Special Exception Interrupt handler (when IV is set in CP0_CAUSE) | 680 | * 0x200 - Special Exception Interrupt handler (when IV is set in CP0_CAUSE) |
659 | */ | 681 | */ |
660 | memcpy((void *)A_K0BASE, (void *)&tlb_refill_handler, 0x20); | 682 | memcpy((void *)A_K0BASE, (void *)&tlb_call_refill, 0x20); |
661 | memcpy((void *)(A_K0BASE + 0x100), (void *)&except_common_entry, 0x20); | 683 | memcpy((void *)(A_K0BASE + 0x100), (void *)&except_common_entry, 0x20); |
662 | memcpy((void *)(A_K0BASE + 0x180), (void *)&except_common_entry, 0x20); | 684 | memcpy((void *)(A_K0BASE + 0x180), (void *)&except_common_entry, 0x20); |
663 | memcpy((void *)(A_K0BASE + 0x200), (void *)&except_common_entry, 0x20); | 685 | memcpy((void *)(A_K0BASE + 0x200), (void *)&except_common_entry, 0x20); |
@@ -671,7 +693,7 @@ void system_main(void) | |||
671 | for(i=0; i<IRQ_MAX; i++) | 693 | for(i=0; i<IRQ_MAX; i++) |
672 | dis_irq(i); | 694 | dis_irq(i); |
673 | 695 | ||
674 | tlb_init(); | 696 | //tlb_init(); |
675 | 697 | ||
676 | sti(); | 698 | sti(); |
677 | 699 | ||