diff options
Diffstat (limited to 'drivers')
34 files changed, 685 insertions, 184 deletions
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c index a603bbf9b1b7..66e012cd3271 100644 --- a/drivers/ata/ahci.c +++ b/drivers/ata/ahci.c | |||
@@ -582,18 +582,18 @@ static const struct pci_device_id ahci_pci_tbl[] = { | |||
582 | { PCI_VDEVICE(NVIDIA, 0x0abd), board_ahci }, /* MCP79 */ | 582 | { PCI_VDEVICE(NVIDIA, 0x0abd), board_ahci }, /* MCP79 */ |
583 | { PCI_VDEVICE(NVIDIA, 0x0abe), board_ahci }, /* MCP79 */ | 583 | { PCI_VDEVICE(NVIDIA, 0x0abe), board_ahci }, /* MCP79 */ |
584 | { PCI_VDEVICE(NVIDIA, 0x0abf), board_ahci }, /* MCP79 */ | 584 | { PCI_VDEVICE(NVIDIA, 0x0abf), board_ahci }, /* MCP79 */ |
585 | { PCI_VDEVICE(NVIDIA, 0x0bc8), board_ahci }, /* MCP7B */ | 585 | { PCI_VDEVICE(NVIDIA, 0x0d84), board_ahci }, /* MCP89 */ |
586 | { PCI_VDEVICE(NVIDIA, 0x0bc9), board_ahci }, /* MCP7B */ | 586 | { PCI_VDEVICE(NVIDIA, 0x0d85), board_ahci }, /* MCP89 */ |
587 | { PCI_VDEVICE(NVIDIA, 0x0bca), board_ahci }, /* MCP7B */ | 587 | { PCI_VDEVICE(NVIDIA, 0x0d86), board_ahci }, /* MCP89 */ |
588 | { PCI_VDEVICE(NVIDIA, 0x0bcb), board_ahci }, /* MCP7B */ | 588 | { PCI_VDEVICE(NVIDIA, 0x0d87), board_ahci }, /* MCP89 */ |
589 | { PCI_VDEVICE(NVIDIA, 0x0bcc), board_ahci }, /* MCP7B */ | 589 | { PCI_VDEVICE(NVIDIA, 0x0d88), board_ahci }, /* MCP89 */ |
590 | { PCI_VDEVICE(NVIDIA, 0x0bcd), board_ahci }, /* MCP7B */ | 590 | { PCI_VDEVICE(NVIDIA, 0x0d89), board_ahci }, /* MCP89 */ |
591 | { PCI_VDEVICE(NVIDIA, 0x0bce), board_ahci }, /* MCP7B */ | 591 | { PCI_VDEVICE(NVIDIA, 0x0d8a), board_ahci }, /* MCP89 */ |
592 | { PCI_VDEVICE(NVIDIA, 0x0bcf), board_ahci }, /* MCP7B */ | 592 | { PCI_VDEVICE(NVIDIA, 0x0d8b), board_ahci }, /* MCP89 */ |
593 | { PCI_VDEVICE(NVIDIA, 0x0bc4), board_ahci }, /* MCP7B */ | 593 | { PCI_VDEVICE(NVIDIA, 0x0d8c), board_ahci }, /* MCP89 */ |
594 | { PCI_VDEVICE(NVIDIA, 0x0bc5), board_ahci }, /* MCP7B */ | 594 | { PCI_VDEVICE(NVIDIA, 0x0d8d), board_ahci }, /* MCP89 */ |
595 | { PCI_VDEVICE(NVIDIA, 0x0bc6), board_ahci }, /* MCP7B */ | 595 | { PCI_VDEVICE(NVIDIA, 0x0d8e), board_ahci }, /* MCP89 */ |
596 | { PCI_VDEVICE(NVIDIA, 0x0bc7), board_ahci }, /* MCP7B */ | 596 | { PCI_VDEVICE(NVIDIA, 0x0d8f), board_ahci }, /* MCP89 */ |
597 | 597 | ||
598 | /* SiS */ | 598 | /* SiS */ |
599 | { PCI_VDEVICE(SI, 0x1184), board_ahci }, /* SiS 966 */ | 599 | { PCI_VDEVICE(SI, 0x1184), board_ahci }, /* SiS 966 */ |
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 9fbf0595f3d4..060bcd601f57 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c | |||
@@ -1322,14 +1322,16 @@ static u64 ata_id_n_sectors(const u16 *id) | |||
1322 | { | 1322 | { |
1323 | if (ata_id_has_lba(id)) { | 1323 | if (ata_id_has_lba(id)) { |
1324 | if (ata_id_has_lba48(id)) | 1324 | if (ata_id_has_lba48(id)) |
1325 | return ata_id_u64(id, 100); | 1325 | return ata_id_u64(id, ATA_ID_LBA_CAPACITY_2); |
1326 | else | 1326 | else |
1327 | return ata_id_u32(id, 60); | 1327 | return ata_id_u32(id, ATA_ID_LBA_CAPACITY); |
1328 | } else { | 1328 | } else { |
1329 | if (ata_id_current_chs_valid(id)) | 1329 | if (ata_id_current_chs_valid(id)) |
1330 | return ata_id_u32(id, 57); | 1330 | return id[ATA_ID_CUR_CYLS] * id[ATA_ID_CUR_HEADS] * |
1331 | id[ATA_ID_CUR_SECTORS]; | ||
1331 | else | 1332 | else |
1332 | return id[1] * id[3] * id[6]; | 1333 | return id[ATA_ID_CYLS] * id[ATA_ID_HEADS] * |
1334 | id[ATA_ID_SECTORS]; | ||
1333 | } | 1335 | } |
1334 | } | 1336 | } |
1335 | 1337 | ||
@@ -4612,7 +4614,7 @@ void ata_sg_clean(struct ata_queued_cmd *qc) | |||
4612 | VPRINTK("unmapping %u sg elements\n", qc->n_elem); | 4614 | VPRINTK("unmapping %u sg elements\n", qc->n_elem); |
4613 | 4615 | ||
4614 | if (qc->n_elem) | 4616 | if (qc->n_elem) |
4615 | dma_unmap_sg(ap->dev, sg, qc->n_elem, dir); | 4617 | dma_unmap_sg(ap->dev, sg, qc->orig_n_elem, dir); |
4616 | 4618 | ||
4617 | qc->flags &= ~ATA_QCFLAG_DMAMAP; | 4619 | qc->flags &= ~ATA_QCFLAG_DMAMAP; |
4618 | qc->sg = NULL; | 4620 | qc->sg = NULL; |
@@ -4727,7 +4729,7 @@ static int ata_sg_setup(struct ata_queued_cmd *qc) | |||
4727 | return -1; | 4729 | return -1; |
4728 | 4730 | ||
4729 | DPRINTK("%d sg elements mapped\n", n_elem); | 4731 | DPRINTK("%d sg elements mapped\n", n_elem); |
4730 | 4732 | qc->orig_n_elem = qc->n_elem; | |
4731 | qc->n_elem = n_elem; | 4733 | qc->n_elem = n_elem; |
4732 | qc->flags |= ATA_QCFLAG_DMAMAP; | 4734 | qc->flags |= ATA_QCFLAG_DMAMAP; |
4733 | 4735 | ||
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c index ce2ef0475339..ea890911d4fa 100644 --- a/drivers/ata/libata-eh.c +++ b/drivers/ata/libata-eh.c | |||
@@ -2423,11 +2423,14 @@ int ata_eh_reset(struct ata_link *link, int classify, | |||
2423 | } | 2423 | } |
2424 | 2424 | ||
2425 | /* prereset() might have cleared ATA_EH_RESET. If so, | 2425 | /* prereset() might have cleared ATA_EH_RESET. If so, |
2426 | * bang classes and return. | 2426 | * bang classes, thaw and return. |
2427 | */ | 2427 | */ |
2428 | if (reset && !(ehc->i.action & ATA_EH_RESET)) { | 2428 | if (reset && !(ehc->i.action & ATA_EH_RESET)) { |
2429 | ata_for_each_dev(dev, link, ALL) | 2429 | ata_for_each_dev(dev, link, ALL) |
2430 | classes[dev->devno] = ATA_DEV_NONE; | 2430 | classes[dev->devno] = ATA_DEV_NONE; |
2431 | if ((ap->pflags & ATA_PFLAG_FROZEN) && | ||
2432 | ata_is_host_link(link)) | ||
2433 | ata_eh_thaw_port(ap); | ||
2431 | rc = 0; | 2434 | rc = 0; |
2432 | goto out; | 2435 | goto out; |
2433 | } | 2436 | } |
@@ -2901,7 +2904,7 @@ static int atapi_eh_clear_ua(struct ata_device *dev) | |||
2901 | int i; | 2904 | int i; |
2902 | 2905 | ||
2903 | for (i = 0; i < ATA_EH_UA_TRIES; i++) { | 2906 | for (i = 0; i < ATA_EH_UA_TRIES; i++) { |
2904 | u8 sense_buffer[SCSI_SENSE_BUFFERSIZE]; | 2907 | u8 *sense_buffer = dev->link->ap->sector_buf; |
2905 | u8 sense_key = 0; | 2908 | u8 sense_key = 0; |
2906 | unsigned int err_mask; | 2909 | unsigned int err_mask; |
2907 | 2910 | ||
diff --git a/drivers/ata/sata_nv.c b/drivers/ata/sata_nv.c index 55a8eed3f3a3..f65b53785a8f 100644 --- a/drivers/ata/sata_nv.c +++ b/drivers/ata/sata_nv.c | |||
@@ -2523,7 +2523,7 @@ static void __exit nv_exit(void) | |||
2523 | module_init(nv_init); | 2523 | module_init(nv_init); |
2524 | module_exit(nv_exit); | 2524 | module_exit(nv_exit); |
2525 | module_param_named(adma, adma_enabled, bool, 0444); | 2525 | module_param_named(adma, adma_enabled, bool, 0444); |
2526 | MODULE_PARM_DESC(adma, "Enable use of ADMA (Default: true)"); | 2526 | MODULE_PARM_DESC(adma, "Enable use of ADMA (Default: false)"); |
2527 | module_param_named(swncq, swncq_enabled, bool, 0444); | 2527 | module_param_named(swncq, swncq_enabled, bool, 0444); |
2528 | MODULE_PARM_DESC(swncq, "Enable use of SWNCQ (Default: true)"); | 2528 | MODULE_PARM_DESC(swncq, "Enable use of SWNCQ (Default: true)"); |
2529 | 2529 | ||
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c index b5a061114630..4f9b6d792017 100644 --- a/drivers/block/cciss.c +++ b/drivers/block/cciss.c | |||
@@ -3606,11 +3606,9 @@ static int __devinit cciss_init_one(struct pci_dev *pdev, | |||
3606 | if (cciss_hard_reset_controller(pdev) || cciss_reset_msi(pdev)) | 3606 | if (cciss_hard_reset_controller(pdev) || cciss_reset_msi(pdev)) |
3607 | return -ENODEV; | 3607 | return -ENODEV; |
3608 | 3608 | ||
3609 | /* Some devices (notably the HP Smart Array 5i Controller) | 3609 | /* Now try to get the controller to respond to a no-op. Some |
3610 | need a little pause here */ | 3610 | devices (notably the HP Smart Array 5i Controller) need |
3611 | schedule_timeout_uninterruptible(30*HZ); | 3611 | up to 30 seconds to respond. */ |
3612 | |||
3613 | /* Now try to get the controller to respond to a no-op */ | ||
3614 | for (i=0; i<30; i++) { | 3612 | for (i=0; i<30; i++) { |
3615 | if (cciss_noop(pdev) == 0) | 3613 | if (cciss_noop(pdev) == 0) |
3616 | break; | 3614 | break; |
diff --git a/drivers/block/loop.c b/drivers/block/loop.c index edbaac6c0573..bf0345577672 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c | |||
@@ -392,8 +392,7 @@ lo_splice_actor(struct pipe_inode_info *pipe, struct pipe_buffer *buf, | |||
392 | struct loop_device *lo = p->lo; | 392 | struct loop_device *lo = p->lo; |
393 | struct page *page = buf->page; | 393 | struct page *page = buf->page; |
394 | sector_t IV; | 394 | sector_t IV; |
395 | size_t size; | 395 | int size, ret; |
396 | int ret; | ||
397 | 396 | ||
398 | ret = buf->ops->confirm(pipe, buf); | 397 | ret = buf->ops->confirm(pipe, buf); |
399 | if (unlikely(ret)) | 398 | if (unlikely(ret)) |
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index b6c8ce254359..8f905089b72b 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c | |||
@@ -977,6 +977,8 @@ static void backend_changed(struct xenbus_device *dev, | |||
977 | break; | 977 | break; |
978 | 978 | ||
979 | case XenbusStateClosing: | 979 | case XenbusStateClosing: |
980 | if (info->gd == NULL) | ||
981 | xenbus_dev_fatal(dev, -ENODEV, "gd is NULL"); | ||
980 | bd = bdget_disk(info->gd, 0); | 982 | bd = bdget_disk(info->gd, 0); |
981 | if (bd == NULL) | 983 | if (bd == NULL) |
982 | xenbus_dev_fatal(dev, -ENODEV, "bdget failed"); | 984 | xenbus_dev_fatal(dev, -ENODEV, "bdget failed"); |
diff --git a/drivers/dca/dca-core.c b/drivers/dca/dca-core.c index 33bd75347518..25b743abfb59 100644 --- a/drivers/dca/dca-core.c +++ b/drivers/dca/dca-core.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright(c) 2007 Intel Corporation. All rights reserved. | 2 | * Copyright(c) 2007 - 2009 Intel Corporation. All rights reserved. |
3 | * | 3 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 4 | * This program is free software; you can redistribute it and/or modify it |
5 | * under the terms of the GNU General Public License as published by the Free | 5 | * under the terms of the GNU General Public License as published by the Free |
diff --git a/drivers/dma/dmatest.c b/drivers/dma/dmatest.c index 732fa1ec36ab..e190d8b30700 100644 --- a/drivers/dma/dmatest.c +++ b/drivers/dma/dmatest.c | |||
@@ -430,13 +430,15 @@ late_initcall(dmatest_init); | |||
430 | static void __exit dmatest_exit(void) | 430 | static void __exit dmatest_exit(void) |
431 | { | 431 | { |
432 | struct dmatest_chan *dtc, *_dtc; | 432 | struct dmatest_chan *dtc, *_dtc; |
433 | struct dma_chan *chan; | ||
433 | 434 | ||
434 | list_for_each_entry_safe(dtc, _dtc, &dmatest_channels, node) { | 435 | list_for_each_entry_safe(dtc, _dtc, &dmatest_channels, node) { |
435 | list_del(&dtc->node); | 436 | list_del(&dtc->node); |
437 | chan = dtc->chan; | ||
436 | dmatest_cleanup_channel(dtc); | 438 | dmatest_cleanup_channel(dtc); |
437 | pr_debug("dmatest: dropped channel %s\n", | 439 | pr_debug("dmatest: dropped channel %s\n", |
438 | dma_chan_name(dtc->chan)); | 440 | dma_chan_name(chan)); |
439 | dma_release_channel(dtc->chan); | 441 | dma_release_channel(chan); |
440 | } | 442 | } |
441 | } | 443 | } |
442 | module_exit(dmatest_exit); | 444 | module_exit(dmatest_exit); |
diff --git a/drivers/dma/fsldma.c b/drivers/dma/fsldma.c index 70126a606239..86d6da47f558 100644 --- a/drivers/dma/fsldma.c +++ b/drivers/dma/fsldma.c | |||
@@ -158,7 +158,8 @@ static void dma_start(struct fsl_dma_chan *fsl_chan) | |||
158 | 158 | ||
159 | static void dma_halt(struct fsl_dma_chan *fsl_chan) | 159 | static void dma_halt(struct fsl_dma_chan *fsl_chan) |
160 | { | 160 | { |
161 | int i = 0; | 161 | int i; |
162 | |||
162 | DMA_OUT(fsl_chan, &fsl_chan->reg_base->mr, | 163 | DMA_OUT(fsl_chan, &fsl_chan->reg_base->mr, |
163 | DMA_IN(fsl_chan, &fsl_chan->reg_base->mr, 32) | FSL_DMA_MR_CA, | 164 | DMA_IN(fsl_chan, &fsl_chan->reg_base->mr, 32) | FSL_DMA_MR_CA, |
164 | 32); | 165 | 32); |
@@ -166,8 +167,11 @@ static void dma_halt(struct fsl_dma_chan *fsl_chan) | |||
166 | DMA_IN(fsl_chan, &fsl_chan->reg_base->mr, 32) & ~(FSL_DMA_MR_CS | 167 | DMA_IN(fsl_chan, &fsl_chan->reg_base->mr, 32) & ~(FSL_DMA_MR_CS |
167 | | FSL_DMA_MR_EMS_EN | FSL_DMA_MR_CA), 32); | 168 | | FSL_DMA_MR_EMS_EN | FSL_DMA_MR_CA), 32); |
168 | 169 | ||
169 | while (!dma_is_idle(fsl_chan) && (i++ < 100)) | 170 | for (i = 0; i < 100; i++) { |
171 | if (dma_is_idle(fsl_chan)) | ||
172 | break; | ||
170 | udelay(10); | 173 | udelay(10); |
174 | } | ||
171 | if (i >= 100 && !dma_is_idle(fsl_chan)) | 175 | if (i >= 100 && !dma_is_idle(fsl_chan)) |
172 | dev_err(fsl_chan->dev, "DMA halt timeout!\n"); | 176 | dev_err(fsl_chan->dev, "DMA halt timeout!\n"); |
173 | } | 177 | } |
diff --git a/drivers/dma/ioat.c b/drivers/dma/ioat.c index 4105d6575b64..ed83dd9df192 100644 --- a/drivers/dma/ioat.c +++ b/drivers/dma/ioat.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | * Intel I/OAT DMA Linux driver | 2 | * Intel I/OAT DMA Linux driver |
3 | * Copyright(c) 2007 Intel Corporation. | 3 | * Copyright(c) 2007 - 2009 Intel Corporation. |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or modify it |
6 | * under the terms and conditions of the GNU General Public License, | 6 | * under the terms and conditions of the GNU General Public License, |
diff --git a/drivers/dma/ioat_dca.c b/drivers/dma/ioat_dca.c index 6cf622da0286..c012a1e15043 100644 --- a/drivers/dma/ioat_dca.c +++ b/drivers/dma/ioat_dca.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | * Intel I/OAT DMA Linux driver | 2 | * Intel I/OAT DMA Linux driver |
3 | * Copyright(c) 2007 Intel Corporation. | 3 | * Copyright(c) 2007 - 2009 Intel Corporation. |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or modify it |
6 | * under the terms and conditions of the GNU General Public License, | 6 | * under the terms and conditions of the GNU General Public License, |
@@ -49,6 +49,23 @@ | |||
49 | 49 | ||
50 | #define DCA_TAG_MAP_MASK 0xDF | 50 | #define DCA_TAG_MAP_MASK 0xDF |
51 | 51 | ||
52 | /* expected tag map bytes for I/OAT ver.2 */ | ||
53 | #define DCA2_TAG_MAP_BYTE0 0x80 | ||
54 | #define DCA2_TAG_MAP_BYTE1 0x0 | ||
55 | #define DCA2_TAG_MAP_BYTE2 0x81 | ||
56 | #define DCA2_TAG_MAP_BYTE3 0x82 | ||
57 | #define DCA2_TAG_MAP_BYTE4 0x82 | ||
58 | |||
59 | /* verify if tag map matches expected values */ | ||
60 | static inline int dca2_tag_map_valid(u8 *tag_map) | ||
61 | { | ||
62 | return ((tag_map[0] == DCA2_TAG_MAP_BYTE0) && | ||
63 | (tag_map[1] == DCA2_TAG_MAP_BYTE1) && | ||
64 | (tag_map[2] == DCA2_TAG_MAP_BYTE2) && | ||
65 | (tag_map[3] == DCA2_TAG_MAP_BYTE3) && | ||
66 | (tag_map[4] == DCA2_TAG_MAP_BYTE4)); | ||
67 | } | ||
68 | |||
52 | /* | 69 | /* |
53 | * "Legacy" DCA systems do not implement the DCA register set in the | 70 | * "Legacy" DCA systems do not implement the DCA register set in the |
54 | * I/OAT device. Software needs direct support for their tag mappings. | 71 | * I/OAT device. Software needs direct support for their tag mappings. |
@@ -452,6 +469,13 @@ struct dca_provider *ioat2_dca_init(struct pci_dev *pdev, void __iomem *iobase) | |||
452 | ioatdca->tag_map[i] = 0; | 469 | ioatdca->tag_map[i] = 0; |
453 | } | 470 | } |
454 | 471 | ||
472 | if (!dca2_tag_map_valid(ioatdca->tag_map)) { | ||
473 | dev_err(&pdev->dev, "APICID_TAG_MAP set incorrectly by BIOS, " | ||
474 | "disabling DCA\n"); | ||
475 | free_dca_provider(dca); | ||
476 | return NULL; | ||
477 | } | ||
478 | |||
455 | err = register_dca_provider(dca, &pdev->dev); | 479 | err = register_dca_provider(dca, &pdev->dev); |
456 | if (err) { | 480 | if (err) { |
457 | free_dca_provider(dca); | 481 | free_dca_provider(dca); |
diff --git a/drivers/dma/ioat_dma.c b/drivers/dma/ioat_dma.c index b3759c4b6536..5905cd36bcd2 100644 --- a/drivers/dma/ioat_dma.c +++ b/drivers/dma/ioat_dma.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | * Intel I/OAT DMA Linux driver | 2 | * Intel I/OAT DMA Linux driver |
3 | * Copyright(c) 2004 - 2007 Intel Corporation. | 3 | * Copyright(c) 2004 - 2009 Intel Corporation. |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or modify it |
6 | * under the terms and conditions of the GNU General Public License, | 6 | * under the terms and conditions of the GNU General Public License, |
@@ -189,11 +189,13 @@ static int ioat_dma_enumerate_channels(struct ioatdma_device *device) | |||
189 | ioat_chan->xfercap = xfercap; | 189 | ioat_chan->xfercap = xfercap; |
190 | ioat_chan->desccount = 0; | 190 | ioat_chan->desccount = 0; |
191 | INIT_DELAYED_WORK(&ioat_chan->work, ioat_dma_chan_reset_part2); | 191 | INIT_DELAYED_WORK(&ioat_chan->work, ioat_dma_chan_reset_part2); |
192 | if (ioat_chan->device->version != IOAT_VER_1_2) { | 192 | if (ioat_chan->device->version == IOAT_VER_2_0) |
193 | writel(IOAT_DCACTRL_CMPL_WRITE_ENABLE | 193 | writel(IOAT_DCACTRL_CMPL_WRITE_ENABLE | |
194 | | IOAT_DMA_DCA_ANY_CPU, | 194 | IOAT_DMA_DCA_ANY_CPU, |
195 | ioat_chan->reg_base + IOAT_DCACTRL_OFFSET); | 195 | ioat_chan->reg_base + IOAT_DCACTRL_OFFSET); |
196 | } | 196 | else if (ioat_chan->device->version == IOAT_VER_3_0) |
197 | writel(IOAT_DMA_DCA_ANY_CPU, | ||
198 | ioat_chan->reg_base + IOAT_DCACTRL_OFFSET); | ||
197 | spin_lock_init(&ioat_chan->cleanup_lock); | 199 | spin_lock_init(&ioat_chan->cleanup_lock); |
198 | spin_lock_init(&ioat_chan->desc_lock); | 200 | spin_lock_init(&ioat_chan->desc_lock); |
199 | INIT_LIST_HEAD(&ioat_chan->free_desc); | 201 | INIT_LIST_HEAD(&ioat_chan->free_desc); |
@@ -1169,9 +1171,8 @@ static void ioat_dma_memcpy_cleanup(struct ioat_dma_chan *ioat_chan) | |||
1169 | * up if the client is done with the descriptor | 1171 | * up if the client is done with the descriptor |
1170 | */ | 1172 | */ |
1171 | if (async_tx_test_ack(&desc->async_tx)) { | 1173 | if (async_tx_test_ack(&desc->async_tx)) { |
1172 | list_del(&desc->node); | 1174 | list_move_tail(&desc->node, |
1173 | list_add_tail(&desc->node, | 1175 | &ioat_chan->free_desc); |
1174 | &ioat_chan->free_desc); | ||
1175 | } else | 1176 | } else |
1176 | desc->async_tx.cookie = 0; | 1177 | desc->async_tx.cookie = 0; |
1177 | } else { | 1178 | } else { |
@@ -1362,6 +1363,7 @@ static int ioat_dma_self_test(struct ioatdma_device *device) | |||
1362 | dma_cookie_t cookie; | 1363 | dma_cookie_t cookie; |
1363 | int err = 0; | 1364 | int err = 0; |
1364 | struct completion cmp; | 1365 | struct completion cmp; |
1366 | unsigned long tmo; | ||
1365 | 1367 | ||
1366 | src = kzalloc(sizeof(u8) * IOAT_TEST_SIZE, GFP_KERNEL); | 1368 | src = kzalloc(sizeof(u8) * IOAT_TEST_SIZE, GFP_KERNEL); |
1367 | if (!src) | 1369 | if (!src) |
@@ -1413,9 +1415,10 @@ static int ioat_dma_self_test(struct ioatdma_device *device) | |||
1413 | } | 1415 | } |
1414 | device->common.device_issue_pending(dma_chan); | 1416 | device->common.device_issue_pending(dma_chan); |
1415 | 1417 | ||
1416 | wait_for_completion_timeout(&cmp, msecs_to_jiffies(3000)); | 1418 | tmo = wait_for_completion_timeout(&cmp, msecs_to_jiffies(3000)); |
1417 | 1419 | ||
1418 | if (device->common.device_is_tx_complete(dma_chan, cookie, NULL, NULL) | 1420 | if (tmo == 0 || |
1421 | device->common.device_is_tx_complete(dma_chan, cookie, NULL, NULL) | ||
1419 | != DMA_SUCCESS) { | 1422 | != DMA_SUCCESS) { |
1420 | dev_err(&device->pdev->dev, | 1423 | dev_err(&device->pdev->dev, |
1421 | "Self-test copy timed out, disabling\n"); | 1424 | "Self-test copy timed out, disabling\n"); |
@@ -1657,6 +1660,13 @@ struct ioatdma_device *ioat_dma_probe(struct pci_dev *pdev, | |||
1657 | " %d channels, device version 0x%02x, driver version %s\n", | 1660 | " %d channels, device version 0x%02x, driver version %s\n", |
1658 | device->common.chancnt, device->version, IOAT_DMA_VERSION); | 1661 | device->common.chancnt, device->version, IOAT_DMA_VERSION); |
1659 | 1662 | ||
1663 | if (!device->common.chancnt) { | ||
1664 | dev_err(&device->pdev->dev, | ||
1665 | "Intel(R) I/OAT DMA Engine problem found: " | ||
1666 | "zero channels detected\n"); | ||
1667 | goto err_setup_interrupts; | ||
1668 | } | ||
1669 | |||
1660 | err = ioat_dma_setup_interrupts(device); | 1670 | err = ioat_dma_setup_interrupts(device); |
1661 | if (err) | 1671 | if (err) |
1662 | goto err_setup_interrupts; | 1672 | goto err_setup_interrupts; |
@@ -1696,6 +1706,9 @@ void ioat_dma_remove(struct ioatdma_device *device) | |||
1696 | struct dma_chan *chan, *_chan; | 1706 | struct dma_chan *chan, *_chan; |
1697 | struct ioat_dma_chan *ioat_chan; | 1707 | struct ioat_dma_chan *ioat_chan; |
1698 | 1708 | ||
1709 | if (device->version != IOAT_VER_3_0) | ||
1710 | cancel_delayed_work(&device->work); | ||
1711 | |||
1699 | ioat_dma_remove_interrupts(device); | 1712 | ioat_dma_remove_interrupts(device); |
1700 | 1713 | ||
1701 | dma_async_device_unregister(&device->common); | 1714 | dma_async_device_unregister(&device->common); |
@@ -1707,10 +1720,6 @@ void ioat_dma_remove(struct ioatdma_device *device) | |||
1707 | pci_release_regions(device->pdev); | 1720 | pci_release_regions(device->pdev); |
1708 | pci_disable_device(device->pdev); | 1721 | pci_disable_device(device->pdev); |
1709 | 1722 | ||
1710 | if (device->version != IOAT_VER_3_0) { | ||
1711 | cancel_delayed_work(&device->work); | ||
1712 | } | ||
1713 | |||
1714 | list_for_each_entry_safe(chan, _chan, | 1723 | list_for_each_entry_safe(chan, _chan, |
1715 | &device->common.channels, device_node) { | 1724 | &device->common.channels, device_node) { |
1716 | ioat_chan = to_ioat_chan(chan); | 1725 | ioat_chan = to_ioat_chan(chan); |
diff --git a/drivers/dma/ioatdma.h b/drivers/dma/ioatdma.h index a3306d0e1372..a52ff4bd4601 100644 --- a/drivers/dma/ioatdma.h +++ b/drivers/dma/ioatdma.h | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright(c) 2004 - 2007 Intel Corporation. All rights reserved. | 2 | * Copyright(c) 2004 - 2009 Intel Corporation. All rights reserved. |
3 | * | 3 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 4 | * This program is free software; you can redistribute it and/or modify it |
5 | * under the terms of the GNU General Public License as published by the Free | 5 | * under the terms of the GNU General Public License as published by the Free |
@@ -29,7 +29,7 @@ | |||
29 | #include <linux/pci_ids.h> | 29 | #include <linux/pci_ids.h> |
30 | #include <net/tcp.h> | 30 | #include <net/tcp.h> |
31 | 31 | ||
32 | #define IOAT_DMA_VERSION "3.30" | 32 | #define IOAT_DMA_VERSION "3.64" |
33 | 33 | ||
34 | enum ioat_interrupt { | 34 | enum ioat_interrupt { |
35 | none = 0, | 35 | none = 0, |
@@ -135,12 +135,14 @@ static inline void ioat_set_tcp_copy_break(struct ioatdma_device *dev) | |||
135 | #ifdef CONFIG_NET_DMA | 135 | #ifdef CONFIG_NET_DMA |
136 | switch (dev->version) { | 136 | switch (dev->version) { |
137 | case IOAT_VER_1_2: | 137 | case IOAT_VER_1_2: |
138 | case IOAT_VER_3_0: | ||
139 | sysctl_tcp_dma_copybreak = 4096; | 138 | sysctl_tcp_dma_copybreak = 4096; |
140 | break; | 139 | break; |
141 | case IOAT_VER_2_0: | 140 | case IOAT_VER_2_0: |
142 | sysctl_tcp_dma_copybreak = 2048; | 141 | sysctl_tcp_dma_copybreak = 2048; |
143 | break; | 142 | break; |
143 | case IOAT_VER_3_0: | ||
144 | sysctl_tcp_dma_copybreak = 262144; | ||
145 | break; | ||
144 | } | 146 | } |
145 | #endif | 147 | #endif |
146 | } | 148 | } |
diff --git a/drivers/dma/ioatdma_hw.h b/drivers/dma/ioatdma_hw.h index f1ae2c776f74..afa57eef86c9 100644 --- a/drivers/dma/ioatdma_hw.h +++ b/drivers/dma/ioatdma_hw.h | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright(c) 2004 - 2007 Intel Corporation. All rights reserved. | 2 | * Copyright(c) 2004 - 2009 Intel Corporation. All rights reserved. |
3 | * | 3 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 4 | * This program is free software; you can redistribute it and/or modify it |
5 | * under the terms of the GNU General Public License as published by the Free | 5 | * under the terms of the GNU General Public License as published by the Free |
diff --git a/drivers/dma/ioatdma_registers.h b/drivers/dma/ioatdma_registers.h index 827cb503cac6..49bc277424f8 100644 --- a/drivers/dma/ioatdma_registers.h +++ b/drivers/dma/ioatdma_registers.h | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright(c) 2004 - 2007 Intel Corporation. All rights reserved. | 2 | * Copyright(c) 2004 - 2009 Intel Corporation. All rights reserved. |
3 | * | 3 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 4 | * This program is free software; you can redistribute it and/or modify it |
5 | * under the terms of the GNU General Public License as published by the Free | 5 | * under the terms of the GNU General Public License as published by the Free |
diff --git a/drivers/dma/iop-adma.c b/drivers/dma/iop-adma.c index 647374acba94..16adbe61cfb2 100644 --- a/drivers/dma/iop-adma.c +++ b/drivers/dma/iop-adma.c | |||
@@ -928,19 +928,19 @@ iop_adma_xor_zero_sum_self_test(struct iop_adma_device *device) | |||
928 | 928 | ||
929 | for (src_idx = 0; src_idx < IOP_ADMA_NUM_SRC_TEST; src_idx++) { | 929 | for (src_idx = 0; src_idx < IOP_ADMA_NUM_SRC_TEST; src_idx++) { |
930 | xor_srcs[src_idx] = alloc_page(GFP_KERNEL); | 930 | xor_srcs[src_idx] = alloc_page(GFP_KERNEL); |
931 | if (!xor_srcs[src_idx]) | 931 | if (!xor_srcs[src_idx]) { |
932 | while (src_idx--) { | 932 | while (src_idx--) |
933 | __free_page(xor_srcs[src_idx]); | 933 | __free_page(xor_srcs[src_idx]); |
934 | return -ENOMEM; | 934 | return -ENOMEM; |
935 | } | 935 | } |
936 | } | 936 | } |
937 | 937 | ||
938 | dest = alloc_page(GFP_KERNEL); | 938 | dest = alloc_page(GFP_KERNEL); |
939 | if (!dest) | 939 | if (!dest) { |
940 | while (src_idx--) { | 940 | while (src_idx--) |
941 | __free_page(xor_srcs[src_idx]); | 941 | __free_page(xor_srcs[src_idx]); |
942 | return -ENOMEM; | 942 | return -ENOMEM; |
943 | } | 943 | } |
944 | 944 | ||
945 | /* Fill in src buffers */ | 945 | /* Fill in src buffers */ |
946 | for (src_idx = 0; src_idx < IOP_ADMA_NUM_SRC_TEST; src_idx++) { | 946 | for (src_idx = 0; src_idx < IOP_ADMA_NUM_SRC_TEST; src_idx++) { |
diff --git a/drivers/dma/ipu/ipu_idmac.c b/drivers/dma/ipu/ipu_idmac.c index 1f154d08e98f..ae50a9d1a4e6 100644 --- a/drivers/dma/ipu/ipu_idmac.c +++ b/drivers/dma/ipu/ipu_idmac.c | |||
@@ -729,7 +729,7 @@ static int ipu_init_channel_buffer(struct idmac_channel *ichan, | |||
729 | 729 | ||
730 | ichan->status = IPU_CHANNEL_READY; | 730 | ichan->status = IPU_CHANNEL_READY; |
731 | 731 | ||
732 | spin_unlock_irqrestore(ipu->lock, flags); | 732 | spin_unlock_irqrestore(&ipu->lock, flags); |
733 | 733 | ||
734 | return 0; | 734 | return 0; |
735 | } | 735 | } |
diff --git a/drivers/dma/mv_xor.c b/drivers/dma/mv_xor.c index 5d5d5b31867f..cb7f26fb9f18 100644 --- a/drivers/dma/mv_xor.c +++ b/drivers/dma/mv_xor.c | |||
@@ -1019,19 +1019,19 @@ mv_xor_xor_self_test(struct mv_xor_device *device) | |||
1019 | 1019 | ||
1020 | for (src_idx = 0; src_idx < MV_XOR_NUM_SRC_TEST; src_idx++) { | 1020 | for (src_idx = 0; src_idx < MV_XOR_NUM_SRC_TEST; src_idx++) { |
1021 | xor_srcs[src_idx] = alloc_page(GFP_KERNEL); | 1021 | xor_srcs[src_idx] = alloc_page(GFP_KERNEL); |
1022 | if (!xor_srcs[src_idx]) | 1022 | if (!xor_srcs[src_idx]) { |
1023 | while (src_idx--) { | 1023 | while (src_idx--) |
1024 | __free_page(xor_srcs[src_idx]); | 1024 | __free_page(xor_srcs[src_idx]); |
1025 | return -ENOMEM; | 1025 | return -ENOMEM; |
1026 | } | 1026 | } |
1027 | } | 1027 | } |
1028 | 1028 | ||
1029 | dest = alloc_page(GFP_KERNEL); | 1029 | dest = alloc_page(GFP_KERNEL); |
1030 | if (!dest) | 1030 | if (!dest) { |
1031 | while (src_idx--) { | 1031 | while (src_idx--) |
1032 | __free_page(xor_srcs[src_idx]); | 1032 | __free_page(xor_srcs[src_idx]); |
1033 | return -ENOMEM; | 1033 | return -ENOMEM; |
1034 | } | 1034 | } |
1035 | 1035 | ||
1036 | /* Fill in src buffers */ | 1036 | /* Fill in src buffers */ |
1037 | for (src_idx = 0; src_idx < MV_XOR_NUM_SRC_TEST; src_idx++) { | 1037 | for (src_idx = 0; src_idx < MV_XOR_NUM_SRC_TEST; src_idx++) { |
diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig index e072903b12f0..5ea3bfad172a 100644 --- a/drivers/ide/Kconfig +++ b/drivers/ide/Kconfig | |||
@@ -721,6 +721,11 @@ config BLK_DEV_IDE_TX4939 | |||
721 | depends on SOC_TX4939 | 721 | depends on SOC_TX4939 |
722 | select BLK_DEV_IDEDMA_SFF | 722 | select BLK_DEV_IDEDMA_SFF |
723 | 723 | ||
724 | config BLK_DEV_IDE_AT91 | ||
725 | tristate "Atmel AT91 (SAM9, CAP9, AT572D940HF) IDE support" | ||
726 | depends on ARM && ARCH_AT91 && !ARCH_AT91RM9200 && !ARCH_AT91X40 | ||
727 | select IDE_TIMINGS | ||
728 | |||
724 | config IDE_ARM | 729 | config IDE_ARM |
725 | tristate "ARM IDE support" | 730 | tristate "ARM IDE support" |
726 | depends on ARM && (ARCH_RPC || ARCH_SHARK) | 731 | depends on ARM && (ARCH_RPC || ARCH_SHARK) |
diff --git a/drivers/ide/Makefile b/drivers/ide/Makefile index d0e3d7d5b467..1c326d94aa6d 100644 --- a/drivers/ide/Makefile +++ b/drivers/ide/Makefile | |||
@@ -116,3 +116,4 @@ obj-$(CONFIG_BLK_DEV_IDE_AU1XXX) += au1xxx-ide.o | |||
116 | 116 | ||
117 | obj-$(CONFIG_BLK_DEV_IDE_TX4938) += tx4938ide.o | 117 | obj-$(CONFIG_BLK_DEV_IDE_TX4938) += tx4938ide.o |
118 | obj-$(CONFIG_BLK_DEV_IDE_TX4939) += tx4939ide.o | 118 | obj-$(CONFIG_BLK_DEV_IDE_TX4939) += tx4939ide.o |
119 | obj-$(CONFIG_BLK_DEV_IDE_AT91) += at91_ide.o | ||
diff --git a/drivers/ide/at91_ide.c b/drivers/ide/at91_ide.c new file mode 100644 index 000000000000..1bb50f46388d --- /dev/null +++ b/drivers/ide/at91_ide.c | |||
@@ -0,0 +1,467 @@ | |||
1 | /* | ||
2 | * IDE host driver for AT91 (SAM9, CAP9, AT572D940HF) Static Memory Controller | ||
3 | * with Compact Flash True IDE logic | ||
4 | * | ||
5 | * Copyright (c) 2008, 2009 Kelvatek Ltd. | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
20 | * | ||
21 | */ | ||
22 | |||
23 | #include <linux/version.h> | ||
24 | #include <linux/kernel.h> | ||
25 | #include <linux/module.h> | ||
26 | #include <linux/clk.h> | ||
27 | #include <linux/err.h> | ||
28 | #include <linux/ide.h> | ||
29 | #include <linux/platform_device.h> | ||
30 | |||
31 | #include <mach/board.h> | ||
32 | #include <mach/gpio.h> | ||
33 | #include <mach/at91sam9263.h> | ||
34 | #include <mach/at91sam9_smc.h> | ||
35 | #include <mach/at91sam9263_matrix.h> | ||
36 | |||
37 | #define DRV_NAME "at91_ide" | ||
38 | |||
39 | #define perr(fmt, args...) pr_err(DRV_NAME ": " fmt, ##args) | ||
40 | #define pdbg(fmt, args...) pr_debug("%s " fmt, __func__, ##args) | ||
41 | |||
42 | /* | ||
43 | * Access to IDE device is possible through EBI Static Memory Controller | ||
44 | * with Compact Flash logic. For details see EBI and SMC datasheet sections | ||
45 | * of any microcontroller from AT91SAM9 family. | ||
46 | * | ||
47 | * Within SMC chip select address space, lines A[23:21] distinguish Compact | ||
48 | * Flash modes (I/O, common memory, attribute memory, True IDE). IDE modes are: | ||
49 | * 0x00c0000 - True IDE | ||
50 | * 0x00e0000 - Alternate True IDE (Alt Status Register) | ||
51 | * | ||
52 | * On True IDE mode Task File and Data Register are mapped at the same address. | ||
53 | * To distinguish access between these two different bus data width is used: | ||
54 | * 8Bit for Task File, 16Bit for Data I/O. | ||
55 | * | ||
56 | * After initialization we do 8/16 bit flipping (changes in SMC MODE register) | ||
57 | * only inside IDE callback routines which are serialized by IDE layer, | ||
58 | * so no additional locking needed. | ||
59 | */ | ||
60 | |||
61 | #define TASK_FILE 0x00c00000 | ||
62 | #define ALT_MODE 0x00e00000 | ||
63 | #define REGS_SIZE 8 | ||
64 | |||
65 | #define enter_16bit(cs, mode) do { \ | ||
66 | mode = at91_sys_read(AT91_SMC_MODE(cs)); \ | ||
67 | at91_sys_write(AT91_SMC_MODE(cs), mode | AT91_SMC_DBW_16); \ | ||
68 | } while (0) | ||
69 | |||
70 | #define leave_16bit(cs, mode) at91_sys_write(AT91_SMC_MODE(cs), mode); | ||
71 | |||
72 | static void set_smc_timings(const u8 chipselect, const u16 cycle, | ||
73 | const u16 setup, const u16 pulse, | ||
74 | const u16 data_float, int use_iordy) | ||
75 | { | ||
76 | unsigned long mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE | | ||
77 | AT91_SMC_BAT_SELECT; | ||
78 | |||
79 | /* disable or enable waiting for IORDY signal */ | ||
80 | if (use_iordy) | ||
81 | mode |= AT91_SMC_EXNWMODE_READY; | ||
82 | |||
83 | /* add data float cycles if needed */ | ||
84 | if (data_float) | ||
85 | mode |= AT91_SMC_TDF_(data_float); | ||
86 | |||
87 | at91_sys_write(AT91_SMC_MODE(chipselect), mode); | ||
88 | |||
89 | /* setup timings in SMC */ | ||
90 | at91_sys_write(AT91_SMC_SETUP(chipselect), AT91_SMC_NWESETUP_(setup) | | ||
91 | AT91_SMC_NCS_WRSETUP_(0) | | ||
92 | AT91_SMC_NRDSETUP_(setup) | | ||
93 | AT91_SMC_NCS_RDSETUP_(0)); | ||
94 | at91_sys_write(AT91_SMC_PULSE(chipselect), AT91_SMC_NWEPULSE_(pulse) | | ||
95 | AT91_SMC_NCS_WRPULSE_(cycle) | | ||
96 | AT91_SMC_NRDPULSE_(pulse) | | ||
97 | AT91_SMC_NCS_RDPULSE_(cycle)); | ||
98 | at91_sys_write(AT91_SMC_CYCLE(chipselect), AT91_SMC_NWECYCLE_(cycle) | | ||
99 | AT91_SMC_NRDCYCLE_(cycle)); | ||
100 | } | ||
101 | |||
102 | static unsigned int calc_mck_cycles(unsigned int ns, unsigned int mck_hz) | ||
103 | { | ||
104 | u64 tmp = ns; | ||
105 | |||
106 | tmp *= mck_hz; | ||
107 | tmp += 1000*1000*1000 - 1; /* round up */ | ||
108 | do_div(tmp, 1000*1000*1000); | ||
109 | return (unsigned int) tmp; | ||
110 | } | ||
111 | |||
112 | static void apply_timings(const u8 chipselect, const u8 pio, | ||
113 | const struct ide_timing *timing, int use_iordy) | ||
114 | { | ||
115 | unsigned int t0, t1, t2, t6z; | ||
116 | unsigned int cycle, setup, pulse, data_float; | ||
117 | unsigned int mck_hz; | ||
118 | struct clk *mck; | ||
119 | |||
120 | /* see table 22 of Compact Flash standard 4.1 for the meaning, | ||
121 | * we do not stretch active (t2) time, so setup (t1) + hold time (th) | ||
122 | * assure at least minimal recovery (t2i) time */ | ||
123 | t0 = timing->cyc8b; | ||
124 | t1 = timing->setup; | ||
125 | t2 = timing->act8b; | ||
126 | t6z = (pio < 5) ? 30 : 20; | ||
127 | |||
128 | pdbg("t0=%u t1=%u t2=%u t6z=%u\n", t0, t1, t2, t6z); | ||
129 | |||
130 | mck = clk_get(NULL, "mck"); | ||
131 | BUG_ON(IS_ERR(mck)); | ||
132 | mck_hz = clk_get_rate(mck); | ||
133 | pdbg("mck_hz=%u\n", mck_hz); | ||
134 | |||
135 | cycle = calc_mck_cycles(t0, mck_hz); | ||
136 | setup = calc_mck_cycles(t1, mck_hz); | ||
137 | pulse = calc_mck_cycles(t2, mck_hz); | ||
138 | data_float = calc_mck_cycles(t6z, mck_hz); | ||
139 | |||
140 | pdbg("cycle=%u setup=%u pulse=%u data_float=%u\n", | ||
141 | cycle, setup, pulse, data_float); | ||
142 | |||
143 | set_smc_timings(chipselect, cycle, setup, pulse, data_float, use_iordy); | ||
144 | } | ||
145 | |||
146 | static void at91_ide_input_data(ide_drive_t *drive, struct request *rq, | ||
147 | void *buf, unsigned int len) | ||
148 | { | ||
149 | ide_hwif_t *hwif = drive->hwif; | ||
150 | struct ide_io_ports *io_ports = &hwif->io_ports; | ||
151 | u8 chipselect = hwif->select_data; | ||
152 | unsigned long mode; | ||
153 | |||
154 | pdbg("cs %u buf %p len %d\n", chipselect, buf, len); | ||
155 | |||
156 | len++; | ||
157 | |||
158 | enter_16bit(chipselect, mode); | ||
159 | __ide_mm_insw((void __iomem *) io_ports->data_addr, buf, len / 2); | ||
160 | leave_16bit(chipselect, mode); | ||
161 | } | ||
162 | |||
163 | static void at91_ide_output_data(ide_drive_t *drive, struct request *rq, | ||
164 | void *buf, unsigned int len) | ||
165 | { | ||
166 | ide_hwif_t *hwif = drive->hwif; | ||
167 | struct ide_io_ports *io_ports = &hwif->io_ports; | ||
168 | u8 chipselect = hwif->select_data; | ||
169 | unsigned long mode; | ||
170 | |||
171 | pdbg("cs %u buf %p len %d\n", chipselect, buf, len); | ||
172 | |||
173 | enter_16bit(chipselect, mode); | ||
174 | __ide_mm_outsw((void __iomem *) io_ports->data_addr, buf, len / 2); | ||
175 | leave_16bit(chipselect, mode); | ||
176 | } | ||
177 | |||
178 | static u8 ide_mm_inb(unsigned long port) | ||
179 | { | ||
180 | return readb((void __iomem *) port); | ||
181 | } | ||
182 | |||
183 | static void ide_mm_outb(u8 value, unsigned long port) | ||
184 | { | ||
185 | writeb(value, (void __iomem *) port); | ||
186 | } | ||
187 | |||
188 | static void at91_ide_tf_load(ide_drive_t *drive, ide_task_t *task) | ||
189 | { | ||
190 | ide_hwif_t *hwif = drive->hwif; | ||
191 | struct ide_io_ports *io_ports = &hwif->io_ports; | ||
192 | struct ide_taskfile *tf = &task->tf; | ||
193 | u8 HIHI = (task->tf_flags & IDE_TFLAG_LBA48) ? 0xE0 : 0xEF; | ||
194 | |||
195 | if (task->tf_flags & IDE_TFLAG_FLAGGED) | ||
196 | HIHI = 0xFF; | ||
197 | |||
198 | if (task->tf_flags & IDE_TFLAG_OUT_DATA) { | ||
199 | u16 data = (tf->hob_data << 8) | tf->data; | ||
200 | |||
201 | at91_ide_output_data(drive, NULL, &data, 2); | ||
202 | } | ||
203 | |||
204 | if (task->tf_flags & IDE_TFLAG_OUT_HOB_FEATURE) | ||
205 | ide_mm_outb(tf->hob_feature, io_ports->feature_addr); | ||
206 | if (task->tf_flags & IDE_TFLAG_OUT_HOB_NSECT) | ||
207 | ide_mm_outb(tf->hob_nsect, io_ports->nsect_addr); | ||
208 | if (task->tf_flags & IDE_TFLAG_OUT_HOB_LBAL) | ||
209 | ide_mm_outb(tf->hob_lbal, io_ports->lbal_addr); | ||
210 | if (task->tf_flags & IDE_TFLAG_OUT_HOB_LBAM) | ||
211 | ide_mm_outb(tf->hob_lbam, io_ports->lbam_addr); | ||
212 | if (task->tf_flags & IDE_TFLAG_OUT_HOB_LBAH) | ||
213 | ide_mm_outb(tf->hob_lbah, io_ports->lbah_addr); | ||
214 | |||
215 | if (task->tf_flags & IDE_TFLAG_OUT_FEATURE) | ||
216 | ide_mm_outb(tf->feature, io_ports->feature_addr); | ||
217 | if (task->tf_flags & IDE_TFLAG_OUT_NSECT) | ||
218 | ide_mm_outb(tf->nsect, io_ports->nsect_addr); | ||
219 | if (task->tf_flags & IDE_TFLAG_OUT_LBAL) | ||
220 | ide_mm_outb(tf->lbal, io_ports->lbal_addr); | ||
221 | if (task->tf_flags & IDE_TFLAG_OUT_LBAM) | ||
222 | ide_mm_outb(tf->lbam, io_ports->lbam_addr); | ||
223 | if (task->tf_flags & IDE_TFLAG_OUT_LBAH) | ||
224 | ide_mm_outb(tf->lbah, io_ports->lbah_addr); | ||
225 | |||
226 | if (task->tf_flags & IDE_TFLAG_OUT_DEVICE) | ||
227 | ide_mm_outb((tf->device & HIHI) | drive->select, io_ports->device_addr); | ||
228 | } | ||
229 | |||
230 | static void at91_ide_tf_read(ide_drive_t *drive, ide_task_t *task) | ||
231 | { | ||
232 | ide_hwif_t *hwif = drive->hwif; | ||
233 | struct ide_io_ports *io_ports = &hwif->io_ports; | ||
234 | struct ide_taskfile *tf = &task->tf; | ||
235 | |||
236 | if (task->tf_flags & IDE_TFLAG_IN_DATA) { | ||
237 | u16 data; | ||
238 | |||
239 | at91_ide_input_data(drive, NULL, &data, 2); | ||
240 | tf->data = data & 0xff; | ||
241 | tf->hob_data = (data >> 8) & 0xff; | ||
242 | } | ||
243 | |||
244 | /* be sure we're looking at the low order bits */ | ||
245 | ide_mm_outb(ATA_DEVCTL_OBS & ~0x80, io_ports->ctl_addr); | ||
246 | |||
247 | if (task->tf_flags & IDE_TFLAG_IN_FEATURE) | ||
248 | tf->feature = ide_mm_inb(io_ports->feature_addr); | ||
249 | if (task->tf_flags & IDE_TFLAG_IN_NSECT) | ||
250 | tf->nsect = ide_mm_inb(io_ports->nsect_addr); | ||
251 | if (task->tf_flags & IDE_TFLAG_IN_LBAL) | ||
252 | tf->lbal = ide_mm_inb(io_ports->lbal_addr); | ||
253 | if (task->tf_flags & IDE_TFLAG_IN_LBAM) | ||
254 | tf->lbam = ide_mm_inb(io_ports->lbam_addr); | ||
255 | if (task->tf_flags & IDE_TFLAG_IN_LBAH) | ||
256 | tf->lbah = ide_mm_inb(io_ports->lbah_addr); | ||
257 | if (task->tf_flags & IDE_TFLAG_IN_DEVICE) | ||
258 | tf->device = ide_mm_inb(io_ports->device_addr); | ||
259 | |||
260 | if (task->tf_flags & IDE_TFLAG_LBA48) { | ||
261 | ide_mm_outb(ATA_DEVCTL_OBS | 0x80, io_ports->ctl_addr); | ||
262 | |||
263 | if (task->tf_flags & IDE_TFLAG_IN_HOB_FEATURE) | ||
264 | tf->hob_feature = ide_mm_inb(io_ports->feature_addr); | ||
265 | if (task->tf_flags & IDE_TFLAG_IN_HOB_NSECT) | ||
266 | tf->hob_nsect = ide_mm_inb(io_ports->nsect_addr); | ||
267 | if (task->tf_flags & IDE_TFLAG_IN_HOB_LBAL) | ||
268 | tf->hob_lbal = ide_mm_inb(io_ports->lbal_addr); | ||
269 | if (task->tf_flags & IDE_TFLAG_IN_HOB_LBAM) | ||
270 | tf->hob_lbam = ide_mm_inb(io_ports->lbam_addr); | ||
271 | if (task->tf_flags & IDE_TFLAG_IN_HOB_LBAH) | ||
272 | tf->hob_lbah = ide_mm_inb(io_ports->lbah_addr); | ||
273 | } | ||
274 | } | ||
275 | |||
276 | static void at91_ide_set_pio_mode(ide_drive_t *drive, const u8 pio) | ||
277 | { | ||
278 | struct ide_timing *timing; | ||
279 | u8 chipselect = drive->hwif->select_data; | ||
280 | int use_iordy = 0; | ||
281 | |||
282 | pdbg("chipselect %u pio %u\n", chipselect, pio); | ||
283 | |||
284 | timing = ide_timing_find_mode(XFER_PIO_0 + pio); | ||
285 | BUG_ON(!timing); | ||
286 | |||
287 | if ((pio > 2 || ata_id_has_iordy(drive->id)) && | ||
288 | !(ata_id_is_cfa(drive->id) && pio > 4)) | ||
289 | use_iordy = 1; | ||
290 | |||
291 | apply_timings(chipselect, pio, timing, use_iordy); | ||
292 | } | ||
293 | |||
294 | static const struct ide_tp_ops at91_ide_tp_ops = { | ||
295 | .exec_command = ide_exec_command, | ||
296 | .read_status = ide_read_status, | ||
297 | .read_altstatus = ide_read_altstatus, | ||
298 | .set_irq = ide_set_irq, | ||
299 | |||
300 | .tf_load = at91_ide_tf_load, | ||
301 | .tf_read = at91_ide_tf_read, | ||
302 | |||
303 | .input_data = at91_ide_input_data, | ||
304 | .output_data = at91_ide_output_data, | ||
305 | }; | ||
306 | |||
307 | static const struct ide_port_ops at91_ide_port_ops = { | ||
308 | .set_pio_mode = at91_ide_set_pio_mode, | ||
309 | }; | ||
310 | |||
311 | static const struct ide_port_info at91_ide_port_info __initdata = { | ||
312 | .port_ops = &at91_ide_port_ops, | ||
313 | .tp_ops = &at91_ide_tp_ops, | ||
314 | .host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA | IDE_HFLAG_SINGLE | | ||
315 | IDE_HFLAG_NO_IO_32BIT | IDE_HFLAG_UNMASK_IRQS, | ||
316 | .pio_mask = ATA_PIO5, | ||
317 | }; | ||
318 | |||
319 | /* | ||
320 | * If interrupt is delivered through GPIO, IRQ are triggered on falling | ||
321 | * and rising edge of signal. Whereas IDE device request interrupt on high | ||
322 | * level (rising edge in our case). This mean we have fake interrupts, so | ||
323 | * we need to check interrupt pin and exit instantly from ISR when line | ||
324 | * is on low level. | ||
325 | */ | ||
326 | |||
327 | irqreturn_t at91_irq_handler(int irq, void *dev_id) | ||
328 | { | ||
329 | int ntries = 8; | ||
330 | int pin_val1, pin_val2; | ||
331 | |||
332 | /* additional deglitch, line can be noisy in badly designed PCB */ | ||
333 | do { | ||
334 | pin_val1 = at91_get_gpio_value(irq); | ||
335 | pin_val2 = at91_get_gpio_value(irq); | ||
336 | } while (pin_val1 != pin_val2 && --ntries > 0); | ||
337 | |||
338 | if (pin_val1 == 0 || ntries <= 0) | ||
339 | return IRQ_HANDLED; | ||
340 | |||
341 | return ide_intr(irq, dev_id); | ||
342 | } | ||
343 | |||
344 | static int __init at91_ide_probe(struct platform_device *pdev) | ||
345 | { | ||
346 | int ret; | ||
347 | hw_regs_t hw; | ||
348 | hw_regs_t *hws[] = { &hw, NULL, NULL, NULL }; | ||
349 | struct ide_host *host; | ||
350 | struct resource *res; | ||
351 | unsigned long tf_base = 0, ctl_base = 0; | ||
352 | struct at91_cf_data *board = pdev->dev.platform_data; | ||
353 | |||
354 | if (!board) | ||
355 | return -ENODEV; | ||
356 | |||
357 | if (board->det_pin && at91_get_gpio_value(board->det_pin) != 0) { | ||
358 | perr("no device detected\n"); | ||
359 | return -ENODEV; | ||
360 | } | ||
361 | |||
362 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
363 | if (!res) { | ||
364 | perr("can't get memory resource\n"); | ||
365 | return -ENODEV; | ||
366 | } | ||
367 | |||
368 | if (!devm_request_mem_region(&pdev->dev, res->start + TASK_FILE, | ||
369 | REGS_SIZE, "ide") || | ||
370 | !devm_request_mem_region(&pdev->dev, res->start + ALT_MODE, | ||
371 | REGS_SIZE, "alt")) { | ||
372 | perr("memory resources in use\n"); | ||
373 | return -EBUSY; | ||
374 | } | ||
375 | |||
376 | pdbg("chipselect %u irq %u res %08lx\n", board->chipselect, | ||
377 | board->irq_pin, (unsigned long) res->start); | ||
378 | |||
379 | tf_base = (unsigned long) devm_ioremap(&pdev->dev, res->start + TASK_FILE, | ||
380 | REGS_SIZE); | ||
381 | ctl_base = (unsigned long) devm_ioremap(&pdev->dev, res->start + ALT_MODE, | ||
382 | REGS_SIZE); | ||
383 | if (!tf_base || !ctl_base) { | ||
384 | perr("can't map memory regions\n"); | ||
385 | return -EBUSY; | ||
386 | } | ||
387 | |||
388 | memset(&hw, 0, sizeof(hw)); | ||
389 | |||
390 | if (board->flags & AT91_IDE_SWAP_A0_A2) { | ||
391 | /* workaround for stupid hardware bug */ | ||
392 | hw.io_ports.data_addr = tf_base + 0; | ||
393 | hw.io_ports.error_addr = tf_base + 4; | ||
394 | hw.io_ports.nsect_addr = tf_base + 2; | ||
395 | hw.io_ports.lbal_addr = tf_base + 6; | ||
396 | hw.io_ports.lbam_addr = tf_base + 1; | ||
397 | hw.io_ports.lbah_addr = tf_base + 5; | ||
398 | hw.io_ports.device_addr = tf_base + 3; | ||
399 | hw.io_ports.command_addr = tf_base + 7; | ||
400 | hw.io_ports.ctl_addr = ctl_base + 3; | ||
401 | } else | ||
402 | ide_std_init_ports(&hw, tf_base, ctl_base + 6); | ||
403 | |||
404 | hw.irq = board->irq_pin; | ||
405 | hw.chipset = ide_generic; | ||
406 | hw.dev = &pdev->dev; | ||
407 | |||
408 | host = ide_host_alloc(&at91_ide_port_info, hws); | ||
409 | if (!host) { | ||
410 | perr("failed to allocate ide host\n"); | ||
411 | return -ENOMEM; | ||
412 | } | ||
413 | |||
414 | /* setup Static Memory Controller - PIO 0 as default */ | ||
415 | apply_timings(board->chipselect, 0, ide_timing_find_mode(XFER_PIO_0), 0); | ||
416 | |||
417 | /* with GPIO interrupt we have to do quirks in handler */ | ||
418 | if (board->irq_pin >= PIN_BASE) | ||
419 | host->irq_handler = at91_irq_handler; | ||
420 | |||
421 | host->ports[0]->select_data = board->chipselect; | ||
422 | |||
423 | ret = ide_host_register(host, &at91_ide_port_info, hws); | ||
424 | if (ret) { | ||
425 | perr("failed to register ide host\n"); | ||
426 | goto err_free_host; | ||
427 | } | ||
428 | platform_set_drvdata(pdev, host); | ||
429 | return 0; | ||
430 | |||
431 | err_free_host: | ||
432 | ide_host_free(host); | ||
433 | return ret; | ||
434 | } | ||
435 | |||
436 | static int __exit at91_ide_remove(struct platform_device *pdev) | ||
437 | { | ||
438 | struct ide_host *host = platform_get_drvdata(pdev); | ||
439 | |||
440 | ide_host_remove(host); | ||
441 | return 0; | ||
442 | } | ||
443 | |||
444 | static struct platform_driver at91_ide_driver = { | ||
445 | .driver = { | ||
446 | .name = DRV_NAME, | ||
447 | .owner = THIS_MODULE, | ||
448 | }, | ||
449 | .remove = __exit_p(at91_ide_remove), | ||
450 | }; | ||
451 | |||
452 | static int __init at91_ide_init(void) | ||
453 | { | ||
454 | return platform_driver_probe(&at91_ide_driver, at91_ide_probe); | ||
455 | } | ||
456 | |||
457 | static void __exit at91_ide_exit(void) | ||
458 | { | ||
459 | platform_driver_unregister(&at91_ide_driver); | ||
460 | } | ||
461 | |||
462 | module_init(at91_ide_init); | ||
463 | module_exit(at91_ide_exit); | ||
464 | |||
465 | MODULE_LICENSE("GPL"); | ||
466 | MODULE_AUTHOR("Stanislaw Gruszka <stf_xl@wp.pl>"); | ||
467 | |||
diff --git a/drivers/ide/ide-disk_proc.c b/drivers/ide/ide-disk_proc.c index 1146f4204c6e..1f86dcbd2b1c 100644 --- a/drivers/ide/ide-disk_proc.c +++ b/drivers/ide/ide-disk_proc.c | |||
@@ -125,5 +125,5 @@ const struct ide_proc_devset ide_disk_settings[] = { | |||
125 | IDE_PROC_DEVSET(multcount, 0, 16), | 125 | IDE_PROC_DEVSET(multcount, 0, 16), |
126 | IDE_PROC_DEVSET(nowerr, 0, 1), | 126 | IDE_PROC_DEVSET(nowerr, 0, 1), |
127 | IDE_PROC_DEVSET(wcache, 0, 1), | 127 | IDE_PROC_DEVSET(wcache, 0, 1), |
128 | { 0 }, | 128 | { NULL }, |
129 | }; | 129 | }; |
diff --git a/drivers/ide/ide-floppy_proc.c b/drivers/ide/ide-floppy_proc.c index 3ec762cb60ab..fcd4d8153df5 100644 --- a/drivers/ide/ide-floppy_proc.c +++ b/drivers/ide/ide-floppy_proc.c | |||
@@ -29,5 +29,5 @@ const struct ide_proc_devset ide_floppy_settings[] = { | |||
29 | IDE_PROC_DEVSET(bios_head, 0, 255), | 29 | IDE_PROC_DEVSET(bios_head, 0, 255), |
30 | IDE_PROC_DEVSET(bios_sect, 0, 63), | 30 | IDE_PROC_DEVSET(bios_sect, 0, 63), |
31 | IDE_PROC_DEVSET(ticks, 0, 255), | 31 | IDE_PROC_DEVSET(ticks, 0, 255), |
32 | { 0 }, | 32 | { NULL }, |
33 | }; | 33 | }; |
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c index 9ee51adf567f..a9a6c208288a 100644 --- a/drivers/ide/ide-io.c +++ b/drivers/ide/ide-io.c | |||
@@ -908,7 +908,7 @@ void ide_timer_expiry (unsigned long data) | |||
908 | ide_drive_t *uninitialized_var(drive); | 908 | ide_drive_t *uninitialized_var(drive); |
909 | ide_handler_t *handler; | 909 | ide_handler_t *handler; |
910 | unsigned long flags; | 910 | unsigned long flags; |
911 | unsigned long wait = -1; | 911 | int wait = -1; |
912 | int plug_device = 0; | 912 | int plug_device = 0; |
913 | 913 | ||
914 | spin_lock_irqsave(&hwif->lock, flags); | 914 | spin_lock_irqsave(&hwif->lock, flags); |
@@ -1162,6 +1162,7 @@ out_early: | |||
1162 | 1162 | ||
1163 | return irq_ret; | 1163 | return irq_ret; |
1164 | } | 1164 | } |
1165 | EXPORT_SYMBOL_GPL(ide_intr); | ||
1165 | 1166 | ||
1166 | /** | 1167 | /** |
1167 | * ide_do_drive_cmd - issue IDE special command | 1168 | * ide_do_drive_cmd - issue IDE special command |
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c index 753b92ebe0ae..b1892bd95c6f 100644 --- a/drivers/ide/ide-iops.c +++ b/drivers/ide/ide-iops.c | |||
@@ -315,6 +315,8 @@ void ide_output_data(ide_drive_t *drive, struct request *rq, void *buf, | |||
315 | u8 io_32bit = drive->io_32bit; | 315 | u8 io_32bit = drive->io_32bit; |
316 | u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0; | 316 | u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0; |
317 | 317 | ||
318 | len++; | ||
319 | |||
318 | if (io_32bit) { | 320 | if (io_32bit) { |
319 | unsigned long uninitialized_var(flags); | 321 | unsigned long uninitialized_var(flags); |
320 | 322 | ||
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c index ce0818a993f6..ee8e3e7cad51 100644 --- a/drivers/ide/ide-probe.c +++ b/drivers/ide/ide-probe.c | |||
@@ -950,6 +950,7 @@ static int ide_port_setup_devices(ide_hwif_t *hwif) | |||
950 | static int init_irq (ide_hwif_t *hwif) | 950 | static int init_irq (ide_hwif_t *hwif) |
951 | { | 951 | { |
952 | struct ide_io_ports *io_ports = &hwif->io_ports; | 952 | struct ide_io_ports *io_ports = &hwif->io_ports; |
953 | irq_handler_t irq_handler; | ||
953 | int sa = 0; | 954 | int sa = 0; |
954 | 955 | ||
955 | mutex_lock(&ide_cfg_mtx); | 956 | mutex_lock(&ide_cfg_mtx); |
@@ -959,6 +960,10 @@ static int init_irq (ide_hwif_t *hwif) | |||
959 | hwif->timer.function = &ide_timer_expiry; | 960 | hwif->timer.function = &ide_timer_expiry; |
960 | hwif->timer.data = (unsigned long)hwif; | 961 | hwif->timer.data = (unsigned long)hwif; |
961 | 962 | ||
963 | irq_handler = hwif->host->irq_handler; | ||
964 | if (irq_handler == NULL) | ||
965 | irq_handler = ide_intr; | ||
966 | |||
962 | #if defined(__mc68000__) | 967 | #if defined(__mc68000__) |
963 | sa = IRQF_SHARED; | 968 | sa = IRQF_SHARED; |
964 | #endif /* __mc68000__ */ | 969 | #endif /* __mc68000__ */ |
@@ -969,7 +974,7 @@ static int init_irq (ide_hwif_t *hwif) | |||
969 | if (io_ports->ctl_addr) | 974 | if (io_ports->ctl_addr) |
970 | hwif->tp_ops->set_irq(hwif, 1); | 975 | hwif->tp_ops->set_irq(hwif, 1); |
971 | 976 | ||
972 | if (request_irq(hwif->irq, &ide_intr, sa, hwif->name, hwif)) | 977 | if (request_irq(hwif->irq, irq_handler, sa, hwif->name, hwif)) |
973 | goto out_up; | 978 | goto out_up; |
974 | 979 | ||
975 | if (!hwif->rqsize) { | 980 | if (!hwif->rqsize) { |
diff --git a/drivers/ide/ide-proc.c b/drivers/ide/ide-proc.c index 1d8978b3314a..a7b9287ee0d4 100644 --- a/drivers/ide/ide-proc.c +++ b/drivers/ide/ide-proc.c | |||
@@ -231,7 +231,7 @@ static const struct ide_proc_devset ide_generic_settings[] = { | |||
231 | IDE_PROC_DEVSET(pio_mode, 0, 255), | 231 | IDE_PROC_DEVSET(pio_mode, 0, 255), |
232 | IDE_PROC_DEVSET(unmaskirq, 0, 1), | 232 | IDE_PROC_DEVSET(unmaskirq, 0, 1), |
233 | IDE_PROC_DEVSET(using_dma, 0, 1), | 233 | IDE_PROC_DEVSET(using_dma, 0, 1), |
234 | { 0 }, | 234 | { NULL }, |
235 | }; | 235 | }; |
236 | 236 | ||
237 | static void proc_ide_settings_warn(void) | 237 | static void proc_ide_settings_warn(void) |
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index bb450a7608c2..4e6181c7bbda 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c | |||
@@ -2166,7 +2166,7 @@ static const struct ide_proc_devset idetape_settings[] = { | |||
2166 | __IDE_PROC_DEVSET(speed, 0, 0xffff, NULL, NULL), | 2166 | __IDE_PROC_DEVSET(speed, 0, 0xffff, NULL, NULL), |
2167 | __IDE_PROC_DEVSET(tdsc, IDETAPE_DSC_RW_MIN, IDETAPE_DSC_RW_MAX, | 2167 | __IDE_PROC_DEVSET(tdsc, IDETAPE_DSC_RW_MIN, IDETAPE_DSC_RW_MAX, |
2168 | mulf_tdsc, divf_tdsc), | 2168 | mulf_tdsc, divf_tdsc), |
2169 | { 0 }, | 2169 | { NULL }, |
2170 | }; | 2170 | }; |
2171 | #endif | 2171 | #endif |
2172 | 2172 | ||
diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c index 9c50e6f1c236..34ce2703d29a 100644 --- a/drivers/mmc/core/mmc_ops.c +++ b/drivers/mmc/core/mmc_ops.c | |||
@@ -248,12 +248,15 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host, | |||
248 | 248 | ||
249 | sg_init_one(&sg, data_buf, len); | 249 | sg_init_one(&sg, data_buf, len); |
250 | 250 | ||
251 | /* | 251 | if (opcode == MMC_SEND_CSD || opcode == MMC_SEND_CID) { |
252 | * The spec states that CSR and CID accesses have a timeout | 252 | /* |
253 | * of 64 clock cycles. | 253 | * The spec states that CSR and CID accesses have a timeout |
254 | */ | 254 | * of 64 clock cycles. |
255 | data.timeout_ns = 0; | 255 | */ |
256 | data.timeout_clks = 64; | 256 | data.timeout_ns = 0; |
257 | data.timeout_clks = 64; | ||
258 | } else | ||
259 | mmc_set_data_timeout(&data, card); | ||
257 | 260 | ||
258 | mmc_wait_for_req(host, &mrq); | 261 | mmc_wait_for_req(host, &mrq); |
259 | 262 | ||
diff --git a/drivers/watchdog/gef_wdt.c b/drivers/watchdog/gef_wdt.c index f0c2b7a1a175..734d9806a872 100644 --- a/drivers/watchdog/gef_wdt.c +++ b/drivers/watchdog/gef_wdt.c | |||
@@ -269,7 +269,7 @@ static int __devinit gef_wdt_probe(struct of_device *dev, | |||
269 | bus_clk = 133; /* in MHz */ | 269 | bus_clk = 133; /* in MHz */ |
270 | 270 | ||
271 | freq = fsl_get_sys_freq(); | 271 | freq = fsl_get_sys_freq(); |
272 | if (freq > 0) | 272 | if (freq != -1) |
273 | bus_clk = freq; | 273 | bus_clk = freq; |
274 | 274 | ||
275 | /* Map devices registers into memory */ | 275 | /* Map devices registers into memory */ |
diff --git a/drivers/watchdog/ks8695_wdt.c b/drivers/watchdog/ks8695_wdt.c index 0b798fdaa378..74c92d384112 100644 --- a/drivers/watchdog/ks8695_wdt.c +++ b/drivers/watchdog/ks8695_wdt.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <linux/watchdog.h> | 21 | #include <linux/watchdog.h> |
22 | #include <linux/io.h> | 22 | #include <linux/io.h> |
23 | #include <linux/uaccess.h> | 23 | #include <linux/uaccess.h> |
24 | #include <mach/timex.h> | ||
24 | #include <mach/regs-timer.h> | 25 | #include <mach/regs-timer.h> |
25 | 26 | ||
26 | #define WDT_DEFAULT_TIME 5 /* seconds */ | 27 | #define WDT_DEFAULT_TIME 5 /* seconds */ |
diff --git a/drivers/watchdog/orion5x_wdt.c b/drivers/watchdog/orion5x_wdt.c index 14a339f58b6a..b64ae1a17832 100644 --- a/drivers/watchdog/orion5x_wdt.c +++ b/drivers/watchdog/orion5x_wdt.c | |||
@@ -29,6 +29,7 @@ | |||
29 | #define WDT_EN 0x0010 | 29 | #define WDT_EN 0x0010 |
30 | #define WDT_VAL (TIMER_VIRT_BASE + 0x0024) | 30 | #define WDT_VAL (TIMER_VIRT_BASE + 0x0024) |
31 | 31 | ||
32 | #define ORION5X_TCLK 166666667 | ||
32 | #define WDT_MAX_DURATION (0xffffffff / ORION5X_TCLK) | 33 | #define WDT_MAX_DURATION (0xffffffff / ORION5X_TCLK) |
33 | #define WDT_IN_USE 0 | 34 | #define WDT_IN_USE 0 |
34 | #define WDT_OK_TO_CLOSE 1 | 35 | #define WDT_OK_TO_CLOSE 1 |
diff --git a/drivers/watchdog/rc32434_wdt.c b/drivers/watchdog/rc32434_wdt.c index 57027f4653ce..f3553fa40b17 100644 --- a/drivers/watchdog/rc32434_wdt.c +++ b/drivers/watchdog/rc32434_wdt.c | |||
@@ -34,104 +34,89 @@ | |||
34 | #include <asm/time.h> | 34 | #include <asm/time.h> |
35 | #include <asm/mach-rc32434/integ.h> | 35 | #include <asm/mach-rc32434/integ.h> |
36 | 36 | ||
37 | #define MAX_TIMEOUT 20 | 37 | #define VERSION "0.4" |
38 | #define RC32434_WDT_INTERVAL (15 * HZ) | ||
39 | |||
40 | #define VERSION "0.2" | ||
41 | 38 | ||
42 | static struct { | 39 | static struct { |
43 | struct completion stop; | ||
44 | int running; | ||
45 | struct timer_list timer; | ||
46 | int queue; | ||
47 | int default_ticks; | ||
48 | unsigned long inuse; | 40 | unsigned long inuse; |
49 | } rc32434_wdt_device; | 41 | } rc32434_wdt_device; |
50 | 42 | ||
51 | static struct integ __iomem *wdt_reg; | 43 | static struct integ __iomem *wdt_reg; |
52 | static int ticks = 100 * HZ; | ||
53 | 44 | ||
54 | static int expect_close; | 45 | static int expect_close; |
55 | static int timeout; | 46 | |
47 | /* Board internal clock speed in Hz, | ||
48 | * the watchdog timer ticks at. */ | ||
49 | extern unsigned int idt_cpu_freq; | ||
50 | |||
51 | /* translate wtcompare value to seconds and vice versa */ | ||
52 | #define WTCOMP2SEC(x) (x / idt_cpu_freq) | ||
53 | #define SEC2WTCOMP(x) (x * idt_cpu_freq) | ||
54 | |||
55 | /* Use a default timeout of 20s. This should be | ||
56 | * safe for CPU clock speeds up to 400MHz, as | ||
57 | * ((2 ^ 32) - 1) / (400MHz / 2) = 21s. */ | ||
58 | #define WATCHDOG_TIMEOUT 20 | ||
59 | |||
60 | static int timeout = WATCHDOG_TIMEOUT; | ||
56 | 61 | ||
57 | static int nowayout = WATCHDOG_NOWAYOUT; | 62 | static int nowayout = WATCHDOG_NOWAYOUT; |
58 | module_param(nowayout, int, 0); | 63 | module_param(nowayout, int, 0); |
59 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" | 64 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" |
60 | __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); | 65 | __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); |
61 | 66 | ||
67 | /* apply or and nand masks to data read from addr and write back */ | ||
68 | #define SET_BITS(addr, or, nand) \ | ||
69 | writel((readl(&addr) | or) & ~nand, &addr) | ||
62 | 70 | ||
63 | static void rc32434_wdt_start(void) | 71 | static void rc32434_wdt_start(void) |
64 | { | 72 | { |
65 | u32 val; | 73 | u32 or, nand; |
66 | |||
67 | if (!rc32434_wdt_device.inuse) { | ||
68 | writel(0, &wdt_reg->wtcount); | ||
69 | 74 | ||
70 | val = RC32434_ERR_WRE; | 75 | /* zero the counter before enabling */ |
71 | writel(readl(&wdt_reg->errcs) | val, &wdt_reg->errcs); | 76 | writel(0, &wdt_reg->wtcount); |
72 | 77 | ||
73 | val = RC32434_WTC_EN; | 78 | /* don't generate a non-maskable interrupt, |
74 | writel(readl(&wdt_reg->wtc) | val, &wdt_reg->wtc); | 79 | * do a warm reset instead */ |
75 | } | 80 | nand = 1 << RC32434_ERR_WNE; |
76 | rc32434_wdt_device.running++; | 81 | or = 1 << RC32434_ERR_WRE; |
77 | } | ||
78 | 82 | ||
79 | static void rc32434_wdt_stop(void) | 83 | /* reset the ERRCS timeout bit in case it's set */ |
80 | { | 84 | nand |= 1 << RC32434_ERR_WTO; |
81 | u32 val; | ||
82 | 85 | ||
83 | if (rc32434_wdt_device.running) { | 86 | SET_BITS(wdt_reg->errcs, or, nand); |
84 | 87 | ||
85 | val = ~RC32434_WTC_EN; | 88 | /* reset WTC timeout bit and enable WDT */ |
86 | writel(readl(&wdt_reg->wtc) & val, &wdt_reg->wtc); | 89 | nand = 1 << RC32434_WTC_TO; |
90 | or = 1 << RC32434_WTC_EN; | ||
87 | 91 | ||
88 | val = ~RC32434_ERR_WRE; | 92 | SET_BITS(wdt_reg->wtc, or, nand); |
89 | writel(readl(&wdt_reg->errcs) & val, &wdt_reg->errcs); | 93 | } |
90 | 94 | ||
91 | rc32434_wdt_device.running = 0; | 95 | static void rc32434_wdt_stop(void) |
92 | } | 96 | { |
97 | /* Disable WDT */ | ||
98 | SET_BITS(wdt_reg->wtc, 0, 1 << RC32434_WTC_EN); | ||
93 | } | 99 | } |
94 | 100 | ||
95 | static void rc32434_wdt_set(int new_timeout) | 101 | static int rc32434_wdt_set(int new_timeout) |
96 | { | 102 | { |
97 | u32 cmp = new_timeout * HZ; | 103 | int max_to = WTCOMP2SEC((u32)-1); |
98 | u32 state, val; | ||
99 | 104 | ||
105 | if (new_timeout < 0 || new_timeout > max_to) { | ||
106 | printk(KERN_ERR KBUILD_MODNAME | ||
107 | ": timeout value must be between 0 and %d", | ||
108 | max_to); | ||
109 | return -EINVAL; | ||
110 | } | ||
100 | timeout = new_timeout; | 111 | timeout = new_timeout; |
101 | /* | 112 | writel(SEC2WTCOMP(timeout), &wdt_reg->wtcompare); |
102 | * store and disable WTC | ||
103 | */ | ||
104 | state = (u32)(readl(&wdt_reg->wtc) & RC32434_WTC_EN); | ||
105 | val = ~RC32434_WTC_EN; | ||
106 | writel(readl(&wdt_reg->wtc) & val, &wdt_reg->wtc); | ||
107 | |||
108 | writel(0, &wdt_reg->wtcount); | ||
109 | writel(cmp, &wdt_reg->wtcompare); | ||
110 | |||
111 | /* | ||
112 | * restore WTC | ||
113 | */ | ||
114 | |||
115 | writel(readl(&wdt_reg->wtc) | state, &wdt_reg); | ||
116 | } | ||
117 | 113 | ||
118 | static void rc32434_wdt_reset(void) | 114 | return 0; |
119 | { | ||
120 | ticks = rc32434_wdt_device.default_ticks; | ||
121 | } | 115 | } |
122 | 116 | ||
123 | static void rc32434_wdt_update(unsigned long unused) | 117 | static void rc32434_wdt_ping(void) |
124 | { | 118 | { |
125 | if (rc32434_wdt_device.running) | ||
126 | ticks--; | ||
127 | |||
128 | writel(0, &wdt_reg->wtcount); | 119 | writel(0, &wdt_reg->wtcount); |
129 | |||
130 | if (rc32434_wdt_device.queue && ticks) | ||
131 | mod_timer(&rc32434_wdt_device.timer, | ||
132 | jiffies + RC32434_WDT_INTERVAL); | ||
133 | else | ||
134 | complete(&rc32434_wdt_device.stop); | ||
135 | } | 120 | } |
136 | 121 | ||
137 | static int rc32434_wdt_open(struct inode *inode, struct file *file) | 122 | static int rc32434_wdt_open(struct inode *inode, struct file *file) |
@@ -142,19 +127,23 @@ static int rc32434_wdt_open(struct inode *inode, struct file *file) | |||
142 | if (nowayout) | 127 | if (nowayout) |
143 | __module_get(THIS_MODULE); | 128 | __module_get(THIS_MODULE); |
144 | 129 | ||
130 | rc32434_wdt_start(); | ||
131 | rc32434_wdt_ping(); | ||
132 | |||
145 | return nonseekable_open(inode, file); | 133 | return nonseekable_open(inode, file); |
146 | } | 134 | } |
147 | 135 | ||
148 | static int rc32434_wdt_release(struct inode *inode, struct file *file) | 136 | static int rc32434_wdt_release(struct inode *inode, struct file *file) |
149 | { | 137 | { |
150 | if (expect_close && nowayout == 0) { | 138 | if (expect_close == 42) { |
151 | rc32434_wdt_stop(); | 139 | rc32434_wdt_stop(); |
152 | printk(KERN_INFO KBUILD_MODNAME ": disabling watchdog timer\n"); | 140 | printk(KERN_INFO KBUILD_MODNAME ": disabling watchdog timer\n"); |
153 | module_put(THIS_MODULE); | 141 | module_put(THIS_MODULE); |
154 | } else | 142 | } else { |
155 | printk(KERN_CRIT KBUILD_MODNAME | 143 | printk(KERN_CRIT KBUILD_MODNAME |
156 | ": device closed unexpectedly. WDT will not stop !\n"); | 144 | ": device closed unexpectedly. WDT will not stop !\n"); |
157 | 145 | rc32434_wdt_ping(); | |
146 | } | ||
158 | clear_bit(0, &rc32434_wdt_device.inuse); | 147 | clear_bit(0, &rc32434_wdt_device.inuse); |
159 | return 0; | 148 | return 0; |
160 | } | 149 | } |
@@ -174,10 +163,10 @@ static ssize_t rc32434_wdt_write(struct file *file, const char *data, | |||
174 | if (get_user(c, data + i)) | 163 | if (get_user(c, data + i)) |
175 | return -EFAULT; | 164 | return -EFAULT; |
176 | if (c == 'V') | 165 | if (c == 'V') |
177 | expect_close = 1; | 166 | expect_close = 42; |
178 | } | 167 | } |
179 | } | 168 | } |
180 | rc32434_wdt_update(0); | 169 | rc32434_wdt_ping(); |
181 | return len; | 170 | return len; |
182 | } | 171 | } |
183 | return 0; | 172 | return 0; |
@@ -197,11 +186,11 @@ static long rc32434_wdt_ioctl(struct file *file, unsigned int cmd, | |||
197 | }; | 186 | }; |
198 | switch (cmd) { | 187 | switch (cmd) { |
199 | case WDIOC_KEEPALIVE: | 188 | case WDIOC_KEEPALIVE: |
200 | rc32434_wdt_reset(); | 189 | rc32434_wdt_ping(); |
201 | break; | 190 | break; |
202 | case WDIOC_GETSTATUS: | 191 | case WDIOC_GETSTATUS: |
203 | case WDIOC_GETBOOTSTATUS: | 192 | case WDIOC_GETBOOTSTATUS: |
204 | value = readl(&wdt_reg->wtcount); | 193 | value = 0; |
205 | if (copy_to_user(argp, &value, sizeof(int))) | 194 | if (copy_to_user(argp, &value, sizeof(int))) |
206 | return -EFAULT; | 195 | return -EFAULT; |
207 | break; | 196 | break; |
@@ -218,6 +207,7 @@ static long rc32434_wdt_ioctl(struct file *file, unsigned int cmd, | |||
218 | break; | 207 | break; |
219 | case WDIOS_DISABLECARD: | 208 | case WDIOS_DISABLECARD: |
220 | rc32434_wdt_stop(); | 209 | rc32434_wdt_stop(); |
210 | break; | ||
221 | default: | 211 | default: |
222 | return -EINVAL; | 212 | return -EINVAL; |
223 | } | 213 | } |
@@ -225,11 +215,9 @@ static long rc32434_wdt_ioctl(struct file *file, unsigned int cmd, | |||
225 | case WDIOC_SETTIMEOUT: | 215 | case WDIOC_SETTIMEOUT: |
226 | if (copy_from_user(&new_timeout, argp, sizeof(int))) | 216 | if (copy_from_user(&new_timeout, argp, sizeof(int))) |
227 | return -EFAULT; | 217 | return -EFAULT; |
228 | if (new_timeout < 1) | 218 | if (rc32434_wdt_set(new_timeout)) |
229 | return -EINVAL; | 219 | return -EINVAL; |
230 | if (new_timeout > MAX_TIMEOUT) | 220 | /* Fall through */ |
231 | return -EINVAL; | ||
232 | rc32434_wdt_set(new_timeout); | ||
233 | case WDIOC_GETTIMEOUT: | 221 | case WDIOC_GETTIMEOUT: |
234 | return copy_to_user(argp, &timeout, sizeof(int)); | 222 | return copy_to_user(argp, &timeout, sizeof(int)); |
235 | default: | 223 | default: |
@@ -254,15 +242,15 @@ static struct miscdevice rc32434_wdt_miscdev = { | |||
254 | .fops = &rc32434_wdt_fops, | 242 | .fops = &rc32434_wdt_fops, |
255 | }; | 243 | }; |
256 | 244 | ||
257 | static char banner[] = KERN_INFO KBUILD_MODNAME | 245 | static char banner[] __devinitdata = KERN_INFO KBUILD_MODNAME |
258 | ": Watchdog Timer version " VERSION ", timer margin: %d sec\n"; | 246 | ": Watchdog Timer version " VERSION ", timer margin: %d sec\n"; |
259 | 247 | ||
260 | static int rc32434_wdt_probe(struct platform_device *pdev) | 248 | static int __devinit rc32434_wdt_probe(struct platform_device *pdev) |
261 | { | 249 | { |
262 | int ret; | 250 | int ret; |
263 | struct resource *r; | 251 | struct resource *r; |
264 | 252 | ||
265 | r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "rb500_wdt_res"); | 253 | r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "rb532_wdt_res"); |
266 | if (!r) { | 254 | if (!r) { |
267 | printk(KERN_ERR KBUILD_MODNAME | 255 | printk(KERN_ERR KBUILD_MODNAME |
268 | "failed to retrieve resources\n"); | 256 | "failed to retrieve resources\n"); |
@@ -277,24 +265,12 @@ static int rc32434_wdt_probe(struct platform_device *pdev) | |||
277 | } | 265 | } |
278 | 266 | ||
279 | ret = misc_register(&rc32434_wdt_miscdev); | 267 | ret = misc_register(&rc32434_wdt_miscdev); |
280 | |||
281 | if (ret < 0) { | 268 | if (ret < 0) { |
282 | printk(KERN_ERR KBUILD_MODNAME | 269 | printk(KERN_ERR KBUILD_MODNAME |
283 | "failed to register watchdog device\n"); | 270 | "failed to register watchdog device\n"); |
284 | goto unmap; | 271 | goto unmap; |
285 | } | 272 | } |
286 | 273 | ||
287 | init_completion(&rc32434_wdt_device.stop); | ||
288 | rc32434_wdt_device.queue = 0; | ||
289 | |||
290 | clear_bit(0, &rc32434_wdt_device.inuse); | ||
291 | |||
292 | setup_timer(&rc32434_wdt_device.timer, rc32434_wdt_update, 0L); | ||
293 | |||
294 | rc32434_wdt_device.default_ticks = ticks; | ||
295 | |||
296 | rc32434_wdt_start(); | ||
297 | |||
298 | printk(banner, timeout); | 274 | printk(banner, timeout); |
299 | 275 | ||
300 | return 0; | 276 | return 0; |
@@ -304,23 +280,17 @@ unmap: | |||
304 | return ret; | 280 | return ret; |
305 | } | 281 | } |
306 | 282 | ||
307 | static int rc32434_wdt_remove(struct platform_device *pdev) | 283 | static int __devexit rc32434_wdt_remove(struct platform_device *pdev) |
308 | { | 284 | { |
309 | if (rc32434_wdt_device.queue) { | ||
310 | rc32434_wdt_device.queue = 0; | ||
311 | wait_for_completion(&rc32434_wdt_device.stop); | ||
312 | } | ||
313 | misc_deregister(&rc32434_wdt_miscdev); | 285 | misc_deregister(&rc32434_wdt_miscdev); |
314 | |||
315 | iounmap(wdt_reg); | 286 | iounmap(wdt_reg); |
316 | |||
317 | return 0; | 287 | return 0; |
318 | } | 288 | } |
319 | 289 | ||
320 | static struct platform_driver rc32434_wdt = { | 290 | static struct platform_driver rc32434_wdt = { |
321 | .probe = rc32434_wdt_probe, | 291 | .probe = rc32434_wdt_probe, |
322 | .remove = rc32434_wdt_remove, | 292 | .remove = __devexit_p(rc32434_wdt_remove), |
323 | .driver = { | 293 | .driver = { |
324 | .name = "rc32434_wdt", | 294 | .name = "rc32434_wdt", |
325 | } | 295 | } |
326 | }; | 296 | }; |