History

Merge tag 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev

Pull libata update from Jeff Garzik: - More ACPI fixes, cleanups - Minor cleanups for sata_highbank, pata_at32, pata_octeon_cf, sata_rcar - pata_legacy: small bug found in opti chipset code (untested fix, due to ancient h/w) - sata_fsl: RX water mark config knob, some h/w needs it - pata_imx: cleanups, DeviceTree support - SCSI<->ATA translator: properly export translator version, not device firmware version * tag 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev: sata_highbank: Rename proc_name to the module name ACPI/libata: Restore libata.noacpi support [libata] acpi: make ata_ap_acpi_handle not block [libata] SCSI: really use SATL version in VPD pata_imx: add devicetree support pata_imx: use void __iomem * for regs pata_imx: cleanup error path pata_imx: Use devm_clk_get sata_rcar: Convert to devm_ioremap_resource() fsl/sata: create a sysfs entry for rx water mark libata-acpi: remove redundent code for power resource handling sata_highbank: make ahci_highbank_pm_ops static pata_octeon_cf: Use resource_size function pata_legacy: bogus clock in opti82c46x_set_piomode() pata_at32: use module_platform_driver_probe()

Linus Torvalds committed 13 years ago

Commit 50528fa2 parents 3ed1c47 2cc114410 files · +140 −85Browse files

Unified · Split

10 files
  1. Documentation/devicetree/bindings/ata/imx-pata.txt +17 −0
  2. drivers/ata/libata-acpi.c +29 −53
  3. drivers/ata/libata-scsi.c +4 −3
  4. drivers/ata/pata_at32.c +1 −12
  5. drivers/ata/pata_imx.c +26 −10
  6. drivers/ata/pata_legacy.c +1 −1
  7. drivers/ata/pata_octeon_cf.c +1 −1
  8. drivers/ata/sata_fsl.c +55 −0
  9. drivers/ata/sata_highbank.c +2 −2
  10. drivers/ata/sata_rcar.c +4 −3
Documentation/devicetree/bindings/ata/imx-pata.txt+17−0
@@ -0,0 +1,17 @@
1+* Freescale i.MX PATA Controller
2+
3+Required properties:
4+- compatible: "fsl,imx27-pata"
5+- reg: Address range of the PATA Controller
6+- interrupts: The interrupt of the PATA Controller
7+- clocks: the clocks for the PATA Controller
8+
9+Example:
10+
11+ pata: pata@83fe0000 {
12+ compatible = "fsl,imx51-pata", "fsl,imx27-pata";
13+ reg = <0x83fe0000 0x4000>;
14+ interrupts = <70>;
15+ clocks = <&clks 161>;
16+ status = "disabled";
17+ };
drivers/ata/libata-acpi.c+29−53
@@ -17,7 +17,6 @@ · 16 unmodified lines
1717 #include <linux/pci.h>
1818 #include <linux/slab.h>
1919 #include <linux/pm_runtime.h>
20−#include <linux/pm_qos.h>
2120 #include <scsi/scsi_device.h>
2221 #include "libata.h"
2322
@@ -61,7 +60,8 @@ acpi_handle ata_ap_acpi_handle(struct ata_port *ap) · 37 unmodified lines
6160 if (ap->flags & ATA_FLAG_ACPI_SATA)
6261 return NULL;
6362
64− return acpi_get_child(DEVICE_ACPI_HANDLE(ap->host->dev), ap->port_no);
63+ return ap->scsi_host ?
64+ DEVICE_ACPI_HANDLE(&ap->scsi_host->shost_gendev) : NULL;
6565 }
6666 EXPORT_SYMBOL(ata_ap_acpi_handle);
6767
@@ -77,7 +77,7 @@ acpi_handle ata_dev_acpi_handle(struct ata_device *dev) · 9 unmodified lines
7777 acpi_integer adr;
7878 struct ata_port *ap = dev->link->ap;
7979
80− if (dev->flags & ATA_DFLAG_ACPI_DISABLED)
80+ if (libata_noacpi || dev->flags & ATA_DFLAG_ACPI_DISABLED)
8181 return NULL;
8282
8383 if (ap->flags & ATA_FLAG_ACPI_SATA) {
@@ -240,28 +240,15 @@ void ata_acpi_dissociate(struct ata_host *host) · 156 unmodified lines
240240 }
241241 }
242242
243−/**
244− * ata_acpi_gtm - execute _GTM
245− * @ap: target ATA port
246− * @gtm: out parameter for _GTM result
247− *
248− * Evaluate _GTM and store the result in @gtm.
249− *
250− * LOCKING:
251− * EH context.
252− *
253− * RETURNS:
254− * 0 on success, -ENOENT if _GTM doesn't exist, -errno on failure.
255− */
256−int ata_acpi_gtm(struct ata_port *ap, struct ata_acpi_gtm *gtm)
243+static int __ata_acpi_gtm(struct ata_port *ap, acpi_handle handle,
244+ struct ata_acpi_gtm *gtm)
257245 {
258246 struct acpi_buffer output = { .length = ACPI_ALLOCATE_BUFFER };
259247 union acpi_object *out_obj;
260248 acpi_status status;
261249 int rc = 0;
262250
263− status = acpi_evaluate_object(ata_ap_acpi_handle(ap), "_GTM", NULL,
264− &output);
251+ status = acpi_evaluate_object(handle, "_GTM", NULL, &output);
265252
266253 rc = -ENOENT;
267254 if (status == AE_NOT_FOUND)
@@ -295,6 +282,27 @@ int ata_acpi_gtm(struct ata_port *ap, struct ata_acpi_gtm *gtm) · 27 unmodified lines
295282 return rc;
296283 }
297284
285+/**
286+ * ata_acpi_gtm - execute _GTM
287+ * @ap: target ATA port
288+ * @gtm: out parameter for _GTM result
289+ *
290+ * Evaluate _GTM and store the result in @gtm.
291+ *
292+ * LOCKING:
293+ * EH context.
294+ *
295+ * RETURNS:
296+ * 0 on success, -ENOENT if _GTM doesn't exist, -errno on failure.
297+ */
298+int ata_acpi_gtm(struct ata_port *ap, struct ata_acpi_gtm *gtm)
299+{
300+ if (ata_ap_acpi_handle(ap))
301+ return __ata_acpi_gtm(ap, ata_ap_acpi_handle(ap), gtm);
302+ else
303+ return -EINVAL;
304+}
305+
298306 EXPORT_SYMBOL_GPL(ata_acpi_gtm);
299307
300308 /**
@@ -1020,38 +1028,6 @@ void ata_acpi_on_disable(struct ata_device *dev) · 719 unmodified lines
10201028 ata_acpi_clear_gtf(dev);
10211029 }
10221030
1023−static void ata_acpi_register_power_resource(struct ata_device *dev)
1024−{
1025− struct scsi_device *sdev = dev->sdev;
1026− acpi_handle handle;
1027−
1028− handle = ata_dev_acpi_handle(dev);
1029− if (handle)
1030− acpi_dev_pm_add_dependent(handle, &sdev->sdev_gendev);
1031−}
1032−
1033−static void ata_acpi_unregister_power_resource(struct ata_device *dev)
1034−{
1035− struct scsi_device *sdev = dev->sdev;
1036− acpi_handle handle;
1037−
1038− handle = ata_dev_acpi_handle(dev);
1039− if (handle)
1040− acpi_dev_pm_remove_dependent(handle, &sdev->sdev_gendev);
1041−}
1042−
1043−void ata_acpi_bind(struct ata_device *dev)
1044−{
1045− ata_acpi_register_power_resource(dev);
1046− if (zpodd_dev_enabled(dev))
1047− dev_pm_qos_expose_flags(&dev->sdev->sdev_gendev, 0);
1048−}
1049−
1050−void ata_acpi_unbind(struct ata_device *dev)
1051−{
1052− ata_acpi_unregister_power_resource(dev);
1053−}
1054−
10551031 static int compat_pci_ata(struct ata_port *ap)
10561032 {
10571033 struct device *dev = ap->tdev.parent;
@@ -1071,7 +1047,7 @@ static int compat_pci_ata(struct ata_port *ap) · 13 unmodified lines
10711047
10721048 static int ata_acpi_bind_host(struct ata_port *ap, acpi_handle *handle)
10731049 {
1074− if (ap->flags & ATA_FLAG_ACPI_SATA)
1050+ if (libata_noacpi || ap->flags & ATA_FLAG_ACPI_SATA)
10751051 return -ENODEV;
10761052
10771053 *handle = acpi_get_child(DEVICE_ACPI_HANDLE(ap->tdev.parent),
@@ -1080,7 +1056,7 @@ static int ata_acpi_bind_host(struct ata_port *ap, acpi_handle *handle) · 2 unmodified lines
10801056 if (!*handle)
10811057 return -ENODEV;
10821058
1083− if (ata_acpi_gtm(ap, &ap->__acpi_init_gtm) == 0)
1059+ if (__ata_acpi_gtm(ap, *handle, &ap->__acpi_init_gtm) == 0)
10841060 ap->pflags |= ATA_PFLAG_INIT_GTM_VALID;
10851061
10861062 return 0;
drivers/ata/libata-scsi.c+4−3
@@ -49,6 +49,7 @@ · 48 unmodified lines
4949 #include <linux/hdreg.h>
5050 #include <linux/uaccess.h>
5151 #include <linux/suspend.h>
52+#include <linux/pm_qos.h>
5253 #include <asm/unaligned.h>
5354
5455 #include "libata.h"
@@ -2126,7 +2127,6 @@ static unsigned int ata_scsiop_inq_89(struct ata_scsi_args *args, u8 *rbuf) · 2071 unmodified lines
21262127 memcpy(&rbuf[8], "linux ", 8);
21272128 memcpy(&rbuf[16], "libata ", 16);
21282129 memcpy(&rbuf[32], DRV_VERSION, 4);
2129− ata_id_string(args->id, &rbuf[32], ATA_ID_FW_REV, 4);
21302130
21312131 /* we don't store the ATA device signature, so we fake it */
21322132
@@ -3668,7 +3668,9 @@ void ata_scsi_scan_host(struct ata_port *ap, int sync) · 1535 unmodified lines
36683668 if (!IS_ERR(sdev)) {
36693669 dev->sdev = sdev;
36703670 scsi_device_put(sdev);
3671− ata_acpi_bind(dev);
3671+ if (zpodd_dev_enabled(dev))
3672+ dev_pm_qos_expose_flags(
3673+ &sdev->sdev_gendev, 0);
36723674 } else {
36733675 dev->sdev = NULL;
36743676 }
@@ -3767,7 +3769,6 @@ static void ata_scsi_remove_dev(struct ata_device *dev) · 92 unmodified lines
37673769
37683770 if (zpodd_dev_enabled(dev))
37693771 zpodd_exit(dev);
3770− ata_acpi_unbind(dev);
37713772
37723773 /* clearing dev->sdev is protected by host lock */
37733774 sdev = dev->sdev;
drivers/ata/pata_at32.c+1−12
@@ -393,18 +393,7 @@ static struct platform_driver pata_at32_driver = { · 392 unmodified lines
393393 },
394394 };
395395
396−static int __init pata_at32_init(void)
397−{
398− return platform_driver_probe(&pata_at32_driver, pata_at32_probe);
399−}
400−
401−static void __exit pata_at32_exit(void)
402−{
403− platform_driver_unregister(&pata_at32_driver);
404−}
405−
406−module_init(pata_at32_init);
407−module_exit(pata_at32_exit);
396+module_platform_driver_probe(pata_at32_driver, pata_at32_probe);
408397
409398 MODULE_LICENSE("GPL");
410399 MODULE_DESCRIPTION("AVR32 SMC/CFC PATA Driver");
drivers/ata/pata_imx.c+26−10
@@ -37,7 +37,7 @@ · 36 unmodified lines
3737 struct pata_imx_priv {
3838 struct clk *clk;
3939 /* timings/interrupt/control regs */
40− u8 *host_regs;
40+ void __iomem *host_regs;
4141 u32 ata_ctl;
4242 };
4343
@@ -98,6 +98,7 @@ static int pata_imx_probe(struct platform_device *pdev) · 54 unmodified lines
9898 struct pata_imx_priv *priv;
9999 int irq = 0;
100100 struct resource *io_res;
101+ int ret;
101102
102103 io_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
103104 if (io_res == NULL)
@@ -112,7 +113,7 @@ static int pata_imx_probe(struct platform_device *pdev) · 8 unmodified lines
112113 if (!priv)
113114 return -ENOMEM;
114115
115− priv->clk = clk_get(&pdev->dev, NULL);
116+ priv->clk = devm_clk_get(&pdev->dev, NULL);
116117 if (IS_ERR(priv->clk)) {
117118 dev_err(&pdev->dev, "Failed to get clock\n");
118119 return PTR_ERR(priv->clk);
@@ -121,8 +122,10 @@ static int pata_imx_probe(struct platform_device *pdev) · 2 unmodified lines
121122 clk_prepare_enable(priv->clk);
122123
123124 host = ata_host_alloc(&pdev->dev, 1);
124− if (!host)
125− goto free_priv;
125+ if (!host) {
126+ ret = -ENOMEM;
127+ goto err;
128+ }
126129
127130 host->private_data = priv;
128131 ap = host->ports[0];
@@ -135,7 +138,8 @@ static int pata_imx_probe(struct platform_device *pdev) · 6 unmodified lines
135138 resource_size(io_res));
136139 if (!priv->host_regs) {
137140 dev_err(&pdev->dev, "failed to map IO/CTL base\n");
138− goto free_priv;
141+ ret = -EBUSY;
142+ goto err;
139143 }
140144
141145 ap->ioaddr.cmd_addr = priv->host_regs + PATA_IMX_DRIVE_DATA;
@@ -158,13 +162,17 @@ static int pata_imx_probe(struct platform_device *pdev) · 16 unmodified lines
158162 priv->host_regs + PATA_IMX_ATA_INT_EN);
159163
160164 /* activate */
161− return ata_host_activate(host, irq, ata_sff_interrupt, 0,
165+ ret = ata_host_activate(host, irq, ata_sff_interrupt, 0,
162166 &pata_imx_sht);
163167
164−free_priv:
168+ if (ret)
169+ goto err;
170+
171+ return 0;
172+err:
165173 clk_disable_unprepare(priv->clk);
166− clk_put(priv->clk);
167− return -ENOMEM;
174+
175+ return ret;
168176 }
169177
170178 static int pata_imx_remove(struct platform_device *pdev)
@@ -177,7 +185,6 @@ static int pata_imx_remove(struct platform_device *pdev) · 6 unmodified lines
177185 __raw_writel(0, priv->host_regs + PATA_IMX_ATA_INT_EN);
178186
179187 clk_disable_unprepare(priv->clk);
180− clk_put(priv->clk);
181188
182189 return 0;
183190 }
@@ -223,11 +230,20 @@ static const struct dev_pm_ops pata_imx_pm_ops = { · 39 unmodified lines
223230 };
224231 #endif
225232
233+static const struct of_device_id imx_pata_dt_ids[] = {
234+ {
235+ .compatible = "fsl,imx27-pata",
236+ }, {
237+ /* sentinel */
238+ }
239+};
240+
226241 static struct platform_driver pata_imx_driver = {
227242 .probe = pata_imx_probe,
228243 .remove = pata_imx_remove,
229244 .driver = {
230245 .name = DRV_NAME,
246+ .of_match_table = imx_pata_dt_ids,
231247 .owner = THIS_MODULE,
232248 #ifdef CONFIG_PM
233249 .pm = &pata_imx_pm_ops,
drivers/ata/pata_legacy.c+1−1
@@ -542,7 +542,7 @@ static void opti82c46x_set_piomode(struct ata_port *ap, struct ata_device *adev) · 541 unmodified lines
542542 u8 sysclk;
543543
544544 /* Get the clock */
545− sysclk = opti_syscfg(0xAC) & 0xC0; /* BIOS set */
545+ sysclk = (opti_syscfg(0xAC) & 0xC0) >> 6; /* BIOS set */
546546
547547 /* Enter configuration mode */
548548 ioread16(ap->ioaddr.error_addr);
drivers/ata/pata_octeon_cf.c+1−1
@@ -926,7 +926,7 @@ static int octeon_cf_probe(struct platform_device *pdev) · 925 unmodified lines
926926 goto free_cf_port;
927927 }
928928 cs1 = devm_ioremap_nocache(&pdev->dev, res_cs1->start,
929− res_cs1->end - res_cs1->start + 1);
929+ resource_size(res_cs1));
930930
931931 if (!cs1)
932932 goto free_cf_port;
drivers/ata/sata_fsl.c+55−0
@@ -285,6 +285,7 @@ struct sata_fsl_host_priv { · 284 unmodified lines
285285 int irq;
286286 int data_snoop;
287287 struct device_attribute intr_coalescing;
288+ struct device_attribute rx_watermark;
288289 };
289290
290291 static void fsl_sata_set_irq_coalescing(struct ata_host *host,
@@ -343,6 +344,48 @@ static ssize_t fsl_sata_intr_coalescing_store(struct device *dev, · 52 unmodified lines
343344 return strlen(buf);
344345 }
345346
347+static ssize_t fsl_sata_rx_watermark_show(struct device *dev,
348+ struct device_attribute *attr, char *buf)
349+{
350+ unsigned int rx_watermark;
351+ unsigned long flags;
352+ struct ata_host *host = dev_get_drvdata(dev);
353+ struct sata_fsl_host_priv *host_priv = host->private_data;
354+ void __iomem *csr_base = host_priv->csr_base;
355+
356+ spin_lock_irqsave(&host->lock, flags);
357+ rx_watermark = ioread32(csr_base + TRANSCFG);
358+ rx_watermark &= 0x1f;
359+
360+ spin_unlock_irqrestore(&host->lock, flags);
361+ return sprintf(buf, "%d\n", rx_watermark);
362+}
363+
364+static ssize_t fsl_sata_rx_watermark_store(struct device *dev,
365+ struct device_attribute *attr,
366+ const char *buf, size_t count)
367+{
368+ unsigned int rx_watermark;
369+ unsigned long flags;
370+ struct ata_host *host = dev_get_drvdata(dev);
371+ struct sata_fsl_host_priv *host_priv = host->private_data;
372+ void __iomem *csr_base = host_priv->csr_base;
373+ u32 temp;
374+
375+ if (sscanf(buf, "%d", &rx_watermark) != 1) {
376+ printk(KERN_ERR "fsl-sata: wrong parameter format.\n");
377+ return -EINVAL;
378+ }
379+
380+ spin_lock_irqsave(&host->lock, flags);
381+ temp = ioread32(csr_base + TRANSCFG);
382+ temp &= 0xffffffe0;
383+ iowrite32(temp | rx_watermark, csr_base + TRANSCFG);
384+
385+ spin_unlock_irqrestore(&host->lock, flags);
386+ return strlen(buf);
387+}
388+
346389 static inline unsigned int sata_fsl_tag(unsigned int tag,
347390 void __iomem *hcr_base)
348391 {
@@ -1500,6 +1543,17 @@ static int sata_fsl_probe(struct platform_device *ofdev) · 1151 unmodified lines
15001543 if (retval)
15011544 goto error_exit_with_cleanup;
15021545
1546+ host_priv->rx_watermark.show = fsl_sata_rx_watermark_show;
1547+ host_priv->rx_watermark.store = fsl_sata_rx_watermark_store;
1548+ sysfs_attr_init(&host_priv->rx_watermark.attr);
1549+ host_priv->rx_watermark.attr.name = "rx_watermark";
1550+ host_priv->rx_watermark.attr.mode = S_IRUGO | S_IWUSR;
1551+ retval = device_create_file(host->dev, &host_priv->rx_watermark);
1552+ if (retval) {
1553+ device_remove_file(&ofdev->dev, &host_priv->intr_coalescing);
1554+ goto error_exit_with_cleanup;
1555+ }
1556+
15031557 return 0;
15041558
15051559 error_exit_with_cleanup:
@@ -1522,6 +1576,7 @@ static int sata_fsl_remove(struct platform_device *ofdev) · 16 unmodified lines
15221576 struct sata_fsl_host_priv *host_priv = host->private_data;
15231577
15241578 device_remove_file(&ofdev->dev, &host_priv->intr_coalescing);
1579+ device_remove_file(&ofdev->dev, &host_priv->rx_watermark);
15251580
15261581 ata_host_detach(host);
15271582
drivers/ata/sata_highbank.c+2−2
@@ -251,7 +251,7 @@ static const struct ata_port_info ahci_highbank_port_info = { · 250 unmodified lines
251251 };
252252
253253 static struct scsi_host_template ahci_highbank_platform_sht = {
254− AHCI_SHT("highbank-ahci"),
254+ AHCI_SHT("sata_highbank"),
255255 };
256256
257257 static const struct of_device_id ahci_of_match[] = {
@@ -418,7 +418,7 @@ static int ahci_highbank_resume(struct device *dev) · 160 unmodified lines
418418 }
419419 #endif
420420
421−SIMPLE_DEV_PM_OPS(ahci_highbank_pm_ops,
421+static SIMPLE_DEV_PM_OPS(ahci_highbank_pm_ops,
422422 ahci_highbank_suspend, ahci_highbank_resume);
423423
424424 static struct platform_driver ahci_highbank_driver = {
drivers/ata/sata_rcar.c+4−3
@@ -17,6 +17,7 @@ · 16 unmodified lines
1717 #include <linux/libata.h>
1818 #include <linux/platform_device.h>
1919 #include <linux/clk.h>
20+#include <linux/err.h>
2021
2122 #define DRV_NAME "sata_rcar"
2223
@@ -799,9 +800,9 @@ static int sata_rcar_probe(struct platform_device *pdev) · 776 unmodified lines
799800
800801 host->private_data = priv;
801802
802− priv->base = devm_request_and_ioremap(&pdev->dev, mem);
803− if (!priv->base) {
804− ret = -EADDRNOTAVAIL;
803+ priv->base = devm_ioremap_resource(&pdev->dev, mem);
804+ if (IS_ERR(priv->base)) {
805+ ret = PTR_ERR(priv->base);
805806 goto cleanup;
806807 }
807808