10 #include <linux/kernel.h>
11 #include <linux/module.h>
15 #include <linux/pci.h>
18 #include <linux/slab.h>
19 #include <asm/byteorder.h>
20 #include <linux/sched.h>
25 static bool r852_enable_dma = 1;
57 static inline void r852_write_reg_dword(
struct r852_device *dev,
79 message(
"Non dma capable device detected, dma disabled");
81 if (!r852_enable_dma) {
82 message(
"disabling dma on user request");
91 static void r852_dma_enable(
struct r852_device *dev)
163 dbg(
"timeout waiting for DMA interrupt");
186 dbg_verbose(
"doing dma %s ", do_read ?
"read" :
"write");
214 r852_dma_enable(dev);
215 spin_unlock_irqrestore(&dev->
irqlock, flags);
218 error = r852_dma_wait(dev);
221 r852_dma_done(dev, error);
225 if (do_read && bounce)
243 r852_do_dma(dev, (
uint8_t *)buf, 0);
249 reg = buf[0] | buf[1] << 8 | buf[2] << 16 | buf[3] << 24;
278 r852_do_dma(dev, buf, 1);
287 *buf++ = (reg >> 8) & 0xFF;
288 *buf++ = (reg >> 16) & 0xFF;
289 *buf++ = (reg >> 24) & 0xFF;
364 unsigned long timeout;
449 oob->
ecc1[1] = (ecc1 >> 8) & 0xFF;
450 oob->
ecc1[2] = (ecc1 >> 16) & 0xFF;
453 oob->
ecc2[1] = (ecc2 >> 8) & 0xFF;
454 oob->
ecc2[2] = (ecc2 >> 16) & 0xFF;
485 for (i = 0 ; i <= 1 ; i++) {
487 ecc_status = (ecc_reg >> 8) & 0xFF;
491 dbg(
"ecc: unrecoverable error, in half %d", i);
499 err_byte = ecc_reg & 0xFF;
500 dbg(
"ecc: recoverable error, "
501 "in half %d, byte %d, bit %d", i,
552 r852_write_reg_dword(dev,
R852_HW, 0);
568 spin_unlock_irqrestore(&dev->
irqlock, flags);
594 char *
data = dev->
sm ?
"smartmedia" :
"xd";
613 spin_unlock_irqrestore(&dev->
irqlock, flags);
621 message(
"detected %s %s card in slot",
622 dev->
sm ?
"SmartMedia" :
"xD",
623 readonly ?
"readonly" :
"writeable");
626 spin_unlock_irqrestore(&dev->
irqlock, flags);
655 message(
"can't create media type sysfs attribute");
711 static void r852_disable_irqs(
struct r852_device *dev)
751 r852_disable_irqs(dev);
773 dbg(
"received dma error IRQ");
774 r852_dma_done(dev, -
EIO);
802 r852_dma_enable(dev);
806 r852_dma_done(dev, 0);
814 dbg(
"bad dma IRQ status = %x", dma_status);
817 dbg(
"strange card status = %x", card_status);
820 spin_unlock_irqrestore(&dev->
irqlock, flags);
869 chip->
ecc.strength = 2;
875 chip->
ecc.read_oob = r852_read_oob;
886 pci_set_drvdata(pci_dev, dev);
918 r852_disable_irqs(dev);
966 struct r852_device *dev = pci_get_drvdata(pci_dev);
977 r852_disable_irqs(dev);
997 struct r852_device *dev = pci_get_drvdata(pci_dev);
1000 r852_disable_irqs(dev);
1017 r852_disable_irqs(dev);
1031 r852_disable_irqs(dev);
1038 dbg(
"card was %s during low power state",
1049 dev->
chip->select_chip(dev->
mtd, 0);
1051 dev->
chip->select_chip(dev->
mtd, -1);
1059 #define r852_suspend NULL
1060 #define r852_resume NULL
1075 .id_table = r852_pci_id_tbl,
1079 .driver.pm = &r852_pm_ops,