diff options
Diffstat (limited to 'drivers/mtd/nand/r852.c')
-rw-r--r-- | drivers/mtd/nand/r852.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/drivers/mtd/nand/r852.c b/drivers/mtd/nand/r852.c index 78a423295474..bcfc851fe550 100644 --- a/drivers/mtd/nand/r852.c +++ b/drivers/mtd/nand/r852.c | |||
@@ -150,7 +150,6 @@ static void r852_dma_done(struct r852_device *dev, int error) | |||
150 | if (dev->phys_dma_addr && dev->phys_dma_addr != dev->phys_bounce_buffer) | 150 | if (dev->phys_dma_addr && dev->phys_dma_addr != dev->phys_bounce_buffer) |
151 | pci_unmap_single(dev->pci_dev, dev->phys_dma_addr, R852_DMA_LEN, | 151 | pci_unmap_single(dev->pci_dev, dev->phys_dma_addr, R852_DMA_LEN, |
152 | dev->dma_dir ? PCI_DMA_FROMDEVICE : PCI_DMA_TODEVICE); | 152 | dev->dma_dir ? PCI_DMA_FROMDEVICE : PCI_DMA_TODEVICE); |
153 | complete(&dev->dma_done); | ||
154 | } | 153 | } |
155 | 154 | ||
156 | /* | 155 | /* |
@@ -182,6 +181,7 @@ static void r852_do_dma(struct r852_device *dev, uint8_t *buf, int do_read) | |||
182 | /* Set dma direction */ | 181 | /* Set dma direction */ |
183 | dev->dma_dir = do_read; | 182 | dev->dma_dir = do_read; |
184 | dev->dma_stage = 1; | 183 | dev->dma_stage = 1; |
184 | INIT_COMPLETION(dev->dma_done); | ||
185 | 185 | ||
186 | dbg_verbose("doing dma %s ", do_read ? "read" : "write"); | 186 | dbg_verbose("doing dma %s ", do_read ? "read" : "write"); |
187 | 187 | ||
@@ -494,6 +494,11 @@ int r852_ecc_correct(struct mtd_info *mtd, uint8_t *dat, | |||
494 | if (dev->card_unstable) | 494 | if (dev->card_unstable) |
495 | return 0; | 495 | return 0; |
496 | 496 | ||
497 | if (dev->dma_error) { | ||
498 | dev->dma_error = 0; | ||
499 | return -1; | ||
500 | } | ||
501 | |||
497 | r852_write_reg(dev, R852_CTL, dev->ctlreg | R852_CTL_ECC_ACCESS); | 502 | r852_write_reg(dev, R852_CTL, dev->ctlreg | R852_CTL_ECC_ACCESS); |
498 | ecc_reg = r852_read_reg_dword(dev, R852_DATALINE); | 503 | ecc_reg = r852_read_reg_dword(dev, R852_DATALINE); |
499 | r852_write_reg(dev, R852_CTL, dev->ctlreg); | 504 | r852_write_reg(dev, R852_CTL, dev->ctlreg); |
@@ -707,6 +712,7 @@ void r852_card_detect_work(struct work_struct *work) | |||
707 | container_of(work, struct r852_device, card_detect_work.work); | 712 | container_of(work, struct r852_device, card_detect_work.work); |
708 | 713 | ||
709 | r852_card_update_present(dev); | 714 | r852_card_update_present(dev); |
715 | r852_update_card_detect(dev); | ||
710 | dev->card_unstable = 0; | 716 | dev->card_unstable = 0; |
711 | 717 | ||
712 | /* False alarm */ | 718 | /* False alarm */ |
@@ -722,7 +728,6 @@ void r852_card_detect_work(struct work_struct *work) | |||
722 | else | 728 | else |
723 | r852_unregister_nand_device(dev); | 729 | r852_unregister_nand_device(dev); |
724 | exit: | 730 | exit: |
725 | /* Update detection logic */ | ||
726 | r852_update_card_detect(dev); | 731 | r852_update_card_detect(dev); |
727 | } | 732 | } |
728 | 733 | ||
@@ -796,6 +801,7 @@ static irqreturn_t r852_irq(int irq, void *data) | |||
796 | if (dma_status & R852_DMA_IRQ_ERROR) { | 801 | if (dma_status & R852_DMA_IRQ_ERROR) { |
797 | dbg("recieved dma error IRQ"); | 802 | dbg("recieved dma error IRQ"); |
798 | r852_dma_done(dev, -EIO); | 803 | r852_dma_done(dev, -EIO); |
804 | complete(&dev->dma_done); | ||
799 | goto out; | 805 | goto out; |
800 | } | 806 | } |
801 | 807 | ||
@@ -825,8 +831,10 @@ static irqreturn_t r852_irq(int irq, void *data) | |||
825 | r852_dma_enable(dev); | 831 | r852_dma_enable(dev); |
826 | 832 | ||
827 | /* Operation done */ | 833 | /* Operation done */ |
828 | if (dev->dma_stage == 3) | 834 | if (dev->dma_stage == 3) { |
829 | r852_dma_done(dev, 0); | 835 | r852_dma_done(dev, 0); |
836 | complete(&dev->dma_done); | ||
837 | } | ||
830 | goto out; | 838 | goto out; |
831 | } | 839 | } |
832 | 840 | ||
@@ -940,18 +948,19 @@ int r852_probe(struct pci_dev *pci_dev, const struct pci_device_id *id) | |||
940 | 948 | ||
941 | r852_dma_test(dev); | 949 | r852_dma_test(dev); |
942 | 950 | ||
951 | dev->irq = pci_dev->irq; | ||
952 | spin_lock_init(&dev->irqlock); | ||
953 | |||
954 | dev->card_detected = 0; | ||
955 | r852_card_update_present(dev); | ||
956 | |||
943 | /*register irq handler*/ | 957 | /*register irq handler*/ |
944 | error = -ENODEV; | 958 | error = -ENODEV; |
945 | if (request_irq(pci_dev->irq, &r852_irq, IRQF_SHARED, | 959 | if (request_irq(pci_dev->irq, &r852_irq, IRQF_SHARED, |
946 | DRV_NAME, dev)) | 960 | DRV_NAME, dev)) |
947 | goto error10; | 961 | goto error10; |
948 | 962 | ||
949 | dev->irq = pci_dev->irq; | ||
950 | spin_lock_init(&dev->irqlock); | ||
951 | |||
952 | /* kick initial present test */ | 963 | /* kick initial present test */ |
953 | dev->card_detected = 0; | ||
954 | r852_card_update_present(dev); | ||
955 | queue_delayed_work(dev->card_workqueue, | 964 | queue_delayed_work(dev->card_workqueue, |
956 | &dev->card_detect_work, 0); | 965 | &dev->card_detect_work, 0); |
957 | 966 | ||
@@ -1081,7 +1090,7 @@ int r852_resume(struct device *device) | |||
1081 | dev->card_detected ? "added" : "removed"); | 1090 | dev->card_detected ? "added" : "removed"); |
1082 | 1091 | ||
1083 | queue_delayed_work(dev->card_workqueue, | 1092 | queue_delayed_work(dev->card_workqueue, |
1084 | &dev->card_detect_work, 1000); | 1093 | &dev->card_detect_work, msecs_to_jiffies(1000)); |
1085 | return 0; | 1094 | return 0; |
1086 | } | 1095 | } |
1087 | 1096 | ||