summaryrefslogtreecommitdiff
path: root/firmware/export
diff options
context:
space:
mode:
authorAidan MacDonald <amachronic@protonmail.com>2021-02-27 22:08:58 +0000
committerAidan MacDonald <amachronic@protonmail.com>2021-03-28 00:01:37 +0000
commit3ec66893e377b088c1284d2d23adb2aeea6d7965 (patch)
treeb647717f83ad56b15dc42cfdef5d04d68cd9bd6b /firmware/export
parent83fcbedc65f4b9ae7e491ecf6f07c0af4b245f74 (diff)
downloadrockbox-3ec66893e377b088c1284d2d23adb2aeea6d7965.tar.gz
rockbox-3ec66893e377b088c1284d2d23adb2aeea6d7965.zip
New port: FiiO M3K on bare metal
Change-Id: I7517e7d5459e129dcfc9465c6fbd708619888fbe
Diffstat (limited to 'firmware/export')
-rw-r--r--firmware/export/ak4376.h152
-rw-r--r--firmware/export/audiohw.h2
-rw-r--r--firmware/export/axp173.h94
-rw-r--r--firmware/export/config.h7
-rw-r--r--firmware/export/config/fiiom3k.h116
-rw-r--r--firmware/export/installer.h31
6 files changed, 402 insertions, 0 deletions
diff --git a/firmware/export/ak4376.h b/firmware/export/ak4376.h
new file mode 100644
index 0000000000..eb06755e92
--- /dev/null
+++ b/firmware/export/ak4376.h
@@ -0,0 +1,152 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2021 Aidan MacDonald
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#ifndef __AK4376_H__
23#define __AK4376_H__
24
25#define AUDIOHW_CAPS (FILTER_ROLL_OFF_CAP|POWER_MODE_CAP)
26#define AUDIOHW_HAVE_SHORT2_ROLL_OFF
27
28#define AK4376_MIN_VOLUME (-890)
29#define AK4376_MAX_VOLUME 150
30
31AUDIOHW_SETTING(VOLUME, "dB", 1, 5, AK4376_MIN_VOLUME, AK4376_MAX_VOLUME, -200)
32AUDIOHW_SETTING(FILTER_ROLL_OFF, "", 0, 1, 0, 3, 0)
33AUDIOHW_SETTING(POWER_MODE, "", 0, 1, 0, 1, 0)
34
35/* Register addresses */
36#define AK4376_REG_PWR1 0x00
37#define AK4376_REG_PWR2 0x01
38#define AK4376_REG_PWR3 0x02
39#define AK4376_REG_PWR4 0x03
40#define AK4376_REG_OUTPUT_MODE 0x04
41#define AK4376_REG_CLOCK_MODE 0x05
42#define AK4376_REG_FILTER 0x06
43#define AK4376_REG_MIXER 0x07
44#define AK4376_REG_LCH_VOLUME 0x0b
45#define AK4376_REG_RCH_VOLUME 0x0c
46#define AK4376_REG_AMP_VOLUME 0x0d
47#define AK4376_REG_PLL_CLK_SRC 0x0e
48#define AK4376_REG_PLL_REF_DIV1 0x0f
49#define AK4376_REG_PLL_REF_DIV2 0x10
50#define AK4376_REG_PLL_FB_DIV1 0x11
51#define AK4376_REG_PLL_FB_DIV2 0x12
52#define AK4376_REG_DAC_CLK_SRC 0x13
53#define AK4376_REG_DAC_CLK_DIV 0x14
54#define AK4376_REG_AUDIO_IF_FMT 0x15
55#define AK4376_REG_CHIP_ID 0x21
56#define AK4376_REG_MODE_CTRL 0x24
57#define AK4376_REG_ADJUST1 0x26
58#define AK4376_REG_ADJUST2 0x2a
59#define AK4376_NUM_REGS 0x2b
60
61/* Mixer controls, simply OR them together.
62 * LCH = add LCH signal to output
63 * RCH = add RCH signal to output
64 * HALF = multiply output by 1/2
65 * INVERT = invert the output after everything else
66 */
67#define AK4376_MIX_MUTE 0
68#define AK4376_MIX_LCH 1
69#define AK4376_MIX_RCH 2
70#define AK4376_MIX_HALF 4
71#define AK4376_MIX_INVERT 8
72
73/* Min/max digital volumes in units of dB/10 */
74#define AK4376_DIG_VOLUME_MIN (-120)
75#define AK4376_DIG_VOLUME_MAX 30
76#define AK4376_DIG_VOLUME_STEP 5
77#define AK4376_DIG_VOLUME_MUTE (AK4376_DIG_VOLUME_MIN - 1)
78
79/* Min/max headphone amp volumes in units of dB/10 */
80#define AK4376_AMP_VOLUME_MIN (-200)
81#define AK4376_AMP_VOLUME_MAX 60
82#define AK4376_AMP_VOLUME_STEP 20
83#define AK4376_AMP_VOLUME_MUTE (AK4376_AMP_VOLUME_MIN - 1)
84
85/* Digital filters */
86#define AK4376_FILTER_SHARP 0
87#define AK4376_FILTER_SLOW 1
88#define AK4376_FILTER_SHORT_SHARP 2
89#define AK4376_FILTER_SHORT_SLOW 3
90
91/* Frequency selection */
92#define AK4376_FS_8 0
93#define AK4376_FS_11 1
94#define AK4376_FS_12 2
95#define AK4376_FS_16 4
96#define AK4376_FS_22 5
97#define AK4376_FS_24 6
98#define AK4376_FS_32 8
99#define AK4376_FS_44 9
100#define AK4376_FS_48 10
101#define AK4376_FS_64 12
102#define AK4376_FS_88 13
103#define AK4376_FS_96 14
104#define AK4376_FS_176 17
105#define AK4376_FS_192 18
106
107/* Functions to power on / off the DAC which should be called from
108 * the target's audiohw_init() / audiohw_close() implementation.
109 */
110extern void ak4376_init(void);
111extern void ak4376_close(void);
112
113/* Register read/write. Cached to avoid redundant reads/writes. */
114extern void ak4376_write(int reg, int value);
115extern int ak4376_read(int reg);
116
117/* Target-specific function to set the PDN pin level. */
118extern void ak4376_set_pdn_pin(int level);
119
120/* Target-specific function to control the external master clock frequency.
121 * This is called by the ak4376's audiohw implementation when switching to
122 * or from a frequency that is configured to use this clock source.
123 *
124 * - hw_freq is the new sample rate -- one of the HW_FREQ_XX constants.
125 * - enabled is true if clock should be output, false if not.
126 *
127 * The return value is the master clock rate as a multiple of the sampling
128 * frequency. The allowed multiples depend on the sampling frequency, shown
129 * in the table below.
130 *
131 * +-----------+------------------------+
132 * | frequency | master clock rate |
133 * +-----------+------------------------+
134 * | 8 - 24 | 256fs / 512fs / 1024fs |
135 * | 32 - 48 | 256fs / 512fs |
136 * | 64 - 96 | 256fs |
137 * | 128 - 192 | 128fs |
138 * +-----------+------------------------+
139 *
140 * For example, at 48 KHz you could return either 256 or 512 depending on
141 * the rate you decided to actually use.
142 *
143 * You need to return a valid master multiplier for supported frequencies
144 * even when enabled = false, since the driver needs to know the multiplier
145 * _before_ enabling the clock.
146 *
147 * For unsupported frequencies you don't need to return a valid master
148 * multiplier, because the DAC doesn't need the return value in such cases.
149 */
150extern int ak4376_set_mclk_freq(int hw_freq, bool enabled);
151
152#endif /* __AK4376_H__ */
diff --git a/firmware/export/audiohw.h b/firmware/export/audiohw.h
index d862c977db..ceafc6ebf7 100644
--- a/firmware/export/audiohw.h
+++ b/firmware/export/audiohw.h
@@ -194,6 +194,8 @@ struct sound_settings_info
194#include "jz4740-codec.h" 194#include "jz4740-codec.h"
195#elif defined(HAVE_AK4537) 195#elif defined(HAVE_AK4537)
196#include "ak4537.h" 196#include "ak4537.h"
197#elif defined(HAVE_AK4376)
198#include "ak4376.h"
197#elif defined(HAVE_RK27XX_CODEC) 199#elif defined(HAVE_RK27XX_CODEC)
198#include "rk27xx_codec.h" 200#include "rk27xx_codec.h"
199#elif defined(HAVE_AIC3X) 201#elif defined(HAVE_AIC3X)
diff --git a/firmware/export/axp173.h b/firmware/export/axp173.h
new file mode 100644
index 0000000000..60519138e1
--- /dev/null
+++ b/firmware/export/axp173.h
@@ -0,0 +1,94 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2021 Aidan MacDonald
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#ifndef __AXP173_H__
23#define __AXP173_H__
24
25#include <stdbool.h>
26#include <stdint.h>
27
28#define ADC_ACIN_VOLTAGE 0
29#define ADC_ACIN_CURRENT 1
30#define ADC_VBUS_VOLTAGE 2
31#define ADC_VBUS_CURRENT 3
32#define ADC_INTERNAL_TEMP 4
33#define ADC_TS_INPUT 5
34#define ADC_BATTERY_VOLTAGE 6
35#define ADC_CHARGE_CURRENT 7
36#define ADC_DISCHARGE_CURRENT 8
37#define ADC_APS_VOLTAGE 9
38#define ADC_BATTERY_POWER 10
39#define NUM_ADC_CHANNELS 11
40
41/* ADC sampling rates */
42#define AXP173_ADC_RATE_25HZ 0
43#define AXP173_ADC_RATE_50HZ 1
44#define AXP173_ADC_RATE_100HZ 2
45#define AXP173_ADC_RATE_200HZ 3
46
47/* Return values of axp173_battery_status() */
48#define AXP173_BATT_DISCHARGING 0
49#define AXP173_BATT_CHARGING 1
50#define AXP173_BATT_FULL 2
51
52/* Bits returned by axp173_input_status() */
53#define AXP173_INPUT_AC (1 << 0)
54#define AXP173_INPUT_USB (1 << 1)
55#define AXP173_INPUT_BATTERY (1 << 2)
56#define AXP173_INPUT_EXTERNAL (AXP173_INPUT_AC|AXP173_INPUT_USB)
57
58/* Must be called from power_init() to initialize the driver state */
59extern void axp173_init(void);
60
61/* Basic battery and power supply status */
62extern int axp173_battery_status(void);
63extern int axp173_input_status(void);
64
65/* ADC access -- ADCs which are not enabled will return INT_MIN if read.
66 * The output of axp173_adc_read() is normalized to appropriate units:
67 *
68 * - for voltages, the scale is millivolts
69 * - for currents, the scale is milliamps
70 * - for temperatures, the scale is tenths of a degree Celsius
71 * - for power, the scale is microwatts
72 *
73 * See the comment in axp173_adc_conv_raw() for raw value precision/scale.
74 */
75extern int axp173_adc_read(int adc);
76extern int axp173_adc_read_raw(int adc);
77extern int axp173_adc_conv_raw(int adc, int value);
78extern int axp173_adc_get_enabled(void);
79extern void axp173_adc_set_enabled(int adc_bits);
80extern int axp173_adc_get_rate(void);
81extern void axp173_adc_set_rate(int rate);
82
83/* - axp173_cc_read() reads the coulomb counters
84 * - axp173_cc_clear() resets both counters to zero
85 * - axp173_cc_enable() will stop/start the counters running
86 */
87extern void axp173_cc_read(uint32_t* charge, uint32_t* discharge);
88extern void axp173_cc_clear(void);
89extern void axp173_cc_enable(bool en);
90
91/* Debug menu */
92extern bool axp173_debug_menu(void);
93
94#endif /* __AXP173_H__ */
diff --git a/firmware/export/config.h b/firmware/export/config.h
index e35d407372..db1c589043 100644
--- a/firmware/export/config.h
+++ b/firmware/export/config.h
@@ -82,6 +82,7 @@
82#define AS3525v2 35252 82#define AS3525v2 35252
83#define IMX233 233 83#define IMX233 233
84#define RK27XX 2700 84#define RK27XX 2700
85#define X1000 1000
85 86
86/* platforms 87/* platforms
87 * bit fields to allow PLATFORM_HOSTED to be OR'ed e.g. with a 88 * bit fields to allow PLATFORM_HOSTED to be OR'ed e.g. with a
@@ -165,6 +166,7 @@
165#define XDUOO_X20_PAD 70 166#define XDUOO_X20_PAD 70
166#define FIIO_M3K_LINUX_PAD 71 167#define FIIO_M3K_LINUX_PAD 71
167#define EROSQ_PAD 72 168#define EROSQ_PAD 72
169#define FIIO_M3K_PAD 73
168 170
169/* CONFIG_REMOTE_KEYPAD */ 171/* CONFIG_REMOTE_KEYPAD */
170#define H100_REMOTE 1 172#define H100_REMOTE 1
@@ -281,6 +283,7 @@
281#define LCD_IHIFI770 66 /* as used by IHIFI 770 */ 283#define LCD_IHIFI770 66 /* as used by IHIFI 770 */
282#define LCD_IHIFI770C 67 /* as used by IHIFI 770C */ 284#define LCD_IHIFI770C 67 /* as used by IHIFI 770C */
283#define LCD_IHIFI800 68 /* as used by IHIFI 800 */ 285#define LCD_IHIFI800 68 /* as used by IHIFI 800 */
286#define LCD_FIIOM3K 69 /* as used by the FiiO M3K */
284 287
285/* LCD_PIXELFORMAT */ 288/* LCD_PIXELFORMAT */
286#define HORIZONTAL_PACKING 1 289#define HORIZONTAL_PACKING 1
@@ -320,6 +323,7 @@ Lyre prototype 1 */
320#define I2C_S5L8702 16 /* Same as S5L8700, but with two channels */ 323#define I2C_S5L8702 16 /* Same as S5L8700, but with two channels */
321#define I2C_IMX233 17 324#define I2C_IMX233 17
322#define I2C_RK27XX 18 325#define I2C_RK27XX 18
326#define I2C_X1000 19
323 327
324/* CONFIG_LED */ 328/* CONFIG_LED */
325#define LED_REAL 1 /* SW controlled LED (Archos recorders, player) */ 329#define LED_REAL 1 /* SW controlled LED (Archos recorders, player) */
@@ -356,6 +360,7 @@ Lyre prototype 1 */
356#define RTC_IMX233 20 360#define RTC_IMX233 20
357#define RTC_STM41T62 21 /* ST M41T62 */ 361#define RTC_STM41T62 21 /* ST M41T62 */
358#define RTC_JZ4760 22 /* Ingenic Jz4760 */ 362#define RTC_JZ4760 22 /* Ingenic Jz4760 */
363#define RTC_X1000 23 /* Ingenic X1000 */
359 364
360/* USB On-the-go */ 365/* USB On-the-go */
361#define USBOTG_M66591 6591 /* M:Robe 500 */ 366#define USBOTG_M66591 6591 /* M:Robe 500 */
@@ -605,6 +610,8 @@ Lyre prototype 1 */
605#include "config/xduoox20.h" 610#include "config/xduoox20.h"
606#elif defined(FIIO_M3K_LINUX) 611#elif defined(FIIO_M3K_LINUX)
607#include "config/fiiom3klinux.h" 612#include "config/fiiom3klinux.h"
613#elif defined(FIIO_M3K)
614#include "config/fiiom3k.h"
608#elif defined(EROS_Q) 615#elif defined(EROS_Q)
609#include "config/aigoerosq.h" 616#include "config/aigoerosq.h"
610#else 617#else
diff --git a/firmware/export/config/fiiom3k.h b/firmware/export/config/fiiom3k.h
new file mode 100644
index 0000000000..68186d7aaf
--- /dev/null
+++ b/firmware/export/config/fiiom3k.h
@@ -0,0 +1,116 @@
1/* RoLo-related defines */
2#define MODEL_NAME "FiiO M3K"
3#define MODEL_NUMBER 114
4#define BOOTFILE_EXT "m3k"
5#define BOOTFILE "rockbox." BOOTFILE_EXT
6#define BOOTDIR "/.rockbox"
7#define FIRMWARE_OFFSET_FILE_CRC 0
8#define FIRMWARE_OFFSET_FILE_DATA 8
9
10/* CPU defines */
11#define CONFIG_CPU X1000
12#define X1000_EXCLK_FREQ 24000000
13#define TIMER_FREQ X1000_EXCLK_FREQ
14#define CPU_FREQ 1008000000
15#define CPUFREQ_MAX CPU_FREQ
16/* TODO: figure out if this does in fact affect power consumption. */
17#define CPUFREQ_DEFAULT (CPUFREQ_MAX/4)
18#define CPUFREQ_NORMAL (CPUFREQ_MAX/4)
19#define HAVE_ADJUSTABLE_CPU_FREQ
20#define HAVE_GUI_BOOST
21
22/* Kernel defines */
23#define INCLUDE_TIMEOUT_API
24#define HAVE_SEMAPHORE_OBJECTS
25
26/* Drivers */
27#define HAVE_I2C_ASYNC
28
29/* Buffer for plugins and codecs. */
30#define PLUGIN_BUFFER_SIZE 0x200000 /* 2 MiB */
31#define CODEC_SIZE 0x100000 /* 1 MiB */
32
33/* LCD defines */
34#define CONFIG_LCD LCD_FIIOM3K
35#define LCD_WIDTH 240
36#define LCD_HEIGHT 320
37#define LCD_DEPTH 16
38#define LCD_PIXELFORMAT RGB565
39#define LCD_DPI 200
40#define HAVE_LCD_COLOR
41#define HAVE_LCD_BITMAP
42#define HAVE_LCD_ENABLE
43#define LCD_X1000_FASTSLEEP
44
45/* Backlight defines */
46#define HAVE_BACKLIGHT
47#define HAVE_BACKLIGHT_BRIGHTNESS
48#define HAVE_BUTTON_LIGHT
49#define HAVE_BUTTONLIGHT_BRIGHTNESS
50#define MIN_BRIGHTNESS_SETTING 1
51#define MAX_BRIGHTNESS_SETTING 100
52#define BRIGHTNESS_STEP 5
53#define DEFAULT_BRIGHTNESS_SETTING 70
54#define CONFIG_BACKLIGHT_FADING BACKLIGHT_FADING_SW_SETTING
55
56/* Codec / audio hardware defines */
57#define HW_SAMPR_CAPS SAMPR_CAP_ALL_192
58#define HAVE_AK4376
59#define HAVE_SW_TONE_CONTROLS
60#define HAVE_SW_VOLUME_CONTROL
61
62/* TODO: Need to implement recording */
63
64/* Button defines */
65#define CONFIG_KEYPAD FIIO_M3K_PAD
66#define HAVE_HEADPHONE_DETECTION
67#define HAVE_TOUCHPAD
68#define HAVE_TOUCHPAD_SENSITIVITY_SETTING
69#define MIN_TOUCHPAD_SENSITIVITY_SETTING (-25)
70#define MAX_TOUCHPAD_SENSITIVITY_SETTING (25)
71#define DEFAULT_TOUCHPAD_SENSITIVITY_SETTING (0)
72#define HAVE_SCROLLWHEEL
73/* #define HAVE_WHEEL_ACCELERATION */
74/* #define WHEEL_ACCELERATION */
75/* #define WHEEL_ACCEL_START */
76
77/* Storage defines */
78#define CONFIG_STORAGE STORAGE_SD
79#define HAVE_HOTSWAP
80#define HAVE_HOTSWAP_STORAGE_AS_MAIN
81#define HAVE_MULTIDRIVE
82#define NUM_DRIVES 1
83#define STORAGE_WANTS_ALIGN
84#define STORAGE_NEEDS_BOUNCE_BUFFER
85
86/* RTC settings */
87#define CONFIG_RTC RTC_X1000
88/* TODO: implement HAVE_RTC_ALARM */
89
90/* Power management */
91#define HAVE_AXP173
92#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
93#define CONFIG_CHARGING CHARGING_MONITOR
94#define HAVE_SW_POWEROFF
95#define HAVE_POWEROFF_WHILE_CHARGING
96
97/* Only one battery type */
98#define BATTERY_CAPACITY_DEFAULT 1100
99#define BATTERY_CAPACITY_MIN 1100
100#define BATTERY_CAPACITY_MAX 1100
101#define BATTERY_CAPACITY_INC 0
102#define BATTERY_TYPES_COUNT 1
103
104/* USB is still TODO. */
105#define USB_NONE
106
107/* Rockbox capabilities */
108#define HAVE_FAT16SUPPORT
109#define HAVE_ALBUMART
110#define HAVE_BMP_SCALING
111#define HAVE_JPEG
112#define HAVE_TAGCACHE
113#define HAVE_VOLUME_IN_LIST
114#define HAVE_QUICKSCREEN
115#define HAVE_HOTKEY
116#define AB_REPEAT_ENABLE
diff --git a/firmware/export/installer.h b/firmware/export/installer.h
new file mode 100644
index 0000000000..802798618d
--- /dev/null
+++ b/firmware/export/installer.h
@@ -0,0 +1,31 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2021 Aidan MacDonald
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#ifndef _INSTALLER_H_
23#define _INSTALLER_H_
24
25/* Provisional interface for installing/dumping a bootloader */
26
27extern int install_bootloader(const char* path);
28extern int dump_bootloader(const char* path);
29extern const char* installer_strerror(int rc);
30
31#endif /* _INSTALLER_H_ */