~ubuntu-branches/ubuntu/trusty/linux-armadaxp/trusty

« back to all changes in this revision

Viewing changes to drivers/ata/libata-sff.c

  • Committer: Package Import Robot
  • Author(s): Michael Casadevall, Bryan Wu, Dann Frazier, Michael Casadeall
  • Date: 2012-03-10 15:00:54 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20120310150054-flugb39zon8vvgwe
Tags: 3.2.0-1600.1
[ Bryan Wu ]
* UBUNTU: import debian/debian.env and debian.armadaxp

[ Dann Frazier ]
* ARM: Armada XP: remove trailing '/' in dirnames in mvRules.mk

[ Michael Casadeall ]
* tools: add some tools for Marvell Armada XP processor
* kernel: timer tick hacking from Marvell
* kernel: Sheeva Errata: add delay on Sheeva when powering down
* net: add Marvell NFP netfilter
* net: socket and skb modifications made by Marvell
* miscdevice: add minor IDs for some Marvell Armada drivers
* fs: introduce memory pool for splice()
* video: EDID detection updates from Marvell Armada XP patchset
* video: backlight: add Marvell Dove LCD backlight driver
* video: display: add THS8200 display driver
* video: framebuffer: add Marvell Dove and Armada XP processor onchip LCD controller driver
* usbtest: add Interrupt transfer testing by Marvell Armada XP code
* usb: ehci: add support for Marvell EHCI controler
* tty/serial: 8250: add support for Marvell Armada XP processor and DeviceTree work
* rtc: add support for Marvell Armada XP onchip RTC controller
* net: pppoe: add Marvell ethernet NFP hook in PPPoE networking driver
* mtd: nand: add support for Marvell Armada XP Nand Flash Controller
* mtd: maps: add Marvell Armada XP specific map driver
* mmc: add support for Marvell Armada XP MMC/SD host controller
* i2c: add support for Marvell Armada XP onchip i2c bus controller
* hwmon: add Kconfig option for Armada XP onchip thermal sensor driver
* dmaengine: add Net DMA support for splice and update Marvell XOR DMA engine driver
* ata: add support for Marvell Armada XP SATA controller and update some quirks
* ARM: add Marvell Armada XP machine to mach-types
* ARM: oprofile: add support for Marvell PJ4B core
* ARM: mm: more ARMv6 switches for Marvell Armada XP
* ARM: remove static declaration to allow compilation
* ARM: alignment access fault trick
* ARM: mm: skip some fault fixing when run on NONE SMP ARMv6 mode during early abort event
* ARM: mm: add Marvell Sheeva CPU Architecture for PJ4B
* ARM: introduce optimized copy operation for Marvell Armada XP
* ARM: SAUCE: hardware breakpoint trick for Marvell Armada XP
* ARM: big endian and little endian tricks for Marvell Armada XP
* ARM: SAUCE: Add Marvell Armada XP build rules to arch/arm/kernel/Makefile
* ARM: vfp: add special handling for Marvell Armada XP
* ARM: add support for Marvell U-Boot
* ARM: add mv_controller_num for ARM PCI drivers
* ARM: add support for local PMUs, general SMP tweaks and cache flushing
* ARM: add Marvell device identifies in glue-proc.h
* ARM: add IPC driver support for Marvell platforms
* ARM: add DMA mapping for Marvell platforms
* ARM: add Sheeva errata and PJ4B code for booting
* ARM: update Kconfig and Makefile to include Marvell Armada XP platforms
* ARM: Armada XP: import LSP from Marvell for Armada XP 3.2 kernel enablement

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
#include <linux/kernel.h>
36
36
#include <linux/gfp.h>
37
37
#include <linux/pci.h>
 
38
#include <linux/module.h>
38
39
#include <linux/libata.h>
39
40
#include <linux/highmem.h>
40
41
 
227
228
        }
228
229
 
229
230
        if (status != 0xff && (status & ATA_BUSY))
230
 
                ata_port_printk(ap, KERN_WARNING,
231
 
                                "port is slow to respond, please be patient "
232
 
                                "(Status 0x%x)\n", status);
 
231
                ata_port_warn(ap,
 
232
                              "port is slow to respond, please be patient (Status 0x%x)\n",
 
233
                              status);
233
234
 
234
235
        timeout = ata_deadline(timer_start, tmout);
