Commit graph

11914 commits

Author SHA1 Message Date
Vencislav Atanasov
4d632a1774 S5L8702: Move IM3 sign/crypt functions from norboot to crypto
Also adds support for IM3 functions and SHA-1 on S5L8720.

Tested on ipod6g (normal and bootloader builds)

This is a part of the large iPod Nano 3G and iPod Nano 4G support patch.

Credit: Cástor Muñoz <cmvidal@gmail.com>
Change-Id: Ic5e6f5a3321d4b1ec4efd753a4c30e29d83fd7c2
2024-12-11 00:04:26 +02:00
Vencislav Atanasov
68c51456ff Switch S5L8702 I2C to ECLK, add I2C support for S5L8720
Tested on ipod6g (normal and bootloader builds)

This is a part of the large iPod Nano 3G and iPod Nano 4G support patch.

Credit: Cástor Muñoz <cmvidal@gmail.com>
Change-Id: I7c21ce2ecb6f94c0b8af4b7b16b3b77c39c6a0a4
2024-12-10 20:24:14 +02:00
Vencislav Atanasov
ca5f12ae58 S5L8702, S5L8720: Merge syscon_preinit() and miu_preinit() between SoC models
No difference in the produced binaries for ipodnano2g and ipod6g (normal and bootloader)

This is a part of the large iPod Nano 3G and iPod Nano 4G support patch.

Credit: Cástor Muñoz <cmvidal@gmail.com>
Change-Id: Ia6a2d2b220d36a56f81fc7c8d05f7c025e2ee766
2024-12-10 12:34:30 -05:00
Solomon Peachy
29e909c25d SDL: Log the version detected
* At build time (in configure script)
 * At runtime (but only for simulator builds)

Change-Id: I01c6f0f39d4c68e3a5a037212b65baf693bb84a9
2024-12-10 09:01:32 -05:00
Solomon Peachy
da3d658880 SDL: Work around build problems with SDL2 < 2.0.6
SDL_AUDIO_ALLOW_SAMPLES_CHANGE was added in 2.0.6, just
ignore it if we're compiling against an old version

Change-Id: Ia317fe9780b9e39b9fa1f882ada845011d4e8e60
2024-12-09 23:35:09 -05:00
Solomon Peachy
d483281fea SDL: Allow SDL_OpenAudioDevice() to override sample count
Change-Id: I4de40a2a168b98e6cc783e4a636903fd88028af4
2024-12-09 21:15:53 -05:00
Solomon Peachy
65d94ecd08 SDL: Allow the audio device used to be specified on the command line
To aid this we display the list of allowed drivers and devices at startup

Change-Id: If27fc2c4873b56cd220a3e3e1ad78e9ede1979e7
2024-12-09 21:06:51 -05:00
Solomon Peachy
b3dac27aa6 SDL: Convert to SDL2's AudioDevice() API
This lets us _demand_ a sane audio configuration that doesn't require
us to convert sample formats.

(Windows always seems to want us to supply 32-bit floating point)

Change-Id: I19113363b33ae99be33afceec50a319c182e9b29
2024-12-09 20:34:21 -05:00
Vencislav Atanasov
f48d1aeb27 S5L8702, S5L8720: Add VIC init, prepare for iPod Nano 3G and iPod Nano 4G
Tested on ipod6g (normal and bootloader builds)

This is a part of the large iPod Nano 3G and iPod Nano 4G support patch.

Credit: Cástor Muñoz <cmvidal@gmail.com>
Change-Id: I712c1b0cf2d595b1b78caf1d86ce298017dfe7e5
2024-12-08 17:35:31 -05:00
Christian Soffke
53b1bc020b hosted sdl: remove SDL_BUTTON_WHEELDOWN, SDL_BUTTON_WHEELUP
Appears to have been overlooked in the SDL2 migration

Change-Id: I1a98b409838b7c3e24beb81d1f17e2470a895c2c
2024-12-07 21:42:13 +01:00
Solomon Peachy
a76ecf1725 erosqnative: Fix operation in a simulator environment
Real hardware needs 24-bit PCM data supplied, but simulator
is still 16bit only.

Change-Id: I20b88a7cb27105829fe5c9e9c434f559a6dbbb60
2024-12-07 14:05:23 -05:00
Solomon Peachy
3b78daed14 simulator: Fix "ErosQ Native" (247) simulator build.
Change-Id: I74d1bafd9c6dbab976aabd6a44d683fb9eb3edaf
2024-12-07 13:43:36 -05:00
Dana Conrad
5ed0db6e90 erosqnative: Repurpose stereosw_select setting for output select
Turns out they did not swap the stereo switch lines on us,
so this setting isn't really useful. Repurpose it to allow
the user to force the device into headphone or line output mode.

