summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/debug_menu.c6
-rw-r--r--apps/plugin.c2
-rw-r--r--apps/plugin.h2
-rw-r--r--firmware/SOURCES2
-rw-r--r--firmware/export/config/samsungypr0.h18
-rw-r--r--firmware/export/power.h3
-rw-r--r--firmware/export/powermgmt.h2
-rw-r--r--firmware/export/storage.h2
-rw-r--r--firmware/powermgmt.c4
-rw-r--r--firmware/target/hosted/ypr0/powermgmt-ypr0.c115
-rw-r--r--firmware/target/hosted/ypr0/sc900776.h134
-rw-r--r--firmware/target/hosted/ypr0/system-ypr0.c11
12 files changed, 194 insertions, 107 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c
index 5773374d36..b4d917a3eb 100644
--- a/apps/debug_menu.c
+++ b/apps/debug_menu.c
@@ -58,7 +58,6 @@
58#if (CONFIG_PLATFORM & PLATFORM_NATIVE) 58#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
59#include "disk.h" 59#include "disk.h"
60#include "adc.h" 60#include "adc.h"
61#include "power.h"
62#include "usb.h" 61#include "usb.h"
63#include "rtc.h" 62#include "rtc.h"
64#include "storage.h" 63#include "storage.h"
@@ -75,6 +74,7 @@
75#include "radio.h" 74#include "radio.h"
76#endif 75#endif
77#endif 76#endif
77#include "power.h"
78 78
79#ifdef HAVE_LCD_BITMAP 79#ifdef HAVE_LCD_BITMAP
80#include "scrollbar.h" 80#include "scrollbar.h"
@@ -900,7 +900,7 @@ static bool tsc2100_debug(void)
900 return simplelist_show_list(&info); 900 return simplelist_show_list(&info);
901} 901}
902#endif 902#endif
903#if (CONFIG_PLATFORM & PLATFORM_NATIVE) 903#if (CONFIG_PLATFORM & PLATFORM_NATIVE) || defined(SAMSUNG_YPR0)
904#ifdef HAVE_LCD_BITMAP 904#ifdef HAVE_LCD_BITMAP
905/* 905/*
906 * view_battery() shows a automatically scaled graph of the battery voltage 906 * view_battery() shows a automatically scaled graph of the battery voltage
@@ -2168,7 +2168,7 @@ static const struct the_menu_item menuitems[] = {
2168 { "View CPU stats", dbg_cpuinfo }, 2168 { "View CPU stats", dbg_cpuinfo },
2169#endif 2169#endif
2170#ifdef HAVE_LCD_BITMAP 2170#ifdef HAVE_LCD_BITMAP
2171#if (CONFIG_PLATFORM & PLATFORM_NATIVE) 2171#if (CONFIG_PLATFORM & PLATFORM_NATIVE) || defined(SAMSUNG_YPR0)
2172 { "View battery", view_battery }, 2172 { "View battery", view_battery },
2173#endif 2173#endif
2174#ifndef APPLICATION 2174#ifndef APPLICATION
diff --git a/apps/plugin.c b/apps/plugin.c
index 6dd84af775..f17ad3c57a 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -664,7 +664,7 @@ static const struct plugin_api rockbox_api = {
664 battery_level, 664 battery_level,
665 battery_level_safe, 665 battery_level_safe,
666 battery_time, 666 battery_time,
667#if (CONFIG_PLATFORM & PLATFORM_NATIVE) 667#if (CONFIG_PLATFORM & PLATFORM_NATIVE) || defined(SAMSUNG_YPR0)
668 battery_voltage, 668 battery_voltage,
669#endif 669#endif
670#if CONFIG_CHARGING 670#if CONFIG_CHARGING
diff --git a/apps/plugin.h b/apps/plugin.h
index 3644e6468d..0bb7262bd8 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -794,7 +794,7 @@ struct plugin_api {
794 int (*battery_level)(void); 794 int (*battery_level)(void);
795 bool (*battery_level_safe)(void); 795 bool (*battery_level_safe)(void);
796 int (*battery_time)(void); 796 int (*battery_time)(void);
797#if (CONFIG_PLATFORM & PLATFORM_NATIVE) 797#if (CONFIG_PLATFORM & PLATFORM_NATIVE) || defined(SAMSUNG_YPR0)
798 unsigned int (*battery_voltage)(void); 798 unsigned int (*battery_voltage)(void);
799#endif 799#endif
800#if CONFIG_CHARGING 800#if CONFIG_CHARGING
diff --git a/firmware/SOURCES b/firmware/SOURCES
index e80a7492b1..46ef51beea 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -13,8 +13,8 @@ powermgmt.c
13target/hosted/cpuinfo-linux.c 13target/hosted/cpuinfo-linux.c
14#endif 14#endif
15 15
16target/hosted/powermgmt.c
17#ifndef SAMSUNG_YPR0 /* uses as3514 rtc */ 16#ifndef SAMSUNG_YPR0 /* uses as3514 rtc */
17target/hosted/powermgmt.c
18target/hosted/rtc.c 18target/hosted/rtc.c
19#endif 19#endif
20#endif 20#endif
diff --git a/firmware/export/config/samsungypr0.h b/firmware/export/config/samsungypr0.h
index 25e1906a80..8d133c4e24 100644
--- a/firmware/export/config/samsungypr0.h
+++ b/firmware/export/config/samsungypr0.h
@@ -21,7 +21,7 @@
21#define USB_NONE 21#define USB_NONE
22 22
23/* Hardware controlled charging with monitoring */ 23/* Hardware controlled charging with monitoring */
24//#define CONFIG_CHARGING CHARGING_MONITOR 24#define CONFIG_CHARGING CHARGING_MONITOR
25 25
26/* There is only USB charging */ 26/* There is only USB charging */
27//#define HAVE_USB_POWER 27//#define HAVE_USB_POWER
@@ -127,16 +127,16 @@
127 127
128/* Define current usage levels. */ 128/* Define current usage levels. */
129/* TODO: to be filled with correct values after implementing power management */ 129/* TODO: to be filled with correct values after implementing power management */
130#define CURRENT_NORMAL 88 /* 18 hours from a 1600 mAh battery */ 130//#define CURRENT_NORMAL 88 /* 18 hours from a 1600 mAh battery */
131#define CURRENT_BACKLIGHT 30 /* TBD */ 131//#define CURRENT_BACKLIGHT 30 /* TBD */
132#define CURRENT_RECORD 0 /* no recording yet */ 132//#define CURRENT_RECORD 0 /* no recording yet */
133 133
134/* TODO: We need to do battery handling */ 134/* TODO: We need to do battery handling */
135//#define BATTERY_CAPACITY_DEFAULT 600 /* default battery capacity */ 135#define BATTERY_CAPACITY_DEFAULT 600 /* default battery capacity */
136//#define BATTERY_CAPACITY_MIN 600 /* min. capacity selectable */ 136#define BATTERY_CAPACITY_MIN 600 /* min. capacity selectable */
137//#define BATTERY_CAPACITY_MAX 700 /* max. capacity selectable */ 137#define BATTERY_CAPACITY_MAX 600 /* max. capacity selectable */
138//#define BATTERY_CAPACITY_INC 50 /* capacity increment */ 138#define BATTERY_CAPACITY_INC 0 /* capacity increment */
139//#define BATTERY_TYPES_COUNT 1 /* only one type */ 139#define BATTERY_TYPES_COUNT 1 /* only one type */
140 140
141/* TODO: We possibly can only watch linux charging */ 141/* TODO: We possibly can only watch linux charging */
142//#define CONFIG_CHARGING CHARGING_TARGET 142//#define CONFIG_CHARGING CHARGING_TARGET
diff --git a/firmware/export/power.h b/firmware/export/power.h
index d46b9ba924..4937705910 100644
--- a/firmware/export/power.h
+++ b/firmware/export/power.h
@@ -23,6 +23,7 @@
23 23
24#include "config.h" 24#include "config.h"
25 25
26#if (CONFIG_PLATFORM & PLATFORM_NATIVE) || defined(SAMSUNG_YPR0)
26#if CONFIG_CHARGING 27#if CONFIG_CHARGING
27enum power_input_flags { 28enum power_input_flags {
28 /* No external power source? Default. */ 29 /* No external power source? Default. */
@@ -100,4 +101,6 @@ bool tuner_power(bool status);
100bool tuner_powered(void); 101bool tuner_powered(void);
101#endif 102#endif
102 103
104#endif
105
103#endif /* _POWER_H_ */ 106#endif /* _POWER_H_ */
diff --git a/firmware/export/powermgmt.h b/firmware/export/powermgmt.h
index d54f1d5a18..837767f56b 100644
--- a/firmware/export/powermgmt.h
+++ b/firmware/export/powermgmt.h
@@ -78,7 +78,7 @@ extern unsigned int power_thread_inputs;
78/* Start up power management thread */ 78/* Start up power management thread */
79void powermgmt_init(void) INIT_ATTR; 79void powermgmt_init(void) INIT_ATTR;
80 80
81#if (CONFIG_PLATFORM & PLATFORM_NATIVE) 81#if (CONFIG_PLATFORM & PLATFORM_NATIVE) || defined(SAMSUNG_YPR0)
82 82
83/* Generic current values that are intentionally meaningless - config header 83/* Generic current values that are intentionally meaningless - config header
84 * should define proper numbers.*/ 84 * should define proper numbers.*/
diff --git a/firmware/export/storage.h b/firmware/export/storage.h
index 58d8d32b6d..6c875bc847 100644
--- a/firmware/export/storage.h
+++ b/firmware/export/storage.h
@@ -71,7 +71,7 @@ static inline void stub_storage_spindown(int timeout) { (void)timeout; }
71 71
72 #define storage_enable(on) 72 #define storage_enable(on)
73 #define storage_sleepnow() 73 #define storage_sleepnow()
74 #define storage_disk_is_active() 74 #define storage_disk_is_active() 0
75 #define storage_soft_reset() 75 #define storage_soft_reset()
76 #define storage_init() 76 #define storage_init()
77 #define storage_close() 77 #define storage_close()
diff --git a/firmware/powermgmt.c b/firmware/powermgmt.c
index 4d554d6d3c..6027414b71 100644
--- a/firmware/powermgmt.c
+++ b/firmware/powermgmt.c
@@ -86,7 +86,7 @@ void handle_auto_poweroff(void);
86static int poweroff_timeout = 0; 86static int poweroff_timeout = 0;
87static long last_event_tick = 0; 87static long last_event_tick = 0;
88 88
89#if (CONFIG_PLATFORM & PLATFORM_NATIVE) 89#if (CONFIG_PLATFORM & PLATFORM_NATIVE) || defined(SAMSUNG_YPR0)
90/* 90/*
91 * Average battery voltage and charger voltage, filtered via a digital 91 * Average battery voltage and charger voltage, filtered via a digital
92 * exponential filter (aka. exponential moving average, scaled): 92 * exponential filter (aka. exponential moving average, scaled):
@@ -108,7 +108,7 @@ static int battery_type = 0;
108/* Power history: power_history[0] is the newest sample */ 108/* Power history: power_history[0] is the newest sample */
109unsigned short power_history[POWER_HISTORY_LEN] = {0}; 109unsigned short power_history[POWER_HISTORY_LEN] = {0};
110 110
111#if CONFIG_CPU == JZ4732 /* FIXME! */ 111#if CONFIG_CPU == JZ4732 /* FIXME! */ || (CONFIG_PLATFORM & PLATFORM_HOSTED)
112static char power_stack[DEFAULT_STACK_SIZE + POWERMGMT_DEBUG_STACK]; 112static char power_stack[DEFAULT_STACK_SIZE + POWERMGMT_DEBUG_STACK];
113#else 113#else
114static char power_stack[DEFAULT_STACK_SIZE/2 + POWERMGMT_DEBUG_STACK]; 114static char power_stack[DEFAULT_STACK_SIZE/2 + POWERMGMT_DEBUG_STACK];
diff --git a/firmware/target/hosted/ypr0/powermgmt-ypr0.c b/firmware/target/hosted/ypr0/powermgmt-ypr0.c
index 5701e9f02f..3a97331083 100644
--- a/firmware/target/hosted/ypr0/powermgmt-ypr0.c
+++ b/firmware/target/hosted/ypr0/powermgmt-ypr0.c
@@ -17,117 +17,72 @@
17 * 17 *
18 ****************************************************************************/ 18 ****************************************************************************/
19#include "config.h" 19#include "config.h"
20#include "system.h" 20#include <sys/ioctl.h>
21#include <time.h>
22#include "kernel.h" 21#include "kernel.h"
23#include "powermgmt.h" 22#include "powermgmt.h"
23#include "power.h"
24#include "file.h"
24#include "ascodec-target.h" 25#include "ascodec-target.h"
25#include "stdio.h" 26#include "as3514.h"
27#include "sc900776.h"
26 28
27#if 0 /*still unused*/
28/* The battery manufacturer's website shows discharge curves down to 3.0V,
29 so 'dangerous' and 'shutoff' levels of 3.4V and 3.3V should be safe.
30 */
31const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] = 29const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
32{ 30{
33 3550 31 3500
34}; 32};
35 33
34/* the OF shuts down at this voltage */
36const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] = 35const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
37{ 36{
38 3450 37 3450
39}; 38};
40 39
41/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */ 40/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
41/* FIXME: This is guessed. Make proper curve using battery_bench */
42const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] = 42const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
43{ 43{
44 { 3300, 3692, 3740, 3772, 3798, 3828, 3876, 3943, 4013, 4094, 4194 } 44 { 3450, 3692, 3740, 3772, 3798, 3828, 3876, 3943, 4013, 4094, 4194 }
45}; 45};
46 46
47#if CONFIG_CHARGING 47#if CONFIG_CHARGING
48/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */ 48/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
49const unsigned short percent_to_volt_charge[11] = 49/* FIXME: This is guessed. Make proper curve using battery_bench */
50const unsigned short const percent_to_volt_charge[11] =
50{ 51{
51 3417, 3802, 3856, 3888, 3905, 3931, 3973, 4025, 4084, 4161, 4219 52 3600, 3802, 3856, 3888, 3905, 3931, 3973, 4025, 4084, 4161, 4219
52}; 53};
53#endif /* CONFIG_CHARGING */
54#endif
55
56#define BATT_MINMVOLT 3450 /* minimum millivolts of battery */
57#define BATT_MAXMVOLT 4150 /* maximum millivolts of battery */
58#define BATT_MAXRUNTIME (10 * 60) /* maximum runtime with full battery in
59 minutes */
60
61extern void send_battery_level_event(void);
62extern int last_sent_battery_level;
63extern int battery_percent;
64
65static unsigned int battery_millivolts = BATT_MAXMVOLT;
66/* estimated remaining time in minutes */
67static int powermgmt_est_runningtime_min = BATT_MAXRUNTIME;
68 54
69static void battery_status_update(void) 55unsigned int power_input_status(void)
70{ 56{
71 static time_t last_change = 0; 57 unsigned status = POWER_INPUT_NONE;
72 time_t now; 58 int fd = open("/dev/minivet", O_RDONLY);
73 59 if (fd >= 0)
74 time(&now); 60 {
75 61 if (ioctl(fd, IOCTL_MINIVET_DET_VBUS, NULL) > 0)
76 if (last_change < now) { 62 status = POWER_INPUT_MAIN_CHARGER;
77 last_change = now; 63 close(fd);
78
79 battery_percent = 100 * (battery_millivolts - BATT_MINMVOLT) /
80 (BATT_MAXMVOLT - BATT_MINMVOLT);
81
82 powermgmt_est_runningtime_min =
83 battery_percent * BATT_MAXRUNTIME / 100;
84 } 64 }
85 65 return status;
86 send_battery_level_event();
87} 66}
88 67
89void battery_read_info(int *voltage, int *level) 68#endif /* CONFIG_CHARGING */
90{
91 battery_status_update();
92
93 if (voltage)
94 *voltage = battery_millivolts;
95
96 if (level)
97 *level = battery_percent;
98}
99
100unsigned int battery_voltage(void)
101{
102 battery_status_update();
103 return battery_millivolts;
104}
105
106int battery_level(void)
107{
108 battery_status_update();
109 return battery_percent;
110}
111
112int battery_time(void)
113{
114 battery_status_update();
115 return powermgmt_est_runningtime_min;
116}
117 69
118bool battery_level_safe(void)
119{
120 return battery_level() >= 10;
121}
122 70
123void set_battery_capacity(int capacity) 71/* Returns battery voltage from ADC [millivolts],
72 * adc returns voltage in 5mV steps */
73unsigned int battery_adc_voltage(void)
124{ 74{
125 (void)capacity; 75 return adc_read(3) * 5;
126} 76}
127 77
128#if BATTERY_TYPES_COUNT > 1 78bool charging_state(void)
129void set_battery_type(int type)
130{ 79{
131 (void)type; 80 /* cannot make this static (initializer not constant error), but gcc
81 * seems to calculate at compile time anyway */
82 const unsigned short charged_thres =
83 ((percent_to_volt_charge[9] + percent_to_volt_charge[10]) / 2);
84
85 bool ret = (power_input_status() == POWER_INPUT_MAIN_CHARGER);
86 /* dont indicate for > ~95% */
87 return ret && (battery_adc_voltage() <= charged_thres);
132} 88}
133#endif
diff --git a/firmware/target/hosted/ypr0/sc900776.h b/firmware/target/hosted/ypr0/sc900776.h
new file mode 100644
index 0000000000..32eb90f797
--- /dev/null
+++ b/firmware/target/hosted/ypr0/sc900776.h
@@ -0,0 +1,134 @@
1/* This file originates from the linux kernel provided in Samsung's YP-R0 Open
2 * Source package.
3 */
4
5/*
6* Bigbang project
7* Copyright (c) 2009 VPS R&D Group, Samsung Electronics, Inc.
8* All rights reserved.
9*/
10
11/**
12* This file defines data structures and APIs for Freescale SC900776
13*
14* @name sc900776.h
15* @author Eung Chan Kim (eungchan.kim@samsung.com)
16* @version 0.1
17* @see
18*/
19
20#ifndef __SC900776_H__
21#define __SC900776_H__
22
23
24typedef enum
25{
26 SC900776_DEVICE_ID = 0x01, /* 01h R */
27 SC900776_CONTROL, /* 02h R/W */
28 SC900776_INTERRUPT1, /* 03h R/C */
29 SC900776_INTERRUPT2, /* 04h R/C */
30 SC900776_INTERRUPT_MASK1, /* 05h R/W */
31 SC900776_INTERRUPT_MASK2, /* 06h R/W */
32 SC900776_ADC_RESULT, /* 07h R */
33 SC900776_TIMING_SET1, /* 08h R/W */
34 SC900776_TIMING_SET2, /* 09h R/W */
35 SC900776_DEVICE_TYPE1, /* 0Ah R */
36 SC900776_DEVICE_TYPE2, /* 0Bh R */
37 SC900776_BUTTON1, /* 0Ch R/C */
38 SC900776_BUTTON2, /* 0Dh R/C */
39 /* 0Eh ~ 12h : reserved */
40 SC900776_MANUAL_SWITCH1 = 0x13, /* 13h R/W */
41 SC900776_MANUAL_SWITCH2, /* 14h R/W */
42 /* 15h ~ 1Fh : reserved */
43 SC900776_FSL_STATUS = 0x20, /* 20h R */
44 SC900776_FSL_CONTROL, /* 21h R/W */
45 SC900776_TIME_DELAY, /* 22h R/W */
46 SC900776_DEVICE_MODE, /* 23h R/W */
47
48 SC900776_REG_MAX
49} eSc900776_register_t;
50
51typedef enum
52{
53 DEVICETYPE1_UNDEFINED = 0,
54 DEVICETYPE1_USB, // 0x04 0x00 // normal usb cable & ad200
55 DEVICETYPE1_DEDICATED, // 0x40 0x00 // dedicated charger cable
56 DEVICETYPE2_JIGUARTON, // 0x00 0x08 // Anygate_UART jig
57 DEVICETYPE2_JIGUSBOFF, // 0x00 0x01 // USB jig(AS center)
58 DEVICETYPE2_JIGUSBON, // 0x00 0x02 // Anygate_USB jig with boot-on, not tested
59} eMinivet_device_t;
60
61/*
62 * sc900776 register bit definitions
63 */
64#define MINIVET_DEVICETYPE1_USBOTG 0x80 /* 1: a USBOTG device is attached */
65#define MINIVET_DEVICETYPE1_DEDICATED 0x40 /* 1: a dedicated charger is attached */
66#define MINIVET_DEVICETYPE1_USBCHG 0x20 /* 1: a USB charger is attached */
67#define MINIVET_DEVICETYPE1_5WCHG 0x10 /* 1: a 5-wire charger (type 1 or 2) is attached */
68#define MINIVET_DEVICETYPE1_UART 0x08 /* 1: a UART cable is attached */
69#define MINIVET_DEVICETYPE1_USB 0x04 /* 1: a USB host is attached */
70#define MINIVET_DEVICETYPE1_AUDIO2 0x02 /* 1: an audio accessory type 2 is attached */
71#define MINIVET_DEVICETYPE1_AUDIO1 0x01 /* 1: an audio accessory type 1 is attached */
72
73#define MINIVET_DEVICETYPE2_AV 0x40 /* 1: an audio/video cable is attached */
74#define MINIVET_DEVICETYPE2_TTY 0x20 /* 1: a TTY converter is attached */
75#define MINIVET_DEVICETYPE2_PPD 0x10 /* 1: a phone powered device is attached */
76#define MINIVET_DEVICETYPE2_JIGUARTON 0x08 /* 1: a UART jig cable with the BOOT-on option is attached */
77#define MINIVET_DEVICETYPE2_JIGUARTOFF 0x04 /* 1: a UART jig cable with the BOOT-off option is attached */
78#define MINIVET_DEVICETYPE2_JIGUSBON 0x02 /* 1: a USB jig cable with the BOOT-on option is attached */
79#define MINIVET_DEVICETYPE2_JIGUSBOFF 0x01 /* 1: a USB jig cable with the BOOT-off option is attached */
80
81#define MINIVET_FSLSTATUS_FETSTATUS 0x40 /* 1: The on status of the power MOSFET */
82#define MINIVET_FSLSTATUS_IDDETEND 0x20 /* 1: ID resistance detection finished */
83#define MINIVET_FSLSTATUS_VBUSDETEND 0x10 /* 1: VBUS power supply type identification completed */
84#define MINIVET_FSLSTATUS_IDGND 0x08 /* 1: ID pin is shorted to ground */
85#define MINIVET_FSLSTATUS_IDFLOAT 0x04 /* 1: ID line is floating */
86#define MINIVET_FSLSTATUS_VBUSDET 0x02 /* 1: VBUS voltage is higher than the POR */
87#define MINIVET_FSLSTATUS_ADCSTATUS 0x01 /* 1: ADC conversion completed */
88
89
90#define SC900776_I2C_SLAVE_ADDR 0x25
91
92typedef struct {
93 unsigned char addr;
94 unsigned char value;
95}__attribute__((packed)) sMinivet_t;
96
97
98#define DRV_IOCTL_MINIVET_MAGIC 'M'
99
100
101typedef enum
102{
103 E_IOCTL_MINIVET_INIT = 0,
104 E_IOCTL_MINIVET_WRITE_BYTE,
105 E_IOCTL_MINIVET_READ_BYTE,
106 E_IOCTL_MINIVET_DET_VBUS,
107 E_IOCTL_MINIVET_MANUAL_USB,
108 E_IOCTL_MINIVET_MANUAL_UART,
109
110 E_IOCTL_MINIVET_MAX
111} eSc900776_ioctl_t;
112
113#define IOCTL_MINIVET_INIT _IO(DRV_IOCTL_MINIVET_MAGIC, E_IOCTL_MINIVET_INIT)
114#define IOCTL_MINIVET_WRITE_BYTE _IOW(DRV_IOCTL_MINIVET_MAGIC, E_IOCTL_MINIVET_WRITE_BYTE, sMinivet_t)
115#define IOCTL_MINIVET_READ_BYTE _IOR(DRV_IOCTL_MINIVET_MAGIC, E_IOCTL_MINIVET_READ_BYTE, sMinivet_t)
116#define IOCTL_MINIVET_DET_VBUS _IO(DRV_IOCTL_MINIVET_MAGIC, E_IOCTL_MINIVET_DET_VBUS)
117#define IOCTL_MINIVET_MANUAL_USB _IO(DRV_IOCTL_MINIVET_MAGIC, E_IOCTL_MINIVET_MANUAL_USB)
118#define IOCTL_MINIVET_MANUAL_UART _IO(DRV_IOCTL_MINIVET_MAGIC, E_IOCTL_MINIVET_MANUAL_UART)
119
120
121#ifndef __MINIVET_ENUM__
122#define __MINIVET_ENUM__
123enum
124{
125 EXT_PWR_UNPLUGGED = 0,
126 EXT_PWR_PLUGGED,
127 EXT_PWR_NOT_OVP,
128 EXT_PWR_OVP,
129};
130
131#endif /* __MINIVET_ENUM__ */
132
133
134#endif /* __MINIVET_IOCTL_H__ */
diff --git a/firmware/target/hosted/ypr0/system-ypr0.c b/firmware/target/hosted/ypr0/system-ypr0.c
index 3a2b30339f..bf3b1cd4c9 100644
--- a/firmware/target/hosted/ypr0/system-ypr0.c
+++ b/firmware/target/hosted/ypr0/system-ypr0.c
@@ -32,16 +32,11 @@
32 32
33#include "ascodec-target.h" 33#include "ascodec-target.h"
34 34
35void sim_do_exit(void) 35void power_off(void)
36{
37 exit(EXIT_SUCCESS);
38}
39
40void shutdown_hw(void)
41{ 36{
42 /* Something that we need to do before exit on our platform YPR0 */ 37 /* Something that we need to do before exit on our platform YPR0 */
43 ascodec_close(); 38 ascodec_close();
44 sim_do_exit(); 39 exit(EXIT_SUCCESS);
45} 40}
46 41
47uintptr_t *stackbegin; 42uintptr_t *stackbegin;
@@ -62,7 +57,7 @@ void system_init(void)
62 57
63void system_reboot(void) 58void system_reboot(void)
64{ 59{
65 sim_do_exit(); 60 power_off();
66} 61}
67 62
68void system_exception_wait(void) 63void system_exception_wait(void)