235
236
        while (status != 0xff && (status & ATA_BUSY) &&
242
243
                return -ENODEV;
243
244
 
244
245
        if (status & ATA_BUSY) {
245
 
                ata_port_printk(ap, KERN_ERR, "port failed to respond "
246
 
                                "(%lu secs, Status 0x%x)\n",
247
 
                                DIV_ROUND_UP(tmout, 1000), status);
 
246
                ata_port_err(ap,
 
247
                             "port failed to respond (%lu secs, Status 0x%x)\n",
 
248
                             DIV_ROUND_UP(tmout, 1000), status);
248
249
                return -EBUSY;
249
250
        }
250
251
 
350
351
                           unsigned int wait, unsigned int can_sleep)
351
352
{
352
353
        if (ata_msg_probe(ap))
353
 
                ata_port_printk(ap, KERN_INFO, "ata_dev_select: ENTER, "
354
 
                                "device %u, wait %u\n", device, wait);
 
354
                ata_port_info(ap, "ata_dev_select: ENTER, device %u, wait %u\n",
 
355
                              device, wait);
355
356
 
356
357
        if (wait)
357
358
                ata_wait_idle(ap);
569
570
 
570
571
        /* Transfer trailing byte, if any. */
571
572
        if (unlikely(buflen & 0x01)) {
572
 
                unsigned char pad[2];
 
573
                unsigned char pad[2] = { };
573
574
 
574
575
                /* Point buf to the tail of buffer */
575
576
                buf += buflen - 1;
628
629
 
629
630
        /* Transfer trailing bytes, if any */
630
631
        if (unlikely(slop)) {
631
 
                unsigned char pad[4];
 
632
                unsigned char pad[4] = { };
632
633
 
633
634
                /* Point buf to the tail of buffer */
634
635
                buf += buflen - slop;
678
679
        unsigned int consumed;
679
680
 
680
681
        local_irq_save(flags);
681
 
        consumed = ata_sff_data_xfer(dev, buf, buflen, rw);
 
682
        consumed = ata_sff_data_xfer32(dev, buf, buflen, rw);
682
683
        local_irq_restore(flags);
683
684
 
684
685
        return consumed;
1333
1334
 
1334
1335
        cancel_delayed_work_sync(&ap->sff_pio_task);
1335
1336
        ap->hsm_task_state = HSM_ST_IDLE;
 
1337
        ap->sff_pio_task_link = NULL;
1336
1338
 
1337
1339
        if (ata_msg_ctl(ap))
1338
 
                ata_port_printk(ap, KERN_DEBUG, "%s: EXIT\n", __func__);
 
1340
                ata_port_dbg(ap, "%s: EXIT\n", __func__);
1339
1341
}
1340
1342
 
1341
1343
static void ata_sff_pio_task(struct work_struct *work)
1513
1515
                ap->ops->sff_check_status(ap);
1514
1516
                if (ap->ops->sff_irq_clear)
1515
1517
                        ap->ops->sff_irq_clear(ap);
1516
 
                ata_port_printk(ap, KERN_WARNING, "irq trap\n");
 
1518
                ata_port_warn(ap, "irq trap\n");
1517
1519
                return 1;
1518
1520
        }
1519
1521
#endif
1711
1713
 
1712
1714
        /* There was a command running, we are no longer busy and we have
1713
1715
           no interrupt. */
1714
 
        ata_port_printk(ap, KERN_WARNING, "lost interrupt (Status 0x%x)\n",
 
1716
        ata_port_warn(ap, "lost interrupt (Status 0x%x)\n",
1715
1717
                                                                status);
1716
1718
        /* Run the host interrupt logic as if the interrupt had not been
1717
1719
           lost */
1798
1800
        if (!ata_link_offline(link)) {
1799
1801
                rc = ata_sff_wait_ready(link, deadline);
1800
1802
                if (rc && rc != -ENODEV) {
1801
 
                        ata_link_printk(link, KERN_WARNING, "device not ready "
1802
 
                                        "(errno=%d), forcing hardreset\n", rc);
 
1803
                        ata_link_warn(link,
 
1804
                                      "device not ready (errno=%d), forcing hardreset\n",
 
1805
                                      rc);
1803
1806
                        ehc->i.action |= ATA_EH_HARDRESET;
1804
1807
                }
1805
1808
        }
2056
2059
        rc = ata_bus_softreset(ap, devmask, deadline);
2057
2060
        /* if link is occupied, -ENODEV too is an error */
2058
2061
        if (rc && (rc != -ENODEV || sata_scr_valid(link))) {
2059
 
                ata_link_printk(link, KERN_ERR, "SRST failed (errno=%d)\n", rc);
 
2062
                ata_link_err(link, "SRST failed (errno=%d)\n", rc);
2060
2063
                return rc;
2061
2064
        }
2062
2065
 
2170
2173
 
2171
2174
        /* Can become DEBUG later */
2172
2175
        if (count)
2173
 
                ata_port_printk(ap, KERN_DEBUG,
2174
 
                        "drained %d bytes to clear DRQ.\n", count);
 
2176
                ata_port_dbg(ap, "drained %d bytes to clear DRQ\n", count);
2175
2177
 
2176
2178
}
2177
2179
EXPORT_SYMBOL_GPL(ata_sff_drain_fifo);
2316
2318
                rc = pcim_iomap_regions(pdev, 0x3 << base,
2317
2319
                                        dev_driver_string(gdev));
2318
2320
                if (rc) {
2319
 
                        dev_printk(KERN_WARNING, gdev,
2320
 
                                   "failed to request/iomap BARs for port %d "
2321
 
                                   "(errno=%d)\n", i, rc);
 
2321
                        dev_warn(gdev,
 
2322
                                 "failed to request/iomap BARs for port %d (errno=%d)\n",
 
2323
                                 i, rc);
2322
2324
                        if (rc == -EBUSY)
2323
2325
                                pcim_pin_device(pdev);
2324
2326
                        ap->ops = &ata_dummy_port_ops;
2340
2342
        }
2341
2343
 
2342
2344
        if (!mask) {
2343
 
                dev_printk(KERN_ERR, gdev, "no available native port\n");
 
2345
                dev_err(gdev, "no available native port\n");
2344
2346
                return -ENODEV;
2345
2347
        }
2346
2348
 
2375
2377
 
2376
2378
        host = ata_host_alloc_pinfo(&pdev->dev, ppi, 2);
2377
2379
        if (!host) {
2378
 
                dev_printk(KERN_ERR, &pdev->dev,
2379
 
                           "failed to allocate ATA host\n");
 
2380
                dev_err(&pdev->dev, "failed to allocate ATA host\n");
2380
2381
                rc = -ENOMEM;
2381
2382
                goto err_out;
2382
2383
        }
2507
2508
        return NULL;
2508
2509
}
2509
2510
 
 
2511
static int ata_pci_init_one(struct pci_dev *pdev,
 
2512
                const struct ata_port_info * const *ppi,
 
2513
                struct scsi_host_template *sht, void *host_priv,
 
2514
                int hflags, bool bmdma)
 
