Commit graph

22 commits

Author SHA1 Message Date
Solomon Peachy
c307fd5525 ata: Parameterize the SMART query, add support to primary ATA driver
There are numerous sub-commands, this makes it possible to call the others.

Also in this patch is the ability for the "default" ATA driver to
query smart data too

Change-Id: Ie3aaf9e0b2d7a5d25d09dea34e4f10ee29047e1b
2025-09-16 09:52:05 -04:00
Aidan MacDonald
4d3190f416 arm: split ARM cache maintenance functions to separate header
Cortex-M processors don't have an MMU, but can still have caches
that need software management, so on those platforms we don't want
to include the MMU related functions.

While here, remove an outdated section of a comment referring to
deprecated cache maintenance functions which no longer exist.

Change-Id: I6f0fe694560bdee25ed7c69a846bf46e3e544cb1
2025-04-21 12:39:47 -04:00
Solomon Peachy
0a2a90c182 FS#13560: ATA: Don't check for 80 pin cables on SATA devices.
On PATA, we'd cap our transers at UDMA2 if the device reported that an
80 pin cable wasn't detected, but SATA devices do not perform this test.

So alter the check to only apply on PATA devices, so that SATA devices
can run at full UDMA speeds.

Change-Id: Id7aa25f2a702c0af73d707395439d69da1e04719
2025-02-10 09:23:11 -05:00
Vencislav Atanasov
eb57d42879 S5L8702: Move I/O addresses from drivers to SoC definitions
No changes to ipod6g binaries (normal + bootloader).

Change-Id: Iaad0d0de16176ff94b1f67aa3fdb7c6cc063b27e
2024-12-14 07:57:53 -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
Solomon Peachy
044ba60bcf ATA: Add some more logf debugging
Change-Id: If1f919c43d02a974e478018750c60e3619db1505
2024-11-12 08:11:18 -05:00
Solomon Peachy
3d1dcebebb ipod6g: Wrap more DMA functionality with HAVE_ATA_DMA
No functional change.

We always have it turned in for ipod6g, but this makes some of the
flow/logic easier to follow.

Change-Id: I3abeace4f70afb197e819e0944e0e76f4edc4800
2024-11-12 08:11:18 -05:00
Solomon Peachy
3664d382e0 ata: if drive doesn't advertise a nonstandard sector size, default to 512
...Instead of SECTOR_SIZE, which might be different.  This way
we can properly validate the value.

Change-Id: I8e6ae5882792f301ac580a144556af94772f4cfe
2024-11-07 18:15:26 -05:00
Solomon Peachy
e29ddfb6be ata: Support for ATA logical sector sizes > 512B
Basically this requires un-hardcoding SECTOR_SIZE everywhere, in
favor of using a variable containing what was reported in IDENTIFY INFO.

Note that the rest of the storage subsystem still needs to be fixed up!

Change-Id: I7f2dbd54ff2bc16b15010721e011949cbf308e12
2024-11-07 07:48:17 -05:00
Solomon Peachy
2824bd5f16 ipod6g: Support MAX_PHYS_SECTOR_SIZE of 4K
This lets us *natively* handle varying physical sector sizes
without playing games and lying about the logical sector size.

(The original drives use 4K _physical_ sectors with 512B logical
 sectors, but you have to access everything in 4K blocks...)

Achieve this by splitting the MAX_PHYS_SECTOR_SIZE code out
of the main ATA driver and re-using it.

Change-Id: I0bc615ab4562f1e3e83171a8633c74fb60c7da1f
2024-11-04 07:33:26 -05:00
Solomon Peachy
0a11b06d93 ata: Correct parsing of the logical sector size in the IDENTIFY DEVICE
....It's specified in 16-bit words, not bytes.  So multiply it by 2.

(This hasn't been a problem in practice as everything uses 512B logical
 sectors so far..)