Note that settings other than "Automatic" will cause jack detection
to not work.

Default Automatic.

Change-Id: If94499fbb8f0d92111811fe51f6107ce213b66ad
2024-12-07 09:20:40 -05:00
Vencislav Atanasov
a29b570ac4 S5L8702: Rename nor-* to norboot-*
Since the SPI NOR flash is only used for the bootloader, rename the files accordingly, This is a preparation for the nandboot driver will be introduced, since S5L8720+ don't have an SPI NOR flash anymore.

This is a part of the large iPod Nano 4G and iPod Touch 2G support patch.

Credit: Cástor Muñoz <cmvidal@gmail.com>
Change-Id: Iea835fd2029470bfe9f813631ad4f3db711facc3
2024-12-07 00:56:06 +02:00
Vencislav Atanasov
2669548bcd S5L8720: Add support for Timers, SPI, CPUFREQ and USB
This also includes a small SPI driver rework for ipod6g. Only the NOR flash currently uses SPI. Tested on target using View SysCfg in Debug menu.

This is a part of the large iPod Nano 4G and iPod Touch 2G support patch.

Credit: Cástor Muñoz <cmvidal@gmail.com>
Change-Id: If2b91c1088034dd606abc6dd0b6ad73dea0152a4
2024-12-06 23:59:27 +02:00
Vencislav Atanasov
b240f01059 S5L8720: Add support for TTB and MMU
This is a part of the large iPod Nano 4G and iPod Touch 2G support patch.

Credit: Cástor Muñoz <cmvidal@gmail.com>
Change-Id: Ica1e2b8e82ea162ebab01cf119f5da2f8877bc05
2024-12-06 22:00:04 +02:00
Dana Conrad
adbd0125fd erosqnative hw1/hw2: Check for DAC in bootloader
Check for the ES9018K2M dac in the bootloader for
hw1/hw2 devices. Assume that all devices newer than
hw2 have ES9018K2M DAC unconditionally.

All devices will now report the correct hw revision
in the debug menu under Device Data.

Add devicedata.version field, current version 0.

Rename device_data.lcd_version to device_data.hw_rev.

hw2 devices with older bootloaders which ID as hw1 are special-
cased to keep using hwvol on them. They should still upgrade though.

Change-Id: If0fd5ce3bc6e85e511047721ec18e42fb89312e7
2024-12-06 11:39:24 -05:00
Christian Soffke
f1010005b0 Fix simulator crashing on MacOS
Event handling must happen on the main
thread for MacOS.

Not sure if button_queue_wait is the
best place for doing the SDL event
polling, but seems to work ok.

Change-Id: If928282df84bdd74e24a48afd7dbc4c4bfcc49e2
2024-12-01 20:18:11 -05:00
Christian Soffke
1745b74576 Make simulator compile on MacOS
Tested on MacOS Sequoia (Apple Silicon) with the
latest Xcode command line tools, gcc 14
(Homebrew GCC 14.2.0_1) and sdl2 (Homebrew 2.30.9)

Make sure 'gcc' (and 'gcc-ar') is in your PATH
ahead of the Xcode-provided "gcc"(clang). E.g.
by setting up symlinks in /usr/local/bin that
point to gcc-14 and gcc-ar-14.

Notes:
- The appropriate bmp from uisimulator/bitmaps
  has to be manually copied to your build folder
  and renamed to UI256.bmp, if you want the sim
  background to be displayed

Change-Id: I559f33d2165065f913f30c016b85906af380fb81
2024-11-30 22:19:02 -05:00
William Wilgus
afb0e845cf strcasestr smaller function for PREFER_SIZE_OVER_SPEED
tester script:
https://onlinegdb.com/TbILrA5E7

Change-Id: Ie5a37db13500510e30e87a20782f13adfe2b4d78
2024-11-28 15:07:55 -05:00
Vencislav Atanasov
12aea7dae6 s5l87xx: Add support for S5L8720 to the GPIO driver
This is a part of the large iPod Nano 3G/4G support patch.

Credit: Cástor Muñoz <cmvidal@gmail.com>
Change-Id: I577eef01f42e8752ad9b2ee64e2b30ad0a9e55be
2024-11-27 21:06:30 -05:00
William Wilgus
da9d67a0fe Button queue handling is split from main button driver
First half of
https://gerrit.rockbox.org/r/c/rockbox/+/570

