diff options
author | Amaury Pouly <amaury.pouly@gmail.com> | 2013-10-22 00:28:09 +0200 |
---|---|---|
committer | Amaury Pouly <amaury.pouly@gmail.com> | 2013-10-22 00:34:44 +0200 |
commit | d3bc64833c76adca4d6300e5b5880ee8ea63de02 (patch) | |
tree | 621978b661c875364c878ba31a9cfed61cf55015 /firmware/target/arm/imx233/creative-zenmozaic | |
parent | 9ed980785429db35f51f8d324cc75c23f2e5fb20 (diff) | |
download | rockbox-d3bc64833c76adca4d6300e5b5880ee8ea63de02.tar.gz rockbox-d3bc64833c76adca4d6300e5b5880ee8ea63de02.zip |
Initial commit for the Creative ZEN Mozaic
Change-Id: Ib65aad9f5de37e514047955cad7ca40dc0af4f74
Diffstat (limited to 'firmware/target/arm/imx233/creative-zenmozaic')
14 files changed, 719 insertions, 0 deletions
diff --git a/firmware/target/arm/imx233/creative-zenmozaic/adc-target.h b/firmware/target/arm/imx233/creative-zenmozaic/adc-target.h new file mode 100644 index 0000000000..5a525152f6 --- /dev/null +++ b/firmware/target/arm/imx233/creative-zenmozaic/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-zenmozaic/adc-zenmozaic.c b/firmware/target/arm/imx233/creative-zenmozaic/adc-zenmozaic.c new file mode 100644 index 0000000000..92c1063c24 --- /dev/null +++ b/firmware/target/arm/imx233/creative-zenmozaic/adc-zenmozaic.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 | |||
24 | int imx233_adc_mapping[] = | ||
25 | { | ||
26 | [ADC_DIE_TEMP] = IMX233_ADC_DIE_TEMP, | ||
27 | [ADC_BATTERY] = IMX233_ADC_BATTERY, | ||
28 | }; | ||
29 | |||
30 | const char *imx233_adc_channel_name[] = | ||
31 | { | ||
32 | "Die temperature(°C)", | ||
33 | "Battery(raw)", | ||
34 | }; | ||
diff --git a/firmware/target/arm/imx233/creative-zenmozaic/audio-target.h b/firmware/target/arm/imx233/creative-zenmozaic/audio-target.h new file mode 100644 index 0000000000..4ee2e2f402 --- /dev/null +++ b/firmware/target/arm/imx233/creative-zenmozaic/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-zenmozaic/backlight-target.h b/firmware/target/arm/imx233/creative-zenmozaic/backlight-target.h new file mode 100644 index 0000000000..78a0a72d85 --- /dev/null +++ b/firmware/target/arm/imx233/creative-zenmozaic/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 | |||
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/creative-zenmozaic/backlight-zenmozaic.c b/firmware/target/arm/imx233/creative-zenmozaic/backlight-zenmozaic.c new file mode 100644 index 0000000000..0d223b52e9 --- /dev/null +++ b/firmware/target/arm/imx233/creative-zenmozaic/backlight-zenmozaic.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 | |||
30 | void _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 | |||
44 | bool _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 | |||
53 | void _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 | |||
62 | void _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-zenmozaic/button-target.h b/firmware/target/arm/imx233/creative-zenmozaic/button-target.h new file mode 100644 index 0000000000..714e9983fd --- /dev/null +++ b/firmware/target/arm/imx233/creative-zenmozaic/button-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 _BUTTON_TARGET_H_ | ||
22 | #define _BUTTON_TARGET_H_ | ||
23 | |||
24 | #include <stdbool.h> | ||
25 | |||
26 | bool button_debug_screen(void); | ||
27 | |||
28 | #define HAS_BUTTON_HOLD | ||
29 | #define HAVE_HEADPHONE_DETECTION | ||
30 | |||
31 | #define IMX233_BUTTON_LRADC_CHANNEL 0 | ||
32 | #define IMX233_BUTTON_LRADC_HOLD_DET BLH_ADC | ||
33 | |||
34 | /* Main unit's buttons */ | ||
35 | #define BUTTON_POWER 0x00000001 | ||
36 | #define BUTTON_LEFT 0x00000002 | ||
37 | #define BUTTON_UP 0x00000004 | ||
38 | #define BUTTON_RIGHT 0x00000008 | ||
39 | #define BUTTON_DOWN 0x00000010 | ||
40 | #define BUTTON_SELECT 0x00000020 | ||
41 | #define BUTTON_PLAYPAUSE 0x00000040 | ||
42 | #define BUTTON_BACK 0x00000080 | ||
43 | #define BUTTON_MENU 0x00000100 | ||
44 | #define BUTTON_SHORTCUT 0x00000200 | ||
45 | |||
46 | |||
47 | #define BUTTON_MAIN (BUTTON_POWER|BUTTON_LEFT|BUTTON_UP|BUTTON_RIGHT|\ | ||
48 | BUTTON_DOWN|BUTTON_SELECT|BUTTON_PLAYPAUSE|BUTTON_BACK|\ | ||
49 | BUTTON_MENU|BUTTON_SHORTCUT) | ||
50 | |||
51 | /* Software power-off */ | ||
52 | #define POWEROFF_BUTTON BUTTON_POWER | ||
53 | #define POWEROFF_COUNT 10 | ||
54 | |||
55 | #endif /* _BUTTON_TARGET_H_ */ | ||
diff --git a/firmware/target/arm/imx233/creative-zenmozaic/button-zenmozaic.c b/firmware/target/arm/imx233/creative-zenmozaic/button-zenmozaic.c new file mode 100644 index 0000000000..bf6729a273 --- /dev/null +++ b/firmware/target/arm/imx233/creative-zenmozaic/button-zenmozaic.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 | #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 | |||
28 | struct imx233_button_lradc_mapping_t imx233_button_lradc_mapping[] = | ||
29 | { | ||
30 | {0, IMX233_BUTTON_LRADC_HOLD}, | ||
31 | {200, BUTTON_MENU}, | ||
32 | {445, BUTTON_SHORTCUT}, | ||
33 | {645, BUTTON_UP}, | ||
34 | {860, BUTTON_LEFT}, | ||
35 | {1060, BUTTON_RIGHT}, | ||
36 | {1260, BUTTON_DOWN}, | ||
37 | {1480, BUTTON_SELECT}, | ||
38 | {2700, BUTTON_BACK}, | ||
39 | {2945, BUTTON_PLAYPAUSE}, | ||
40 | {3400, 0}, | ||
41 | {0, IMX233_BUTTON_LRADC_END}, | ||
42 | }; | ||
43 | |||
44 | void button_init_device(void) | ||
45 | { | ||
46 | imx233_button_lradc_init(); | ||
47 | |||
48 | imx233_pinctrl_acquire(2, 8, "jack_detect"); | ||
49 | imx233_pinctrl_set_function(2, 8, PINCTRL_FUNCTION_GPIO); | ||
50 | imx233_pinctrl_enable_gpio(2, 8, false); | ||
51 | } | ||
52 | |||
53 | bool headphones_inserted(void) | ||
54 | { | ||
55 | return imx233_pinctrl_get_gpio(2, 8); | ||
56 | } | ||
57 | |||
58 | bool button_hold(void) | ||
59 | { | ||
60 | return imx233_button_lradc_hold(); | ||
61 | } | ||
62 | |||
63 | int button_read_device(void) | ||
64 | { | ||
65 | int btn = 0; | ||
66 | if(BF_RD(POWER_STS, PSWITCH) == 1) | ||
67 | btn |= BUTTON_POWER; | ||
68 | return imx233_button_lradc_read(btn); | ||
69 | } | ||
diff --git a/firmware/target/arm/imx233/creative-zenmozaic/debug-zenmozaic.c b/firmware/target/arm/imx233/creative-zenmozaic/debug-zenmozaic.c new file mode 100644 index 0000000000..a350d0ae62 --- /dev/null +++ b/firmware/target/arm/imx233/creative-zenmozaic/debug-zenmozaic.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 | |||
26 | bool dbg_hw_target_info(void) | ||
27 | { | ||
28 | return false; | ||
29 | } | ||
diff --git a/firmware/target/arm/imx233/creative-zenmozaic/fmradio-i2c-zenmozaic.c b/firmware/target/arm/imx233/creative-zenmozaic/fmradio-i2c-zenmozaic.c new file mode 100644 index 0000000000..a1377ce1f2 --- /dev/null +++ b/firmware/target/arm/imx233/creative-zenmozaic/fmradio-i2c-zenmozaic.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 | |||
28 | void fmradio_i2c_init(void) | ||
29 | { | ||
30 | } | ||
31 | |||
32 | int fmradio_i2c_write(unsigned char address, const unsigned char* buf, int count) | ||
33 | { | ||
34 | return i2c_write(address, buf, count); | ||
35 | } | ||
36 | |||
37 | int 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-zenmozaic/lcd-target.h b/firmware/target/arm/imx233/creative-zenmozaic/lcd-target.h new file mode 100644 index 0000000000..5133c75d1b --- /dev/null +++ b/firmware/target/arm/imx233/creative-zenmozaic/lcd-target.h | |||
@@ -0,0 +1,27 @@ | |||
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 | |||
24 | bool lcd_debug_screen(void); | ||
25 | void lcd_set_contrast(int val); | ||
26 | |||
27 | #endif /* LCD_TARGET_H */ | ||
diff --git a/firmware/target/arm/imx233/creative-zenmozaic/lcd-zenmozaic.c b/firmware/target/arm/imx233/creative-zenmozaic/lcd-zenmozaic.c new file mode 100644 index 0000000000..eac36676ae --- /dev/null +++ b/firmware/target/arm/imx233/creative-zenmozaic/lcd-zenmozaic.c | |||
@@ -0,0 +1,152 @@ | |||
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 "dcp-imx233.h" | ||
31 | #include "logf.h" | ||
32 | #ifndef BOOTLOADER | ||
33 | #include "button.h" | ||
34 | #include "font.h" | ||
35 | #include "action.h" | ||
36 | #endif | ||
37 | |||
38 | #ifdef HAVE_LCD_ENABLE | ||
39 | static bool lcd_on; | ||
40 | #endif | ||
41 | |||
42 | static void lcd_write_reg(uint16_t reg, uint16_t value) | ||
43 | { | ||
44 | imx233_lcdif_set_data_swizzle(3); | ||
45 | imx233_lcdif_pio_send(false, 2, ®); | ||
46 | if(reg != 0x22) | ||
47 | imx233_lcdif_pio_send(true, 2, &value); | ||
48 | } | ||
49 | |||
50 | void lcd_init_device(void) | ||
51 | { | ||
52 | /* clock at 24MHZ */ | ||
53 | imx233_clkctrl_enable(CLK_PIX, false); | ||
54 | imx233_clkctrl_set_div(CLK_PIX, 3); | ||
55 | imx233_clkctrl_set_bypass(CLK_PIX, true); /* use XTAL */ | ||
56 | imx233_clkctrl_enable(CLK_PIX, true); | ||
57 | imx233_lcdif_init(); | ||
58 | imx233_lcdif_setup_system_pins(8); | ||
59 | imx233_lcdif_set_timings(2, 2, 2, 2); | ||
60 | imx233_lcdif_set_word_length(8); | ||
61 | |||
62 | lcd_write_reg(0, 1); | ||
63 | lcd_write_reg(3, 0); | ||
64 | |||
65 | lcd_write_reg(3, 0x510); | ||
66 | lcd_write_reg(9, 8); | ||
67 | lcd_write_reg(0xc, 0); | ||
68 | lcd_write_reg(0xd, 0); | ||
69 | lcd_write_reg(0xe, 0); | ||
70 | lcd_write_reg(0x5b, 4); | ||
71 | lcd_write_reg(0xd, 0x10); | ||
72 | lcd_write_reg(9, 0); | ||
73 | lcd_write_reg(3, 0x10); | ||
74 | lcd_write_reg(0xd, 0x14); | ||
75 | lcd_write_reg(0xe, 0x2b12); | ||
76 | lcd_write_reg(1, 0x21f); | ||
77 | lcd_write_reg(2, 0x700); | ||
78 | lcd_write_reg(5, 0x30); | ||
79 | lcd_write_reg(6, 0); | ||
80 | lcd_write_reg(8, 0x202); | ||
81 | lcd_write_reg(0xa, 0x3); // OF uses 0xc0003 with 3 transfers/pixels | ||
82 | lcd_write_reg(0xb, 0); | ||
83 | lcd_write_reg(0xf, 0); | ||
84 | lcd_write_reg(0x10, 0); | ||
85 | lcd_write_reg(0x11, 0); | ||
86 | lcd_write_reg(0x14, 0x9f00); | ||
87 | lcd_write_reg(0x15, 0x9f00); | ||
88 | lcd_write_reg(0x16, 0x7f00); | ||
89 | lcd_write_reg(0x17, 0x9f00); | ||
90 | lcd_write_reg(0x20, 0); | ||
91 | lcd_write_reg(0x21, 0); | ||
92 | lcd_write_reg(0x23, 0); | ||
93 | lcd_write_reg(0x24, 0); | ||
94 | lcd_write_reg(0x25, 0); | ||
95 | lcd_write_reg(0x26, 0); | ||
96 | lcd_write_reg(0x30, 0x707); | ||
97 | lcd_write_reg(0x31, 0x504); | ||
98 | lcd_write_reg(0x32, 7); | ||
99 | lcd_write_reg(0x33, 0x307); | ||
100 | lcd_write_reg(0x34, 7); | ||
101 | lcd_write_reg(0x35, 0x400); | ||
102 | lcd_write_reg(0x36, 0x607); | ||
103 | lcd_write_reg(0x37, 0x703); | ||
104 | lcd_write_reg(0x3a, 0x1a0d); | ||
105 | lcd_write_reg(0x3b, 0x1309); | ||
106 | |||
107 | lcd_write_reg(9, 4); | ||
108 | lcd_write_reg(7, 5); | ||
109 | lcd_write_reg(7, 0x25); | ||
110 | lcd_write_reg(7, 0x27); | ||
111 | lcd_write_reg(0x5b, 0); | ||
112 | lcd_write_reg(7, 0x37); | ||
113 | #ifdef HAVE_LCD_ENABLE | ||
114 | lcd_on = true; | ||
115 | #endif | ||
116 | } | ||
117 | |||
118 | #ifdef HAVE_LCD_ENABLE | ||
119 | bool lcd_active(void) | ||
120 | { | ||
121 | return lcd_on; | ||
122 | } | ||
123 | |||
124 | void lcd_enable(bool enable) | ||
125 | { | ||
126 | if(lcd_on == enable) | ||
127 | return; | ||
128 | |||
129 | lcd_on = enable; | ||
130 | } | ||
131 | #endif | ||
132 | |||
133 | void lcd_update(void) | ||
134 | { | ||
135 | lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT); | ||
136 | } | ||
137 | |||
138 | void lcd_update_rect(int x, int y, int w, int h) | ||
139 | { | ||
140 | #ifdef HAVE_LCD_ENABLE | ||
141 | if(!lcd_on) | ||
142 | return; | ||
143 | #endif | ||
144 | |||
145 | imx233_lcdif_wait_ready(); | ||
146 | lcd_write_reg(0x16, x | (x + w - 1) << 8); | ||
147 | lcd_write_reg(0x17, y | (y + h - 1) << 8); | ||
148 | lcd_write_reg(0x21, y * LCD_WIDTH + x); | ||
149 | lcd_write_reg(0x22, 0); | ||
150 | for(int yy = y; yy < y + h; yy++) | ||
151 | imx233_lcdif_pio_send(true, 2 * w, FBADDR(x, yy)); | ||
152 | } | ||
diff --git a/firmware/target/arm/imx233/creative-zenmozaic/power-zenmozaic.c b/firmware/target/arm/imx233/creative-zenmozaic/power-zenmozaic.c new file mode 100644 index 0000000000..1bed2ffcca --- /dev/null +++ b/firmware/target/arm/imx233/creative-zenmozaic/power-zenmozaic.c | |||
@@ -0,0 +1,57 @@ | |||
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 | |||
29 | static bool tuner_enable = false; | ||
30 | static bool initialised = false; | ||
31 | |||
32 | static void init(void) | ||
33 | { | ||
34 | /* CE is B2P15 (active high) */ | ||
35 | imx233_pinctrl_acquire(2, 15, "tuner power"); | ||
36 | imx233_pinctrl_set_function(2, 15, PINCTRL_FUNCTION_GPIO); | ||
37 | imx233_pinctrl_enable_gpio(2, 15, true); | ||
38 | initialised = true; | ||
39 | } | ||
40 | |||
41 | bool tuner_power(bool enable) | ||
42 | { | ||
43 | if(!initialised) | ||
44 | init(); | ||
45 | if(tuner_enable != enable) | ||
46 | { | ||
47 | imx233_pinctrl_set_gpio(2, 15, enable); | ||
48 | sleep(HZ / 5); | ||
49 | tuner_enable = enable; | ||
50 | } | ||
51 | return tuner_enable; | ||
52 | } | ||
53 | |||
54 | bool tuner_powered(void) | ||
55 | { | ||
56 | return tuner_enable; | ||
57 | } \ No newline at end of file | ||
diff --git a/firmware/target/arm/imx233/creative-zenmozaic/powermgmt-target.h b/firmware/target/arm/imx233/creative-zenmozaic/powermgmt-target.h new file mode 100644 index 0000000000..57a6b82ec9 --- /dev/null +++ b/firmware/target/arm/imx233/creative-zenmozaic/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 Mozaic 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-zenmozaic/powermgmt-zenmozaic.c b/firmware/target/arm/imx233/creative-zenmozaic/powermgmt-zenmozaic.c new file mode 100644 index 0000000000..1e986813f9 --- /dev/null +++ b/firmware/target/arm/imx233/creative-zenmozaic/powermgmt-zenmozaic.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 | |||
27 | const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] = | ||
28 | { | ||
29 | 0 | ||
30 | }; | ||
31 | |||
32 | const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] = | ||
33 | { | ||
34 | 0 | ||
35 | }; | ||
36 | |||
37 | /* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */ | ||
38 | const 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 */ | ||
45 | const 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 | ||