summaryrefslogtreecommitdiff
path: root/firmware/target/arm/imx233
diff options
context:
space:
mode:
authorLorenzo Miori <memorys60@gmail.com>2013-11-15 22:05:40 +0100
committerAmaury Pouly <amaury.pouly@gmail.com>2013-12-02 20:48:21 +0100
commit1deab739803ee768e393bba41446450a792b6410 (patch)
tree26b5a121d6a03d2f394aa285ab017b1f317caf37 /firmware/target/arm/imx233
parent15155ed10006f84c42bc435e354a16b3f391d55e (diff)
downloadrockbox-1deab739803ee768e393bba41446450a792b6410.tar.gz
rockbox-1deab739803ee768e393bba41446450a792b6410.zip
Initial commit for the YP-Z5 port
The port uses the imx233 soc, it's a STMP3650 based Samsung player Change-Id: I50b6d7e77fd292fab5ed26de87853cd5aaf9eaa4 Reviewed-on: http://gerrit.rockbox.org/490 Reviewed-by: Amaury Pouly <amaury.pouly@gmail.com>
Diffstat (limited to 'firmware/target/arm/imx233')
-rw-r--r--firmware/target/arm/imx233/power-imx233.c2
-rw-r--r--firmware/target/arm/imx233/samsung-ypz5/audio-target.h31
-rw-r--r--firmware/target/arm/imx233/samsung-ypz5/backlight-target.h28
-rw-r--r--firmware/target/arm/imx233/samsung-ypz5/backlight-ypz5.c149
-rw-r--r--firmware/target/arm/imx233/samsung-ypz5/button-target.h59
-rw-r--r--firmware/target/arm/imx233/samsung-ypz5/button-ypz5.c273
-rw-r--r--firmware/target/arm/imx233/samsung-ypz5/debug-ypz5.c29
-rw-r--r--firmware/target/arm/imx233/samsung-ypz5/fmradio-target.h31
-rw-r--r--firmware/target/arm/imx233/samsung-ypz5/ftl-target.h39
-rw-r--r--firmware/target/arm/imx233/samsung-ypz5/lcd-target.h25
-rw-r--r--firmware/target/arm/imx233/samsung-ypz5/lcd-ypz5.c294
-rw-r--r--firmware/target/arm/imx233/samsung-ypz5/powermgmt-target.h37
-rw-r--r--firmware/target/arm/imx233/samsung-ypz5/powermgmt-ypz5.c48
-rw-r--r--firmware/target/arm/imx233/touchscreen-imx233.c27
14 files changed, 1072 insertions, 0 deletions
diff --git a/firmware/target/arm/imx233/power-imx233.c b/firmware/target/arm/imx233/power-imx233.c
index af333dea59..9ad8734823 100644
--- a/firmware/target/arm/imx233/power-imx233.c
+++ b/firmware/target/arm/imx233/power-imx233.c
@@ -137,6 +137,8 @@ void imx233_power_init(void)
137#endif 137#endif
138 /* enable vbusvalid detection method for the dcdc (improves efficiency) */ 138 /* enable vbusvalid detection method for the dcdc (improves efficiency) */
139 BF_SET(POWER_5VCTRL, VBUSVALID_5VDETECT); 139 BF_SET(POWER_5VCTRL, VBUSVALID_5VDETECT);
140 /* disable shutdown on 5V fail */
141 BF_CLR(POWER_5VCTRL, PWDN_5VBRNOUT);
140#ifdef USE_VBUSVALID 142#ifdef USE_VBUSVALID
141 /* make sure VBUSVALID is unlocked */ 143 /* make sure VBUSVALID is unlocked */
142 BF_CLR(POWER_DEBUG, VBUSVALIDPIOLOCK); 144 BF_CLR(POWER_DEBUG, VBUSVALIDPIOLOCK);
diff --git a/firmware/target/arm/imx233/samsung-ypz5/audio-target.h b/firmware/target/arm/imx233/samsung-ypz5/audio-target.h
new file mode 100644
index 0000000000..c0bee26e45
--- /dev/null
+++ b/firmware/target/arm/imx233/samsung-ypz5/audio-target.h
@@ -0,0 +1,31 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2013 by Lorenzo Miori
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 __audio_target__
22#define __audio_target__
23
24/* MUTE_ON toggles a transistor that in turns toggles a mosfet... */
25#define IMX233_AUDIO_HP_GATE_BANK 1
26#define IMX233_AUDIO_HP_GATE_PIN 22
27#define IMX233_AUDIO_HP_GATE_INVERTED
28
29#define IMX233_AUDIO_COUPLING_MODE ACM_CAP
30
31#endif /* __audio_target__ */
diff --git a/firmware/target/arm/imx233/samsung-ypz5/backlight-target.h b/firmware/target/arm/imx233/samsung-ypz5/backlight-target.h
new file mode 100644
index 0000000000..5fa2ed38f9
--- /dev/null
+++ b/firmware/target/arm/imx233/samsung-ypz5/backlight-target.h
@@ -0,0 +1,28 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 *
9 * Copyright (C) 2013 by Lorenzo Miori
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
15 *
16 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
17 * KIND, either express or implied.
18 *
19 ****************************************************************************/
20#ifndef BACKLIGHT_TARGET_H
21#define BACKLIGHT_TARGET_H
22
23bool _backlight_init(void);
24void _backlight_on(void);
25void _backlight_off(void);
26void _backlight_set_brightness(int brightness);
27
28#endif /* BACKLIGHT_TARGET_H */
diff --git a/firmware/target/arm/imx233/samsung-ypz5/backlight-ypz5.c b/firmware/target/arm/imx233/samsung-ypz5/backlight-ypz5.c
new file mode 100644
index 0000000000..27a7ecedfc
--- /dev/null
+++ b/firmware/target/arm/imx233/samsung-ypz5/backlight-ypz5.c
@@ -0,0 +1,149 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 *
9 * Copyright (C) 2013 by Lorenzo Miori
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
15 *
16 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
17 * KIND, either express or implied.
18 *
19 ****************************************************************************/
20
21#include "config.h"
22#include "system.h"
23#include "lcd.h"
24#include "backlight.h"
25#include "backlight-target.h"
26#include "pinctrl-imx233.h"
27
28/**
29 * AAT3151 Backlight Controller
30 */
31
32/* Timings */
33#define TIME_OFF 500
34#define TIME_LOW 50
35#define TIME_HI 50
36#define TIME_LAT 500
37
38/* Number of raising edges to select the particular register */
39#define D1_D4_CURRENT_E 17
40#define D1_D3_CURRENT_E 18
41#define D4_CURRENT_E 19
42#define MAX_CURRENT_E 20
43#define LOW_CURRENT_E 21
44
45/* The actual register address / number */
46#define D1_D4_CURRENT 1
47#define D1_D3_CURRENT 2
48#define D4_CURRENT 3
49#define MAX_CURRENT 4
50#define LOW_CURRENT 5
51
52/* Valid values for LOW_CURRENT register */
53#define MAX_CURRENT_20 1
54#define MAX_CURRENT_30 2
55#define MAX_CURRENT_15 3
56#define MAX_CURRENT_LOW_CURRENT 4
57
58static int current_level = -1;
59
60static void create_raising_edges(int num)
61{
62 while (num--)
63 {
64 /* Setting a register takes a sufficient small amount of time,
65 * in the order of 50 ns. Thus the necessary 2 delays TIME_LOW/TIME_HI
66 * are not strictly necessary */
67 imx233_pinctrl_set_gpio(3, 13, false);
68 imx233_pinctrl_set_gpio(3, 13, true);
69 }
70}
71
72static void aat3151_write(int addr, int data)
73{
74 create_raising_edges(16 + addr);
75 udelay(TIME_LAT);
76 create_raising_edges(data);
77 udelay(TIME_LAT);
78}
79
80void _backlight_set_brightness(int level)
81{
82 /* Don't try to reset backlight if not necessary
83 * Moreover this helps to avoid flickering when
84 * being in some screens like USB mode and
85 * pressing some keys / touchpad...
86 */
87 if (current_level == level) return;
88
89 /* Check for limits and adjust in case */
90 level = MIN(MAX_BRIGHTNESS_SETTING, MAX(0, level));
91
92 if (level == 0)
93 {
94 /* Set pin low for a sufficient time, puts the device into low-power consumption state
95 * In other words backlight goes off
96 */
97 imx233_pinctrl_set_gpio(3, 13, false);
98 udelay(TIME_OFF);
99 }
100 else
101 {
102 if (level > 3) {
103 /* This enables 16 levels of backlight */
104 aat3151_write(MAX_CURRENT, MAX_CURRENT_15);
105 /* Set the value according Table 1 in datasheet
106 * For MAX_CURRENT_15, the scale is from 0 mA to 15 mA in 16 steps
107 */
108 aat3151_write(D1_D3_CURRENT, 19 - level);
109 }
110 else {
111 /* This enables other 4 levels of backlight */
112 aat3151_write(MAX_CURRENT, MAX_CURRENT_LOW_CURRENT);
113 /* Set the value according Table 1 in datasheet
114 * For LOW_CURRENT, there is no "real" scale. We have scattered values.
115 * We are interested in the last 3 -> 0.5 mA; 1 mA; 2 mA
116 */
117 aat3151_write(LOW_CURRENT, 13 + level);
118 }
119 }
120 current_level = level;
121}
122
123bool _backlight_init(void)
124{
125 imx233_pinctrl_acquire(3, 13, "backlight");
126 imx233_pinctrl_set_function(3, 13, PINCTRL_FUNCTION_GPIO);
127 imx233_pinctrl_set_drive(3, 13, PINCTRL_DRIVE_4mA);
128 imx233_pinctrl_enable_gpio(3, 13, true);
129 imx233_pinctrl_set_gpio(3, 13, false);
130 return true;
131}
132
133void _backlight_on(void)
134{
135#ifdef HAVE_LCD_ENABLE
136 lcd_enable(true); /* power on lcd + visible display */
137#endif
138 /* restore the previous backlight level */
139 _backlight_set_brightness(backlight_brightness);
140}
141
142void _backlight_off(void)
143{
144 /* there is no real on/off but we can set to 0 brightness */
145 _backlight_set_brightness(0);
146#ifdef HAVE_LCD_ENABLE
147 lcd_enable(false); /* power off visible display */
148#endif
149}
diff --git a/firmware/target/arm/imx233/samsung-ypz5/button-target.h b/firmware/target/arm/imx233/samsung-ypz5/button-target.h
new file mode 100644
index 0000000000..2f94f5fb31
--- /dev/null
+++ b/firmware/target/arm/imx233/samsung-ypz5/button-target.h
@@ -0,0 +1,59 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2013 by Lorenzo Miori
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
26#define HAS_BUTTON_HOLD
27#define IMX233_BUTTON_LRADC_CHANNEL 0
28#define IMX233_BUTTON_LRADC_HOLD_DET BLH_GPIO
29#define BLH_GPIO_BANK 0
30#define BLH_GPIO_PIN 13
31
32#define IMX233_BUTTON_LRADC_CHANNEL 0
33
34/* Main unit's buttons */
35#define BUTTON_POWER 0x00000001
36#define BUTTON_VOL_UP 0x00000002
37#define BUTTON_VOL_DOWN 0x00000004
38/* Directional buttons by touchpad */
39#define BUTTON_LEFT 0x00000008
40#define BUTTON_UP 0x00000010
41#define BUTTON_RIGHT 0x00000020
42#define BUTTON_DOWN 0x00000040
43#define BUTTON_SELECT 0x00000080
44#define BUTTON_BACK 0x00000100
45#define BUTTON_REW 0x00000200
46#define BUTTON_FF 0x00000400
47
48
49#define BUTTON_MAIN (BUTTON_VOL_UP | BUTTON_VOL_DOWN | BUTTON_POWER | BUTTON_LEFT | \
50 BUTTON_UP | BUTTON_RIGHT | BUTTON_DOWN | BUTTON_SELECT | \
51 BUTTON_BACK | BUTTON_REW | BUTTON_FF)
52
53/* Software power-off */
54#define POWEROFF_BUTTON BUTTON_POWER
55#define POWEROFF_COUNT 10
56
57bool button_debug_screen(void);
58
59#endif /* _BUTTON_TARGET_H_ */
diff --git a/firmware/target/arm/imx233/samsung-ypz5/button-ypz5.c b/firmware/target/arm/imx233/samsung-ypz5/button-ypz5.c
new file mode 100644
index 0000000000..cee82e2e9f
--- /dev/null
+++ b/firmware/target/arm/imx233/samsung-ypz5/button-ypz5.c
@@ -0,0 +1,273 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 *
9 * Copyright (C) 2013 by Lorenzo Miori
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
15 *
16 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
17 * KIND, either express or implied.
18 *
19 ****************************************************************************/
20
21#include "system.h"
22#include "lcd.h"
23#include "string.h"
24#include "pinctrl-imx233.h"
25#include "power-imx233.h"
26#include "button-lradc-imx233.h"
27#include "button-target.h"
28
29#ifndef BOOTLOADER
30#include "touchscreen.h"
31#include "touchscreen-imx233.h"
32#include "button.h"
33#include "font.h"
34#include "action.h"
35#endif
36
37struct imx233_button_lradc_mapping_t imx233_button_lradc_mapping[] =
38{
39 {455, BUTTON_VOL_UP},
40 {900, BUTTON_VOL_DOWN},
41 {1410, BUTTON_BACK},
42 {1868, BUTTON_FF},
43 {2311, BUTTON_REW},
44 {2700, 0},
45 {3300, IMX233_BUTTON_LRADC_END},
46};
47
48#ifndef BOOTLOADER
49static int last_x = 0;
50static int last_y = 0;
51static bool touching = false;
52#endif /* BOOTLOADER */
53
54#ifndef BOOTLOADER
55
56/* Touchpad extra pin initialization
57 * Strange facts:
58 * 1. In the fully working sample I have, it seems that pins
59 * must be all set to low
60 * 2. In the other sample without LCD, it seems (by measurement) that
61 * not all the pins are set to low! Actually, I still need to see if
62 * touchpad works in this other sample.
63*/
64void touchpad_pin_setup(void)
65{
66 /* TX+ */
67 imx233_pinctrl_acquire(0, 25, "touchpad X+ power low");
68 imx233_pinctrl_set_function(0, 25, PINCTRL_FUNCTION_GPIO);
69 imx233_pinctrl_set_drive(0, 25, PINCTRL_DRIVE_4mA);
70 imx233_pinctrl_enable_gpio(0, 25, true);
71
72 /* TY+ */
73 imx233_pinctrl_acquire(0, 26, "touchpad Y+ power high");
74 imx233_pinctrl_set_function(0, 26, PINCTRL_FUNCTION_GPIO);
75 imx233_pinctrl_set_drive(0, 26, PINCTRL_DRIVE_4mA);
76 imx233_pinctrl_enable_gpio(0, 26, true);
77
78 /* TY- */
79 imx233_pinctrl_acquire(1, 21, "touchpad Y- power low");
80 imx233_pinctrl_set_function(1, 21, PINCTRL_FUNCTION_GPIO);
81 imx233_pinctrl_set_drive(1, 21, PINCTRL_DRIVE_4mA);
82 imx233_pinctrl_enable_gpio(1, 21, true);
83
84 /* TX- */
85 imx233_pinctrl_acquire(3, 15, "touchpad X- power high");
86 imx233_pinctrl_set_function(3, 15, PINCTRL_FUNCTION_GPIO);
87 imx233_pinctrl_set_drive(3, 15, PINCTRL_DRIVE_4mA);
88 imx233_pinctrl_enable_gpio(3, 15, true);
89
90}
91#endif /* BOOTLOADER */
92
93void button_init_device(void)
94{
95 imx233_button_lradc_init();
96#ifndef BOOTLOADER
97 touchpad_pin_setup();
98 /* Now that is powered up, proceed with touchpad initialization */
99 imx233_touchscreen_init();
100 imx233_touchscreen_enable(true);
101#endif /* BOOTLOADER */
102}
103
104bool button_hold(void)
105{
106 return imx233_button_lradc_hold();
107}
108
109/* X, Y, RadiusX, RadiusY */
110#define TOUCH_UP 2400, 1050, 650, 250
111#define TOUCH_DOWN 2057, 3320, 500, 350
112#define TOUCH_LEFT 3581, 2297, 300, 350
113#define TOUCH_RIGHT 1000, 2100, 400, 700
114#define TOUCH_CENTER 2682, 2167, 335, 276
115
116bool coord_in_radius(int x, int y, int cx, int cy, int rx, int ry)
117{
118 return ((x >= cx - rx && x <= cx + rx) && (y >= cy - ry && y <= cy + ry));
119}
120
121int button_read_device(void)
122{
123 int res = 0;
124
125 switch(imx233_power_read_pswitch())
126 {
127 case 1: res |= BUTTON_POWER; break;
128 case 3: res |= BUTTON_SELECT; break;
129 }
130
131#ifndef BOOTLOADER
132 touching = imx233_touchscreen_get_touch(&last_x, &last_y);
133 if(touching)
134 {
135 if (coord_in_radius(last_x, last_y, TOUCH_LEFT))
136 {
137 res |= BUTTON_LEFT;
138 }
139 else if (coord_in_radius(last_x, last_y, TOUCH_RIGHT))
140 {
141 res |= BUTTON_RIGHT;
142 }
143 else if (coord_in_radius(last_x, last_y, TOUCH_DOWN))
144 {
145 res |= BUTTON_DOWN;
146 }
147 else if (coord_in_radius(last_x, last_y, TOUCH_UP))
148 {
149 res |= BUTTON_UP;
150 }
151 }
152#endif /* BOOTLOADER */
153 return imx233_button_lradc_read(res);
154}
155
156#ifndef BOOTLOADER
157
158#define MAX_ENTRIES 100
159#define VIEWPORT_HEIGHT 100
160#define VIEWPORT_WIDTH 100
161#define MAX_X 3700
162#define MAX_Y 3700
163#define ADAPT_TO_VIEWPORT(cx, cy, rx, ry) ((float)(cx) / MAX_X) * VIEWPORT_WIDTH, \
164 ((float)(cy) / MAX_Y) * VIEWPORT_HEIGHT, \
165 ((float)(rx) / MAX_X) * VIEWPORT_WIDTH, \
166 ((float)(ry) / MAX_Y) * VIEWPORT_HEIGHT
167static void draw_calibration_rect(int cx, int cy, int rx, int ry)
168{
169 if (coord_in_radius(last_x, last_y, cx, cy, rx, ry))
170 lcd_set_drawinfo(DRMODE_SOLID, LCD_RGBPACK(0xff, 0xff, 0xff), LCD_BLACK);
171 else
172 lcd_set_drawinfo(DRMODE_SOLID, LCD_RGBPACK(0xff, 0, 0), LCD_BLACK);
173 lcd_drawrect(ADAPT_TO_VIEWPORT(cx - rx, cy - ry, 2 * rx, 2 * ry));
174}
175
176bool button_debug_screen(void)
177{
178 int last = 0;
179 struct point_t
180 {
181 int x;
182 int y;
183 };
184 struct point_t last_entries[MAX_ENTRIES];
185 struct viewport report_vp;
186
187 memset(&report_vp, 0, sizeof(report_vp));
188 report_vp.x = (LCD_WIDTH - VIEWPORT_WIDTH) / 2;
189 report_vp.y = (LCD_HEIGHT - VIEWPORT_HEIGHT) / 2;
190 report_vp.width = VIEWPORT_WIDTH;
191 report_vp.height = VIEWPORT_HEIGHT;
192
193 lcd_setfont(FONT_SYSFIXED);
194 lcd_clear_display();
195
196 while(1)
197 {
198 int button = get_action(CONTEXT_STD, HZ / 10);
199 switch(button)
200 {
201 case ACTION_STD_OK:
202 case ACTION_STD_MENU:
203 lcd_set_viewport(NULL);
204 lcd_setfont(FONT_UI);
205 lcd_clear_display();
206 return true;
207 case ACTION_STD_CANCEL:
208 lcd_set_viewport(NULL);
209 lcd_setfont(FONT_UI);
210 lcd_clear_display();
211 return false;
212 }
213
214 lcd_set_viewport(NULL);
215 lcd_putsf(0, 1, "(%d,%d) %s", last_x, last_y, touching ? "touching!" : "");
216 lcd_putsf(0, 0, "Type %s", imx233_pinctrl_get_gpio(0, 31) ? "CAP" : "REG");
217 lcd_set_viewport(&report_vp);
218 lcd_set_drawinfo(DRMODE_SOLID, LCD_RGBPACK(0, 0, 0xff), LCD_BLACK);
219 lcd_drawrect(0, 0, 100, 100);
220 float percent_x = ((float)(last_x) / MAX_X);
221 float percent_y = ((float)(last_y) / MAX_Y);
222 if (touching)
223 {
224 lcd_set_viewport(NULL);
225 if (last < MAX_ENTRIES)
226 {
227 last_entries[last].x = last_x;
228 last_entries[last].y = last_y;
229 last++;
230 lcd_putsf(0, 17, "Recording: %d captures left", MAX_ENTRIES - last);
231 }
232 else
233 {
234 int min_x = 9999;
235 int min_y = 9999;
236 int max_x = -1;
237 int max_y = -1;
238 int median_x = 0;
239 int median_y = 0;
240 for (int i = 0; i < MAX_ENTRIES; i++)
241 {
242 min_x = MIN(min_x, last_entries[i].x);
243 min_y = MIN(min_y, last_entries[i].y);
244 max_x = MAX(max_x, last_entries[i].x);
245 max_y = MAX(max_y, last_entries[i].y);
246 median_x += last_entries[i].x;
247 median_y += last_entries[i].y;
248 }
249 median_x /= MAX_ENTRIES;
250 median_y /= MAX_ENTRIES;
251 lcd_putsf(0, 17, "center(%d,%d)", median_x, median_y);
252 lcd_putsf(0, 18, "radius(%d,%d)", median_x / 2, median_y / 2);
253 }
254 lcd_set_viewport(&report_vp);
255 lcd_set_drawinfo(DRMODE_SOLID, LCD_RGBPACK(0xff, 0x8c, 0), LCD_BLACK);
256 lcd_fillrect(VIEWPORT_WIDTH * percent_x, VIEWPORT_HEIGHT * percent_y, 2, 2);
257 }
258
259 /* Draw current calibration settings */
260 lcd_set_viewport(&report_vp);
261 draw_calibration_rect(TOUCH_UP);
262 draw_calibration_rect(TOUCH_DOWN);
263 draw_calibration_rect(TOUCH_CENTER);
264 draw_calibration_rect(TOUCH_LEFT);
265 draw_calibration_rect(TOUCH_RIGHT);
266
267 lcd_update();
268 yield();
269 }
270
271 return true;
272}
273#endif
diff --git a/firmware/target/arm/imx233/samsung-ypz5/debug-ypz5.c b/firmware/target/arm/imx233/samsung-ypz5/debug-ypz5.c
new file mode 100644
index 0000000000..c125eac973
--- /dev/null
+++ b/firmware/target/arm/imx233/samsung-ypz5/debug-ypz5.c
@@ -0,0 +1,29 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2013 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 "system.h"
23#include "button-target.h"
24#include "lcd-target.h"
25
26bool dbg_hw_target_info(void)
27{
28 return button_debug_screen() && lcd_debug_screen();
29}
diff --git a/firmware/target/arm/imx233/samsung-ypz5/fmradio-target.h b/firmware/target/arm/imx233/samsung-ypz5/fmradio-target.h
new file mode 100644
index 0000000000..66bceb4071
--- /dev/null
+++ b/firmware/target/arm/imx233/samsung-ypz5/fmradio-target.h
@@ -0,0 +1,31 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2013 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 _FMRADIO_TARGET_H_
22#define _FMRADIO_TARGET_H_
23
24#define IMX233_FMRADIO_I2C FMI_HW
25
26#define IMX233_FMRADIO_POWER FMP_GPIO
27#define FMP_GPIO_BANK 0
28#define FMP_GPIO_PIN 10
29#define FMP_GPIO_DELAY (HZ / 5)
30
31#endif /* _FMRADIO_TARGET_H_ */
diff --git a/firmware/target/arm/imx233/samsung-ypz5/ftl-target.h b/firmware/target/arm/imx233/samsung-ypz5/ftl-target.h
new file mode 100644
index 0000000000..cb943e34f2
--- /dev/null
+++ b/firmware/target/arm/imx233/samsung-ypz5/ftl-target.h
@@ -0,0 +1,39 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2009 by Michael Sparmann
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#ifndef __FTL_TARGET_H__
23#define __FTL_TARGET_H__
24
25#include "config.h"
26#include "inttypes.h"
27
28#ifdef BOOTLOADER
29/* Bootloaders don't need write access */
30#define FTL_READONLY
31#endif
32
33uint32_t ftl_init(void);
34uint32_t ftl_read(uint32_t sector, uint32_t count, void* buffer);
35uint32_t ftl_write(uint32_t sector, uint32_t count, const void* buffer);
36uint32_t ftl_sync(void);
37
38
39#endif
diff --git a/firmware/target/arm/imx233/samsung-ypz5/lcd-target.h b/firmware/target/arm/imx233/samsung-ypz5/lcd-target.h
new file mode 100644
index 0000000000..9993b7d731
--- /dev/null
+++ b/firmware/target/arm/imx233/samsung-ypz5/lcd-target.h
@@ -0,0 +1,25 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 *
9 * Copyright (c) 2013 by Amaury Pouly
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
15 *
16 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
17 * KIND, either express or implied.
18 *
19 ****************************************************************************/
20#ifndef LCD_TARGET_H
21#define LCD_TARGET_H
22
23bool lcd_debug_screen(void);
24
25#endif /* LCD_TARGET_H */
diff --git a/firmware/target/arm/imx233/samsung-ypz5/lcd-ypz5.c b/firmware/target/arm/imx233/samsung-ypz5/lcd-ypz5.c
new file mode 100644
index 0000000000..4f7d9b88b5
--- /dev/null
+++ b/firmware/target/arm/imx233/samsung-ypz5/lcd-ypz5.c
@@ -0,0 +1,294 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 *
9 * Copyright (c) 2013 by Lorenzo Miori
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
15 *
16 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
17 * KIND, either express or implied.
18 *
19 ****************************************************************************/
20#include <sys/types.h> /* off_t */
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#include "dcp-imx233.h"
30#include "logf.h"
31#ifndef BOOTLOADER
32#include "button.h"
33#include "font.h"
34#include "action.h"
35#endif
36#include "dma-imx233.h"
37
38#include "regs/regs-lcdif.h"
39
40/**
41 * NOTE
42 * We don't know exact LCD models nor we have datasheets for them
43 * Register function are partly guessed from the values, others are guessed from other LCD
44 * drivers and others have been confirmed studying their values
45 */
46
47static enum lcd_type_t
48{
49 LCD_TYPE_ZERO = 0,
50 LCD_TYPE_ONE = 1
51} lcd_type = LCD_TYPE_ZERO;
52
53static void lcd_write_reg(uint16_t reg, uint16_t data)
54{
55 imx233_lcdif_pio_send(false, 1, &reg);
56 if(reg != 0x22)
57 imx233_lcdif_pio_send(true, 1, &data);
58}
59
60/*
61 * The two LCD types require different initialization sequences
62 */
63void lcd_init_seq(void)
64{
65 switch (lcd_type)
66 {
67 case LCD_TYPE_ZERO:
68 {
69 lcd_write_reg(0x11, 0x1f1e);
70 lcd_write_reg(0x38, 0xf0f);
71 lcd_write_reg(0x12, 0x1101);
72 lcd_write_reg(0x13, 0x808);
73 lcd_write_reg(0x14, 0x3119);
74 lcd_write_reg(0x10, 0x1a10);
75 udelay(0xc350);
76 lcd_write_reg(0x13, 0x83b);
77 udelay(0x30d40);
78 lcd_write_reg(1, 0x90c); /* Display mode */
79 lcd_write_reg(2, 0x200);
80 lcd_write_reg(3, 0x1030);
81 lcd_write_reg(7, 5);
82 lcd_write_reg(8, 0x503);
83 lcd_write_reg(11, 0);
84 lcd_write_reg(12, 0);
85 /* Gamma control */
86 lcd_write_reg(0x30, 0x606);
87 lcd_write_reg(0x31, 0x606);
88 lcd_write_reg(0x32, 0x305);
89 lcd_write_reg(0x33, 2);
90 lcd_write_reg(0x34, 0x503);
91 lcd_write_reg(0x35, 0x606);
92 lcd_write_reg(0x36, 0x606);
93 lcd_write_reg(0x37, 0x200);
94
95 lcd_write_reg(0x11, 0x1f1e);
96 lcd_write_reg(0x38, 0xf0f);
97 /* Set initial LCD limits and RAM settings */
98 lcd_write_reg(0x40, 0); //BPP ?
99 lcd_write_reg(0x42, 0x9f00);
100 lcd_write_reg(0x43, 0);
101 lcd_write_reg(0x44, 0x7f00); /* Horizontal initial refresh zone [0 - 127] */
102 lcd_write_reg(0x45, 0x9f00); /* Vertical initial refresh zone [0 - 159] */
103
104 lcd_write_reg(14, 0x13);
105 lcd_write_reg(0xa9, 0x14);
106 lcd_write_reg(0xa7, 0x30);
107 lcd_write_reg(0xa8, 0x124);
108 lcd_write_reg(0x6f, 0x1d00);
109 lcd_write_reg(0x70, 3);
110 lcd_write_reg(7, 1);
111 lcd_write_reg(0x10, 0x1a10);
112 udelay(0x9c40);
113 lcd_write_reg(7, 0x21);
114 lcd_write_reg(7, 0x23);
115 udelay(0x9c40);
116 lcd_write_reg(7, 0x37); /* Seems to be "power on" */
117 break;
118 }
119 case LCD_TYPE_ONE:
120 {
121 lcd_write_reg(0, 1);
122 udelay(0x2710);
123 lcd_write_reg(0x11, 0x171b);
124 lcd_write_reg(0x12, 0);
125 lcd_write_reg(0x13, 0x80d);
126 lcd_write_reg(0x14, 0x18);
127 lcd_write_reg(0x10, 0x1a10);
128 udelay(0xc350);
129 lcd_write_reg(0x13, 0x81d);
130 udelay(0xc350);
131 lcd_write_reg(1, 0x90c); /* Display mode */
132 lcd_write_reg(2, 0x200);
133 lcd_write_reg(3, 0x1030);
134 lcd_write_reg(7, 5);
135 lcd_write_reg(8, 0x30a);
136 lcd_write_reg(11, 4);
137 lcd_write_reg(12, 0);
138 /* Gamma control */
139 lcd_write_reg(0x30, 0x300);
140 lcd_write_reg(0x31, 0);
141 lcd_write_reg(0x32, 0);
142 lcd_write_reg(0x33, 0x404);
143 lcd_write_reg(0x34, 0x707);
144 lcd_write_reg(0x35, 0x700);
145 lcd_write_reg(0x36, 0x703);
146 lcd_write_reg(0x37, 4);
147
148 lcd_write_reg(0x38, 0);
149 /* Set initial LCD limits and RAM settings */
150 lcd_write_reg(0x40, 0);
151 lcd_write_reg(0x42, 0x9f00); /* LCD Display Start Address Register 0 */
152 lcd_write_reg(0x43, 0); /* LCD Display Start Address Register 1 */
153 lcd_write_reg(0x44, 0x7f00); /* Horizontal initial refresh zone [0 - 127] */
154 lcd_write_reg(0x45, 0x9f00); /* Vertical initial refresh zone [0 - 159] */
155
156 lcd_write_reg(7, 1);
157 udelay(0x2710);
158 lcd_write_reg(7, 0x21);
159 lcd_write_reg(7, 0x23);
160 udelay(0x2710);
161 lcd_write_reg(7, 0x1037);
162 udelay(0x2710);
163 lcd_write_reg(7, 0x35);
164 lcd_write_reg(7, 0x36);
165 lcd_write_reg(7, 0x37);
166 udelay(10000);
167 break;
168 }
169 default:
170 break;
171 }
172}
173
174static void send_update_rect(uint8_t x, uint8_t y, uint8_t w, uint8_t h)
175{
176 /* Set horizontal refresh zone */
177 lcd_write_reg(0x44, (x | (y + w - 1) << 0x8));
178 /* Set vertical refresh zone */
179 lcd_write_reg(0x45, (y | (y + h - 1) << 0x8));
180 lcd_write_reg(0x21, x | y << 8);
181 /* Set register index to 0x22 to write screen data. 0 is mock value */
182 lcd_write_reg(0x22, 0);
183}
184
185static void setup_lcd_pins(void)
186{
187 imx233_lcdif_setup_system_pins(16);
188 /* lcd_rd */
189 imx233_pinctrl_acquire(0, 9, "lcd rd");
190 imx233_pinctrl_set_function(0, 9, PINCTRL_FUNCTION_GPIO);
191 imx233_pinctrl_set_gpio(0, 9, false);
192 /*
193 * This pin is important to know the LCD type
194 * There are two types that require two different initialization sequences
195 */
196 /* lcd_tp */
197 imx233_pinctrl_acquire(3, 12, "lcd type");
198 imx233_pinctrl_set_function(3, 12, PINCTRL_FUNCTION_GPIO);
199 imx233_pinctrl_enable_gpio(3, 12, false);
200 /* Sense LCD Type */
201 lcd_type = imx233_pinctrl_get_gpio(3, 12) ? LCD_TYPE_ONE : LCD_TYPE_ZERO;
202}
203
204static void setup_parameters(void)
205{
206 imx233_lcdif_init();
207 imx233_lcdif_enable(true);
208 imx233_lcdif_set_word_length(16);
209 imx233_lcdif_set_data_swizzle(false);
210 imx233_lcdif_set_timings(2, 1, 1, 1);
211 BF_WR_V(LCDIF_CTRL, MODE86, 8080_MODE);
212
213 imx233_lcdif_reset_lcd(true);
214 udelay(50);
215 imx233_lcdif_reset_lcd(false);
216 udelay(10);
217 imx233_lcdif_reset_lcd(true);
218}
219
220void lcd_init_device(void)
221{
222 /* Setup interface pins */
223 setup_lcd_pins();
224 /* Set LCD parameters */
225 setup_parameters();
226 /* Send initialization sequence to LCD */
227 lcd_init_seq();
228}
229
230struct lcdif_cmd_t
231{
232 struct apb_dma_command_t dma;
233 uint32_t ctrl0;
234 uint32_t pad[4];
235} __attribute__((packed)) CACHEALIGN_ATTR;
236
237struct lcdif_cmd_t lcdif_dma;
238void lcd_update(void)
239{
240 unsigned size = LCD_WIDTH * LCD_HEIGHT * sizeof(fb_data);
241
242 send_update_rect(0,0,LCD_WIDTH,LCD_HEIGHT);
243 /* We can safely do the transfer in a single shot, since 160 * 128 * 2 < 65k,
244 * the maximum transfer size!
245 */
246 lcdif_dma.dma.cmd |= BF_OR3(APB_CHx_CMD, CMDWORDS(1), XFER_COUNT(size), COMMAND(2));
247 lcdif_dma.ctrl0 = HW_LCDIF_CTRL & ~BM_LCDIF_CTRL_COUNT;
248 lcdif_dma.ctrl0 |= BF_OR2(LCDIF_CTRL, COUNT(size/2), DATA_SELECT(1));
249 lcdif_dma.dma.buffer = FBADDR(0,0);
250 lcdif_dma.dma.cmd |= BM_APB_CHx_CMD_SEMAPHORE;
251
252 imx233_dma_start_command(APB_LCDIF, &lcdif_dma.dma);
253 imx233_dma_wait_completion(APB_LCDIF, HZ);
254}
255
256void lcd_update_rect(int x, int y, int w, int h)
257{
258 (void)x;
259 (void)y;
260 (void)w;
261 (void)h;
262 lcd_update();
263}
264
265#ifndef BOOTLOADER
266bool lcd_debug_screen(void)
267{
268 lcd_setfont(FONT_SYSFIXED);
269
270 while(1)
271 {
272 int button = get_action(CONTEXT_STD, HZ / 10);
273 switch(button)
274 {
275 case ACTION_STD_NEXT:
276 case ACTION_STD_PREV:
277 case ACTION_STD_OK:
278 case ACTION_STD_MENU:
279 lcd_setfont(FONT_UI);
280 return true;
281 case ACTION_STD_CANCEL:
282 lcd_setfont(FONT_UI);
283 return false;
284 }
285
286 lcd_clear_display();
287 lcd_putsf(0, 0, "LCD type: %d", lcd_type);
288 lcd_update();
289 yield();
290 }
291
292 return true;
293}
294#endif
diff --git a/firmware/target/arm/imx233/samsung-ypz5/powermgmt-target.h b/firmware/target/arm/imx233/samsung-ypz5/powermgmt-target.h
new file mode 100644
index 0000000000..5d32bc5e9c
--- /dev/null
+++ b/firmware/target/arm/imx233/samsung-ypz5/powermgmt-target.h
@@ -0,0 +1,37 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2013 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 POWERMGMT_TARGET_H
22#define POWERMGMT_TARGET_H
23
24#include "config.h"
25#include "powermgmt-imx233.h"
26
27#define IMX233_CHARGE_CURRENT 100
28#define IMX233_STOP_CURRENT 10
29#define IMX233_TOPOFF_TIMEOUT (30 * 60 * HZ)
30#define IMX233_CHARGING_TIMEOUT (4 * 3600 * HZ)
31#define IMX233_DIE_TEMP_HIGH 71
32#define IMX233_DIE_TEMP_LOW 56
33#define IMX233_BATT_TEMP_SENSOR 0
34#define IMX233_BATT_TEMP_HIGH 1100
35#define IMX233_BATT_TEMP_LOW 220
36
37#endif /* POWERMGMT_TARGET_H */
diff --git a/firmware/target/arm/imx233/samsung-ypz5/powermgmt-ypz5.c b/firmware/target/arm/imx233/samsung-ypz5/powermgmt-ypz5.c
new file mode 100644
index 0000000000..9d9ed7de99
--- /dev/null
+++ b/firmware/target/arm/imx233/samsung-ypz5/powermgmt-ypz5.c
@@ -0,0 +1,48 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2013 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 "config.h"
22#include "powermgmt-target.h"
23#include "power-imx233.h"
24
25
26const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
27{
28 3400
29};
30
31const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
32{
33 3300
34};
35
36/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
37const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
38{
39 /* Sansa Fuze+ Li Ion 600mAH figured from discharge curve */
40 { 3100, 3650, 3720, 3750, 3780, 3820, 3880, 4000, 4040, 4125, 4230 },
41};
42
43/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
44const unsigned short percent_to_volt_charge[11] =
45{
46 /* Sansa Fuze+ Li Ion 600mAH figured from charge curve */
47 3480, 3790, 3845, 3880, 3900, 3935, 4005, 4070, 4150, 4250, 4335
48};
diff --git a/firmware/target/arm/imx233/touchscreen-imx233.c b/firmware/target/arm/imx233/touchscreen-imx233.c
index c4d2f4d726..53d9d0e320 100644
--- a/firmware/target/arm/imx233/touchscreen-imx233.c
+++ b/firmware/target/arm/imx233/touchscreen-imx233.c
@@ -20,6 +20,9 @@
20 ****************************************************************************/ 20 ****************************************************************************/
21#include "touchscreen-imx233.h" 21#include "touchscreen-imx233.h"
22#include "stdlib.h" 22#include "stdlib.h"
23#ifdef SAMSUNG_YPZ5
24#include "pinctrl-imx233.h"
25#endif
23 26
24/* Description: 27/* Description:
25 * the driver basically has 2 modes: 28 * the driver basically has 2 modes:
@@ -72,6 +75,24 @@ static void touch_channel_irq(int chan)
72 process(); 75 process();
73} 76}
74 77
78#ifdef SAMSUNG_YPZ5
79/* On this target we need to manually setup pulldown pins,
80 * using specific GPIO lines
81 */
82static void pulldown_setup(bool xminus_enable, bool yminus_enable,
83 bool xplus_enable, bool yplus_enable)
84{
85 /* TX+ */
86 imx233_pinctrl_set_gpio(0, 25, xplus_enable);
87 /* TX- */
88 imx233_pinctrl_set_gpio(3, 15, xminus_enable);
89 /* TY+ */
90 imx233_pinctrl_set_gpio(0, 26, yplus_enable);
91 /* TY- */
92 imx233_pinctrl_set_gpio(1, 21, yminus_enable);
93}
94#endif
95
75static void kick_measure(bool pull_x, bool pull_y, bool detect, int src) 96static void kick_measure(bool pull_x, bool pull_y, bool detect, int src)
76{ 97{
77 if(touch_chan >= 0) 98 if(touch_chan >= 0)
@@ -84,6 +105,9 @@ static void kick_measure(bool pull_x, bool pull_y, bool detect, int src)
84 imx233_icoll_enable_interrupt(INT_SRC_LRADC_CHx(touch_chan), true); 105 imx233_icoll_enable_interrupt(INT_SRC_LRADC_CHx(touch_chan), true);
85 imx233_lradc_enable_channel_irq(touch_chan, true); 106 imx233_lradc_enable_channel_irq(touch_chan, true);
86 /* setup measurement: x- pull down and x+ pull up */ 107 /* setup measurement: x- pull down and x+ pull up */
108#ifdef SAMSUNG_YPZ5
109 pulldown_setup(pull_x, pull_y, pull_x, pull_y);
110#endif
87 imx233_lradc_setup_touch(pull_x, pull_y, pull_x, pull_y, detect); 111 imx233_lradc_setup_touch(pull_x, pull_y, pull_x, pull_y, detect);
88 imx233_lradc_enable_touch_detect_irq(false); 112 imx233_lradc_enable_touch_detect_irq(false);
89 imx233_lradc_enable_channel_irq(touch_chan, true); 113 imx233_lradc_enable_channel_irq(touch_chan, true);
@@ -102,6 +126,9 @@ static void enter_state(enum touch_state_t state)
102 switch(state) 126 switch(state)
103 { 127 {
104 case TOUCH_STATE_WAIT: 128 case TOUCH_STATE_WAIT:
129#ifdef SAMSUNG_YPZ5
130 pulldown_setup(false, false, false, false);
131#endif
105 imx233_lradc_setup_touch(false, false, false, false, true); 132 imx233_lradc_setup_touch(false, false, false, false, true);
106 imx233_lradc_enable_touch_detect_irq(true); 133 imx233_lradc_enable_touch_detect_irq(true);
107 break; 134 break;