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
32 unsigned int reg_shift = 0;32 unsigned int reg_shift = 0;
33 int pio_mode = 0;33 int pio_mode = 0;
34 int pio_mask;34 int pio_mask;
35 bool use16bit;
35 36
36 ret = of_address_to_resource(dn, 0, &io_res);37 ret = of_address_to_resource(dn, 0, &io_res);
37 if (ret) {38 if (ret) {
@@ -60,11 +61,14 @@ static int pata_of_platform_probe(struct platform_device *ofdev) · 22 unmodified lines
60 dev_info(&ofdev->dev, "pio-mode unspecified, assuming PIO0\n");61 dev_info(&ofdev->dev, "pio-mode unspecified, assuming PIO0\n");
61 }62 }
62 63
64 use16bit = of_property_read_bool(dn, "ata-generic,use16bit");
65
63 pio_mask = 1 << pio_mode;66 pio_mask = 1 << pio_mode;
64 pio_mask |= (1 << pio_mode) - 1;67 pio_mask |= (1 << pio_mode) - 1;
65 68
66 return __pata_platform_probe(&ofdev->dev, &io_res, &ctl_res, irq_res,69 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);
68}72}
69 73
70static const struct of_device_id pata_of_platform_match[] = {74static 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
47 ATA_PIO_SHT(DRV_NAME),47 ATA_PIO_SHT(DRV_NAME),
48};48};
49 49
50static 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
57static void pata_platform_setup_port(struct ata_ioports *ioaddr,50static void pata_platform_setup_port(struct ata_ioports *ioaddr,
58 unsigned int shift)51 unsigned int shift)
59{52{
@@ -79,6 +72,7 @@ static void pata_platform_setup_port(struct ata_ioports *ioaddr, · 19 unmodified lines
79 * @ioport_shift: I/O port shift72 * @ioport_shift: I/O port shift
80 * @__pio_mask: PIO mask73 * @__pio_mask: PIO mask
81 * @sht: scsi_host_template to use when registering74 * @sht: scsi_host_template to use when registering
75 * @use16bit: Flag to indicate 16-bit IO instead of 32-bit
82 *76 *
83 * Register a platform bus IDE interface. Such interfaces are PIO and we77 * Register a platform bus IDE interface. Such interfaces are PIO and we
84 * assume do not support IRQ sharing.78 * assume do not support IRQ sharing.
@@ -101,7 +95,7 @@ static void pata_platform_setup_port(struct ata_ioports *ioaddr, · 16 unmodified lines
101int __pata_platform_probe(struct device *dev, struct resource *io_res,95int __pata_platform_probe(struct device *dev, struct resource *io_res,
102 struct resource *ctl_res, struct resource *irq_res,96 struct resource *ctl_res, struct resource *irq_res,
103 unsigned int ioport_shift, int __pio_mask,97 unsigned int ioport_shift, int __pio_mask,
104 struct scsi_host_template *sht)98 struct scsi_host_template *sht, bool use16bit)
105{99{
106 struct ata_host *host;100 struct ata_host *host;
107 struct ata_port *ap;101 struct ata_port *ap;
@@ -131,7 +125,15 @@ int __pata_platform_probe(struct device *dev, struct resource *io_res, · 23 unmodified lines
131 return -ENOMEM;125 return -ENOMEM;
132 ap = host->ports[0];126 ap = host->ports[0];
133 127
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
135 ap->pio_mask = __pio_mask;137 ap->pio_mask = __pio_mask;
136 ap->flags |= ATA_FLAG_SLAVE_POSS;138 ap->flags |= ATA_FLAG_SLAVE_POSS;
137 139
@@ -218,7 +220,7 @@ static int pata_platform_probe(struct platform_device *pdev) · 80 unmodified lines
218 220
219 return __pata_platform_probe(&pdev->dev, io_res, ctl_res, irq_res,221 return __pata_platform_probe(&pdev->dev, io_res, ctl_res, irq_res,
220 pp_info ? pp_info->ioport_shift : 0,222 pp_info ? pp_info->ioport_shift : 0,
221 pio_mask, &pata_platform_sht);223 pio_mask, &pata_platform_sht, false);
222}224}
223 225
224static struct platform_driver pata_platform_driver = {226static 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
19 struct resource *irq_res,19 struct resource *irq_res,
20 unsigned int ioport_shift,20 unsigned int ioport_shift,
21 int __pio_mask,21 int __pio_mask,
22 struct scsi_host_template *sht);22 struct scsi_host_template *sht,
23 bool use16bit);
23 24
24/*25/*
25 * Marvell SATA private data26 * 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