Change-Id: I0b1abd0f6184330f0b7f5c000c5ad547038f7c95
2024-10-31 21:51:42 -04:00
Solomon Peachy
e829ea9a5e ata: Rework how flushing, sleeping, and power off interacts
* FLUSH_EXT is used if featureflag is set and we are using LBA48
   (unconditionally used for CE-ATA on ipod6g)
 * FLUSH is used if featureflag is set (ATA6+) or if device claims to be ATA5+

 * Rename ata_disk_can_power_off() to ata_disk_can_sleep() as that is
   what it actually tests for.  Only use it to gate issuing the
   STANDBY IMMEDIATE command.
 * Restore behavior of ata_disk_is_active() to return 1 if drive is
   "spinning" or powered up.
 * Allow poweroff if drive claims PM support OR we are able to issue
   FLUSH/FLUSH_EXT commands.

 * Added ata_flush() to explicitly trigger a flush operation, and hook it
   up to storage_flush() in the device shutdown path. (Flushes were
   only previously used in the storage device power management path)

 * After issuing all settings, re-issue IDENTIFY_DEVICE to make sure
   it reflects everything we've enabled.

 * Update manual section on Flash/SSD mods.

Change-Id: I6770a54ef3a87f4c47120bcb96c944a6652f1bf4
2024-10-31 12:51:54 -04:00
Solomon Peachy
3951fbf9d2 ATA: Restrict to UDMA2 if we don't detect an "80-pin" cable
Change-Id: I55861065741f3365491445f1f3f5b0041f33e1c6
2024-10-26 15:09:10 -04:00
Solomon Peachy
563da70139 ipod6g: Reworking the bespoke ATA driver
ipod6g was configured with SECTOR_SIZE of 4096, but this ATA driver
unconditionally translated these to 512B operations on the actual
storage device.

Rockbox's storage layer already has robust support for "logical sectors
larger than physical storage sectors" through use of
MAX_LOG_SECTOR_SIZE.  So switch to that mechanism, allowing the ipod6g
ATA driver to be simplified.

If we want to support drives with physical sector sizes > 512B, then
we need to port the MAX_PHYS_SECTOR_SIZE logic from the primary ATA driver.

Additional changes:

 * Simplify MWDMA/UDMA selection logic
 * Report CE-ATA mode in debug menu
 * Use LBA48 commands only if drive is over 128GiB.
 * Drop default sleep/poweroff time from 20s to 7s (matching main ATA driver)

Finally, the bulk of the changes are the first phase of a badly needed
style cleanup that made reading this driver a lot harder than it should
be. I intend to split this into a separate patch.

Change-Id: I2feca9fd319c8d6cfb3c2610208970428d2fa947
2024-10-17 20:30:37 -04:00
Solomon Peachy
e0df9952fd ata: Alter ata_is_active() when drive doesn't support power management
Due to the heisenberg principle, we don't want to check the battery
level when the ATA drive is "spun up".

Unfortunately some ATA devices *cough most SD adapters cough* don't
support mandatory ATA power management commands like flushing caches and
(safely) shutting down so we have to leave them "spinning".

This leads to us never updating our battery status with these
out-of-spec devices.  Work around this issue by having is_active() always
return false if that's what we have.

Change-Id: I629f3fdbc7e5cffb0a4d546c80cb5fca8529c0e6
2024-09-18 08:26:14 -04:00
Solomon Peachy
15e5237469 storage: 64-bit sector offsets
* Create new 'sector_t' type alias:
    * uint64_t for all targets with HAVE_LBA48 or HAVE_SDUC
    * unsigned long for the everything else
 * Alter all storage APIs to use sector_t instead of 'unsigned long'
 * Alter Volume/Partition/storage info structures to use sector_t
 * Disk cache converted to sector_t
 * ATA Core:
    * convert to using sector_t for sector addresses and drive sizes
    * Always fill out upper 16 bits of LBA48 addresses
    * IDENTIFY INFO is fixed at 512 bytes, not SECTOR_SIZE
 * USB mass storage:
    * convert to using sector_t for sector addesses and drive sizes
    * Implement READ_16/WRITE_16 for LBA48 addresses
 * Convert FAT code to use sector_t for all sector references
 * output_dyn_value() now accepts int64_t instead of 'int'
 * Corrected "rockbox info" to work for (MULTIVOLUME & !MULTIDRIVE)
 * Better reporting of disk and (logical+physical) sector sizes in debug info
 * Detect SDUC cards and report on storage debug_info screen

