History

ata: pata_of_platform: Allow to use 16-bit wide data transfer

In some cases, the system bus can be configured for 16-bit mode, in this case using read/write functions for 32-bit values results in two cycles of 16 bits each, which is wrong. This patch adds the devicetree flag to switch the driver to use 16-bit mode for I/O transfers.

Alexander Shiyan committed 7 years ago

Commit f3d5e4f1 parent 740c68a3 files · +19 −12Browse files

Unified · Split

3 files
  1. drivers/ata/pata_of_platform.c +5 −1
  2. drivers/ata/pata_platform.c +12 −10
  3. include/linux/ata_platform.h +2 −1
drivers/ata/pata_of_platform.c+5−1
@@ -32,6 +32,7 @@ static int pata_of_platform_probe(struct platform_device *ofdev) · 31 unmodified lines
3232 unsigned int reg_shift = 0;
3333 int pio_mode = 0;
3434 int pio_mask;
35+ bool use16bit;
3536
3637 ret = of_address_to_resource(dn, 0, &io_res);
3738 if (ret) {
@@ -60,11 +61,14 @@ static int pata_of_platform_probe(struct platform_device *ofdev) · 22 unmodified lines
6061 dev_info(&ofdev->dev, "pio-mode unspecified, assuming PIO0\n");
6162 }
6263
64+ use16bit = of_property_read_bool(dn, "ata-generic,use16bit");
65+
6366 pio_mask = 1 << pio_mode;
6467 pio_mask |= (1 << pio_mode) - 1;
6568
6669 return __pata_platform_probe(&ofdev->dev, &io_res, &ctl_res, irq_res,
67− reg_shift, pio_mask, &pata_platform_sht);
70+ reg_shift, pio_mask, &pata_platform_sht,
71+ use16bit);
6872 }
6973
7074 static const struct of_device_id pata_of_platform_match[] = {
drivers/ata/pata_platform.c+12−10
@@ -47,13 +47,6 @@ static struct scsi_host_template pata_platform_sht = { · 46 unmodified lines
4747 ATA_PIO_SHT(DRV_NAME),
4848 };
4949
50−static struct ata_port_operations pata_platform_port_ops = {
51− .inherits = &ata_sff_port_ops,
52− .sff_data_xfer = ata_sff_data_xfer32,
53− .cable_detect = ata_cable_unknown,
54− .set_mode = pata_platform_set_mode,
55−};
56−
5750 static void pata_platform_setup_port(struct ata_ioports *ioaddr,
5851 unsigned int shift)
5952 {
@@ -79,6 +72,7 @@ static void pata_platform_setup_port(struct ata_ioports *ioaddr, · 19 unmodified lines
7972 * @ioport_shift: I/O port shift
8073 * @__pio_mask: PIO mask
8174 * @sht: scsi_host_template to use when registering
75+ * @use16bit: Flag to indicate 16-bit IO instead of 32-bit
8276 *
8377 * Register a platform bus IDE interface. Such interfaces are PIO and we
8478 * assume do not support IRQ sharing.
@@ -101,7 +95,7 @@ static void pata_platform_setup_port(struct ata_ioports *ioaddr, · 16 unmodified lines
10195 int __pata_platform_probe(struct device *dev, struct resource *io_res,
10296 struct resource *ctl_res, struct resource *irq_res,
10397 unsigned int ioport_shift, int __pio_mask,
104− struct scsi_host_template *sht)
98+ struct scsi_host_template *sht, bool use16bit)
10599 {
106100 struct ata_host *host;
107101 struct ata_port *ap;
@@ -131,7 +125,15 @@ int __pata_platform_probe(struct device *dev, struct resource *io_res, · 23 unmodified lines
131125 return -ENOMEM;
132126 ap = host->ports[0];
133127
134− ap->ops = &pata_platform_port_ops;
128+ ap->ops = devm_kzalloc(dev, sizeof(*ap->ops), GFP_KERNEL);
129+ ap->ops->inherits = &ata_sff_port_ops;
130+ ap->ops->cable_detect = ata_cable_unknown;
131+ ap->ops->set_mode = pata_platform_set_mode;
132+ if (use16bit)
133+ ap->ops->sff_data_xfer = ata_sff_data_xfer;
134+ else
135+ ap->ops->sff_data_xfer = ata_sff_data_xfer32;
136+
135137 ap->pio_mask = __pio_mask;
136138 ap->flags |= ATA_FLAG_SLAVE_POSS;
137139
@@ -218,7 +220,7 @@ static int pata_platform_probe(struct platform_device *pdev) · 80 unmodified lines
218220
219221 return __pata_platform_probe(&pdev->dev, io_res, ctl_res, irq_res,
220222 pp_info ? pp_info->ioport_shift : 0,
221− pio_mask, &pata_platform_sht);
223+ pio_mask, &pata_platform_sht, false);
222224 }
223225
224226 static struct platform_driver pata_platform_driver = {
include/linux/ata_platform.h+2−1
@@ -19,7 +19,8 @@ extern int __pata_platform_probe(struct device *dev, · 18 unmodified lines
1919 struct resource *irq_res,
2020 unsigned int ioport_shift,
2121 int __pio_mask,
22− struct scsi_host_template *sht);
22+ struct scsi_host_template *sht,
23+ bool use16bit);
2324
2425 /*
2526 * Marvell SATA private data

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t