Change-Id: Icc64dfd8194c18f69564ed5f8bf7dd70a4330eb9
2024-11-27 20:16:53 -05:00
William Wilgus
cb478d9d3f add INIT_ATTR to dircache_load and core_load_key_remap
both of these are only called in main at init

Change-Id: If2020c2832df837aca23a331474bbf2352d803d4
2024-11-26 22:13:43 -05:00
Vencislav Atanasov
9b4bab7e0a ipod6g: Move pmu_is_hibernated() from bootloader to PMU driver, misc fixes
Added better comments about the PMU registers, added pmu_set_cpu_voltage() (still unused).

Credit: Cástor Muñoz <cmvidal@gmail.com>
Change-Id: I0ca21a49ece007c913c1b199952009e4dcae80e5
2024-11-26 20:15:25 -05:00
Vencislav Atanasov
88a1d90236 s5l87xx: Add S5L8720 registers
This adds some confirmed and some to-be-confirmed (TBC) registers for Samsung S5L8720, which is used in iPod Nano 4G, iPod Touch 2G and the 920-0614-03 development/prototype board.

All credit goes to Cástor Muñoz <cmvidal@gmail.com>

Change-Id: I9fe5052fe9f05cd33f34de4e228cdb291944aa11
2024-11-26 19:04:12 -05:00
Solomon Peachy
6231407df7 fat: MAX_VIRT_SETOR_SIZE -> MAX_VIRT_SECTOR_SIZE
Change-Id: I18d7998e0f23cbe9b95f5e8c90214975ae03a10e
2024-11-26 09:00:58 -05:00
Solomon Peachy
dfbbfb12d4 storage: Misc corrections and cleanups
* Make the partial sector logic a little clearer (no functional change)
 * Corrections for debugging messages
 * Also use MAX_VIRT_SECTOR_SIZE in BOUNCE_BUFFER calculations

Change-Id: I89363824b092b2e3bddd5e0f75bf81200c9bc513
2024-11-26 08:37:55 -05:00
Solomon Peachy
127b583a4d ipod6g: Turn on STORAGE_NEEDS_BOUNCE_BUFFER
The s5l8702's ATA controller can only DMA in/out of cacheline-
aligned buffers.  The more general buffering code already ensures
its buffers are aligned, but this covers the rest of the
users of the general I/O path.

Change-Id: Iae54d98797efb61756cb73e3901308775a0c5e52
2024-11-26 08:20:02 -05:00
Solomon Peachy
b8d2ba3fc4 fat: Ensure bounce buffer is a multiple of MAX_PHYS_SECTOR_SIZE
* if MAX_VARIABLE_LOG_SECTOR is defined, use that
 * if MAX_PHYS_SECTOR_SIZE is defined, use that
 * use SECTOR_SIZE

Change-Id: Ia314f590fdb300e99df2c60587657c9563b9ce80
2024-11-26 08:20:02 -05:00
Solomon Peachy
87e55baaad ata: Use a better default for SET_MULTIPLE_MODE
* If the device returns a valid upper limit (word 47) use that.
 * If the current limit (word 59) is valid, use that.
 * Fall back to 1 as a default, not 16!

Note this is only used for PIO transfers!

Change-Id: I269b751466242bbcce91ee991d9ade449cc84b6b
2024-11-24 23:26:09 -05:00
Vencislav Atanasov
375a6bc9b1 s5l87xx: Use pointer arithmetic in register address calculation
This allows to reuse a register definition across similar SoCs that have the same layout of registers (same offsets), but are using a different base address for the peripheral. The include guard was also fixed to reflect the new file name of the header.

Some registers were renamed in order to match the datasheet and for consistency with the other register numbering.

Change-Id: I0192e227a3c467504b8fcd1eb684a7fc861f7896
2024-11-24 20:02:44 -05:00
Vencislav Atanasov
9e2c85e076 Merge s5l8700.h and s5l8702.h into s5l87xx.h
This is part of the preparation to add support for iPod Nano 3G and Nano 4G. There are some optimisations left, like merging similar blocks of registers that share the same layout, but the base address have changed between SoC generations.

Change-Id: I4f06727b4061977141b65d39ae19591bd5b29680
2024-11-24 15:56:23 +02:00
Vencislav Atanasov
7fcc6a34a5 Unify S5L87xx register definitions
This is a preparation for merging both files to a new header named s5l87xx.h. Also removed unused register types.