To-do: SDUC

 * Refactor SD core to remove duplicate code in every driver
   * Card probe and init state machine
 * Implement core SDUC support
   * SD2.0 needs to be 2.0+ (fixed for jz47xx and x1000)
   * Host and Card ID (ACMD41)
   * 32-bit addressing for all read/write/erase operations (CMD22)
 * ADD SDUC to target device drivers, defining HAVE_SDUC as appropriate

Change-Id: Ib0138781a0081664d11511037685503df1b93608
2024-08-12 14:23:44 -04:00
Solomon Peachy
aa7357861a ipod6g: Issue a FLUSH_CACHE[_EXT] command if device can't sleep.
Additionally, synchronize with the standard ATA driver's feature table

 * Acoustic management set to quietest
 * Set power mode to lowest w/o standby

Change-Id: I12e64354d4c946228e9a55fc8da2114127d08d28
2024-04-26 07:28:01 -04:00
Solomon Peachy
2905ba2f72 ipod6g: ata: Don't power down devices that can't handle it
...by checking to see if the mandatory ATA PM feature flag is set

The common CF->SD adapters don't report this.

TODO:  When PM is not available, issue a CMD_FLUSH[_EXT] instead?

Change-Id: If9200bd3c03a984376203aeea4fbe11e230a9b4d
2024-04-22 15:47:10 -04:00
Solomon Peachy
00440f2137 ipod6g:: Get rid of magic command numbers in ata driver
Use CMD_* macros instead.  Makes the code a bit easier to follow.

No functional change.

Change-Id: Ieb3d8f6fcca503421d3067aafbd0011a908368e0
2021-06-04 01:03:51 +00:00
Michael Sevakis
1654efc313 Unify storage threads into one
* Editing a bunch of drivers' thread routines in order to
implement a new feature is tedious.

* No matter the number of storage drivers, they share one thread.
No extra threads needed for CONFIG_STORAGE_MULTI.

* Each has an event callback called by the storage thread.

* A default callback is provided to fake sleeping in order to
trigger idle callbacks. It could also do other default processing.
Changes to it will be part of driver code without editing each
one.

* Drivers may sleep and wake as they please as long as they give
a low pulse on their storage bit to ask to go into sleep mode.
Idle callback is called on its behalf and driver immediately put
into sleep mode.

* Drivers may indicate they are to continue receiving events in
USB mode, otherwise they receve nothing until disconnect (they
do receive SYS_USB_DISCONNECTED no matter what).

* Rework a few things to keep the callback implementation sane
and maintainable. ata.c was dreadful with all those bools; make
it a state machine and easier to follow. Remove last_user_activity;
it has no purpose that isn't served by keeping the disk active
through last_disk_activity instead.

* Even-out stack sizes partly because of a lack of a decent place
to define them by driver or SoC or whatever; it doesn't seem too
critical to do that anyway. Many are simply too large while at
least one isn't really adequate. They may be individually
overridden if necessary (figure out where). The thread uses the
greatest size demanded. Newer file code is much more frugal with
stack space. I barely see use crack 50% after idle callbacks
(usually mid-40s). Card insert/eject doesn't demand much.

* No forcing of idle callbacks. If it isn't necessary for one or
more non-disk storage types, it really isn't any more necessary for
disk storage. Besides, it makes the whole thing easier to implement.

Change-Id: Id30c284d82a8af66e47f2cfe104c52cbd8aa7215
2017-10-26 14:35:41 -04:00
Cástor Muñoz
1ba5ef716d ipod6g: rename some target files
As preparation to add new targets to the s5l8702 directory,
rename files as:

s5l8702/ipod6g/*-ipod6g.c -> s5l8702/ipod6g/*-6g.c

Change-Id: I0cd03d6bcf39b2aa198235f9014cb6948bbafcd5
2017-03-03 22:50:38 +01:00
Renamed from firmware/target/arm/s5l8702/ipod6g/storage_ata-ipod6g.c (Browse further)