2515
{
 
2516
        struct device *dev = &pdev->dev;
 
2517
        const struct ata_port_info *pi;
 
2518
        struct ata_host *host = NULL;
 
2519
        int rc;
 
2520
 
 
2521
        DPRINTK("ENTER\n");
 
2522
 
 
2523
        pi = ata_sff_find_valid_pi(ppi);
 
2524
        if (!pi) {
 
2525
                dev_err(&pdev->dev, "no valid port_info specified\n");
 
2526
                return -EINVAL;
 
2527
        }
 
2528
 
 
2529
        if (!devres_open_group(dev, NULL, GFP_KERNEL))
 
2530
                return -ENOMEM;
 
2531
 
 
2532
        rc = pcim_enable_device(pdev);
 
2533
        if (rc)
 
2534
                goto out;
 
2535
 
 
2536
#ifdef CONFIG_ATA_BMDMA
 
2537
        if (bmdma)
 
2538
                /* prepare and activate BMDMA host */
 
2539
                rc = ata_pci_bmdma_prepare_host(pdev, ppi, &host);
 
2540
        else
 
2541
#endif
 
2542
                /* prepare and activate SFF host */
 
2543
                rc = ata_pci_sff_prepare_host(pdev, ppi, &host);
 
2544
        if (rc)
 
2545
                goto out;
 
2546
        host->private_data = host_priv;
 
2547
        host->flags |= hflags;
 
2548
 
 
2549
#ifdef CONFIG_ATA_BMDMA
 
2550
        if (bmdma) {
 
2551
                pci_set_master(pdev);
 
2552
                rc = ata_pci_sff_activate_host(host, ata_bmdma_interrupt, sht);
 
2553
        } else
 
2554
#endif
 
2555
                rc = ata_pci_sff_activate_host(host, ata_sff_interrupt, sht);
 
2556
out:
 
2557
        if (rc == 0)
 
2558
                devres_remove_group(&pdev->dev, NULL);
 
2559
        else
 
2560
                devres_release_group(&pdev->dev, NULL);
 
2561
 
 
2562
        return rc;
 
2563
}
 
