Hi Michael, On Fri, Aug 25, 2023 at 3:13 AM Michael Schmitz <schmitzmic@xxxxxxxxx> wrote:
Some users of pata_falcon on Q40 have IDE disks in default IDE little endian byte order, whereas legacy disks use host-native big-endian byte order as on the Atari Falcon. Add module parameter 'data_swab' to allow connecting drives with non-native data byte order. Drives selected by the data_swap bit mask will have their user data byte-swapped to host byte order, i.e. 'pata_falcon.data_swab=2' will byte-swap all user data on drive B, leaving data on drive A in native byte order. On Q40, drives on a second IDE interface may be added to the bit mask as bits 2 and 3. Default setting is no byte swapping, i.e. compatibility with the native Falcon or Q40 operating system disk format. Cc: William R Sowerbutts <will@xxxxxxxxxxxxxx> Cc: Finn Thain <fthain@xxxxxxxxxxxxxx> Cc: Geert Uytterhoeven <geert@xxxxxxxxxxxxxx> Tested-by: William R Sowerbutts <will@xxxxxxxxxxxxxx> Signed-off-by: Michael Schmitz <schmitzmic@xxxxxxxxx> Reviewed-by: Sergey Shtylyov <s.shtylyov@xxxxxx> Reviewed-by: Geert Uytterhoeven <geert@xxxxxxxxxxxxxx> --- Changes since v4: Damien Le Moal: - spell out bitmask shift calculation
Thanks for the update! Sorry to bother you again...
--- a/drivers/ata/pata_falcon.c +++ b/drivers/ata/pata_falcon.c
@@ -124,7 +129,7 @@ static int __init pata_falcon_init_one(struct platform_device *pdev) struct ata_host *host; struct ata_port *ap; void __iomem *base, *ctl_base; - int irq = 0, io_offset = 1, reg_shift = 2; /* Falcon defaults */ + int irq = 0, io_offset = 1, reg_shift = 2, mask_shift; /* Falcon defaults */
The comment does not apply to the mask_shift variable, unless you pre-initialize it to 0...
dev_info(&pdev->dev, "Atari Falcon and Q40/Q60 PATA controller\n"); @@ -194,6 +199,12 @@ static int __init pata_falcon_init_one(struct platform_device *pdev) ata_port_desc(ap, "cmd %px ctl %px data %px", base, ctl_base, ap->ioaddr.data_addr); + if (pdev->id > 0) + mask_shift = 2; + else + mask_shift = 0;
... and drop the else.
+ ap->private_data = (void *)(uintptr_t)(pata_falcon_swap_mask >> mask_shift); + irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); if (irq_res && irq_res->start > 0) { irq = irq_res->start;
Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds