Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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()

+140 -85
+17
Documentation/devicetree/bindings/ata/imx-pata.txt
··· 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 + };
+29 -53
drivers/ata/libata-acpi.c
··· 17 17 #include <linux/pci.h> 18 18 #include <linux/slab.h> 19 19 #include <linux/pm_runtime.h> 20 - #include <linux/pm_qos.h> 21 20 #include <scsi/scsi_device.h> 22 21 #include "libata.h" 23 22 ··· 60 61 if (ap->flags & ATA_FLAG_ACPI_SATA) 61 62 return NULL; 62 63 63 - return acpi_get_child(DEVICE_ACPI_HANDLE(ap->host->dev), ap->port_no); 64 + return ap->scsi_host ? 65 + DEVICE_ACPI_HANDLE(&ap->scsi_host->shost_gendev) : NULL; 64 66 } 65 67 EXPORT_SYMBOL(ata_ap_acpi_handle); 66 68 ··· 77 77 acpi_integer adr; 78 78 struct ata_port *ap = dev->link->ap; 79 79 80 - if (dev->flags & ATA_DFLAG_ACPI_DISABLED) 80 + if (libata_noacpi || dev->flags & ATA_DFLAG_ACPI_DISABLED) 81 81 return NULL; 82 82 83 83 if (ap->flags & ATA_FLAG_ACPI_SATA) { ··· 240 240 } 241 241 } 242 242 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) 257 245 { 258 246 struct acpi_buffer output = { .length = ACPI_ALLOCATE_BUFFER }; 259 247 union acpi_object *out_obj; 260 248 acpi_status status; 261 249 int rc = 0; 262 250 263 - status = acpi_evaluate_object(ata_ap_acpi_handle(ap), "_GTM", NULL, 264 - &output); 251 + status = acpi_evaluate_object(handle, "_GTM", NULL, &output); 265 252 266 253 rc = -ENOENT; 267 254 if (status == AE_NOT_FOUND) ··· 280 293 out_free: 281 294 kfree(output.pointer); 282 295 return rc; 296 + } 297 + 298 + /** 299 + * ata_acpi_gtm - execute _GTM 300 + * @ap: target ATA port 301 + * @gtm: out parameter for _GTM result 302 + * 303 + * Evaluate _GTM and store the result in @gtm. 304 + * 305 + * LOCKING: 306 + * EH context. 307 + * 308 + * RETURNS: 309 + * 0 on success, -ENOENT if _GTM doesn't exist, -errno on failure. 310 + */ 311 + int ata_acpi_gtm(struct ata_port *ap, struct ata_acpi_gtm *gtm) 312 + { 313 + if (ata_ap_acpi_handle(ap)) 314 + return __ata_acpi_gtm(ap, ata_ap_acpi_handle(ap), gtm); 315 + else 316 + return -EINVAL; 283 317 } 284 318 285 319 EXPORT_SYMBOL_GPL(ata_acpi_gtm); ··· 1028 1020 ata_acpi_clear_gtf(dev); 1029 1021 } 1030 1022 1031 - static void ata_acpi_register_power_resource(struct ata_device *dev) 1032 - { 1033 - struct scsi_device *sdev = dev->sdev; 1034 - acpi_handle handle; 1035 - 1036 - handle = ata_dev_acpi_handle(dev); 1037 - if (handle) 1038 - acpi_dev_pm_add_dependent(handle, &sdev->sdev_gendev); 1039 - } 1040 - 1041 - static void ata_acpi_unregister_power_resource(struct ata_device *dev) 1042 - { 1043 - struct scsi_device *sdev = dev->sdev; 1044 - acpi_handle handle; 1045 - 1046 - handle = ata_dev_acpi_handle(dev); 1047 - if (handle) 1048 - acpi_dev_pm_remove_dependent(handle, &sdev->sdev_gendev); 1049 - } 1050 - 1051 - void ata_acpi_bind(struct ata_device *dev) 1052 - { 1053 - ata_acpi_register_power_resource(dev); 1054 - if (zpodd_dev_enabled(dev)) 1055 - dev_pm_qos_expose_flags(&dev->sdev->sdev_gendev, 0); 1056 - } 1057 - 1058 - void ata_acpi_unbind(struct ata_device *dev) 1059 - { 1060 - ata_acpi_unregister_power_resource(dev); 1061 - } 1062 - 1063 1023 static int compat_pci_ata(struct ata_port *ap) 1064 1024 { 1065 1025 struct device *dev = ap->tdev.parent; ··· 1047 1071 1048 1072 static int ata_acpi_bind_host(struct ata_port *ap, acpi_handle *handle) 1049 1073 { 1050 - if (ap->flags & ATA_FLAG_ACPI_SATA) 1074 + if (libata_noacpi || ap->flags & ATA_FLAG_ACPI_SATA) 1051 1075 return -ENODEV; 1052 1076 1053 1077 *handle = acpi_get_child(DEVICE_ACPI_HANDLE(ap->tdev.parent), ··· 1056 1080 if (!*handle) 1057 1081 return -ENODEV; 1058 1082 1059 - if (ata_acpi_gtm(ap, &ap->__acpi_init_gtm) == 0) 1083 + if (__ata_acpi_gtm(ap, *handle, &ap->__acpi_init_gtm) == 0) 1060 1084 ap->pflags |= ATA_PFLAG_INIT_GTM_VALID; 1061 1085 1062 1086 return 0;
+4 -3
drivers/ata/libata-scsi.c
··· 49 49 #include <linux/hdreg.h> 50 50 #include <linux/uaccess.h> 51 51 #include <linux/suspend.h> 52 + #include <linux/pm_qos.h> 52 53 #include <asm/unaligned.h> 53 54 54 55 #include "libata.h" ··· 2127 2126 memcpy(&rbuf[8], "linux ", 8); 2128 2127 memcpy(&rbuf[16], "libata ", 16); 2129 2128 memcpy(&rbuf[32], DRV_VERSION, 4); 2130 - ata_id_string(args->id, &rbuf[32], ATA_ID_FW_REV, 4); 2131 2129 2132 2130 /* we don't store the ATA device signature, so we fake it */ 2133 2131 ··· 3668 3668 if (!IS_ERR(sdev)) { 3669 3669 dev->sdev = sdev; 3670 3670 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); 3672 3674 } else { 3673 3675 dev->sdev = NULL; 3674 3676 } ··· 3769 3767 3770 3768 if (zpodd_dev_enabled(dev)) 3771 3769 zpodd_exit(dev); 3772 - ata_acpi_unbind(dev); 3773 3770 3774 3771 /* clearing dev->sdev is protected by host lock */ 3775 3772 sdev = dev->sdev;
+1 -12
drivers/ata/pata_at32.c
··· 393 393 }, 394 394 }; 395 395 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); 408 397 409 398 MODULE_LICENSE("GPL"); 410 399 MODULE_DESCRIPTION("AVR32 SMC/CFC PATA Driver");
+26 -10
drivers/ata/pata_imx.c
··· 37 37 struct pata_imx_priv { 38 38 struct clk *clk; 39 39 /* timings/interrupt/control regs */ 40 - u8 *host_regs; 40 + void __iomem *host_regs; 41 41 u32 ata_ctl; 42 42 }; 43 43 ··· 98 98 struct pata_imx_priv *priv; 99 99 int irq = 0; 100 100 struct resource *io_res; 101 + int ret; 101 102 102 103 io_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 103 104 if (io_res == NULL) ··· 113 112 if (!priv) 114 113 return -ENOMEM; 115 114 116 - priv->clk = clk_get(&pdev->dev, NULL); 115 + priv->clk = devm_clk_get(&pdev->dev, NULL); 117 116 if (IS_ERR(priv->clk)) { 118 117 dev_err(&pdev->dev, "Failed to get clock\n"); 119 118 return PTR_ERR(priv->clk); ··· 122 121 clk_prepare_enable(priv->clk); 123 122 124 123 host = ata_host_alloc(&pdev->dev, 1); 125 - if (!host) 126 - goto free_priv; 124 + if (!host) { 125 + ret = -ENOMEM; 126 + goto err; 127 + } 127 128 128 129 host->private_data = priv; 129 130 ap = host->ports[0]; ··· 138 135 resource_size(io_res)); 139 136 if (!priv->host_regs) { 140 137 dev_err(&pdev->dev, "failed to map IO/CTL base\n"); 141 - goto free_priv; 138 + ret = -EBUSY; 139 + goto err; 142 140 } 143 141 144 142 ap->ioaddr.cmd_addr = priv->host_regs + PATA_IMX_DRIVE_DATA; ··· 162 158 priv->host_regs + PATA_IMX_ATA_INT_EN); 163 159 164 160 /* activate */ 165 - return ata_host_activate(host, irq, ata_sff_interrupt, 0, 161 + ret = ata_host_activate(host, irq, ata_sff_interrupt, 0, 166 162 &pata_imx_sht); 167 163 168 - free_priv: 164 + if (ret) 165 + goto err; 166 + 167 + return 0; 168 + err: 169 169 clk_disable_unprepare(priv->clk); 170 - clk_put(priv->clk); 171 - return -ENOMEM; 170 + 171 + return ret; 172 172 } 173 173 174 174 static int pata_imx_remove(struct platform_device *pdev) ··· 185 177 __raw_writel(0, priv->host_regs + PATA_IMX_ATA_INT_EN); 186 178 187 179 clk_disable_unprepare(priv->clk); 188 - clk_put(priv->clk); 189 180 190 181 return 0; 191 182 } ··· 230 223 }; 231 224 #endif 232 225 226 + static const struct of_device_id imx_pata_dt_ids[] = { 227 + { 228 + .compatible = "fsl,imx27-pata", 229 + }, { 230 + /* sentinel */ 231 + } 232 + }; 233 + 233 234 static struct platform_driver pata_imx_driver = { 234 235 .probe = pata_imx_probe, 235 236 .remove = pata_imx_remove, 236 237 .driver = { 237 238 .name = DRV_NAME, 239 + .of_match_table = imx_pata_dt_ids, 238 240 .owner = THIS_MODULE, 239 241 #ifdef CONFIG_PM 240 242 .pm = &pata_imx_pm_ops,
+1 -1
drivers/ata/pata_legacy.c
··· 542 542 u8 sysclk; 543 543 544 544 /* Get the clock */ 545 - sysclk = opti_syscfg(0xAC) & 0xC0; /* BIOS set */ 545 + sysclk = (opti_syscfg(0xAC) & 0xC0) >> 6; /* BIOS set */ 546 546 547 547 /* Enter configuration mode */ 548 548 ioread16(ap->ioaddr.error_addr);
+1 -1
drivers/ata/pata_octeon_cf.c
··· 926 926 goto free_cf_port; 927 927 } 928 928 cs1 = devm_ioremap_nocache(&pdev->dev, res_cs1->start, 929 - res_cs1->end - res_cs1->start + 1); 929 + resource_size(res_cs1)); 930 930 931 931 if (!cs1) 932 932 goto free_cf_port;
+55
drivers/ata/sata_fsl.c
··· 285 285 int irq; 286 286 int data_snoop; 287 287 struct device_attribute intr_coalescing; 288 + struct device_attribute rx_watermark; 288 289 }; 289 290 290 291 static void fsl_sata_set_irq_coalescing(struct ata_host *host, ··· 341 340 fsl_sata_set_irq_coalescing(dev_get_drvdata(dev), 342 341 coalescing_count, coalescing_ticks); 343 342 343 + return strlen(buf); 344 + } 345 + 346 + static ssize_t fsl_sata_rx_watermark_show(struct device *dev, 347 + struct device_attribute *attr, char *buf) 348 + { 349 + unsigned int rx_watermark; 350 + unsigned long flags; 351 + struct ata_host *host = dev_get_drvdata(dev); 352 + struct sata_fsl_host_priv *host_priv = host->private_data; 353 + void __iomem *csr_base = host_priv->csr_base; 354 + 355 + spin_lock_irqsave(&host->lock, flags); 356 + rx_watermark = ioread32(csr_base + TRANSCFG); 357 + rx_watermark &= 0x1f; 358 + 359 + spin_unlock_irqrestore(&host->lock, flags); 360 + return sprintf(buf, "%d\n", rx_watermark); 361 + } 362 + 363 + static ssize_t fsl_sata_rx_watermark_store(struct device *dev, 364 + struct device_attribute *attr, 365 + const char *buf, size_t count) 366 + { 367 + unsigned int rx_watermark; 368 + unsigned long flags; 369 + struct ata_host *host = dev_get_drvdata(dev); 370 + struct sata_fsl_host_priv *host_priv = host->private_data; 371 + void __iomem *csr_base = host_priv->csr_base; 372 + u32 temp; 373 + 374 + if (sscanf(buf, "%d", &rx_watermark) != 1) { 375 + printk(KERN_ERR "fsl-sata: wrong parameter format.\n"); 376 + return -EINVAL; 377 + } 378 + 379 + spin_lock_irqsave(&host->lock, flags); 380 + temp = ioread32(csr_base + TRANSCFG); 381 + temp &= 0xffffffe0; 382 + iowrite32(temp | rx_watermark, csr_base + TRANSCFG); 383 + 384 + spin_unlock_irqrestore(&host->lock, flags); 344 385 return strlen(buf); 345 386 } 346 387 ··· 1543 1500 if (retval) 1544 1501 goto error_exit_with_cleanup; 1545 1502 1503 + host_priv->rx_watermark.show = fsl_sata_rx_watermark_show; 1504 + host_priv->rx_watermark.store = fsl_sata_rx_watermark_store; 1505 + sysfs_attr_init(&host_priv->rx_watermark.attr); 1506 + host_priv->rx_watermark.attr.name = "rx_watermark"; 1507 + host_priv->rx_watermark.attr.mode = S_IRUGO | S_IWUSR; 1508 + retval = device_create_file(host->dev, &host_priv->rx_watermark); 1509 + if (retval) { 1510 + device_remove_file(&ofdev->dev, &host_priv->intr_coalescing); 1511 + goto error_exit_with_cleanup; 1512 + } 1513 + 1546 1514 return 0; 1547 1515 1548 1516 error_exit_with_cleanup: ··· 1576 1522 struct sata_fsl_host_priv *host_priv = host->private_data; 1577 1523 1578 1524 device_remove_file(&ofdev->dev, &host_priv->intr_coalescing); 1525 + device_remove_file(&ofdev->dev, &host_priv->rx_watermark); 1579 1526 1580 1527 ata_host_detach(host); 1581 1528
+2 -2
drivers/ata/sata_highbank.c
··· 251 251 }; 252 252 253 253 static struct scsi_host_template ahci_highbank_platform_sht = { 254 - AHCI_SHT("highbank-ahci"), 254 + AHCI_SHT("sata_highbank"), 255 255 }; 256 256 257 257 static const struct of_device_id ahci_of_match[] = { ··· 418 418 } 419 419 #endif 420 420 421 - SIMPLE_DEV_PM_OPS(ahci_highbank_pm_ops, 421 + static SIMPLE_DEV_PM_OPS(ahci_highbank_pm_ops, 422 422 ahci_highbank_suspend, ahci_highbank_resume); 423 423 424 424 static struct platform_driver ahci_highbank_driver = {
+4 -3
drivers/ata/sata_rcar.c
··· 17 17 #include <linux/libata.h> 18 18 #include <linux/platform_device.h> 19 19 #include <linux/clk.h> 20 + #include <linux/err.h> 20 21 21 22 #define DRV_NAME "sata_rcar" 22 23 ··· 800 799 801 800 host->private_data = priv; 802 801 803 - priv->base = devm_request_and_ioremap(&pdev->dev, mem); 804 - if (!priv->base) { 805 - ret = -EADDRNOTAVAIL; 802 + priv->base = devm_ioremap_resource(&pdev->dev, mem); 803 + if (IS_ERR(priv->base)) { 804 + ret = PTR_ERR(priv->base); 806 805 goto cleanup; 807 806 } 808 807