summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2013-10-22 00:30:43 +0200
committerAmaury Pouly <amaury.pouly@gmail.com>2013-10-22 00:34:45 +0200
commita0728672bf07f626049f8dc0007772794ae95ee1 (patch)
treebb8ca610c9d0c8fb441a99ccf33102964cafd003 /firmware
parentd3bc64833c76adca4d6300e5b5880ee8ea63de02 (diff)
downloadrockbox-a0728672bf07f626049f8dc0007772794ae95ee1.tar.gz
rockbox-a0728672bf07f626049f8dc0007772794ae95ee1.zip
Initial commit for the Creative ZEN and ZEN X-Fi
Change-Id: Ibd7b1b0b957ef11c200cb63eff7da53f11774748
Diffstat (limited to 'firmware')
-rw-r--r--firmware/SOURCES12
-rw-r--r--firmware/export/config.h5
-rw-r--r--firmware/target/arm/imx233/creative-zen/adc-target.h29
-rw-r--r--firmware/target/arm/imx233/creative-zen/adc-zen.c34
-rw-r--r--firmware/target/arm/imx233/creative-zen/audio-target.h25
-rw-r--r--firmware/target/arm/imx233/creative-zen/backlight-target.h29
-rw-r--r--firmware/target/arm/imx233/creative-zen/backlight-zen.c69
-rw-r--r--firmware/target/arm/imx233/creative-zen/button-target.h60
-rw-r--r--firmware/target/arm/imx233/creative-zen/button-zen.c88
-rw-r--r--firmware/target/arm/imx233/creative-zen/debug-zen.c29
-rw-r--r--firmware/target/arm/imx233/creative-zen/fmradio-i2c-zen.c40
-rw-r--r--firmware/target/arm/imx233/creative-zen/lcd-target.h26
-rw-r--r--firmware/target/arm/imx233/creative-zen/lcd-zen.c347
-rw-r--r--firmware/target/arm/imx233/creative-zen/power-zen.c43
-rw-r--r--firmware/target/arm/imx233/creative-zen/powermgmt-target.h55
-rw-r--r--firmware/target/arm/imx233/creative-zen/powermgmt-zen.c49
-rw-r--r--firmware/target/arm/imx233/sdmmc-imx233.c17
17 files changed, 957 insertions, 0 deletions
diff --git a/firmware/SOURCES b/firmware/SOURCES
index f6df418049..2a9ae0c266 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -1161,6 +1161,18 @@ target/arm/tms320dm320/creative-zvm/powermgmt-creativezvm.c
1161target/arm/tms320dm320/creative-zvm/usb-creativezvm.c 1161target/arm/tms320dm320/creative-zvm/usb-creativezvm.c
1162#endif /* CREATIVE_ZVx */ 1162#endif /* CREATIVE_ZVx */
1163 1163
1164#if defined(CREATIVE_ZEN) || defined(CREATIVE_ZENXFI)
1165target/arm/imx233/creative-zen/fmradio-i2c-zen.c
1166target/arm/imx233/creative-zen/backlight-zen.c
1167target/arm/imx233/creative-zen/lcd-zen.c
1168target/arm/imx233/creative-zen/button-zen.c
1169target/arm/imx233/creative-zen/debug-zen.c
1170target/arm/imx233/creative-zen/power-zen.c
1171target/arm/imx233/creative-zen/adc-zen.c
1172target/arm/imx233/creative-zen/powermgmt-zen.c
1173target/arm/imx233/button-lradc-imx233.c
1174#endif
1175
1164#ifdef CREATIVE_ZENXFI2 1176#ifdef CREATIVE_ZENXFI2
1165target/arm/imx233/creative-zenxfi2/fmradio-i2c-zenxfi2.c 1177target/arm/imx233/creative-zenxfi2/fmradio-i2c-zenxfi2.c
1166target/arm/imx233/creative-zenxfi2/backlight-zenxfi2.c 1178target/arm/imx233/creative-zenxfi2/backlight-zenxfi2.c
diff --git a/firmware/export/config.h b/firmware/export/config.h
index 37146b649d..a5c199484b 100644
--- a/firmware/export/config.h
+++ b/firmware/export/config.h
@@ -254,6 +254,7 @@
254#define LCD_ILI9342 50 /* as used by HiFi E.T MA9/MA8 */ 254#define LCD_ILI9342 50 /* as used by HiFi E.T MA9/MA8 */
255#define LCD_NWZE370 51 /* as used by Sony NWZ-E370 series */ 255#define LCD_NWZE370 51 /* as used by Sony NWZ-E370 series */
256#define LCD_NWZE360 52 /* as used by Sony NWZ-E360 series */ 256#define LCD_NWZE360 52 /* as used by Sony NWZ-E360 series */
257#define LCD_CREATIVEZEN 55 /* as used by the Creative ZEN (X-Fi) (LMS250GF03-001(S6D0139)) */
257#define LCD_CREATIVEZENMOZAIC 56 /* as used by the Creative ZEN Mozaic (FGD0801) */ 258#define LCD_CREATIVEZENMOZAIC 56 /* as used by the Creative ZEN Mozaic (FGD0801) */
258 259
259/* LCD_PIXELFORMAT */ 260/* LCD_PIXELFORMAT */
@@ -523,8 +524,12 @@ Lyre prototype 1 */
523#include "config/pandora.h" 524#include "config/pandora.h"
524#elif defined(SAMSUNG_YPR0) 525#elif defined(SAMSUNG_YPR0)
525#include "config/samsungypr0.h" 526#include "config/samsungypr0.h"
527#elif defined(CREATIVE_ZENXFI)
528#include "config/creativezenxfi.h"
526#elif defined(CREATIVE_ZENMOZAIC) 529#elif defined(CREATIVE_ZENMOZAIC)
527#include "config/creativezenmozaic.h" 530#include "config/creativezenmozaic.h"
531#elif defined(CREATIVE_ZEN)
532#include "config/creativezen.h"
528#elif defined(MA9) 533#elif defined(MA9)
529#include "config/hifietma9.h" 534#include "config/hifietma9.h"
530#elif defined(SONY_NWZE370) 535#elif defined(SONY_NWZE370)
diff --git a/firmware/target/arm/imx233/creative-zen/adc-target.h b/firmware/target/arm/imx233/creative-zen/adc-target.h
new file mode 100644
index 0000000000..5a525152f6
--- /dev/null
+++ b/firmware/target/arm/imx233/creative-zen/adc-target.h
@@ -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#ifndef _ADC_TARGET_H_
22#define _ADC_TARGET_H_
23
24#define NUM_ADC_CHANNELS 2
25
26#define ADC_BATTERY 0
27#define ADC_DIE_TEMP 1
28
29#endif
diff --git a/firmware/target/arm/imx233/creative-zen/adc-zen.c b/firmware/target/arm/imx233/creative-zen/adc-zen.c
new file mode 100644
index 0000000000..92c1063c24
--- /dev/null
+++ b/firmware/target/arm/imx233/creative-zen/adc-zen.c
@@ -0,0 +1,34 @@
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 "adc-target.h"
22#include "adc-imx233.h"
23
24int imx233_adc_mapping[] =
25{
26 [ADC_DIE_TEMP] = IMX233_ADC_DIE_TEMP,
27 [ADC_BATTERY] = IMX233_ADC_BATTERY,
28};
29
30const char *imx233_adc_channel_name[] =
31{
32 "Die temperature(°C)",
33 "Battery(raw)",
34};
diff --git a/firmware/target/arm/imx233/creative-zen/audio-target.h b/firmware/target/arm/imx233/creative-zen/audio-target.h
new file mode 100644
index 0000000000..4ee2e2f402
--- /dev/null
+++ b/firmware/target/arm/imx233/creative-zen/audio-target.h
@@ -0,0 +1,25 @@
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 __audio_target__
22#define __audio_target__
23
24#endif /* __audio_target__ */
25
diff --git a/firmware/target/arm/imx233/creative-zen/backlight-target.h b/firmware/target/arm/imx233/creative-zen/backlight-target.h
new file mode 100644
index 0000000000..78a0a72d85
--- /dev/null
+++ b/firmware/target/arm/imx233/creative-zen/backlight-target.h
@@ -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#ifndef BACKLIGHT_TARGET_H
22#define BACKLIGHT_TARGET_H
23
24bool _backlight_init(void);
25void _backlight_on(void);
26void _backlight_off(void);
27void _backlight_set_brightness(int brightness);
28
29#endif /* BACKLIGHT_TARGET_H */
diff --git a/firmware/target/arm/imx233/creative-zen/backlight-zen.c b/firmware/target/arm/imx233/creative-zen/backlight-zen.c
new file mode 100644
index 0000000000..0d223b52e9
--- /dev/null
+++ b/firmware/target/arm/imx233/creative-zen/backlight-zen.c
@@ -0,0 +1,69 @@
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 "config.h"
23#include "system.h"
24#include "backlight.h"
25#include "lcd.h"
26#include "backlight-target.h"
27#include "uartdbg-imx233.h"
28#include "pinctrl-imx233.h"
29
30void _backlight_set_brightness(int level)
31{
32 unsigned val = (level + 200) * level / 1000;
33 if(level != 0)
34 {
35 for(unsigned mask = 0x10; mask; mask >>= 1)
36 imx233_uartdbg_send((val & mask) ? 0xff : 0xf8);
37 imx233_uartdbg_send(0);
38 imx233_pinctrl_set_gpio(1, 12, true);
39 }
40 else
41 imx233_pinctrl_set_gpio(1, 12, false);
42}
43
44bool _backlight_init(void)
45{
46 imx233_pinctrl_acquire(1, 12, "backlight_enable");
47 imx233_pinctrl_set_function(1, 12, PINCTRL_FUNCTION_GPIO);
48 imx233_pinctrl_enable_gpio(1, 12, true);
49 imx233_uartdbg_init(BAUD_38400);
50 return true;
51}
52
53void _backlight_on(void)
54{
55#ifdef HAVE_LCD_ENABLE
56 lcd_enable(true); /* power on lcd + visible display */
57#endif
58 /* restore the previous backlight level */
59 _backlight_set_brightness(backlight_brightness);
60}
61
62void _backlight_off(void)
63{
64 /* there is no real on/off but we can set to 0 brightness */
65 _backlight_set_brightness(0);
66#ifdef HAVE_LCD_ENABLE
67 lcd_enable(false); /* power off visible display */
68#endif
69}
diff --git a/firmware/target/arm/imx233/creative-zen/button-target.h b/firmware/target/arm/imx233/creative-zen/button-target.h
new file mode 100644
index 0000000000..33ba7a9db5
--- /dev/null
+++ b/firmware/target/arm/imx233/creative-zen/button-target.h
@@ -0,0 +1,60 @@
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 _BUTTON_TARGET_H_
22#define _BUTTON_TARGET_H_
23
24#include <stdbool.h>
25
26bool button_debug_screen(void);
27
28#define HAS_BUTTON_HOLD
29#ifdef CREATIVE_ZENXFI
30#define HAVE_HEADPHONE_DETECTION
31#endif
32
33#define IMX233_BUTTON_LRADC_CHANNEL 0
34#define IMX233_BUTTON_LRADC_HOLD_DET BLH_ADC
35
36/* Main unit's buttons */
37#define BUTTON_POWER 0x00000001
38#define BUTTON_LEFT 0x00000002
39#define BUTTON_UP 0x00000004
40#define BUTTON_RIGHT 0x00000008
41#define BUTTON_DOWN 0x00000010
42#define BUTTON_SELECT 0x00000020
43#define BUTTON_PLAYPAUSE 0x00000040
44#define BUTTON_BACK 0x00000080
45#define BUTTON_MENU 0x00000100
46#define BUTTON_SHORTCUT 0x00000200
47#ifdef CREATIVE_ZENXFI
48#define BUTTON_BOTTOMLEFT 0x00000400
49#define BUTTON_BOTTOMRIGHT 0x00000800
50#define BUTTON_TOPLEFT 0x00001000
51#define BUTTON_TOPRIGHT 0x00002000
52#endif
53
54#define BUTTON_MAIN 0x00003fff
55
56/* Software power-off */
57#define POWEROFF_BUTTON BUTTON_POWER
58#define POWEROFF_COUNT 10
59
60#endif /* _BUTTON_TARGET_H_ */
diff --git a/firmware/target/arm/imx233/creative-zen/button-zen.c b/firmware/target/arm/imx233/creative-zen/button-zen.c
new file mode 100644
index 0000000000..cacc47d448
--- /dev/null
+++ b/firmware/target/arm/imx233/creative-zen/button-zen.c
@@ -0,0 +1,88 @@
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 "button-target.h"
22#include "system.h"
23#include "system-target.h"
24#include "pinctrl-imx233.h"
25#include "power-imx233.h"
26#include "button-lradc-imx233.h"
27
28struct imx233_button_lradc_mapping_t imx233_button_lradc_mapping[] =
29{
30#if defined(CREATIVE_ZEN)
31 {200, IMX233_BUTTON_LRADC_HOLD},
32 {250, BUTTON_MENU},
33 {520, BUTTON_SHORTCUT},
34 {1490, BUTTON_UP},
35 {1740, BUTTON_SELECT},
36 {2015, BUTTON_LEFT},
37 {2255, BUTTON_RIGHT},
38 {2485, BUTTON_DOWN},
39 {2700, BUTTON_BACK},
40 {2945, BUTTON_PLAYPAUSE},
41 {3400, 0},
42 {0, IMX233_BUTTON_LRADC_END},
43#elif defined(CREATIVE_ZENXFI)
44 {0, IMX233_BUTTON_LRADC_HOLD},
45 {200, BUTTON_MENU},
46 {445, BUTTON_SHORTCUT},
47 {645, BUTTON_UP},
48 {860, BUTTON_LEFT},
49 {1060, BUTTON_RIGHT},
50 {1260, BUTTON_DOWN},
51 {1480, BUTTON_SELECT},
52 {1700, BUTTON_TOPRIGHT},
53 {1920, BUTTON_BOTTOMLEFT},
54 {2145, BUTTON_TOPLEFT},
55 {2460, BUTTON_BOTTOMRIGHT},
56 {2700, BUTTON_BACK},
57 {2945, BUTTON_PLAYPAUSE},
58 {3400, 0},
59 {0, IMX233_BUTTON_LRADC_END},
60#else
61#error wrong target
62#endif
63};
64
65void button_init_device(void)
66{
67 imx233_button_lradc_init();
68}
69
70bool button_hold(void)
71{
72 return imx233_button_lradc_hold();
73}
74
75#ifdef CREATIVE_ZENXFI
76bool headphones_inserted(void)
77{
78 return !imx233_pinctrl_get_gpio(2, 8);
79}
80#endif
81
82int button_read_device(void)
83{
84 int btn = 0;
85 if(BF_RD(POWER_STS, PSWITCH) == 1)
86 btn |= BUTTON_POWER;
87 return imx233_button_lradc_read(btn);
88}
diff --git a/firmware/target/arm/imx233/creative-zen/debug-zen.c b/firmware/target/arm/imx233/creative-zen/debug-zen.c
new file mode 100644
index 0000000000..a350d0ae62
--- /dev/null
+++ b/firmware/target/arm/imx233/creative-zen/debug-zen.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 false;
29}
diff --git a/firmware/target/arm/imx233/creative-zen/fmradio-i2c-zen.c b/firmware/target/arm/imx233/creative-zen/fmradio-i2c-zen.c
new file mode 100644
index 0000000000..a1377ce1f2
--- /dev/null
+++ b/firmware/target/arm/imx233/creative-zen/fmradio-i2c-zen.c
@@ -0,0 +1,40 @@
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 "config.h"
23#include "system.h"
24#include "fmradio_i2c.h"
25#include "pinctrl-imx233.h"
26#include "i2c.h"
27
28void fmradio_i2c_init(void)
29{
30}
31
32int fmradio_i2c_write(unsigned char address, const unsigned char* buf, int count)
33{
34 return i2c_write(address, buf, count);
35}
36
37int fmradio_i2c_read(unsigned char address, unsigned char* buf, int count)
38{
39 return i2c_read(address, buf, count);
40}
diff --git a/firmware/target/arm/imx233/creative-zen/lcd-target.h b/firmware/target/arm/imx233/creative-zen/lcd-target.h
new file mode 100644
index 0000000000..b28bda347a
--- /dev/null
+++ b/firmware/target/arm/imx233/creative-zen/lcd-target.h
@@ -0,0 +1,26 @@
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 LCD_TARGET_H
22#define LCD_TARGET_H
23
24bool lcd_debug_screen(void);
25
26#endif /* LCD_TARGET_H */
diff --git a/firmware/target/arm/imx233/creative-zen/lcd-zen.c b/firmware/target/arm/imx233/creative-zen/lcd-zen.c
new file mode 100644
index 0000000000..8390d192c8
--- /dev/null
+++ b/firmware/target/arm/imx233/creative-zen/lcd-zen.c
@@ -0,0 +1,347 @@
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 <sys/types.h> /* off_t */
22#include <string.h>
23#include "cpu.h"
24#include "system.h"
25#include "backlight-target.h"
26#include "lcd.h"
27#include "lcdif-imx233.h"
28#include "clkctrl-imx233.h"
29#include "pinctrl-imx233.h"
30#include "dma-imx233.h"
31#include "regs/regs-uartdbg.h"
32#include "logf.h"
33#ifndef BOOTLOADER
34#include "button.h"
35#include "font.h"
36#include "action.h"
37#endif
38
39#ifdef HAVE_LCD_ENABLE
40static bool lcd_on;
41#endif
42
43/**
44 * DMA
45 */
46
47/* Used for DMA */
48struct lcdif_dma_command_t
49{
50 struct apb_dma_command_t dma;
51 uint32_t pad;
52} __attribute__((packed)) CACHEALIGN_ATTR;
53
54__ENSURE_STRUCT_CACHE_FRIENDLY(struct lcdif_dma_command_t)
55
56#define NR_CMDS ((IMX233_FRAMEBUFFER_SIZE + IMX233_MAX_SINGLE_DMA_XFER_SIZE - 1) / IMX233_MAX_SINGLE_DMA_XFER_SIZE)
57
58struct lcdif_dma_command_t lcdif_dma[NR_CMDS];
59
60/**
61 * Utils
62 */
63static int g_wait_nr_frame = 0;
64static struct semaphore g_wait_sema;
65
66static void wait_frames_cb(void)
67{
68 if(--g_wait_nr_frame == 0)
69 semaphore_release(&g_wait_sema);
70}
71
72static void wait_nr_frames(int nr)
73{
74 g_wait_nr_frame = 1 + nr; // +1 because we want entire frames
75 imx233_lcdif_set_vsync_edge_cb(wait_frames_cb);
76 imx233_lcdif_enable_vsync_edge_irq(true);
77 semaphore_wait(&g_wait_sema, TIMEOUT_BLOCK);
78 imx233_lcdif_enable_vsync_edge_irq(false);
79}
80
81/**
82 * SPI
83 */
84
85#define SPI_CS(v) imx233_pinctrl_set_gpio(1, 11, v)
86#define SPI_SCL(v) imx233_pinctrl_set_gpio(1, 10, v)
87#define SPI_SDO(v) imx233_pinctrl_set_gpio(1, 9, v)
88
89#define DEV_ID 0x74
90#define RS 0x2
91#define RW 0x1
92
93static void spi_init(void)
94{
95 imx233_pinctrl_acquire(1, 9, "lcd_spi_sdo");
96 imx233_pinctrl_acquire(1, 10, "lcd_spi_scl");
97 imx233_pinctrl_acquire(1, 11, "lcd_spi_cs");
98 imx233_pinctrl_set_function(1, 9, PINCTRL_FUNCTION_GPIO);
99 imx233_pinctrl_set_function(1, 10, PINCTRL_FUNCTION_GPIO);
100 imx233_pinctrl_set_function(1, 11, PINCTRL_FUNCTION_GPIO);
101 imx233_pinctrl_set_gpio(1, 9, true);
102 imx233_pinctrl_set_gpio(1, 10, true);
103 imx233_pinctrl_set_gpio(1, 11, true);
104 imx233_pinctrl_enable_gpio(1, 9, true);
105 imx233_pinctrl_enable_gpio(1, 10, true);
106 imx233_pinctrl_enable_gpio(1, 11, true);
107}
108
109static void spi_delay(void)
110{
111 udelay(1);
112}
113
114static void spi_begin(void)
115{
116 SPI_CS(false);
117 spi_delay();
118}
119
120static void spi_write(unsigned char b)
121{
122 for(int i = 7; i >= 0; i--)
123 {
124 SPI_SCL(false);
125 spi_delay();
126 SPI_SDO((b >> i) & 1);
127 spi_delay();
128 SPI_SCL(true);
129 spi_delay();
130 }
131}
132
133static void spi_end(void)
134{
135 SPI_CS(true);
136 spi_delay();
137}
138
139static void spi_write_reg(uint8_t reg, uint16_t value)
140{
141 spi_begin();
142 spi_write(DEV_ID);
143 spi_write(0);
144 spi_write(reg);
145 spi_end();
146 spi_begin();
147 spi_write(DEV_ID | RS);
148 spi_write(value >> 8);
149 spi_write(value & 0xff);
150 spi_end();
151}
152
153/**
154 * LCD control
155 */
156
157static void lcd_power(bool en)
158{
159 imx233_pinctrl_set_gpio(1, 8, en);
160 mdelay(10);
161}
162
163static void lcd_power_seq(void)
164{
165 spi_write_reg(0x7, 0);
166 mdelay(10);
167 spi_write_reg(0x12, 0x1618);
168 spi_write_reg(0x11, 0x2227);
169 spi_write_reg(0x13, 0x61d1);
170 spi_write_reg(0x10, 0x550c);
171 wait_nr_frames(5);
172 spi_write_reg(0x12, 0x0c58);
173}
174
175static void lcd_init_seq(void)
176{
177 /* NOTE I don't understand why I have to use BGR, logic would say I should not */
178 spi_write_reg(0x1, 0x2b1d);// inversion
179 spi_write_reg(0x2, 0x300);
180 /* NOTE by default stmp3700 has vsync/hsync active low and data launch
181 * at negative edge of dotclk, reflect this in the polarity settings */
182 spi_write_reg(0x3, 0xd040);// polarity (OF uses 0xc040, seems incorrect)
183 spi_write_reg(0x8, 0); // vsync back porch (0=3H)
184 spi_write_reg(0x9, 0); // hsync back porhc (0=24clk)
185 spi_write_reg(0x76, 0x2213);
186 spi_write_reg(0xb, 0x33e1);
187 spi_write_reg(0xc, 0x23);
188 spi_write_reg(0x76, 0);
189 spi_write_reg(0xd, 7);
190 spi_write_reg(0xe, 0);
191 spi_write_reg(0x15, 0x803);
192 spi_write_reg(0x14, 0);
193 spi_write_reg(0x16, 0);
194 spi_write_reg(0x30, 0x706);
195 spi_write_reg(0x31, 0x406);
196 spi_write_reg(0x32, 0xc09);
197 spi_write_reg(0x33, 0x606);
198 spi_write_reg(0x34, 0x706);
199 spi_write_reg(0x35, 0x406);
200 spi_write_reg(0x36, 0xc06);
201 spi_write_reg(0x37, 0x601);
202 spi_write_reg(0x38, 0x504);
203 spi_write_reg(0x39, 0x504);
204}
205
206static void lcd_display_on_seq(void)
207{
208 spi_write_reg(0x7, 1);
209 wait_nr_frames(1);
210 spi_write_reg(0x7, 0x101);
211 wait_nr_frames(2);
212 spi_write_reg(0x76, 0x2213);
213 spi_write_reg(0x1c, 0x6650);
214 spi_write_reg(0xb, 0x33e1);
215 spi_write_reg(0x76, 0);
216 spi_write_reg(0x7, 0x103);
217}
218
219static void lcd_display_off_seq(void)
220{
221 spi_write_reg(0xb, 0x30e1);
222 spi_write_reg(0x7, 0x102);
223 wait_nr_frames(2);
224 spi_write_reg(0x7, 0);
225 spi_write_reg(0x12, 0);
226 spi_write_reg(0x10, 0x100);
227}
228
229static void lcd_standby_in_seq(void)
230{
231 lcd_display_off_seq();
232 spi_write_reg(0x10, 0x1);
233}
234
235static void lcd_standby_out_seq(void)
236{
237 spi_write_reg(0x10, 0);
238 lcd_power_seq();
239 lcd_display_on_seq();
240}
241
242/**
243 * Rockbox
244 */
245
246void lcd_init_device(void)
247{
248 semaphore_init(&g_wait_sema, 1, 0);
249#ifdef HAVE_LCD_ENABLE
250 lcd_on = true;
251#endif
252 /** lcd is 320x240, data bus is 8-bit, depth is 24-bit so we need 3clk/pix
253 * by running PIX clock at 24MHz we can sustain ~100 fps */
254 imx233_clkctrl_enable(CLK_PIX, false);
255 imx233_clkctrl_set_div(CLK_PIX, 2);
256 imx233_clkctrl_set_bypass(CLK_PIX, true); /* use XTAL */
257 imx233_clkctrl_enable(CLK_PIX, true);
258 imx233_dma_reset_channel(APB_LCDIF);
259 imx233_dma_clkgate_channel(APB_LCDIF, true);
260 imx233_lcdif_init();
261 imx233_lcdif_setup_dotclk_pins(8, false);
262 imx233_lcdif_set_word_length(8);
263 /** Datasheet states:
264 * 257H >= VBP >= 3H, VBP > VLW, VFP > 1H
265 * 1533clk >= HBP >= 24clk, HBP > HLW, HFP >= 4clk
266 *
267 * Take VLW=1H, VBP=3H, VFP=2H, HLW=8, HBP=24, HFP=4
268 * Take 3clk/pix because we send 24-bit/pix with 8-bit data bus
269 * Keep consistent with register setting in lcd_init_seq
270 */
271 imx233_lcdif_setup_dotclk_ex(/*v_pulse_width*/1, /*v_back_porch*/3,
272 /*v_front_porch*/1, /*h_pulse_width*/8, /*h_back_porch*/24,
273 /*h_front_porch*/4, LCD_WIDTH, LCD_HEIGHT, /*clk_per_pix*/3,
274 /*enable_present*/false);
275 imx233_lcdif_set_byte_packing_format(0xf);
276 // prepare pins
277 spi_init();
278 imx233_pinctrl_acquire(1, 8, "lcd_power");
279 imx233_pinctrl_set_function(1, 8, PINCTRL_FUNCTION_GPIO);
280 imx233_pinctrl_enable_gpio(1, 8, true);
281 // power up
282 lcd_power(true);
283 // reset lcd
284 imx233_lcdif_reset_lcd(true);
285 mdelay(1);
286 imx233_lcdif_reset_lcd(false);
287 mdelay(1);
288 imx233_lcdif_reset_lcd(true);
289 mdelay(1);
290 // setup registers
291 imx233_lcdif_enable_sync_signals(true); // we need frame signals during init
292 lcd_power_seq();
293 lcd_init_seq();
294 lcd_display_on_seq();
295 // setup refresh
296 unsigned size = IMX233_FRAMEBUFFER_SIZE;
297 uint8_t *frame_p = FRAME;
298 for(int i = 0; i < NR_CMDS; i++)
299 {
300 unsigned xfer = MIN(IMX233_MAX_SINGLE_DMA_XFER_SIZE, size);
301 lcdif_dma[i].dma.next = &lcdif_dma[(i + 1) % NR_CMDS].dma;
302 lcdif_dma[i].dma.cmd = BF_OR3(APB_CHx_CMD, CHAIN(1),
303 COMMAND(BV_APB_CHx_CMD_COMMAND__READ), XFER_COUNT(xfer));
304 lcdif_dma[i].dma.buffer = frame_p;
305 size -= xfer;
306 frame_p += xfer;
307 }
308 imx233_dma_start_command(APB_LCDIF, &lcdif_dma[0].dma);
309 BF_SET(LCDIF_CTRL, RUN);
310}
311
312#ifdef HAVE_LCD_ENABLE
313bool lcd_active(void)
314{
315 return lcd_on;
316}
317
318void lcd_enable(bool enable)
319{
320 if(lcd_on == enable)
321 return;
322
323 lcd_on = enable;
324}
325#endif
326
327void lcd_update(void)
328{
329 lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT);
330}
331
332void lcd_update_rect(int x, int y, int w, int h)
333{
334 #ifdef HAVE_LCD_ENABLE
335 if(!lcd_on)
336 return;
337 #endif
338 uint8_t *p = FRAME;
339 for(int y = 0; y < LCD_HEIGHT; y++)
340 for(int x = 0; x < LCD_WIDTH; x++)
341 {
342 uint16_t pix = *FBADDR(x,y);
343 *p++ = RGB_UNPACK_RED(pix);
344 *p++ = RGB_UNPACK_GREEN(pix);
345 *p++ = RGB_UNPACK_BLUE(pix);
346 }
347}
diff --git a/firmware/target/arm/imx233/creative-zen/power-zen.c b/firmware/target/arm/imx233/creative-zen/power-zen.c
new file mode 100644
index 0000000000..81157da511
--- /dev/null
+++ b/firmware/target/arm/imx233/creative-zen/power-zen.c
@@ -0,0 +1,43 @@
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 "power.h"
24#include "tuner.h"
25#include "fmradio_i2c.h"
26#include "pinctrl-imx233.h"
27#include "power-imx233.h"
28
29static bool tuner_enable = false;
30
31bool tuner_power(bool enable)
32{
33 if(enable != tuner_enable)
34 {
35 tuner_enable = enable;
36 }
37 return tuner_enable;
38}
39
40bool tuner_powered(void)
41{
42 return tuner_enable;
43} \ No newline at end of file
diff --git a/firmware/target/arm/imx233/creative-zen/powermgmt-target.h b/firmware/target/arm/imx233/creative-zen/powermgmt-target.h
new file mode 100644
index 0000000000..716ee4dac3
--- /dev/null
+++ b/firmware/target/arm/imx233/creative-zen/powermgmt-target.h
@@ -0,0 +1,55 @@
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/* ZEN X-Fi OF settings:
28 * - current ramp slope:
29 * - conditioning threshold voltage:
30 * - conditioning max voltage:
31 * - conditioning current:
32 * - conditioning timeout:
33 * - charging voltage:
34 * - charging current:
35 * - charging threshold current:
36 * - charging timeout:
37 * - top off period:
38 * - high die temperature:
39 * - low die temperature:
40 * - safe die temperature current:
41 * - battery temperature channel:
42 * - high battery temperature:
43 * - low battery temperature:
44 * - safe battery temperature current:
45 * - low DCDC battery voltage:
46 */
47
48#define IMX233_CHARGE_CURRENT 200
49#define IMX233_STOP_CURRENT 30
50#define IMX233_TOPOFF_TIMEOUT (30 * 60 * HZ)
51#define IMX233_CHARGING_TIMEOUT (4 * 3600 * HZ)
52#define IMX233_DIE_TEMP_HIGH 71
53#define IMX233_DIE_TEMP_LOW 56
54
55#endif /* POWERMGMT_TARGET_H */
diff --git a/firmware/target/arm/imx233/creative-zen/powermgmt-zen.c b/firmware/target/arm/imx233/creative-zen/powermgmt-zen.c
new file mode 100644
index 0000000000..1e986813f9
--- /dev/null
+++ b/firmware/target/arm/imx233/creative-zen/powermgmt-zen.c
@@ -0,0 +1,49 @@
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#warning FIXME calibrate
26
27const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
28{
29 0
30};
31
32const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
33{
34 0
35};
36
37/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
38const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
39{
40 /* Sansa Fuze+ Li Ion 600mAH figured from discharge curve */
41 { 3100, 3650, 3720, 3750, 3780, 3820, 3880, 4000, 4040, 4125, 4230 },
42};
43
44/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
45const unsigned short percent_to_volt_charge[11] =
46{
47 /* Sansa Fuze+ Li Ion 600mAH figured from charge curve */
48 3480, 3790, 3845, 3880, 3900, 3935, 4005, 4070, 4150, 4250, 4335
49}; \ No newline at end of file
diff --git a/firmware/target/arm/imx233/sdmmc-imx233.c b/firmware/target/arm/imx233/sdmmc-imx233.c
index 15eeed1371..cff801f6b9 100644
--- a/firmware/target/arm/imx233/sdmmc-imx233.c
+++ b/firmware/target/arm/imx233/sdmmc-imx233.c
@@ -127,6 +127,23 @@ struct sdmmc_config_t sdmmc_config[] =
127 .ssp = 1, 127 .ssp = 1,
128 .mode = SD_MODE, 128 .mode = SD_MODE,
129 }, 129 },
130#elif defined(CREATIVE_ZENXFI) || defined(CREATIVE_ZEN)
131 {
132 .name = "internal/SD",
133 .flags = WINDOW,
134 .ssp = 2,
135 .mode = SD_MODE,
136 },
137 /* The Zen X-Fi uses pin #B0P10 for power*/
138 {
139 .name = "microSD",
140 .flags = POWER_PIN | REMOVABLE | DETECT_INVERTED | POWER_DELAY | WP_PIN,
141 .power_pin = PIN(0, 10),
142 .wp_pin = PIN(0, 11),
143 .power_delay = HZ / 10, /* extra delay, to ramp up voltage? */
144 .ssp = 1,
145 .mode = SD_MODE,
146 },
130#elif defined(CREATIVE_ZENMOZAIC) 147#elif defined(CREATIVE_ZENMOZAIC)
131 { 148 {
132 .name = "internal/SD", 149 .name = "internal/SD",