diff options
Diffstat (limited to 'firmware/target/arm/imx233/sansa-fuzeplus')
6 files changed, 569 insertions, 0 deletions
diff --git a/firmware/target/arm/imx233/sansa-fuzeplus/adc-target.h b/firmware/target/arm/imx233/sansa-fuzeplus/adc-target.h new file mode 100644 index 0000000000..e6b5152f5b --- /dev/null +++ b/firmware/target/arm/imx233/sansa-fuzeplus/adc-target.h | |||
@@ -0,0 +1,24 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2011 by Amaury Pouly | ||
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 | #endif | ||
diff --git a/firmware/target/arm/imx233/sansa-fuzeplus/backlight-fuzeplus.c b/firmware/target/arm/imx233/sansa-fuzeplus/backlight-fuzeplus.c new file mode 100644 index 0000000000..0638e30aeb --- /dev/null +++ b/firmware/target/arm/imx233/sansa-fuzeplus/backlight-fuzeplus.c | |||
@@ -0,0 +1,66 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2011 by Amaury Pouly | ||
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 "lcd.h" | ||
25 | #include "backlight.h" | ||
26 | #include "backlight-target.h" | ||
27 | #include "pinctrl-imx233.h" | ||
28 | |||
29 | void _backlight_set_brightness(int brightness) | ||
30 | { | ||
31 | imx233_set_gpio_output(1, 28, false); | ||
32 | udelay(600); | ||
33 | while(brightness-- > 0) | ||
34 | { | ||
35 | imx233_set_gpio_output(1, 28, false); | ||
36 | imx233_set_gpio_output(1, 28, true); | ||
37 | } | ||
38 | } | ||
39 | |||
40 | bool _backlight_init(void) | ||
41 | { | ||
42 | imx233_set_pin_function(1, 28, PINCTRL_FUNCTION_GPIO); | ||
43 | imx233_set_pin_drive_strength(1, 28, PINCTRL_DRIVE_8mA); | ||
44 | imx233_enable_gpio_output(1, 28, true); | ||
45 | imx233_set_gpio_output(1, 29, true); | ||
46 | udelay(600); | ||
47 | _backlight_set_brightness(100); | ||
48 | return true; | ||
49 | } | ||
50 | |||
51 | void _backlight_on(void) | ||
52 | { | ||
53 | #ifdef HAVE_LCD_ENABLE | ||
54 | lcd_enable(true); /* power on lcd + visible display */ | ||
55 | #endif | ||
56 | /* don't do anything special, the core will set the brightness */ | ||
57 | } | ||
58 | |||
59 | void _backlight_off(void) | ||
60 | { | ||
61 | /* there is no real on/off but we can set to 0 brightness */ | ||
62 | _backlight_set_brightness(0); | ||
63 | #ifdef HAVE_LCD_ENABLE | ||
64 | lcd_enable(false); /* power off visible display */ | ||
65 | #endif | ||
66 | } | ||
diff --git a/firmware/target/arm/imx233/sansa-fuzeplus/backlight-target.h b/firmware/target/arm/imx233/sansa-fuzeplus/backlight-target.h new file mode 100644 index 0000000000..e3766965d8 --- /dev/null +++ b/firmware/target/arm/imx233/sansa-fuzeplus/backlight-target.h | |||
@@ -0,0 +1,29 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2011 by Amaury Pouly | ||
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 | bool _backlight_init(void); | ||
25 | void _backlight_on(void); | ||
26 | void _backlight_off(void); | ||
27 | void _backlight_set_brightness(int brightness); | ||
28 | |||
29 | #endif /* BACKLIGHT_TARGET_H */ | ||
diff --git a/firmware/target/arm/imx233/sansa-fuzeplus/button-fuzeplus.c b/firmware/target/arm/imx233/sansa-fuzeplus/button-fuzeplus.c new file mode 100644 index 0000000000..7f37d67d43 --- /dev/null +++ b/firmware/target/arm/imx233/sansa-fuzeplus/button-fuzeplus.c | |||
@@ -0,0 +1,30 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2011 by Amaury Pouly | ||
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 | #include "button-target.h" | ||
22 | |||
23 | void button_init_device(void) | ||
24 | { | ||
25 | } | ||
26 | |||
27 | int button_read_device(void) | ||
28 | { | ||
29 | return 0; | ||
30 | } | ||
diff --git a/firmware/target/arm/imx233/sansa-fuzeplus/button-target.h b/firmware/target/arm/imx233/sansa-fuzeplus/button-target.h new file mode 100644 index 0000000000..b5d27bb176 --- /dev/null +++ b/firmware/target/arm/imx233/sansa-fuzeplus/button-target.h | |||
@@ -0,0 +1,44 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2011 by Amaury Pouly | ||
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 | void button_init_device(void); | ||
28 | int button_read_device(void); | ||
29 | |||
30 | /* Main unit's buttons */ | ||
31 | #define BUTTON_POWER 0x00000001 | ||
32 | |||
33 | #define BUTTON_VOL_UP 0x00000002 | ||
34 | #define BUTTON_VOL_DOWN 0x00000004 | ||
35 | |||
36 | #define BUTTON_MAIN (BUTTON_VOL_UP|BUTTON_VOL_DOWN|BUTTON_POWER) | ||
37 | |||
38 | #define BUTTON_REMOTE 0 | ||
39 | |||
40 | /* Software power-off */ | ||
41 | #define POWEROFF_BUTTON BUTTON_POWER | ||
42 | #define POWEROFF_COUNT 10 | ||
43 | |||
44 | #endif /* _BUTTON_TARGET_H_ */ | ||
diff --git a/firmware/target/arm/imx233/sansa-fuzeplus/lcd-fuzeplus.c b/firmware/target/arm/imx233/sansa-fuzeplus/lcd-fuzeplus.c new file mode 100644 index 0000000000..d6f8f5323b --- /dev/null +++ b/firmware/target/arm/imx233/sansa-fuzeplus/lcd-fuzeplus.c | |||
@@ -0,0 +1,376 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (c) 2011 by Amaury Pouly | ||
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 | #include <string.h> | ||
22 | #include "cpu.h" | ||
23 | #include "system.h" | ||
24 | #include "backlight-target.h" | ||
25 | #include "lcd.h" | ||
26 | #include "lcdif-imx233.h" | ||
27 | #include "clkctrl-imx233.h" | ||
28 | #include "pinctrl-imx233.h" | ||
29 | |||
30 | #define logf(...) | ||
31 | |||
32 | static enum lcd_kind_t | ||
33 | { | ||
34 | LCD_KIND_7783 = 0x7783, | ||
35 | LCD_KIND_9325 = 0x9325, | ||
36 | LCD_KIND_OTHER = 0, | ||
37 | } lcd_kind = LCD_KIND_OTHER; | ||
38 | |||
39 | static void setup_parameters(void) | ||
40 | { | ||
41 | imx233_lcdif_reset(); | ||
42 | imx233_lcdif_set_lcd_databus_width(HW_LCDIF_CTRL__LCD_DATABUS_WIDTH_18_BIT); | ||
43 | imx233_lcdif_set_word_length(HW_LCDIF_CTRL__WORD_LENGTH_18_BIT); | ||
44 | imx233_lcdif_set_timings(1, 2, 2, 2); | ||
45 | } | ||
46 | |||
47 | static void setup_lcd_pins(bool use_lcdif) | ||
48 | { | ||
49 | if(use_lcdif) | ||
50 | { | ||
51 | imx233_set_pin_function(1, 25, PINCTRL_FUNCTION_GPIO); /* lcd_vsync */ | ||
52 | imx233_set_pin_function(1, 21, PINCTRL_FUNCTION_MAIN); /* lcd_cs */ | ||
53 | imx233_set_pin_function(1, 22, PINCTRL_FUNCTION_GPIO); /* lcd_dotclk */ | ||
54 | imx233_set_pin_function(1, 23, PINCTRL_FUNCTION_GPIO); /* lcd_enable */ | ||
55 | imx233_set_pin_function(1, 24, PINCTRL_FUNCTION_GPIO); /* lcd_hsync */ | ||
56 | imx233_set_pin_function(1, 18, PINCTRL_FUNCTION_MAIN); /* lcd_reset */ | ||
57 | imx233_set_pin_function(1, 19, PINCTRL_FUNCTION_MAIN); /* lcd_rs */ | ||
58 | imx233_set_pin_function(1, 16, PINCTRL_FUNCTION_MAIN); /* lcd_d16 */ | ||
59 | imx233_set_pin_function(1, 17, PINCTRL_FUNCTION_MAIN); /* lcd_d17 */ | ||
60 | imx233_set_pin_function(1, 20, PINCTRL_FUNCTION_MAIN); /* lcd_wr */ | ||
61 | __REG_CLR(HW_PINCTRL_MUXSEL(2)) = 0xffffffff; /* lcd_d{0-15} */ | ||
62 | } | ||
63 | else | ||
64 | { | ||
65 | |||
66 | __REG_SET(HW_PINCTRL_MUXSEL(2)) = 0xffffffff; /* lcd_d{0-15} */ | ||
67 | imx233_enable_gpio_output_mask(1, 0x3ffffff, false); /* lcd_{d{0-17},reset,rs,wr,cs,dotclk,enable,hsync,vsync} */ | ||
68 | imx233_set_pin_function(1, 16, PINCTRL_FUNCTION_GPIO); /* lcd_d16 */ | ||
69 | imx233_set_pin_function(1, 17, PINCTRL_FUNCTION_GPIO); /* lcd_d17 */ | ||
70 | imx233_set_pin_function(1, 19, PINCTRL_FUNCTION_GPIO); /* lcd_rs */ | ||
71 | imx233_set_pin_function(1, 20, PINCTRL_FUNCTION_GPIO); /* lcd_wr */ | ||
72 | imx233_set_pin_function(1, 21, PINCTRL_FUNCTION_GPIO); /* lcd_cs */ | ||
73 | imx233_set_pin_function(1, 22, PINCTRL_FUNCTION_GPIO); /* lcd_dotclk */ | ||
74 | imx233_set_pin_function(1, 23, PINCTRL_FUNCTION_GPIO); /* lcd_enable */ | ||
75 | imx233_set_pin_function(1, 24, PINCTRL_FUNCTION_GPIO); /* lcd_hsync */ | ||
76 | imx233_set_pin_function(1, 25, PINCTRL_FUNCTION_GPIO); /* lcd_vsync */ | ||
77 | } | ||
78 | } | ||
79 | |||
80 | static void setup_lcd_pins_i80(bool i80) | ||
81 | { | ||
82 | if(i80) | ||
83 | { | ||
84 | imx233_set_pin_drive_strength(1, 19, PINCTRL_DRIVE_12mA); /* lcd_rs */ | ||
85 | imx233_set_pin_drive_strength(1, 20, PINCTRL_DRIVE_12mA); /* lcd_wr */ | ||
86 | imx233_set_pin_drive_strength(1, 21, PINCTRL_DRIVE_12mA); /* lcd_cs */ | ||
87 | imx233_set_pin_drive_strength(1, 23, PINCTRL_DRIVE_12mA); /* lcd_enable */ | ||
88 | imx233_set_pin_function(1, 19, PINCTRL_FUNCTION_GPIO); /* lcd_rs */ | ||
89 | imx233_set_pin_function(1, 20, PINCTRL_FUNCTION_GPIO); /* lcd_wr */ | ||
90 | imx233_set_pin_function(1, 21, PINCTRL_FUNCTION_GPIO); /* lcd_cs */ | ||
91 | imx233_set_pin_function(1, 23, PINCTRL_FUNCTION_GPIO); /* lcd_enable */ | ||
92 | /* lcd_{rs,wr,cs,enable} */ | ||
93 | imx233_enable_gpio_output_mask(1, (1 << 19) | (1 << 20) | (1 << 21) | (1 << 23), true); | ||
94 | imx233_set_gpio_output_mask(1, (1 << 19) | (1 << 20) | (1 << 21) | (1 << 23), true); | ||
95 | |||
96 | imx233_enable_gpio_output_mask(1, 0x3ffff, false); /* lcd_d{0-17} */ | ||
97 | __REG_SET(HW_PINCTRL_MUXSEL(2)) = 0xffffffff; /* lcd_d{0-15} as GPIO */ | ||
98 | imx233_set_pin_function(1, 16, PINCTRL_FUNCTION_GPIO); /* lcd_d16 */ | ||
99 | imx233_set_pin_function(1, 17, PINCTRL_FUNCTION_GPIO); /* lcd_d17 */ | ||
100 | imx233_set_pin_function(1, 18, PINCTRL_FUNCTION_GPIO); /* lcd_reset */ | ||
101 | imx233_set_pin_function(1, 19, PINCTRL_FUNCTION_GPIO); /* lcd_rs */ | ||
102 | } | ||
103 | else | ||
104 | { | ||
105 | imx233_set_gpio_output_mask(1, (1 << 19) | (1 << 20) | (1 << 21) | (1 << 23), true); | ||
106 | imx233_set_pin_drive_strength(1, 19, PINCTRL_DRIVE_4mA); /* lcd_rs */ | ||
107 | imx233_set_pin_drive_strength(1, 20, PINCTRL_DRIVE_4mA); /* lcd_wr */ | ||
108 | imx233_set_pin_drive_strength(1, 21, PINCTRL_DRIVE_4mA); /* lcd_cs */ | ||
109 | imx233_set_pin_drive_strength(1, 23, PINCTRL_DRIVE_4mA); /* lcd_enable */ | ||
110 | imx233_set_pin_function(1, 19, PINCTRL_FUNCTION_MAIN); /* lcd_rs */ | ||
111 | imx233_set_pin_function(1, 20, PINCTRL_FUNCTION_MAIN); /* lcd_wr */ | ||
112 | imx233_set_pin_function(1, 21, PINCTRL_FUNCTION_MAIN); /* lcd_cs */ | ||
113 | imx233_enable_gpio_output_mask(1, 0x3ffff, false); /* lcd_d{0-17} */ | ||
114 | __REG_CLR(HW_PINCTRL_MUXSEL(2)) = 0xffffffff; /* lcd_d{0-15} as lcd_d{0-15} */ | ||
115 | imx233_set_pin_function(1, 16, PINCTRL_FUNCTION_MAIN); /* lcd_d16 */ | ||
116 | imx233_set_pin_function(1, 17, PINCTRL_FUNCTION_MAIN); /* lcd_d17 */ | ||
117 | imx233_set_pin_function(1, 18, PINCTRL_FUNCTION_MAIN); /* lcd_reset */ | ||
118 | imx233_set_pin_function(1, 19, PINCTRL_FUNCTION_MAIN); /* lcd_rs */ | ||
119 | } | ||
120 | } | ||
121 | |||
122 | static void common_lcd_enable(bool enable) | ||
123 | { | ||
124 | imx233_lcdif_enable(enable); | ||
125 | setup_lcd_pins(enable); /* use GPIO pins when disable */ | ||
126 | } | ||
127 | |||
128 | static void setup_lcdif(void) | ||
129 | { | ||
130 | setup_parameters(); | ||
131 | common_lcd_enable(true); | ||
132 | imx233_lcdif_enable_bus_master(true); | ||
133 | //imx233_lcdif_enable_irqs(HW_LCDIF__CUR_FRAME_DONE_IRQ); | ||
134 | } | ||
135 | |||
136 | static inline uint32_t encode_16_to_18(uint32_t a) | ||
137 | { | ||
138 | return ((a & 0xff) << 1) | (((a >> 8) & 0xff) << 10); | ||
139 | } | ||
140 | |||
141 | static inline uint32_t decode_18_to_16(uint32_t a) | ||
142 | { | ||
143 | return ((a >> 1) & 0xff) | ((a >> 2) & 0xff00); | ||
144 | } | ||
145 | |||
146 | static void setup_lcdif_clock(void) | ||
147 | { | ||
148 | /* the LCD seems to works at 24Mhz, so use the xtal clock with no divider */ | ||
149 | imx233_enable_clock(CLK_PIX, false); | ||
150 | imx233_set_clock_divisor(CLK_PIX, 1); | ||
151 | imx233_set_bypass_pll(CLK_PIX, true); /* use XTAL */ | ||
152 | imx233_enable_clock(CLK_PIX, true); | ||
153 | } | ||
154 | |||
155 | static uint32_t i80_write_read_single(uint32_t data_out) | ||
156 | { | ||
157 | imx233_set_gpio_output(1, 21, true); /* lcd_cs */ | ||
158 | imx233_set_gpio_output(1, 19, true); /* lcd_rs */ | ||
159 | imx233_set_gpio_output(1, 23, true); /* lcd_enable */ | ||
160 | imx233_set_gpio_output(1, 20, true); /* lcd_wr */ | ||
161 | imx233_enable_gpio_output_mask(1, 0x3ffff, true); /* lcd_d{0-17} */ | ||
162 | udelay(2); | ||
163 | imx233_set_gpio_output(1, 19, false); /* lcd_rs */ | ||
164 | udelay(1); | ||
165 | imx233_set_gpio_output(1, 21, false); /* lcd_cs */ | ||
166 | udelay(1); | ||
167 | imx233_set_gpio_output(1, 20, false); /* lcd_wr */ | ||
168 | udelay(1); | ||
169 | imx233_set_gpio_output_mask(1, data_out & 0x3ffff, true); /* lcd_d{0-17} */ | ||
170 | udelay(1); | ||
171 | imx233_set_gpio_output(1, 20, true); /* lcd_wr */ | ||
172 | udelay(3); | ||
173 | imx233_enable_gpio_output_mask(1, 0x3ffff, false); /* lcd_d{0-17} */ | ||
174 | udelay(2); | ||
175 | imx233_set_gpio_output(1, 23, false); /* lcd_enable */ | ||
176 | udelay(1); | ||
177 | imx233_set_gpio_output(1, 19, true); /* lcd_rs */ | ||
178 | udelay(1); | ||
179 | imx233_set_gpio_output(1, 23, true); /* lcd_enable */ | ||
180 | udelay(3); | ||
181 | imx233_set_gpio_output(1, 23, false); /* lcd_enable */ | ||
182 | udelay(2); | ||
183 | uint32_t data_in = imx233_get_gpio_input_mask(1, 0x3ffff); /* lcd_d{0-17} */ | ||
184 | udelay(1); | ||
185 | imx233_set_gpio_output(1, 23, true); /* lcd_enable */ | ||
186 | udelay(1); | ||
187 | imx233_set_gpio_output(1, 21, true); /* lcd_cs */ | ||
188 | udelay(1); | ||
189 | return data_in; | ||
190 | } | ||
191 | |||
192 | static void lcd_write_reg(uint32_t reg, uint32_t data) | ||
193 | { | ||
194 | uint32_t old_reg = reg; | ||
195 | /* get back to 18-bit word length */ | ||
196 | imx233_lcdif_set_word_length(HW_LCDIF_CTRL__WORD_LENGTH_18_BIT); | ||
197 | reg = encode_16_to_18(reg); | ||
198 | data = encode_16_to_18(data); | ||
199 | |||
200 | imx233_lcdif_pio_send(false, 2, ®); | ||
201 | if(old_reg != 0x22) | ||
202 | imx233_lcdif_pio_send(true, 2, &data); | ||
203 | } | ||
204 | |||
205 | static uint32_t lcd_read_reg(uint32_t reg) | ||
206 | { | ||
207 | setup_lcd_pins_i80(true); | ||
208 | uint32_t data_in = i80_write_read_single(encode_16_to_18(reg)); | ||
209 | setup_lcd_pins_i80(false); | ||
210 | lcd_write_reg(0x22, 0); | ||
211 | return decode_18_to_16(data_in); | ||
212 | } | ||
213 | |||
214 | static void lcd_init_seq_7783(void) | ||
215 | { | ||
216 | __REG_SET(HW_LCDIF_CTRL1) = HW_LCDIF_CTRL1__RESET; | ||
217 | udelay(50); | ||
218 | __REG_CLR(HW_LCDIF_CTRL1) = HW_LCDIF_CTRL1__RESET; | ||
219 | udelay(10); | ||
220 | __REG_SET(HW_LCDIF_CTRL1) = HW_LCDIF_CTRL1__RESET; | ||
221 | udelay(200); | ||
222 | lcd_write_reg(1, 0x100); | ||
223 | lcd_write_reg(2, 0x700); | ||
224 | lcd_write_reg(3, 0x1030); | ||
225 | lcd_write_reg(7, 0x121); | ||
226 | lcd_write_reg(8, 0x302); | ||
227 | lcd_write_reg(9, 0x200); | ||
228 | lcd_write_reg(0xa, 0); | ||
229 | lcd_write_reg(0x10, 0x790); | ||
230 | lcd_write_reg(0x11, 5); | ||
231 | lcd_write_reg(0x12, 0); | ||
232 | lcd_write_reg(0x13, 0); | ||
233 | udelay(100); | ||
234 | lcd_write_reg(0x10, 0x12b0); | ||
235 | udelay(100); | ||
236 | lcd_write_reg(0x11, 7); | ||
237 | udelay(100); | ||
238 | lcd_write_reg(0x12, 0x89); | ||
239 | lcd_write_reg(0x13, 0x1d00); | ||
240 | lcd_write_reg(0x29, 0x2f); | ||
241 | udelay(50); | ||
242 | lcd_write_reg(0x30, 0); | ||
243 | lcd_write_reg(0x31, 0x505); | ||
244 | lcd_write_reg(0x32, 0x205); | ||
245 | lcd_write_reg(0x35, 0x206); | ||
246 | lcd_write_reg(0x36, 0x408); | ||
247 | lcd_write_reg(0x37, 0); | ||
248 | lcd_write_reg(0x38, 0x504); | ||
249 | lcd_write_reg(0x39, 0x206); | ||
250 | lcd_write_reg(0x3c, 0x206); | ||
251 | lcd_write_reg(0x3d, 0x408); | ||
252 | lcd_write_reg(0x50, 0); /* left X ? */ | ||
253 | lcd_write_reg(0x51, 0xef); /* right X ? */ | ||
254 | lcd_write_reg(0x52, 0); /* top Y ? */ | ||
255 | lcd_write_reg(0x53, 0x13f); /* bottom Y ? */ | ||
256 | lcd_write_reg(0x20, 0); /* left X ? */ | ||
257 | lcd_write_reg(0x21, 0); /* top Y ? */ | ||
258 | lcd_write_reg(0x60, 0xa700); | ||
259 | lcd_write_reg(0x61, 1); | ||
260 | lcd_write_reg(0x90, 0x33); | ||
261 | lcd_write_reg(0x2b, 0xa); | ||
262 | lcd_write_reg(9, 0); | ||
263 | lcd_write_reg(7, 0x133); | ||
264 | udelay(50); | ||
265 | lcd_write_reg(0x22, 0); | ||
266 | } | ||
267 | |||
268 | static void lcd_init_seq_9325(void) | ||
269 | { | ||
270 | |||
271 | } | ||
272 | |||
273 | void lcd_init_device(void) | ||
274 | { | ||
275 | setup_lcdif(); | ||
276 | setup_lcdif_clock(); | ||
277 | |||
278 | for(int i = 0; i < 10; i++) | ||
279 | { | ||
280 | uint32_t kind = lcd_read_reg(0); | ||
281 | if(kind == LCD_KIND_7783 || kind == LCD_KIND_9325) | ||
282 | { | ||
283 | lcd_kind = kind; | ||
284 | break; | ||
285 | } | ||
286 | else | ||
287 | { | ||
288 | lcd_kind = LCD_KIND_OTHER; | ||
289 | } | ||
290 | } | ||
291 | udelay(5); | ||
292 | switch(lcd_kind) | ||
293 | { | ||
294 | case LCD_KIND_7783: lcd_init_seq_7783(); break; | ||
295 | case LCD_KIND_9325: lcd_init_seq_9325(); break; | ||
296 | default: | ||
297 | lcd_init_seq_7783(); break; | ||
298 | } | ||
299 | } | ||
300 | |||
301 | |||
302 | static void lcd_enable_7783(bool enable) | ||
303 | { | ||
304 | if(!enable) | ||
305 | { | ||
306 | lcd_write_reg(7, 0x131); | ||
307 | udelay(50); | ||
308 | lcd_write_reg(7, 0x20); | ||
309 | udelay(50); | ||
310 | lcd_write_reg(0x10, 0x82); | ||
311 | udelay(50); | ||
312 | } | ||
313 | else | ||
314 | { | ||
315 | lcd_write_reg(0x11, 5); | ||
316 | lcd_write_reg(0x10, 0x12b0); | ||
317 | udelay(50); | ||
318 | lcd_write_reg(7, 0x11); | ||
319 | udelay(50); | ||
320 | lcd_write_reg(0x12, 0x89); | ||
321 | udelay(50); | ||
322 | lcd_write_reg(0x13, 0x1d00); | ||
323 | udelay(50); | ||
324 | lcd_write_reg(0x29, 0x2f); | ||
325 | udelay(50); | ||
326 | lcd_write_reg(0x2b, 0xa); | ||
327 | lcd_write_reg(7, 0x133); | ||
328 | udelay(50); | ||
329 | lcd_write_reg(0x22, 0); | ||
330 | } | ||
331 | } | ||
332 | |||
333 | static void lcd_enable_9325(bool enable) | ||
334 | { | ||
335 | (void) enable; | ||
336 | } | ||
337 | |||
338 | void lcd_enable(bool enable) | ||
339 | { | ||
340 | if(enable) | ||
341 | common_lcd_enable(true); | ||
342 | switch(lcd_kind) | ||
343 | { | ||
344 | case LCD_KIND_7783: lcd_enable_7783(enable); break; | ||
345 | case LCD_KIND_9325: lcd_enable_9325(enable); break; | ||
346 | default: lcd_enable_7783(enable); break; | ||
347 | } | ||
348 | if(!enable) | ||
349 | common_lcd_enable(false); | ||
350 | } | ||
351 | |||
352 | void lcd_update(void) | ||
353 | { | ||
354 | lcd_write_reg(0x50, 0); | ||
355 | lcd_write_reg(0x51, LCD_WIDTH - 1); | ||
356 | lcd_write_reg(0x52, 0); | ||
357 | lcd_write_reg(0x53, LCD_HEIGHT - 1); | ||
358 | lcd_write_reg(0x20, 0); | ||
359 | lcd_write_reg(0x21, 0); | ||
360 | lcd_write_reg(0x22, 0); | ||
361 | imx233_lcdif_wait_ready(); | ||
362 | imx233_lcdif_set_word_length(HW_LCDIF_CTRL__WORD_LENGTH_16_BIT); | ||
363 | imx233_lcdif_set_byte_packing_format(0xf); /* two pixels per 32-bit word */ | ||
364 | imx233_lcdif_set_data_format(false, false, false); /* RGB565, don't care, don't care */ | ||
365 | imx233_lcdif_dma_send(lcd_framebuffer, LCD_WIDTH, LCD_HEIGHT); | ||
366 | imx233_lcdif_wait_ready(); | ||
367 | } | ||
368 | |||
369 | void lcd_update_rect(int x, int y, int width, int height) | ||
370 | { | ||
371 | (void) x; | ||
372 | (void) y; | ||
373 | (void) width; | ||
374 | (void) height; | ||
375 | lcd_update(); | ||
376 | } | ||