diff options
Diffstat (limited to 'firmware/target/hosted/samsungypr/ypr0/system-ypr0.c')
-rw-r--r-- | firmware/target/hosted/samsungypr/ypr0/system-ypr0.c | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/firmware/target/hosted/samsungypr/ypr0/system-ypr0.c b/firmware/target/hosted/samsungypr/ypr0/system-ypr0.c new file mode 100644 index 0000000000..7ee2697a24 --- /dev/null +++ b/firmware/target/hosted/samsungypr/ypr0/system-ypr0.c | |||
@@ -0,0 +1,104 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2011-2013 by Lorenzo Miori | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or | ||
12 | * modify it under the terms of the GNU General Public License | ||
13 | * as published by the Free Software Foundation; either version 2 | ||
14 | * of the License, or (at your option) any later version. | ||
15 | * | ||
16 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
17 | * KIND, either express or implied. | ||
18 | * | ||
19 | ****************************************************************************/ | ||
20 | |||
21 | #include <stdlib.h> | ||
22 | #include <string.h> | ||
23 | #include <inttypes.h> | ||
24 | #include "system.h" | ||
25 | #include "panic.h" | ||
26 | #include "debug.h" | ||
27 | |||
28 | #if defined(HAVE_SDL_AUDIO) || defined(HAVE_SDL_THREADS) || defined(HAVE_SDL) | ||
29 | #include <SDL.h> | ||
30 | #endif | ||
31 | |||
32 | #include "ascodec.h" | ||
33 | #include "gpio-target.h" | ||
34 | |||
35 | void power_off(void) | ||
36 | { | ||
37 | /* Something that we need to do before exit on our platform YPR0 */ | ||
38 | ascodec_close(); | ||
39 | gpio_close(); | ||
40 | exit(EXIT_SUCCESS); | ||
41 | } | ||
42 | |||
43 | uintptr_t *stackbegin; | ||
44 | uintptr_t *stackend; | ||
45 | void system_init(void) | ||
46 | { | ||
47 | int *s; | ||
48 | /* fake stack, OS manages size (and growth) */ | ||
49 | stackbegin = stackend = (uintptr_t*)&s; | ||
50 | |||
51 | #if defined(HAVE_SDL_AUDIO) || defined(HAVE_SDL_THREADS) || defined(HAVE_SDL) | ||
52 | SDL_Init(0); /* need this if using any SDL subsystem */ | ||
53 | #endif | ||
54 | |||
55 | /* Here begins our platform specific initilization for various things */ | ||
56 | ascodec_init(); | ||
57 | gpio_init(); | ||
58 | } | ||
59 | |||
60 | |||
61 | void system_reboot(void) | ||
62 | { | ||
63 | power_off(); | ||
64 | } | ||
65 | |||
66 | void system_exception_wait(void) | ||
67 | { | ||
68 | system_reboot(); | ||
69 | } | ||
70 | |||
71 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ | ||
72 | #include <stdio.h> | ||
73 | #include "file.h" | ||
74 | /* This is the Linux Kernel CPU governor... */ | ||
75 | static void set_cpu_freq(int speed) | ||
76 | { | ||
77 | char temp[10]; | ||
78 | int cpu_dev; | ||
79 | cpu_dev = open("/sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed", O_WRONLY); | ||
80 | if (cpu_dev < 0) | ||
81 | return; | ||
82 | write(cpu_dev, temp, sprintf(temp, "%d", speed) + 1); | ||
83 | close(cpu_dev); | ||
84 | } | ||
85 | |||
86 | void set_cpu_frequency(long frequency) | ||
87 | { | ||
88 | switch (frequency) | ||
89 | { | ||
90 | case CPUFREQ_MAX: | ||
91 | set_cpu_freq(532000); | ||
92 | cpu_frequency = CPUFREQ_MAX; | ||
93 | break; | ||
94 | case CPUFREQ_NORMAL: | ||
95 | set_cpu_freq(400000); | ||
96 | cpu_frequency = CPUFREQ_NORMAL; | ||
97 | break; | ||
98 | default: | ||
99 | set_cpu_freq(200000); | ||
100 | cpu_frequency = CPUFREQ_DEFAULT; | ||
101 | break; | ||
102 | } | ||
103 | } | ||
104 | #endif | ||