Skip to content

Commit 8847d42

Browse files
Michael Schmitzdamien-lemoal
authored andcommitted
ata: pata_falcon: add data_swab option to byte-swap disk data
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@sowerbutts.com> Cc: Finn Thain <fthain@linux-m68k.org> Cc: Geert Uytterhoeven <geert@linux-m68k.org> Tested-by: William R Sowerbutts <will@sowerbutts.com> Signed-off-by: Michael Schmitz <schmitzmic@gmail.com> Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru> Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
1 parent 8a1f00b commit 8847d42

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

drivers/ata/pata_falcon.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@
3232
#define DRV_NAME "pata_falcon"
3333
#define DRV_VERSION "0.1.0"
3434

35+
static int pata_falcon_swap_mask;
36+
37+
module_param_named(data_swab, pata_falcon_swap_mask, int, 0444);
38+
MODULE_PARM_DESC(data_swab, "Data byte swap enable/disable bitmap (0x1==drive1, 0x2==drive2, 0x4==drive3, 0x8==drive4, default==0)");
39+
3540
static const struct scsi_host_template pata_falcon_sht = {
3641
ATA_PIO_SHT(DRV_NAME),
3742
};
@@ -49,7 +54,7 @@ static unsigned int pata_falcon_data_xfer(struct ata_queued_cmd *qc,
4954

5055
if (dev->class == ATA_DEV_ATA && cmd &&
5156
!blk_rq_is_passthrough(scsi_cmd_to_rq(cmd)))
52-
swap = 0;
57+
swap = (uintptr_t)ap->private_data & BIT(dev->devno);
5358

5459
/* Transfer multiple of 2 bytes */
5560
if (rw == READ) {
@@ -123,6 +128,7 @@ static int __init pata_falcon_init_one(struct platform_device *pdev)
123128
struct ata_host *host;
124129
struct ata_port *ap;
125130
void __iomem *base, *ctl_base;
131+
int mask_shift = 0; /* Q40 & Falcon default */
126132
int irq = 0, io_offset = 1, reg_shift = 2; /* Falcon defaults */
127133

128134
dev_info(&pdev->dev, "Atari Falcon and Q40/Q60 PATA controller\n");
@@ -193,6 +199,10 @@ static int __init pata_falcon_init_one(struct platform_device *pdev)
193199
ata_port_desc(ap, "cmd %px ctl %px data %px",
194200
base, ctl_base, ap->ioaddr.data_addr);
195201

202+
if (pdev->id > 0)
203+
mask_shift = 2;
204+
ap->private_data = (void *)(uintptr_t)(pata_falcon_swap_mask >> mask_shift);
205+
196206
irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
197207
if (irq_res && irq_res->start > 0) {
198208
irq = irq_res->start;

0 commit comments

Comments
 (0)