Change-Id: I6aa231064d6a7c734aa297e68b899d6988a88bdc
2024-11-24 15:56:23 +02:00
Solomon Peachy
0624e265ab build: Various LTO fixes
* Give arm panicf_f() USED_ATTR
 * Ensure start_thread() has USED_ATTR

Change-Id: I6a833be7fbe25410c21e0df233fcae91e451bf00
2024-11-24 08:43:23 -05:00
Solomon Peachy
bdf1690cb2 build: Allow LTO to work globally, not just codecs/plugins
IMPORTANT: There is no guarantee this will compile cleanly much less
_work_ on any given target.  This is purely to enable future hackery.

Change-Id: Ib58f21b717719fd4325622b446a60779406ae035
2024-11-24 08:23:38 -05:00
Solomon Peachy
7ea64a315b Revert "storage: Disk Cache buffer size may need to be larger than SECTOR_SIZE"
This reverts commit dcec6828a3.

This did not solve the reported problem, and it turns out that the original
code did the right thing with respect to the device's logical sector size.

Change-Id: I5bed2520ba8f5ca01df0ddd71588d3ed69c1d77c
2024-11-24 00:57:57 -05:00
Solomon Peachy
dcec6828a3 storage: Disk Cache buffer size may need to be larger than SECTOR_SIZE
The file I/O code operates in terms of the FILESYSTEM sector size, which
may be much larger than the underlying device's logical sector size. So
the disk cache buffers need to be the the larger of:

 * Max allowed filesystem sector size (MAX_VIRT_SECTOR_SIZE) (if defined)
 * Max allowed logical sector size (MAX_VARIABLE_LOG_SECTOR) (if defined)
 * Fixed logical size (SECTOR_SIZE)

Change-Id: Ica0ec36d113406f24c12c696317a8d3520e7852c
2024-11-24 00:00:04 -05:00
Solomon Peachy
7df324b819 sdmmc: the tCardInfo.initialized field needs to be an integer, not bool
Some drivers (Notably the PP SD driver) uses negative values to indicate
errors.

Change-Id: I9dbb065cbe90a62cde8a1d89bf6b450f40721790
2024-11-23 23:07:12 -05:00
Solomon Peachy
21ebfd574a fix more red in hosted targets that don't share the generic system implementation
Change-Id: I38f59005e75fb7326e655f22bbe63048f31573a3
2024-11-23 21:20:17 -05:00
Solomon Peachy
57cd8cd712 fix warnings and errors in a41a001258
* volume_partition() wasn't defined for hosted targets
 * wrap the "special" volume stuff in HAVE_MULTIDRIVE

Change-Id: Icbea256ab6438e1f7e45d361ed61724feec7ef0b
2024-11-23 20:59:32 -05:00
Vencislav Atanasov
1535a42b68 Add include guard to s5l8700.h
Change-Id: I246a626c788bc0173cb7709fb5b004bdaac97883
2024-11-23 17:19:18 -05:00
Vencislav Atanasov
f4bbddb044 ipod6g: Fix config
- NOR flash size is 1MB, not 10MB
- BOOTFILE_EXT2 is not used, the Rockbox binary is always unencrypted on iPod 6G. This looks like a leftover from ipodnano2g config

Change-Id: Iea76c1e87f27e25b3d59924ef02e22d91448e39d
2024-11-23 17:19:18 -05:00
Dana Conrad
253eb79db3 erosqnative: hw4 support
Support hw4 units with AXP2101 PMU

Bootloader successfully compiles and loads onto device.
The LCD appears to be identical to hw3 units.
Scroll wheel and buttons work
Audio output works, including volume.
HP/LO detect works
Rockbox build is generic
GPIO gating logic seems to be working as intended now.

 - Added new GPIO definitions - some significant overlaps with pins
    from previous hardware revisions...
 - Added some GPIO definitions for older players we didn't know about
 - Add register definitions for AXP2101 from datasheet
    (these are very different from AXP192!)
 - Add AXP2101 regulator definitions, need to support multiple step
    sizes per regulator.
 - Verify AXP2101 voltage set multi-range logic
 - Verify AXP2101 voltage get multi-range logic
 - Make AXP2101 its own driver
 - AXP2101 driver should be "minimally viable", though I think
    there is some extra functionality that could be implemented.
 - Disabling the coulomb counter stuff - we could maybe make
   the E-Gauge work for the same purpose, but it only appears to
   be used on the debug screen at the moment so it doesn't seem
   like it's worth the effort.
 - Found new button GPIOs
 - Found error in my GPIO setting logic, blue light works now!
 - Set LDO/DCDC output voltages to OF's settings, as far as
   I can tell.
 - Determined we probably want TCS1421_CFG1:0 to be 0x00,
   for UFP behavior
 - Tested this rb build with both old and new bootloaders on hw1.5,
   hw2, hw4 in as many configurations as I can think of, works across
   the board.
 - Bootloader can install itself on hw4, so nand chip isn't novel
 - Uninstallation file can be made by patcher script, works on hw4
 - Installation file can be made by patcher script, works on hw4
 - Added HW4 to rbutil, manual

