diff options
Diffstat (limited to 'firmware')
26 files changed, 752 insertions, 50 deletions
diff --git a/firmware/SOURCES b/firmware/SOURCES index 610cc42112..21917de72d 100644 --- a/firmware/SOURCES +++ b/firmware/SOURCES | |||
@@ -269,6 +269,8 @@ drivers/rtc/rtc_s35390a.c | |||
269 | drivers/rtc/rtc_s35380a.c | 269 | drivers/rtc/rtc_s35380a.c |
270 | #elif (CONFIG_RTC == RTC_D2) | 270 | #elif (CONFIG_RTC == RTC_D2) |
271 | drivers/rtc/rtc_d2.c | 271 | drivers/rtc/rtc_d2.c |
272 | #elif (CONFIG_RTC == RTC_IMX233) | ||
273 | drivers/rtc/rtc_imx233.c | ||
272 | #endif /* (CONFIG_RTC == RTC_) */ | 274 | #endif /* (CONFIG_RTC == RTC_) */ |
273 | #endif /* PLATFORM_NATIVE */ | 275 | #endif /* PLATFORM_NATIVE */ |
274 | 276 | ||
@@ -490,6 +492,7 @@ target/arm/pnx0101/timer-pnx0101.c | |||
490 | #endif | 492 | #endif |
491 | 493 | ||
492 | #if CONFIG_CPU == IMX233 | 494 | #if CONFIG_CPU == IMX233 |
495 | target/arm/mmu-arm.S | ||
493 | target/arm/imx233/lcdif-imx233.c | 496 | target/arm/imx233/lcdif-imx233.c |
494 | target/arm/imx233/clkctrl-imx233.c | 497 | target/arm/imx233/clkctrl-imx233.c |
495 | target/arm/imx233/system-imx233.c | 498 | target/arm/imx233/system-imx233.c |
@@ -499,9 +502,15 @@ target/arm/imx233/kernel-imx233.c | |||
499 | target/arm/imx233/sd-imx233.c | 502 | target/arm/imx233/sd-imx233.c |
500 | target/arm/imx233/mmc-imx233.c | 503 | target/arm/imx233/mmc-imx233.c |
501 | target/arm/imx233/ssp-imx233.c | 504 | target/arm/imx233/ssp-imx233.c |
502 | target/arm/imx233/usb-imx233.c | ||
503 | target/arm/imx233/dma-imx233.c | 505 | target/arm/imx233/dma-imx233.c |
504 | target/arm/imx233/pinctrl-imx233.c | 506 | target/arm/imx233/pinctrl-imx233.c |
507 | target/arm/imx233/power-imx233.c | ||
508 | target/arm/imx233/powermgmt-imx233.c | ||
509 | target/arm/imx233/adc-imx233.c | ||
510 | target/arm/imx233/debug-imx233.c | ||
511 | #if !defined(BOOTLOADER) || defined(HAVE_BOOTLOADER_USB_MODE) | ||
512 | target/arm/imx233/usb-imx233.c | ||
513 | #endif | ||
505 | #endif /* IMX233 */ | 514 | #endif /* IMX233 */ |
506 | 515 | ||
507 | #if CONFIG_CPU == AS3525 || CONFIG_CPU == AS3525v2 | 516 | #if CONFIG_CPU == AS3525 || CONFIG_CPU == AS3525v2 |
@@ -1456,10 +1465,13 @@ target/arm/as3525/lcd-as-e200v2-fuze-fuzev2.S | |||
1456 | #ifndef SIMULATOR | 1465 | #ifndef SIMULATOR |
1457 | drivers/synaptics-rmi.c | 1466 | drivers/synaptics-rmi.c |
1458 | drivers/generic_i2c.c | 1467 | drivers/generic_i2c.c |
1468 | target/arm/lcd-as-memframe.S | ||
1459 | target/arm/imx233/sansa-fuzeplus/fmradio-i2c-fuzeplus.c | 1469 | target/arm/imx233/sansa-fuzeplus/fmradio-i2c-fuzeplus.c |
1460 | target/arm/imx233/sansa-fuzeplus/backlight-fuzeplus.c | 1470 | target/arm/imx233/sansa-fuzeplus/backlight-fuzeplus.c |
1461 | target/arm/imx233/sansa-fuzeplus/lcd-fuzeplus.c | 1471 | target/arm/imx233/sansa-fuzeplus/lcd-fuzeplus.c |
1462 | target/arm/imx233/sansa-fuzeplus/button-fuzeplus.c | 1472 | target/arm/imx233/sansa-fuzeplus/button-fuzeplus.c |
1473 | target/arm/imx233/sansa-fuzeplus/debug-fuzeplus.c | ||
1474 | target/arm/imx233/sansa-fuzeplus/power-fuzeplus.c | ||
1463 | #endif /* SIMULATOR */ | 1475 | #endif /* SIMULATOR */ |
1464 | #endif | 1476 | #endif |
1465 | 1477 | ||
diff --git a/firmware/drivers/fat.c b/firmware/drivers/fat.c index a4eb24ce7f..f76b10c078 100644 --- a/firmware/drivers/fat.c +++ b/firmware/drivers/fat.c | |||
@@ -218,7 +218,7 @@ static struct mutex tempbuf_mutex; | |||
218 | static char fat_tempbuf[SECTOR_SIZE] CACHEALIGN_ATTR; | 218 | static char fat_tempbuf[SECTOR_SIZE] CACHEALIGN_ATTR; |
219 | static bool tempbuf_locked; | 219 | static bool tempbuf_locked; |
220 | 220 | ||
221 | #if defined(HAVE_HOTSWAP) && !(CONFIG_STORAGE & STORAGE_MMC) /* A better condition ?? */ | 221 | #if defined(HAVE_HOTSWAP) |
222 | void fat_lock(void) | 222 | void fat_lock(void) |
223 | { | 223 | { |
224 | mutex_lock(&cache_mutex); | 224 | mutex_lock(&cache_mutex); |
diff --git a/firmware/drivers/rtc/rtc_imx233.c b/firmware/drivers/rtc/rtc_imx233.c new file mode 100644 index 0000000000..4368610875 --- /dev/null +++ b/firmware/drivers/rtc/rtc_imx233.c | |||
@@ -0,0 +1,68 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2011 by Amaury Pouly | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include "system.h" | ||
23 | #include "rtc.h" | ||
24 | #include "timefuncs.h" | ||
25 | |||
26 | void rtc_init(void) | ||
27 | { | ||
28 | } | ||
29 | |||
30 | int rtc_read_datetime(struct tm *tm) | ||
31 | { | ||
32 | (void) tm; | ||
33 | return -1; | ||
34 | } | ||
35 | |||
36 | int rtc_write_datetime(const struct tm *tm) | ||
37 | { | ||
38 | (void) tm; | ||
39 | return -1; | ||
40 | } | ||
41 | |||
42 | void rtc_set_alarm(int h, int m) | ||
43 | { | ||
44 | (void) h; | ||
45 | (void) m; | ||
46 | } | ||
47 | |||
48 | void rtc_get_alarm(int *h, int *m) | ||
49 | { | ||
50 | (void) h; | ||
51 | (void) m; | ||
52 | } | ||
53 | |||
54 | void rtc_enable_alarm(bool enable) | ||
55 | { | ||
56 | (void) enable; | ||
57 | } | ||
58 | |||
59 | bool rtc_check_alarm_started(bool release_alarm) | ||
60 | { | ||
61 | (void) release_alarm; | ||
62 | return false; | ||
63 | } | ||
64 | |||
65 | bool rtc_check_alarm_flag(void) | ||
66 | { | ||
67 | return false; | ||
68 | } | ||
diff --git a/firmware/export/audiohw.h b/firmware/export/audiohw.h index 651c9cd254..593924d370 100644 --- a/firmware/export/audiohw.h +++ b/firmware/export/audiohw.h | |||
@@ -70,6 +70,8 @@ | |||
70 | #include "ak4537.h" | 70 | #include "ak4537.h" |
71 | #elif defined(HAVE_CS42L55) | 71 | #elif defined(HAVE_CS42L55) |
72 | #include "cs42l55.h" | 72 | #include "cs42l55.h" |
73 | #elif defined(HAVE_IMX233_CODEC) | ||
74 | #include "imx233-codec.h" | ||
73 | #endif | 75 | #endif |
74 | #if (CONFIG_PLATFORM & PLATFORM_HOSTED) | 76 | #if (CONFIG_PLATFORM & PLATFORM_HOSTED) |
75 | /* #include <SDL_audio.h> gives errors in other code areas, | 77 | /* #include <SDL_audio.h> gives errors in other code areas, |
diff --git a/firmware/export/config.h b/firmware/export/config.h index 37acec04e1..036354180c 100644 --- a/firmware/export/config.h +++ b/firmware/export/config.h | |||
@@ -869,7 +869,7 @@ Lyre prototype 1 */ | |||
869 | #endif | 869 | #endif |
870 | 870 | ||
871 | #if (defined(CPU_PP) || (CONFIG_CPU == AS3525) || (CONFIG_CPU == AS3525v2) || \ | 871 | #if (defined(CPU_PP) || (CONFIG_CPU == AS3525) || (CONFIG_CPU == AS3525v2) || \ |
872 | (CONFIG_CPU == IMX31L)) \ | 872 | (CONFIG_CPU == IMX31L) || (CONFIG_CPU == IMX233)) \ |
873 | && (CONFIG_PLATFORM & PLATFORM_NATIVE) && !defined(BOOTLOADER) | 873 | && (CONFIG_PLATFORM & PLATFORM_NATIVE) && !defined(BOOTLOADER) |
874 | /* Functions that have INIT_ATTR attached are NOT guaranteed to survive after | 874 | /* Functions that have INIT_ATTR attached are NOT guaranteed to survive after |
875 | * root_menu() has been called. Their code may be overwritten by other data or | 875 | * root_menu() has been called. Their code may be overwritten by other data or |
diff --git a/firmware/export/config/sansafuzeplus.h b/firmware/export/config/sansafuzeplus.h index 4c3cd6014b..971ff019b6 100644 --- a/firmware/export/config/sansafuzeplus.h +++ b/firmware/export/config/sansafuzeplus.h | |||
@@ -28,7 +28,7 @@ | |||
28 | /* define this if you have a colour LCD */ | 28 | /* define this if you have a colour LCD */ |
29 | #define HAVE_LCD_COLOR | 29 | #define HAVE_LCD_COLOR |
30 | 30 | ||
31 | #ifndef BOOTLOADER/* define this if you want album art for this target */ | 31 | #ifndef BOOTLOADER |
32 | #define HAVE_ALBUMART | 32 | #define HAVE_ALBUMART |
33 | 33 | ||
34 | /* define this to enable bitmap scaling */ | 34 | /* define this to enable bitmap scaling */ |
@@ -37,9 +37,6 @@ | |||
37 | /* define this to enable JPEG decoding */ | 37 | /* define this to enable JPEG decoding */ |
38 | #define HAVE_JPEG | 38 | #define HAVE_JPEG |
39 | 39 | ||
40 | /* define this if you have a light associated with the buttons */ | ||
41 | #define HAVE_BUTTON_LIGHT | ||
42 | |||
43 | /* define this if you have access to the quickscreen */ | 40 | /* define this if you have access to the quickscreen */ |
44 | #define HAVE_QUICKSCREEN | 41 | #define HAVE_QUICKSCREEN |
45 | 42 | ||
@@ -69,13 +66,19 @@ | |||
69 | /* define this if you have a real-time clock */ | 66 | /* define this if you have a real-time clock */ |
70 | #define CONFIG_RTC RTC_IMX233 | 67 | #define CONFIG_RTC RTC_IMX233 |
71 | 68 | ||
69 | /* define this if you have a real-time clock with alarm facilities */ | ||
70 | #define HAVE_RTC_ALARM | ||
71 | |||
72 | #endif /* !BOOTLOADER */ | ||
73 | |||
74 | /* define this if you have an i.MX23 codec */ | ||
75 | #define HAVE_IMX233_CODEC | ||
76 | |||
72 | #define CONFIG_TUNER SI4700 | 77 | #define CONFIG_TUNER SI4700 |
73 | 78 | ||
74 | /* There is no hardware tone control */ | 79 | /* There is no hardware tone control */ |
75 | #define HAVE_SW_TONE_CONTROLS | 80 | #define HAVE_SW_TONE_CONTROLS |
76 | 81 | ||
77 | #endif /* !BOOTLOADER */ | ||
78 | |||
79 | #define CONFIG_KEYPAD SANSA_FUZEPLUS_PAD | 82 | #define CONFIG_KEYPAD SANSA_FUZEPLUS_PAD |
80 | 83 | ||
81 | /* Define this to enable morse code input */ | 84 | /* Define this to enable morse code input */ |
@@ -84,7 +87,6 @@ | |||
84 | /* Define this if you do software codec */ | 87 | /* Define this if you do software codec */ |
85 | #define CONFIG_CODEC SWCODEC | 88 | #define CONFIG_CODEC SWCODEC |
86 | 89 | ||
87 | |||
88 | /* LCD dimensions */ | 90 | /* LCD dimensions */ |
89 | #define LCD_WIDTH 240 | 91 | #define LCD_WIDTH 240 |
90 | #define LCD_HEIGHT 320 | 92 | #define LCD_HEIGHT 320 |
diff --git a/firmware/export/imx233-codec.h b/firmware/export/imx233-codec.h new file mode 100644 index 0000000000..99d49f6adb --- /dev/null +++ b/firmware/export/imx233-codec.h | |||
@@ -0,0 +1,29 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2011 by Amaury Pouly | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #ifndef __IMX233_CODEC_H_ | ||
22 | #define __IMX233_CODEC_H_ | ||
23 | |||
24 | #define VOLUME_MIN -1000 | ||
25 | #define VOLUME_MAX -5 | ||
26 | |||
27 | void audiohw_set_volume(int v); | ||
28 | |||
29 | #endif /* __IMX233_CODEC_H_ */ | ||
diff --git a/firmware/target/arm/imx233/adc-imx233.c b/firmware/target/arm/imx233/adc-imx233.c new file mode 100644 index 0000000000..8236f58767 --- /dev/null +++ b/firmware/target/arm/imx233/adc-imx233.c | |||
@@ -0,0 +1,34 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2011 by Amaury Pouly | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include "config.h" | ||
23 | #include "adc.h" | ||
24 | #include "adc-target.h" | ||
25 | |||
26 | void adc_init(void) | ||
27 | { | ||
28 | } | ||
29 | |||
30 | unsigned short adc_read(int channel) | ||
31 | { | ||
32 | (void) channel; | ||
33 | return 0; | ||
34 | } | ||
diff --git a/firmware/target/arm/imx233/sansa-fuzeplus/adc-target.h b/firmware/target/arm/imx233/adc-target.h index e6b5152f5b..e6b5152f5b 100644 --- a/firmware/target/arm/imx233/sansa-fuzeplus/adc-target.h +++ b/firmware/target/arm/imx233/adc-target.h | |||
diff --git a/firmware/target/arm/imx233/app.lds b/firmware/target/arm/imx233/app.lds new file mode 100644 index 0000000000..66d0b04391 --- /dev/null +++ b/firmware/target/arm/imx233/app.lds | |||
@@ -0,0 +1,119 @@ | |||
1 | #include "config.h" | ||
2 | #include "cpu.h" | ||
3 | |||
4 | ENTRY(start) | ||
5 | OUTPUT_FORMAT(elf32-littlearm) | ||
6 | OUTPUT_ARCH(arm) | ||
7 | STARTUP(target/arm/imx233/crt0.o) | ||
8 | |||
9 | #define PLUGINSIZE PLUGIN_BUFFER_SIZE | ||
10 | #define CODECSIZE CODEC_SIZE | ||
11 | |||
12 | #define DRAMORIG DRAM_ORIG | ||
13 | #define IRAMORIG IRAM_ORIG | ||
14 | |||
15 | #define IRAMSIZE (IRAM_SIZE - TTB_SIZE) | ||
16 | |||
17 | #define DRAMSIZE (DRAM_SIZE - PLUGINSIZE - CODECSIZE - FRAME_SIZE) | ||
18 | |||
19 | /* End of the audio buffer, where the codec buffer starts */ | ||
20 | #define ENDAUDIOADDR (DRAMORIG + DRAMSIZE) | ||
21 | |||
22 | /* Where the codec buffer ends, and the plugin buffer starts */ | ||
23 | #define ENDADDR (ENDAUDIOADDR + CODEC_SIZE) | ||
24 | |||
25 | /* INIT section is the codec buffer */ | ||
26 | #define INITSIZE CODEC_SIZE | ||
27 | #define INITSTART ENDAUDIOADDR | ||
28 | |||
29 | MEMORY | ||
30 | { | ||
31 | IRAM : ORIGIN = IRAMORIG, LENGTH = IRAMSIZE | ||
32 | DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE | ||
33 | } | ||
34 | |||
35 | SECTIONS | ||
36 | { | ||
37 | .text : | ||
38 | { | ||
39 | loadaddress = .; | ||
40 | _loadaddress = .; | ||
41 | *(.text*) | ||
42 | } > DRAM | ||
43 | |||
44 | .data : | ||
45 | { | ||
46 | *(.data*) | ||
47 | *(.rodata*) | ||
48 | _dataend = . ; | ||
49 | } > DRAM | ||
50 | |||
51 | .iram : | ||
52 | { | ||
53 | _iramstart = .; // always 0 | ||
54 | *(.vectors) | ||
55 | KEEP(*(.vectors));// otherwise there are no references to it and the linker strip it | ||
56 | *(.icode) | ||
57 | *(.irodata) | ||
58 | *(.idata) | ||
59 | . = ALIGN(0x4); | ||
60 | _iramend = .; | ||
61 | } > IRAM AT> DRAM | ||
62 | |||
63 | _iramcopy = LOADADDR(.iram); | ||
64 | |||
65 | .ibss (NOLOAD) : | ||
66 | { | ||
67 | _iedata = .; | ||
68 | *(.qharray) | ||
69 | *(.ibss) | ||
70 | . = ALIGN(0x4); | ||
71 | _iend = .; | ||
72 | } > IRAM | ||
73 | |||
74 | .init ENDAUDIOADDR : | ||
75 | { | ||
76 | . = ALIGN(4); | ||
77 | _initstart = .; | ||
78 | *(.init) | ||
79 | _initend = .; | ||
80 | } AT> DRAM | ||
81 | |||
82 | _initcopy = LOADADDR(.init); | ||
83 | |||
84 | .stack (NOLOAD) : | ||
85 | { | ||
86 | *(.stack) | ||
87 | stackbegin = .; | ||
88 | . += 0x2000; | ||
89 | stackend = .; | ||
90 | } > DRAM | ||
91 | |||
92 | .bss (NOLOAD) : | ||
93 | { | ||
94 | _edata = .; | ||
95 | *(.bss*); | ||
96 | _end = .; | ||
97 | } > DRAM | ||
98 | |||
99 | .audiobuf (NOLOAD) : | ||
100 | { | ||
101 | . = ALIGN(4); | ||
102 | _audiobuffer = .; | ||
103 | audiobuffer = .; | ||
104 | } > DRAM | ||
105 | |||
106 | .codec ENDAUDIOADDR (NOLOAD) : | ||
107 | { | ||
108 | audiobufend = .; | ||
109 | _audiobufend = .; | ||
110 | codecbuf = .; | ||
111 | _codecbuf = .; | ||
112 | } > DRAM | ||
113 | |||
114 | .plugin ENDADDR (NOLOAD) : | ||
115 | { | ||
116 | _pluginbuf = .; | ||
117 | pluginbuf = .; | ||
118 | } | ||
119 | } | ||
diff --git a/firmware/target/arm/imx233/crt0.S b/firmware/target/arm/imx233/crt0.S index b8b63e5f26..a0f9ec270b 100644 --- a/firmware/target/arm/imx233/crt0.S +++ b/firmware/target/arm/imx233/crt0.S | |||
@@ -39,6 +39,13 @@ start: | |||
39 | /* Save r0 */ | 39 | /* Save r0 */ |
40 | mov r6, r0 | 40 | mov r6, r0 |
41 | msr cpsr_c, #0xd3 /* enter supervisor mode, disable IRQ/FIQ */ | 41 | msr cpsr_c, #0xd3 /* enter supervisor mode, disable IRQ/FIQ */ |
42 | /* Disable MMU, disable caching and buffering; | ||
43 | * use low exception range address (the core uses high range by default) */ | ||
44 | mrc p15, 0, r0, c1, c0, 0 | ||
45 | ldr r1, =0x3005 | ||
46 | bic r0, r1 | ||
47 | mcr p15, 0, r0, c1, c0, 0 | ||
48 | |||
42 | /* Zero out IBSS */ | 49 | /* Zero out IBSS */ |
43 | ldr r2, =_iedata | 50 | ldr r2, =_iedata |
44 | ldr r3, =_iend | 51 | ldr r3, =_iend |
@@ -59,6 +66,22 @@ start: | |||
59 | strhi r5, [r3], #4 | 66 | strhi r5, [r3], #4 |
60 | bhi 1b | 67 | bhi 1b |
61 | 68 | ||
69 | #ifdef HAVE_INIT_ATTR | ||
70 | /* copy init data to codec buffer */ | ||
71 | /* must be done before bss is zeroed */ | ||
72 | ldr r2, =_initcopy | ||
73 | ldr r3, =_initstart | ||
74 | ldr r4, =_initend | ||
75 | 1: | ||
76 | cmp r4, r3 | ||
77 | ldrhi r5, [r2], #4 | ||
78 | strhi r5, [r3], #4 | ||
79 | bhi 1b | ||
80 | |||
81 | mov r2, #0 | ||
82 | mcr p15, 0, r2, c7, c5, 0 @ Invalidate ICache | ||
83 | #endif | ||
84 | |||
62 | /* Initialise bss section to zero */ | 85 | /* Initialise bss section to zero */ |
63 | ldr r2, =_edata | 86 | ldr r2, =_edata |
64 | ldr r3, =_end | 87 | ldr r3, =_end |
@@ -68,7 +91,6 @@ start: | |||
68 | strhi r4, [r2], #4 | 91 | strhi r4, [r2], #4 |
69 | bhi 1b | 92 | bhi 1b |
70 | 93 | ||
71 | |||
72 | /* Set up some stack and munge it with 0xdeadbeef */ | 94 | /* Set up some stack and munge it with 0xdeadbeef */ |
73 | ldr sp, =stackend | 95 | ldr sp, =stackend |
74 | ldr r2, =stackbegin | 96 | ldr r2, =stackbegin |
@@ -92,16 +114,12 @@ start: | |||
92 | msr cpsr_c, #0xdb | 114 | msr cpsr_c, #0xdb |
93 | ldr sp, =irq_stack | 115 | ldr sp, =irq_stack |
94 | 116 | ||
117 | /* Enable MMU */ | ||
118 | bl memory_init | ||
119 | |||
95 | /* Switch back to supervisor mode */ | 120 | /* Switch back to supervisor mode */ |
96 | msr cpsr_c, #0xd3 | 121 | msr cpsr_c, #0xd3 |
97 | 122 | ||
98 | /* Disable MMU, disable caching and buffering; | ||
99 | * use low exception range address (the core uses high range by default) */ | ||
100 | mrc p15, 0, r0, c1, c0, 0 | ||
101 | ldr r1, =0x3005 | ||
102 | bic r0, r1 | ||
103 | mcr p15, 0, r0, c1, c0, 0 | ||
104 | |||
105 | /* Jump to main */ | 123 | /* Jump to main */ |
106 | mov r0, r6 | 124 | mov r0, r6 |
107 | bl main | 125 | bl main |
diff --git a/firmware/target/arm/imx233/debug-imx233.c b/firmware/target/arm/imx233/debug-imx233.c new file mode 100644 index 0000000000..4cfddb3de8 --- /dev/null +++ b/firmware/target/arm/imx233/debug-imx233.c | |||
@@ -0,0 +1,33 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2011 by Amaury Pouly | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include "system.h" | ||
23 | #include "debug-target.h" | ||
24 | |||
25 | bool dbg_hw_info(void) | ||
26 | { | ||
27 | return false; | ||
28 | } | ||
29 | |||
30 | bool dbg_ports(void) | ||
31 | { | ||
32 | return false; | ||
33 | } | ||
diff --git a/firmware/target/arm/imx233/debug-target.h b/firmware/target/arm/imx233/debug-target.h new file mode 100644 index 0000000000..402514ae83 --- /dev/null +++ b/firmware/target/arm/imx233/debug-target.h | |||
@@ -0,0 +1,30 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2011 by Amaury Pouly | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #ifndef DEBUG_TARGET_H | ||
22 | #define DEBUG_TARGET_H | ||
23 | |||
24 | #define DEBUG_CANCEL BUTTON_BACK | ||
25 | |||
26 | bool dbg_hw_target_info(void); | ||
27 | bool dbg_hw_info(void); | ||
28 | bool dbg_ports(void); | ||
29 | |||
30 | #endif /* DEBUG_TARGET_H */ | ||
diff --git a/firmware/target/arm/imx233/dma-imx233.c b/firmware/target/arm/imx233/dma-imx233.c index d75c334aeb..8a42bd12da 100644 --- a/firmware/target/arm/imx233/dma-imx233.c +++ b/firmware/target/arm/imx233/dma-imx233.c | |||
@@ -106,8 +106,54 @@ bool imx233_dma_is_channel_error_irq(unsigned chan) | |||
106 | HW_APBH_CTRL2__CHx_ERROR_IRQ(APB_GET_DMA_CHANNEL(chan))); | 106 | HW_APBH_CTRL2__CHx_ERROR_IRQ(APB_GET_DMA_CHANNEL(chan))); |
107 | } | 107 | } |
108 | 108 | ||
109 | /* Commit and/or discard all DMA descriptors and buffers pointed by them, | ||
110 | * handle circular lists */ | ||
111 | static void imx233_dma_commit_and_discard(struct apb_dma_command_t *cmd) | ||
112 | { | ||
113 | /* We handle circular descriptors by using unused bits: | ||
114 | * bits 8-11 are not used by the hardware so we first go through the whole | ||
115 | * list and mark them all a special value at the same time we commit buffers | ||
116 | * and then we go through the list another time to clear the mark and | ||
117 | * commit the descriptors */ | ||
118 | struct apb_dma_command_t *cur = cmd; | ||
119 | |||
120 | while((cur->cmd & HW_APB_CHx_CMD__UNUSED_BM) != HW_APB_CHx_CMD__UNUSED_MAGIC) | ||
121 | { | ||
122 | cur->cmd = (cur->cmd & ~HW_APB_CHx_CMD__UNUSED_BM) | HW_APB_CHx_CMD__UNUSED_MAGIC; | ||
123 | int op = cur->cmd & HW_APB_CHx_CMD__COMMAND_BM; | ||
124 | int sz = (cur->cmd & HW_APB_CHx_CMD__XFER_COUNT_BM) >> HW_APB_CHx_CMD__XFER_COUNT_BP; | ||
125 | /* device > host: discard */ | ||
126 | if(op == HW_APB_CHx_CMD__COMMAND__WRITE) | ||
127 | discard_dcache_range(cur->buffer, sz); | ||
128 | /* host > device: commit and discard */ | ||
129 | else if(op == HW_APB_CHx_CMD__COMMAND__READ) | ||
130 | commit_discard_dcache_range(cur->buffer, sz); | ||
131 | /* chain ? */ | ||
132 | if(cur->cmd & HW_APB_CHx_CMD__CHAIN) | ||
133 | cur = cur->next; | ||
134 | else | ||
135 | break; | ||
136 | } | ||
137 | |||
138 | cur = cmd; | ||
139 | while((cur->cmd & HW_APB_CHx_CMD__UNUSED_BM) != 0) | ||
140 | { | ||
141 | cur->cmd = cur->cmd & ~HW_APB_CHx_CMD__UNUSED_BM; | ||
142 | int sz = (cur->cmd & HW_APB_CHx_CMD__CMDWORDS_BM) >> HW_APB_CHx_CMD__CMDWORDS_BP; | ||
143 | /* commit descriptor (don't discard since we access it after) */ | ||
144 | commit_dcache_range(cur, | ||
145 | sizeof(struct apb_dma_command_t) + sizeof(uint32_t) * sz); | ||
146 | /* chain ? */ | ||
147 | if(cur->cmd & HW_APB_CHx_CMD__CHAIN) | ||
148 | cur = cur->next; | ||
149 | else | ||
150 | break; | ||
151 | } | ||
152 | } | ||
153 | |||
109 | void imx233_dma_start_command(unsigned chan, struct apb_dma_command_t *cmd) | 154 | void imx233_dma_start_command(unsigned chan, struct apb_dma_command_t *cmd) |
110 | { | 155 | { |
156 | imx233_dma_commit_and_discard(cmd); | ||
111 | if(APB_IS_APBX_CHANNEL(chan)) | 157 | if(APB_IS_APBX_CHANNEL(chan)) |
112 | { | 158 | { |
113 | HW_APBX_CHx_NXTCMDAR(APB_GET_DMA_CHANNEL(chan)) = (uint32_t)cmd; | 159 | HW_APBX_CHx_NXTCMDAR(APB_GET_DMA_CHANNEL(chan)) = (uint32_t)cmd; |
@@ -129,5 +175,5 @@ void imx233_dma_wait_completion(unsigned chan) | |||
129 | sema = &HW_APBH_CHx_SEMA(APB_GET_DMA_CHANNEL(chan)); | 175 | sema = &HW_APBH_CHx_SEMA(APB_GET_DMA_CHANNEL(chan)); |
130 | 176 | ||
131 | while(*sema & HW_APB_CHx_SEMA__PHORE_BM) | 177 | while(*sema & HW_APB_CHx_SEMA__PHORE_BM) |
132 | ; | 178 | yield(); |
133 | } | 179 | } |
diff --git a/firmware/target/arm/imx233/dma-imx233.h b/firmware/target/arm/imx233/dma-imx233.h index fcf1a2c5c2..bb88a746d0 100644 --- a/firmware/target/arm/imx233/dma-imx233.h +++ b/firmware/target/arm/imx233/dma-imx233.h | |||
@@ -138,11 +138,16 @@ struct apb_dma_command_t | |||
138 | #define HW_APBH_CHx_CMD__NANDWAIT4READY (1 << 5) | 138 | #define HW_APBH_CHx_CMD__NANDWAIT4READY (1 << 5) |
139 | #define HW_APB_CHx_CMD__SEMAPHORE (1 << 6) | 139 | #define HW_APB_CHx_CMD__SEMAPHORE (1 << 6) |
140 | #define HW_APB_CHx_CMD__WAIT4ENDCMD (1 << 7) | 140 | #define HW_APB_CHx_CMD__WAIT4ENDCMD (1 << 7) |
141 | #define HW_APB_CHx_CMD__HALTONTERMINATE (1 << 8) | 141 | /* An errata advise not to use it */ |
142 | #define HW_APB_CHx_CMD__CMDWORDS_BM 0xf000 | 142 | //#define HW_APB_CHx_CMD__HALTONTERMINATE (1 << 8) |
143 | #define HW_APB_CHx_CMD__CMDWORDS_BP 12 | 143 | #define HW_APB_CHx_CMD__CMDWORDS_BM 0xf000 |
144 | #define HW_APB_CHx_CMD__XFER_COUNT_BM 0xffff0000 | 144 | #define HW_APB_CHx_CMD__CMDWORDS_BP 12 |
145 | #define HW_APB_CHx_CMD__XFER_COUNT_BP 16 | 145 | #define HW_APB_CHx_CMD__XFER_COUNT_BM 0xffff0000 |
146 | #define HW_APB_CHx_CMD__XFER_COUNT_BP 16 | ||
147 | /* For software use */ | ||
148 | #define HW_APB_CHx_CMD__UNUSED_BP 8 | ||
149 | #define HW_APB_CHx_CMD__UNUSED_BM (0xf << 8) | ||
150 | #define HW_APB_CHx_CMD__UNUSED_MAGIC (0xa << 8) | ||
146 | 151 | ||
147 | #define HW_APB_CHx_SEMA__PHORE_BM 0xff0000 | 152 | #define HW_APB_CHx_SEMA__PHORE_BM 0xff0000 |
148 | #define HW_APB_CHx_SEMA__PHORE_BP 16 | 153 | #define HW_APB_CHx_SEMA__PHORE_BP 16 |
diff --git a/firmware/target/arm/imx233/i2c-imx233.c b/firmware/target/arm/imx233/i2c-imx233.c index 9d29605bce..6fa3182066 100644 --- a/firmware/target/arm/imx233/i2c-imx233.c +++ b/firmware/target/arm/imx233/i2c-imx233.c | |||
@@ -53,7 +53,7 @@ void INT_I2C_DMA(void) | |||
53 | semaphore_release(&i2c_sema); | 53 | semaphore_release(&i2c_sema); |
54 | } | 54 | } |
55 | 55 | ||
56 | void imx233_i2c_init(void) | 56 | void i2c_init(void) |
57 | { | 57 | { |
58 | __REG_SET(HW_I2C_CTRL0) = __BLOCK_SFTRST | __BLOCK_CLKGATE; | 58 | __REG_SET(HW_I2C_CTRL0) = __BLOCK_SFTRST | __BLOCK_CLKGATE; |
59 | /* setup pins (must be done when shutdown) */ | 59 | /* setup pins (must be done when shutdown) */ |
diff --git a/firmware/target/arm/imx233/i2c-imx233.h b/firmware/target/arm/imx233/i2c-imx233.h index 5ee22efd2a..de90e168f2 100644 --- a/firmware/target/arm/imx233/i2c-imx233.h +++ b/firmware/target/arm/imx233/i2c-imx233.h | |||
@@ -126,7 +126,7 @@ enum imx233_i2c_error_t | |||
126 | I2C_SLAVE_NAK = -5 | 126 | I2C_SLAVE_NAK = -5 |
127 | }; | 127 | }; |
128 | 128 | ||
129 | void imx233_i2c_init(void); | 129 | void i2c_init(void); |
130 | /* start building a transfer, will acquire an exclusive lock */ | 130 | /* start building a transfer, will acquire an exclusive lock */ |
131 | void imx233_i2c_begin(void); | 131 | void imx233_i2c_begin(void); |
132 | /* add stage */ | 132 | /* add stage */ |
diff --git a/firmware/target/arm/imx233/power-imx233.c b/firmware/target/arm/imx233/power-imx233.c new file mode 100644 index 0000000000..f01a4ad3f2 --- /dev/null +++ b/firmware/target/arm/imx233/power-imx233.c | |||
@@ -0,0 +1,46 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2011 by Amaury Pouly | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include "config.h" | ||
23 | #include "system.h" | ||
24 | #include "power.h" | ||
25 | #include "system-target.h" | ||
26 | |||
27 | void power_init(void) | ||
28 | { | ||
29 | } | ||
30 | |||
31 | void power_off(void) | ||
32 | { | ||
33 | /* power down */ | ||
34 | HW_POWER_RESET = HW_POWER_RESET__UNLOCK | HW_POWER_RESET__PWD; | ||
35 | while(1); | ||
36 | } | ||
37 | |||
38 | unsigned int power_input_status(void) | ||
39 | { | ||
40 | return POWER_INPUT_NONE; | ||
41 | } | ||
42 | |||
43 | bool charging_state(void) | ||
44 | { | ||
45 | return false; | ||
46 | } | ||
diff --git a/firmware/target/arm/imx233/powermgmt-imx233.c b/firmware/target/arm/imx233/powermgmt-imx233.c new file mode 100644 index 0000000000..f11618b50c --- /dev/null +++ b/firmware/target/arm/imx233/powermgmt-imx233.c | |||
@@ -0,0 +1,34 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2011 by Amaury Pouly | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include "powermgmt.h" | ||
23 | |||
24 | void powermgmt_init_target(void) | ||
25 | { | ||
26 | } | ||
27 | |||
28 | void charging_algorithm_step(void) | ||
29 | { | ||
30 | } | ||
31 | |||
32 | void charging_algorithm_close(void) | ||
33 | { | ||
34 | } | ||
diff --git a/firmware/target/arm/imx233/sansa-fuzeplus/button-target.h b/firmware/target/arm/imx233/sansa-fuzeplus/button-target.h index f22c06882f..d68bc9eda4 100644 --- a/firmware/target/arm/imx233/sansa-fuzeplus/button-target.h +++ b/firmware/target/arm/imx233/sansa-fuzeplus/button-target.h | |||
@@ -32,8 +32,18 @@ void button_debug_screen(void); | |||
32 | #define BUTTON_POWER 0x00000001 | 32 | #define BUTTON_POWER 0x00000001 |
33 | #define BUTTON_VOL_UP 0x00000002 | 33 | #define BUTTON_VOL_UP 0x00000002 |
34 | #define BUTTON_VOL_DOWN 0x00000004 | 34 | #define BUTTON_VOL_DOWN 0x00000004 |
35 | /* Virtual buttons */ | ||
36 | #define BUTTON_LEFT 0x00000008 | ||
37 | #define BUTTON_UP 0x00000010 | ||
38 | #define BUTTON_RIGHT 0x00000020 | ||
39 | #define BUTTON_DOWN 0x00000040 | ||
40 | #define BUTTON_SELECT 0x00000080 | ||
41 | #define BUTTON_PLAYPAUSE 0x00000100 | ||
42 | #define BUTTON_BACK 0x00000200 | ||
35 | 43 | ||
36 | #define BUTTON_MAIN (BUTTON_VOL_UP|BUTTON_VOL_DOWN|BUTTON_POWER) | 44 | #define BUTTON_MAIN (BUTTON_VOL_UP|BUTTON_VOL_DOWN|BUTTON_POWER|BUTTON_LEFT| \ |
45 | BUTTON_UP|BUTTON_RIGHT|BUTTON_DOWN|BUTTON_SELECT| \ | ||
46 | BUTTON_PLAYPAUSE|BUTTON_BACK) | ||
37 | 47 | ||
38 | #define BUTTON_REMOTE 0 | 48 | #define BUTTON_REMOTE 0 |
39 | 49 | ||
diff --git a/firmware/target/arm/imx233/sansa-fuzeplus/debug-fuzeplus.c b/firmware/target/arm/imx233/sansa-fuzeplus/debug-fuzeplus.c new file mode 100644 index 0000000000..c27f28fe24 --- /dev/null +++ b/firmware/target/arm/imx233/sansa-fuzeplus/debug-fuzeplus.c | |||
@@ -0,0 +1,28 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2011 by Amaury Pouly | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include "system.h" | ||
23 | #include "debug-target.h" | ||
24 | |||
25 | bool dbg_hw_target_info(void) | ||
26 | { | ||
27 | return false; | ||
28 | } | ||
diff --git a/firmware/target/arm/imx233/sansa-fuzeplus/fmradio-i2c-fuzeplus.c b/firmware/target/arm/imx233/sansa-fuzeplus/fmradio-i2c-fuzeplus.c index 5882a7da9f..d4113332ac 100644 --- a/firmware/target/arm/imx233/sansa-fuzeplus/fmradio-i2c-fuzeplus.c +++ b/firmware/target/arm/imx233/sansa-fuzeplus/fmradio-i2c-fuzeplus.c | |||
@@ -85,22 +85,17 @@ struct i2c_interface fmradio_i2c = | |||
85 | .delay_thigh = 4 | 85 | .delay_thigh = 4 |
86 | }; | 86 | }; |
87 | 87 | ||
88 | void fmradio_i2c_init(void) | 88 | void fmradio_i2c_enable(bool enable) |
89 | { | 89 | { |
90 | if(fmradio_i2c_bus == -1) | ||
91 | fmradio_i2c_bus = i2c_add_node(&fmradio_i2c); | ||
90 | imx233_set_pin_function(0, 29, PINCTRL_FUNCTION_GPIO); | 92 | imx233_set_pin_function(0, 29, PINCTRL_FUNCTION_GPIO); |
91 | imx233_set_pin_function(1, 24, PINCTRL_FUNCTION_GPIO); | 93 | imx233_set_pin_function(1, 24, PINCTRL_FUNCTION_GPIO); |
92 | imx233_set_pin_function(1, 22, PINCTRL_FUNCTION_GPIO); | 94 | imx233_set_pin_function(1, 22, PINCTRL_FUNCTION_GPIO); |
93 | imx233_enable_gpio_output(1, 22, true); | 95 | imx233_enable_gpio_output(1, 22, enable); |
94 | imx233_enable_gpio_output(1, 24, true); | 96 | imx233_enable_gpio_output(1, 24, enable); |
95 | imx233_set_gpio_output(1, 22, true); | 97 | imx233_set_gpio_output(1, 22, enable); |
96 | imx233_set_gpio_output(1, 24, true); | 98 | imx233_set_gpio_output(1, 24, enable); |
97 | fmradio_i2c_bus = i2c_add_node(&fmradio_i2c); | ||
98 | } | ||
99 | |||
100 | void fmradio_i2c_enable(bool enable) | ||
101 | { | ||
102 | imx233_enable_gpio_output(0, 29, enable); | ||
103 | imx233_set_gpio_output(0, 29, enable); | ||
104 | } | 99 | } |
105 | 100 | ||
106 | int fmradio_i2c_write(unsigned char address, const unsigned char* buf, int count) | 101 | int fmradio_i2c_write(unsigned char address, const unsigned char* buf, int count) |
diff --git a/firmware/target/arm/imx233/sansa-fuzeplus/lcd-fuzeplus.c b/firmware/target/arm/imx233/sansa-fuzeplus/lcd-fuzeplus.c index bc8a20d2ff..dba54373be 100644 --- a/firmware/target/arm/imx233/sansa-fuzeplus/lcd-fuzeplus.c +++ b/firmware/target/arm/imx233/sansa-fuzeplus/lcd-fuzeplus.c | |||
@@ -29,6 +29,16 @@ | |||
29 | 29 | ||
30 | #define logf(...) | 30 | #define logf(...) |
31 | 31 | ||
32 | /* Copies a rectangle from one framebuffer to another. Can be used in | ||
33 | single transfer mode with width = num pixels, and height = 1 which | ||
34 | allows a full-width rectangle to be copied more efficiently. */ | ||
35 | extern void lcd_copy_buffer_rect(fb_data *dst, const fb_data *src, | ||
36 | int width, int height); | ||
37 | |||
38 | #ifdef HAVE_LCD_ENABLE | ||
39 | static bool lcd_on = false; | ||
40 | #endif | ||
41 | |||
32 | static enum lcd_kind_t | 42 | static enum lcd_kind_t |
33 | { | 43 | { |
34 | LCD_KIND_7783 = 0x7783, | 44 | LCD_KIND_7783 = 0x7783, |
@@ -375,7 +385,7 @@ void lcd_init_device(void) | |||
375 | } | 385 | } |
376 | } | 386 | } |
377 | 387 | ||
378 | 388 | #ifdef HAVE_LCD_ENABLE | |
379 | static void lcd_enable_7783(bool enable) | 389 | static void lcd_enable_7783(bool enable) |
380 | { | 390 | { |
381 | if(!enable) | 391 | if(!enable) |
@@ -454,6 +464,10 @@ static void lcd_enable_9325(bool enable) | |||
454 | 464 | ||
455 | void lcd_enable(bool enable) | 465 | void lcd_enable(bool enable) |
456 | { | 466 | { |
467 | if(lcd_on == enable) | ||
468 | return; | ||
469 | lcd_on = enable; | ||
470 | |||
457 | if(enable) | 471 | if(enable) |
458 | common_lcd_enable(true); | 472 | common_lcd_enable(true); |
459 | switch(lcd_kind) | 473 | switch(lcd_kind) |
@@ -466,8 +480,19 @@ void lcd_enable(bool enable) | |||
466 | common_lcd_enable(false); | 480 | common_lcd_enable(false); |
467 | } | 481 | } |
468 | 482 | ||
483 | bool lcd_active(void) | ||
484 | { | ||
485 | return lcd_on; | ||
486 | } | ||
487 | #endif | ||
488 | |||
469 | void lcd_update(void) | 489 | void lcd_update(void) |
470 | { | 490 | { |
491 | #ifdef HAVE_LCD_ENABLE | ||
492 | if(!lcd_on) | ||
493 | return; | ||
494 | #endif | ||
495 | imx233_lcdif_wait_ready(); | ||
471 | lcd_write_reg(0x50, 0); | 496 | lcd_write_reg(0x50, 0); |
472 | lcd_write_reg(0x51, LCD_WIDTH - 1); | 497 | lcd_write_reg(0x51, LCD_WIDTH - 1); |
473 | lcd_write_reg(0x52, 0); | 498 | lcd_write_reg(0x52, 0); |
@@ -479,8 +504,9 @@ void lcd_update(void) | |||
479 | imx233_lcdif_set_word_length(HW_LCDIF_CTRL__WORD_LENGTH_16_BIT); | 504 | imx233_lcdif_set_word_length(HW_LCDIF_CTRL__WORD_LENGTH_16_BIT); |
480 | imx233_lcdif_set_byte_packing_format(0xf); /* two pixels per 32-bit word */ | 505 | imx233_lcdif_set_byte_packing_format(0xf); /* two pixels per 32-bit word */ |
481 | imx233_lcdif_set_data_format(false, false, false); /* RGB565, don't care, don't care */ | 506 | imx233_lcdif_set_data_format(false, false, false); /* RGB565, don't care, don't care */ |
482 | imx233_lcdif_dma_send(lcd_framebuffer, LCD_WIDTH, LCD_HEIGHT); | 507 | lcd_copy_buffer_rect((fb_data *)FRAME, &lcd_framebuffer[0][0], |
483 | imx233_lcdif_wait_ready(); | 508 | LCD_WIDTH * LCD_HEIGHT, 1); |
509 | imx233_lcdif_dma_send(FRAME, LCD_WIDTH, LCD_HEIGHT); | ||
484 | } | 510 | } |
485 | 511 | ||
486 | void lcd_update_rect(int x, int y, int width, int height) | 512 | void lcd_update_rect(int x, int y, int width, int height) |
diff --git a/firmware/target/arm/imx233/sansa-fuzeplus/power-fuzeplus.c b/firmware/target/arm/imx233/sansa-fuzeplus/power-fuzeplus.c new file mode 100644 index 0000000000..5cda13e2bb --- /dev/null +++ b/firmware/target/arm/imx233/sansa-fuzeplus/power-fuzeplus.c | |||
@@ -0,0 +1,46 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2011 by Amaury Pouly | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include "system.h" | ||
23 | #include "power.h" | ||
24 | #include "tuner.h" | ||
25 | #include "fmradio_i2c.h" | ||
26 | #include "pinctrl-imx233.h" | ||
27 | |||
28 | static bool tuner_enable = false; | ||
29 | |||
30 | bool tuner_power(bool enable) | ||
31 | { | ||
32 | if(enable != tuner_enable) | ||
33 | { | ||
34 | fmradio_i2c_enable(enable); | ||
35 | /* CE is B029 (active high) */ | ||
36 | imx233_enable_gpio_output(0, 29, enable); | ||
37 | imx233_set_gpio_output(0, 29, enable); | ||
38 | tuner_enable = enable; | ||
39 | } | ||
40 | return tuner_enable; | ||
41 | } | ||
42 | |||
43 | bool tuner_powered(void) | ||
44 | { | ||
45 | return tuner_enable; | ||
46 | } | ||
diff --git a/firmware/target/arm/imx233/sd-imx233.c b/firmware/target/arm/imx233/sd-imx233.c index 5e9f2cf030..b9114ae130 100644 --- a/firmware/target/arm/imx233/sd-imx233.c +++ b/firmware/target/arm/imx233/sd-imx233.c | |||
@@ -25,6 +25,10 @@ | |||
25 | #include "ssp-imx233.h" | 25 | #include "ssp-imx233.h" |
26 | #include "pinctrl-imx233.h" | 26 | #include "pinctrl-imx233.h" |
27 | #include "button-target.h" | 27 | #include "button-target.h" |
28 | #include "fat.h" | ||
29 | #include "disk.h" | ||
30 | #include "usb.h" | ||
31 | #include "debug.h" | ||
28 | 32 | ||
29 | /** | 33 | /** |
30 | * This code assumes a single SD card slot | 34 | * This code assumes a single SD card slot |
@@ -37,7 +41,13 @@ | |||
37 | #endif | 41 | #endif |
38 | 42 | ||
39 | static tCardInfo card_info; | 43 | static tCardInfo card_info; |
44 | static long sd_stack [(DEFAULT_STACK_SIZE*2 + 0x200)/sizeof(long)]; | ||
40 | static struct mutex sd_mutex; | 45 | static struct mutex sd_mutex; |
46 | static const char sd_thread_name[] = "sd"; | ||
47 | static struct event_queue sd_queue; | ||
48 | static int sd_first_drive; | ||
49 | static bool sd_initialized; | ||
50 | static int last_disk_activity; | ||
41 | 51 | ||
42 | static void sd_detect_callback(int ssp) | 52 | static void sd_detect_callback(int ssp) |
43 | { | 53 | { |
@@ -53,22 +63,132 @@ static void sd_detect_callback(int ssp) | |||
53 | imx233_ssp_sdmmc_setup_detect(SD_SSP, true, sd_detect_callback); | 63 | imx233_ssp_sdmmc_setup_detect(SD_SSP, true, sd_detect_callback); |
54 | } | 64 | } |
55 | 65 | ||
56 | int sd_init(void) | 66 | void sd_enable(bool on) |
57 | { | 67 | { |
58 | mutex_init(&sd_mutex); | 68 | static bool sd_enable = false; |
69 | if(sd_enable == on) | ||
70 | return; | ||
59 | 71 | ||
72 | mutex_lock(&sd_mutex); | ||
73 | if(on) | ||
74 | imx233_ssp_start(SD_SSP); | ||
75 | else | ||
76 | imx233_ssp_stop(SD_SSP); | ||
77 | mutex_unlock(&sd_mutex); | ||
78 | sd_enable = on; | ||
79 | } | ||
80 | |||
81 | static int sd_init_card(void) | ||
82 | { | ||
83 | printf("sd_init_card"); | ||
60 | imx233_ssp_start(SD_SSP); | 84 | imx233_ssp_start(SD_SSP); |
61 | imx233_ssp_softreset(SD_SSP); | 85 | imx233_ssp_softreset(SD_SSP); |
62 | imx233_ssp_set_mode(SD_SSP, HW_SSP_CTRL1__SSP_MODE__SD_MMC); | 86 | imx233_ssp_set_mode(SD_SSP, HW_SSP_CTRL1__SSP_MODE__SD_MMC); |
63 | #ifdef SANSA_FUZEPLUS | ||
64 | imx233_ssp_setup_ssp1_sd_mmc_pins(true, 4, PINCTRL_DRIVE_8mA, false); | ||
65 | #endif | ||
66 | imx233_ssp_sdmmc_setup_detect(SD_SSP, true, sd_detect_callback); | ||
67 | /* SSPCLK @ 96MHz | 87 | /* SSPCLK @ 96MHz |
68 | * gives bitrate of 96000 / 240 / 1 = 400kHz */ | 88 | * gives bitrate of 96000 / 240 / 1 = 400kHz */ |
69 | imx233_ssp_set_timings(SD_SSP, 240, 0, 0xffff); | 89 | imx233_ssp_set_timings(SD_SSP, 240, 0, 0xffff); |
70 | imx233_ssp_set_bus_width(SD_SSP, 1); | 90 | imx233_ssp_set_bus_width(SD_SSP, 1); |
71 | imx233_ssp_set_block_size(SD_SSP, 9); | 91 | imx233_ssp_set_block_size(SD_SSP, 9); |
92 | |||
93 | card_info.rca = 0; | ||
94 | bool is_v2 = false; | ||
95 | uint32_t resp; | ||
96 | /* go to idle state */ | ||
97 | int ret = imx233_ssp_sd_mmc_transfer(SD_SSP, SD_GO_IDLE_STATE, 0, SSP_NO_RESP, NULL, 0, false, false, NULL); | ||
98 | if(ret != 0) | ||
99 | return -1; | ||
100 | /* CMD8 Check for v2 sd card. Must be sent before using ACMD41 | ||
101 | Non v2 cards will not respond to this command*/ | ||
102 | ret = imx233_ssp_sd_mmc_transfer(SD_SSP, SD_SEND_IF_COND, 0x1AA, SSP_SHORT_RESP, NULL, 0, false, false, &resp); | ||
103 | if(ret == 0 && (resp & 0xFFF) == 0x1AA) | ||
104 | is_v2 = true; | ||
105 | |||
106 | return -10; | ||
107 | } | ||
108 | |||
109 | static void sd_thread(void) NORETURN_ATTR; | ||
110 | static void sd_thread(void) | ||
111 | { | ||
112 | struct queue_event ev; | ||
113 | |||
114 | while (1) | ||
115 | { | ||
116 | queue_wait_w_tmo(&sd_queue, &ev, HZ); | ||
117 | |||
118 | switch(ev.id) | ||
119 | { | ||
120 | case SYS_HOTSWAP_INSERTED: | ||
121 | case SYS_HOTSWAP_EXTRACTED: | ||
122 | { | ||
123 | int microsd_init = 1; | ||
124 | fat_lock(); /* lock-out FAT activity first - | ||
125 | prevent deadlocking via disk_mount that | ||
126 | would cause a reverse-order attempt with | ||
127 | another thread */ | ||
128 | mutex_lock(&sd_mutex); /* lock-out card activity - direct calls | ||
129 | into driver that bypass the fat cache */ | ||
130 | |||
131 | /* We now have exclusive control of fat cache and sd */ | ||
132 | |||
133 | disk_unmount(sd_first_drive); /* release "by force", ensure file | ||
134 | descriptors aren't leaked and any busy | ||
135 | ones are invalid if mounting */ | ||
136 | /* Force card init for new card, re-init for re-inserted one or | ||
137 | * clear if the last attempt to init failed with an error. */ | ||
138 | card_info.initialized = 0; | ||
139 | |||
140 | if(ev.id == SYS_HOTSWAP_INSERTED) | ||
141 | { | ||
142 | int ret = sd_init_card(); | ||
143 | if(ret == 0) | ||
144 | { | ||
145 | ret = disk_mount(sd_first_drive); /* 0 if fail */ | ||
146 | if(ret < 0) | ||
147 | DEBUGF("disk_mount failed: %d", ret); | ||
148 | } | ||
149 | else | ||
150 | DEBUGF("sd_init_card failed: %d", ret); | ||
151 | } | ||
152 | |||
153 | /* | ||
154 | * Mount succeeded, or this was an EXTRACTED event, | ||
155 | * in both cases notify the system about the changed filesystems | ||
156 | */ | ||
157 | if(card_info.initialized) | ||
158 | queue_broadcast(SYS_FS_CHANGED, 0); | ||
159 | |||
160 | /* Access is now safe */ | ||
161 | mutex_unlock(&sd_mutex); | ||
162 | fat_unlock(); | ||
163 | } | ||
164 | break; | ||
165 | case SYS_TIMEOUT: | ||
166 | if(!TIME_BEFORE(current_tick, last_disk_activity+(3*HZ))) | ||
167 | sd_enable(false); | ||
168 | break; | ||
169 | case SYS_USB_CONNECTED: | ||
170 | usb_acknowledge(SYS_USB_CONNECTED_ACK); | ||
171 | /* Wait until the USB cable is extracted again */ | ||
172 | usb_wait_for_disconnect(&sd_queue); | ||
173 | break; | ||
174 | } | ||
175 | } | ||
176 | } | ||
177 | |||
178 | int sd_init(void) | ||
179 | { | ||
180 | mutex_init(&sd_mutex); | ||
181 | queue_init(&sd_queue, true); | ||
182 | create_thread(sd_thread, sd_stack, sizeof(sd_stack), 0, | ||
183 | sd_thread_name IF_PRIO(, PRIORITY_USER_INTERFACE) IF_COP(, CPU)); | ||
184 | |||
185 | #ifdef SANSA_FUZEPLUS | ||
186 | imx233_ssp_setup_ssp1_sd_mmc_pins(true, 4, PINCTRL_DRIVE_8mA, false); | ||
187 | #endif | ||
188 | imx233_ssp_sdmmc_setup_detect(SD_SSP, true, sd_detect_callback); | ||
189 | |||
190 | if(imx233_ssp_sdmmc_detect(SD_SSP)) | ||
191 | queue_broadcast(SYS_HOTSWAP_INSERTED, 0); | ||
72 | 192 | ||
73 | return 0; | 193 | return 0; |
74 | } | 194 | } |
@@ -101,7 +221,7 @@ tCardInfo *card_get_info_target(int card_no) | |||
101 | 221 | ||
102 | int sd_num_drives(int first_drive) | 222 | int sd_num_drives(int first_drive) |
103 | { | 223 | { |
104 | (void) first_drive; | 224 | sd_first_drive = first_drive; |
105 | return 1; | 225 | return 1; |
106 | } | 226 | } |
107 | 227 | ||
diff --git a/firmware/target/arm/imx233/ssp-imx233.c b/firmware/target/arm/imx233/ssp-imx233.c index c3ce8a8f58..912f9c3ae4 100644 --- a/firmware/target/arm/imx233/ssp-imx233.c +++ b/firmware/target/arm/imx233/ssp-imx233.c | |||
@@ -325,7 +325,6 @@ void imx233_ssp_sd_mmc_power_up_sequence(int ssp) | |||
325 | 325 | ||
326 | static int ssp_detect_oneshot_callback(int ssp) | 326 | static int ssp_detect_oneshot_callback(int ssp) |
327 | { | 327 | { |
328 | printf("ssp_detect_oneshot_callback(%d)", ssp); | ||
329 | if(ssp_detect_cb[ssp - 1]) | 328 | if(ssp_detect_cb[ssp - 1]) |
330 | ssp_detect_cb[ssp - 1](ssp); | 329 | ssp_detect_cb[ssp - 1](ssp); |
331 | 330 | ||