diff options
author | Dana Conrad <dconrad@fastmail.com> | 2021-06-26 12:07:11 -0500 |
---|---|---|
committer | Aidan MacDonald <amachronic@protonmail.com> | 2021-07-18 12:14:35 +0000 |
commit | 3e7a09cb0dee0ee04b5c77f427bf89d990ec8d0b (patch) | |
tree | be1eb7e1d4166f60b245a0603e9f7dc11e1f5614 /firmware/target/mips/ingenic_x1000/erosqnative/power-erosqnative.c | |
parent | 64a24591aec049682167b193700a07572fc04c4c (diff) | |
download | rockbox-3e7a09cb0dee0ee04b5c77f427bf89d990ec8d0b.tar.gz rockbox-3e7a09cb0dee0ee04b5c77f427bf89d990ec8d0b.zip |
New Port: Eros Q Native
What works:
- LCD: 16-bit RGB565
- all buttons, including scrollwheel
- SD Card
- Battery level and charging/not charging status
- USB
- audio
- sample rate switching
- HP / LO detect, with "safe" fixed LO volume -
LO volume will only be put to user-defined max volume
if headphones are not present.
- rtc
- Plugins build, tried a couple and they seem OK
- Bootloader, installable to nand via usbboot
What doesn't work:
- Dual Boot
- power on/off has intermittent, low volume audio click
(sometimes it's completely silent, sometimes there's
a click)
- Audio uses 16-bit volume scaling, so clicking/popping
is pretty bad at lower volumes - need 32 bit volume
scaling, 24 bit I2S data
- USB HID keys not yet defined
- no jztool support
Unknowns:
- Stereo Switch pins: Direction select, AC_DC
(probably not even hooked up)
- What is the actual purpose of the Stereo Swtich?
- How does the bluetooth module connect?
"Someday" stuff:
- get LCD working at higher bit depth
- Bluetooth
Change-Id: I70dda8fc092c6e3f4352f2245e4164193f803c33
Diffstat (limited to 'firmware/target/mips/ingenic_x1000/erosqnative/power-erosqnative.c')
-rw-r--r-- | firmware/target/mips/ingenic_x1000/erosqnative/power-erosqnative.c | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/firmware/target/mips/ingenic_x1000/erosqnative/power-erosqnative.c b/firmware/target/mips/ingenic_x1000/erosqnative/power-erosqnative.c new file mode 100644 index 0000000000..c466db66b1 --- /dev/null +++ b/firmware/target/mips/ingenic_x1000/erosqnative/power-erosqnative.c | |||
@@ -0,0 +1,110 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2021 Aidan MacDonald, Dana Conrad | ||
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 | // whole file copied from m3k | ||
23 | |||
24 | #include "power.h" | ||
25 | #include "adc.h" | ||
26 | #include "system.h" | ||
27 | #include "kernel.h" | ||
28 | #ifdef HAVE_USB_CHARGING_ENABLE | ||
29 | # include "usb_core.h" | ||
30 | #endif | ||
31 | #include "axp-pmu.h" | ||
32 | #include "i2c-x1000.h" | ||
33 | |||
34 | const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] = | ||
35 | { | ||
36 | 3470 | ||
37 | }; | ||
38 | |||
39 | /* the OF shuts down at this voltage */ | ||
40 | const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] = | ||
41 | { | ||
42 | 3400 | ||
43 | }; | ||
44 | |||
45 | /* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */ | ||
46 | const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] = | ||
47 | { | ||
48 | { 3400, 3639, 3697, 3723, 3757, 3786, 3836, 3906, 3980, 4050, 4159 } | ||
49 | }; | ||
50 | |||
51 | /* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */ | ||
52 | const unsigned short percent_to_volt_charge[11] = | ||
53 | { | ||
54 | 3485, 3780, 3836, 3857, 3890, 3930, 3986, 4062, 4158, 4185, 4196 | ||
55 | }; | ||
56 | |||
57 | void power_init(void) | ||
58 | { | ||
59 | /* Initialize driver */ | ||
60 | i2c_x1000_set_freq(2, I2C_FREQ_400K); | ||
61 | axp_init(); | ||
62 | |||
63 | /* Set lowest sample rate */ | ||
64 | axp_adc_set_rate(AXP_ADC_RATE_25HZ); | ||
65 | |||
66 | /* Ensure battery voltage ADC is enabled */ | ||
67 | int bits = axp_adc_get_enabled(); | ||
68 | bits |= (1 << ADC_BATTERY_VOLTAGE); | ||
69 | axp_adc_set_enabled(bits); | ||
70 | |||
71 | /* Turn on all power outputs */ | ||
72 | i2c_reg_modify1(AXP_PMU_BUS, AXP_PMU_ADDR, | ||
73 | AXP_REG_PWROUTPUTCTRL2, 0, 0x5f, NULL); | ||
74 | i2c_reg_modify1(AXP_PMU_BUS, AXP_PMU_ADDR, | ||
75 | AXP_REG_DCDCWORKINGMODE, 0, 0xc0, NULL); | ||
76 | |||
77 | /* Set the default charging current. This is the same as the | ||
78 | * OF's setting, although it's not strictly within the USB spec. */ | ||
79 | axp_set_charge_current(780); | ||
80 | |||
81 | /* Short delay to give power outputs time to stabilize */ | ||
82 | mdelay(5); | ||
83 | } | ||
84 | |||
85 | #ifdef HAVE_USB_CHARGING_ENABLE | ||
86 | void usb_charging_maxcurrent_change(int maxcurrent) | ||
87 | { | ||
88 | axp_set_charge_current(maxcurrent); | ||
89 | } | ||
90 | #endif | ||
91 | |||
92 | void adc_init(void) | ||
93 | { | ||
94 | } | ||
95 | |||
96 | void power_off(void) | ||
97 | { | ||
98 | axp_power_off(); | ||
99 | while(1); | ||
100 | } | ||
101 | |||
102 | bool charging_state(void) | ||
103 | { | ||
104 | return axp_battery_status() == AXP_BATT_CHARGING; | ||
105 | } | ||
106 | |||
107 | int _battery_voltage(void) | ||
108 | { | ||
109 | return axp_adc_read(ADC_BATTERY_VOLTAGE); | ||
110 | } | ||