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
This commit is contained in:
Solomon Peachy 2024-10-14 18:09:17 -04:00
parent 9efed5542e
commit 563da70139
5 changed files with 277 additions and 199 deletions

View file

@ -12,7 +12,7 @@
/* define this if you use an ATA controller */
#define CONFIG_STORAGE STORAGE_ATA
#define HAVE_ATA_DMA
#define HAVE_ATA_DMA
#define ATA_MAX_UDMA 4
#define ATA_MAX_MWDMA 2
@ -139,7 +139,7 @@
/* 6g has a standard battery of 550mAh, except for the thick 6g (2007 160gb)
* which has a standard battery of 850mAh.
*
*
* It's possible to buy 3rd party batteries up to 3000mAh.
*/
#define BATTERY_CAPACITY_DEFAULT 550 /* default battery capacity */
@ -189,17 +189,12 @@
/* Define this if you can read an absolute wheel position */
#define HAVE_WHEEL_POSITION
#define SECTOR_SIZE 4096
#define HAVE_ATA_SMART
#define SECTOR_SIZE 512
/* define this if the device has larger sectors when accessed via USB */
/* (only relevant in disk.c, fat.c now always supports large virtual sectors) */
//#define MAX_LOG_SECTOR_SIZE 4096
/* define this if the hard drive uses large physical sectors (ATA-7 feature) */
/* and doesn't handle them in the drive firmware */
//#define MAX_PHYS_SECTOR_SIZE 4096
#define MAX_LOG_SECTOR_SIZE 4096
//#define MAX_PHYS_SECTOR_SIZE 4096 // Only if we have various physical sector sizes
#define HAVE_HARDWARE_CLICK

View file

@ -170,14 +170,6 @@
/* Define this if you have adjustable CPU frequency */
#define HAVE_ADJUSTABLE_CPU_FREQ
/* define this if the device has larger sectors when accessed via USB */
/* (only relevant in disk.c, fat.c now always supports large virtual sectors) */
/* #define MAX_LOG_SECTOR_SIZE 2048 */
/* define this if the hard drive uses large physical sectors (ATA-7 feature) */
/* and doesn't handle them in the drive firmware */
/* #define MAX_PHYS_SECTOR_SIZE 1024 */
#define MI4_FORMAT
#define BOOTFILE_EXT "mi4"
#define BOOTFILE "rockbox." BOOTFILE_EXT
@ -185,9 +177,6 @@
#define ICODE_ATTR_TREMOR_NOT_MDCT
/* DMA is used only for reading on PP502x because although reads are ~8x faster
* writes appear to be ~25% slower.
*/
#ifndef BOOTLOADER
#define HAVE_ATA_DMA
#endif