Change-Id: I5b75782273e81c2c6f2b9c79501c8b7cbf88391f
2024-11-22 17:01:39 -05:00
Vencislav Atanasov
d7b57e33d9 Add support for S5L8720 in various places
Due to its similarity with S5L8702, clickwheel support and sleep can be used as-is on S5L8720. DRAM and IRAM are also configured.

Change-Id: I52f8a3417e6a25c7360b1cae2fb5eed621e2e0db
2024-11-22 16:45:29 -05:00
Vencislav Atanasov
fb134c9533 Rename UC870x to UC87xx
This is a driver for the UART controller on the S5L87xx series of SoCs, which is named after the SoC family.
Since S5L8720 is confirmed to have the same interface and the newer models probably also have it, the driver is renamed to reflect this.

Change-Id: I974c002924372e860db0e49235d108dab87f8831
2024-11-21 20:07:50 -05:00
Vencislav Atanasov
39f8101d60 Enable UC870x "auto baud" and "fine tune" features based on the SoC capabilities
This makes it easier to add support for the remaining SoCs of the S5L87xx series.

Change-Id: I563aa55eed385b5f8e1c52edb866b08176ea116e
2024-11-21 20:05:18 -05:00
Vencislav Atanasov
1c7fddad5b Add the remaining iPod Nano SoCs to config
Currently only S5L8701 (Nano 2G) and S5L8702 (Classic/6G, Nano 3G) are defined. This change adds the remaining to CONFIG_CPU, as a preparation for porting to these platforms. It also defines the RTC types for Nano 3G and Nano 4G.

New CONFIG_CPU options:
S5L8720 - iPod Nano 4G
S5L8730 - iPod Nano 5G
S5L8723 - iPod Nano 6G
S5L8760 - iPod Nano 7G

Change-Id: I4e9e00163c0d0d5a5303f9eee428f9be47a48359
2024-11-21 20:03:32 -05:00
Vencislav Atanasov
f040c4c9ec Rename CPU_S5L870X to CPU_S5L87XX
This is a preparation to introduce support for the following SoC models: S5L8720 (iPod Nano 4G, iPod Touch 2G), S5L8730 (iPod Nano 5G), S5L8723 (iPod Nano 6G) and S5L8740 (iPod Nano 7G)

The whole family consists of SoCs which are similar, running ARMv6 and Thumb2 instructions, but some peripherals are located at a different address.

No functional change is to be expected so far.

Change-Id: If1f7669c49cf110ccc52c5234cc42ffd6f2b4e80
2024-11-20 10:58:32 -05:00
Solomon Peachy
9bf033dd66 ata: Prefer using "virtual" sector size where possible
Normally, if a device uses larger physical sector size than the logical
size and supports so-called "512e" mode, we let the device deal with
partial sector reads/writes.

However, if MAX_VIRT_SECTOR_SIZE is defined, we support
partitioning/filesystems that use a larger "virtual" sector than the
logical sector.  typically this matches the physical sector size of the
drive, which means that despite a small logical sector size, all I/O
is done in terms of the physical sector size.

Therefore, when MAX_VIRT_SECTOR_SIZE and MAX_PHYS_SECTOR_SIZE are
enabled (currently only ipod5g and ipod6g), prefer software-based
partial sector I/O.

Change-Id: I0815ad0a2f987b89bb2debfbf3d0ed64cdf85525
2024-11-15 07:24:08 -05:00
Solomon Peachy
120906dc8b ata: Ensure that the bounce buffer is minimum 32-bit aligned
Basically, if STORAGE_ALIGN_ATTR isn't defined, define it to be
sizeof(uint32_t) in the ATA code.

Change-Id: I13de61788cb71e3e8d3a956ab5f2e251471ce76d
2024-11-15 07:24:08 -05:00