2564
 
2510
2565
/**
2511
2566
 *      ata_pci_sff_init_one - Initialize/register PIO-only PCI IDE controller
2512
2567
 *      @pdev: Controller to be initialized
2533
2588
                 const struct ata_port_info * const *ppi,
2534
2589
                 struct scsi_host_template *sht, void *host_priv, int hflag)
2535
2590
{
2536
 
        struct device *dev = &pdev->dev;
2537
 
        const struct ata_port_info *pi;
2538
 
        struct ata_host *host = NULL;
2539
 
        int rc;
2540
 
 
2541
 
        DPRINTK("ENTER\n");
2542
 
 
2543
 
        pi = ata_sff_find_valid_pi(ppi);
2544
 
        if (!pi) {
2545
 
                dev_printk(KERN_ERR, &pdev->dev,
2546
 
                           "no valid port_info specified\n");
2547
 
                return -EINVAL;
2548
 
        }
2549
 
 
2550
 
        if (!devres_open_group(dev, NULL, GFP_KERNEL))
2551
 
                return -ENOMEM;
2552
 
 
2553
 
        rc = pcim_enable_device(pdev);
2554
 
        if (rc)
2555
 
                goto out;
2556
 
 
2557
 
        /* prepare and activate SFF host */
2558
 
        rc = ata_pci_sff_prepare_host(pdev, ppi, &host);
2559
 
        if (rc)
2560
 
                goto out;
2561
 
        host->private_data = host_priv;
2562
 
        host->flags |= hflag;
2563
 
 
2564
 
        rc = ata_pci_sff_activate_host(host, ata_sff_interrupt, sht);
2565
 
out:
2566
 
        if (rc == 0)
2567
 
                devres_remove_group(&pdev->dev, NULL);
2568
 
        else
2569
 
                devres_release_group(&pdev->dev, NULL);
2570
 
 
2571
 
        return rc;
 
2591
        return ata_pci_init_one(pdev, ppi, sht, host_priv, hflag, 0);
2572
2592
}
2573
2593
EXPORT_SYMBOL_GPL(ata_pci_sff_init_one);
2574
2594
 
3164
3184
{
3165
3185
        int i;
3166
3186
 
3167
 
        dev_printk(KERN_ERR, host->dev, "BMDMA: %s, falling back to PIO\n",
3168
 
                   reason);
 
3187
        dev_err(host->dev, "BMDMA: %s, falling back to PIO\n", reason);
3169
3188
 
3170
3189
        for (i = 0; i < 2; i++) {
3171
3190
                host->ports[i]->mwdma_mask = 0;
3288
3307
                           struct scsi_host_template *sht, void *host_priv,
3289
3308
                           int hflags)
3290
3309
{
3291
 
        struct device *dev = &pdev->dev;
3292
 
        const struct ata_port_info *pi;
3293
 
        struct ata_host *host = NULL;
3294
 
        int rc;
3295
 
 
3296
 
        DPRINTK("ENTER\n");
3297
 
 
3298
 
        pi = ata_sff_find_valid_pi(ppi);
3299
 
        if (!pi) {
3300
 
                dev_printk(KERN_ERR, &pdev->dev,
3301
 
                           "no valid port_info specified\n");
3302
 
                return -EINVAL;
3303
 
        }
3304
 
 
3305
 
        if (!devres_open_group(dev, NULL, GFP_KERNEL))
3306
 
                return -ENOMEM;
3307
 
 
3308
 
        rc = pcim_enable_device(pdev);
3309
 
        if (rc)
3310
 
                goto out;
3311
 
 
3312
 
        /* prepare and activate BMDMA host */
3313
 
        rc = ata_pci_bmdma_prepare_host(pdev, ppi, &host);
3314
 
        if (rc)
3315
 
                goto out;
3316
 
        host->private_data = host_priv;
3317
 
        host->flags |= hflags;
3318
 
 
3319
 
        pci_set_master(pdev);
3320
 
        rc = ata_pci_sff_activate_host(host, ata_bmdma_interrupt, sht);
3321
 
 out:
3322
 
        if (rc == 0)
3323
 
                devres_remove_group(&pdev->dev, NULL);
3324
 
        else
3325
 
                devres_release_group(&pdev->dev, NULL);
3326
 
 
3327
 
        return rc;
 
3310
        return ata_pci_init_one(pdev, ppi, sht, host_priv, hflags, 1);
3328
3311
}
3329
3312
EXPORT_SYMBOL_GPL(ata_pci_bmdma_init_one);
3330
3313