Blame view
drivers/ata/pata_marvell.c
4.43 KB
75742cb41
|
1 2 3 4 5 6 7 |
/* * Marvell PATA driver. * * For the moment we drive the PATA port in legacy mode. That * isn't making full use of the device functionality but it is * easy to get working. * |
ab7716300
|
8 |
* (c) 2006 Red Hat |
75742cb41
|
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
*/ #include <linux/kernel.h> #include <linux/module.h> #include <linux/pci.h> #include <linux/init.h> #include <linux/blkdev.h> #include <linux/delay.h> #include <linux/device.h> #include <scsi/scsi_host.h> #include <linux/libata.h> #include <linux/ata.h> #define DRV_NAME "pata_marvell" |
5b66c829b
|
23 |
#define DRV_VERSION "0.1.6" |
75742cb41
|
24 25 |
/** |
5b66c829b
|
26 27 |
* marvell_pata_active - check if PATA is active * @pdev: PCI device |
75742cb41
|
28 |
* |
5b66c829b
|
29 30 |
* Returns 1 if the PATA port may be active. We know how to check this * for the 6145 but not the other devices |
75742cb41
|
31 |
*/ |
5b66c829b
|
32 |
static int marvell_pata_active(struct pci_dev *pdev) |
75742cb41
|
33 |
{ |
5b66c829b
|
34 |
int i; |
75742cb41
|
35 |
u32 devices; |
75742cb41
|
36 |
void __iomem *barp; |
75742cb41
|
37 |
|
5b66c829b
|
38 39 |
/* We don't yet know how to do this for other devices */ if (pdev->device != 0x6145) |
4fca377f7
|
40 |
return 1; |
75742cb41
|
41 |
|
6e9d8629b
|
42 |
barp = pci_iomap(pdev, 5, 0x10); |
75742cb41
|
43 44 |
if (barp == NULL) return -ENOMEM; |
5b66c829b
|
45 |
|
75742cb41
|
46 47 |
printk("BAR5:"); for(i = 0; i <= 0x0F; i++) |
90925d305
|
48 |
printk("%02X:%02X ", i, ioread8(barp + i)); |
75742cb41
|
49 50 |
printk(" "); |
f20b16ff7
|
51 |
|
90925d305
|
52 |
devices = ioread32(barp + 0x0C); |
6e9d8629b
|
53 |
pci_iounmap(pdev, barp); |
f20b16ff7
|
54 |
|
5b66c829b
|
55 56 57 58 59 60 |
if (devices & 0x10) return 1; return 0; } /** |
2a2beac92
|
61 |
* marvell_pre_reset - probe begin |
5b66c829b
|
62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
* @link: link * @deadline: deadline jiffies for the operation * * Perform the PATA port setup we need. */ static int marvell_pre_reset(struct ata_link *link, unsigned long deadline) { struct ata_port *ap = link->ap; struct pci_dev *pdev = to_pci_dev(ap->host->dev); if (pdev->device == 0x6145 && ap->port_no == 0 && !marvell_pata_active(pdev)) /* PATA enable ? */ return -ENOENT; |
27c78b372
|
76 |
|
9363c3825
|
77 |
return ata_sff_prereset(link, deadline); |
307c6054a
|
78 |
} |
75742cb41
|
79 |
|
307c6054a
|
80 81 |
static int marvell_cable_detect(struct ata_port *ap) { |
75742cb41
|
82 83 84 |
/* Cable type */ switch(ap->port_no) { |
6e9d8629b
|
85 |
case 0: |
0d5ff5667
|
86 |
if (ioread8(ap->ioaddr.bmdma_addr + 1) & 1) |
307c6054a
|
87 88 |
return ATA_CBL_PATA40; return ATA_CBL_PATA80; |
6e9d8629b
|
89 |
case 1: /* Legacy SATA port */ |
307c6054a
|
90 |
return ATA_CBL_SATA; |
75742cb41
|
91 |
} |
d4b2bab4f
|
92 |
|
307c6054a
|
93 94 |
BUG(); return 0; /* Our BUG macro needs the right markup */ |
75742cb41
|
95 |
} |
75742cb41
|
96 97 98 |
/* No PIO or DMA methods needed for this device */ static struct scsi_host_template marvell_sht = { |
68d1d07b5
|
99 |
ATA_BMDMA_SHT(DRV_NAME), |
75742cb41
|
100 |
}; |
029cfd6b7
|
101 102 |
static struct ata_port_operations marvell_ops = { .inherits = &ata_bmdma_port_ops, |
307c6054a
|
103 |
.cable_detect = marvell_cable_detect, |
887125e37
|
104 |
.prereset = marvell_pre_reset, |
75742cb41
|
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
}; /** * marvell_init_one - Register Marvell ATA PCI device with kernel services * @pdev: PCI device to register * @ent: Entry in marvell_pci_tbl matching with @pdev * * Called from kernel PCI layer. * * LOCKING: * Inherited from PCI layer (may sleep). * * RETURNS: * Zero on success, or -ERRNO value. */ static int marvell_init_one (struct pci_dev *pdev, const struct pci_device_id *id) { |
1626aeb88
|
124 |
static const struct ata_port_info info = { |
1d2808fd3
|
125 |
.flags = ATA_FLAG_SLAVE_POSS, |
75742cb41
|
126 |
|
14bdef982
|
127 128 |
.pio_mask = ATA_PIO4, .mwdma_mask = ATA_MWDMA2, |
bf6263a85
|
129 |
.udma_mask = ATA_UDMA5, |
75742cb41
|
130 131 132 |
.port_ops = &marvell_ops, }; |
1626aeb88
|
133 |
static const struct ata_port_info info_sata = { |
75742cb41
|
134 |
/* Slave possible as its magically mapped not real */ |
1d2808fd3
|
135 |
.flags = ATA_FLAG_SLAVE_POSS, |
75742cb41
|
136 |
|
14bdef982
|
137 138 |
.pio_mask = ATA_PIO4, .mwdma_mask = ATA_MWDMA2, |
bf6263a85
|
139 |
.udma_mask = ATA_UDMA6, |
75742cb41
|
140 141 142 |
.port_ops = &marvell_ops, }; |
1626aeb88
|
143 |
const struct ata_port_info *ppi[] = { &info, &info_sata }; |
6e9d8629b
|
144 |
|
75742cb41
|
145 |
if (pdev->device == 0x6101) |
1626aeb88
|
146 |
ppi[1] = &ata_dummy_port_info; |
6e9d8629b
|
147 |
|
cb6643e1c
|
148 |
#if defined(CONFIG_SATA_AHCI) || defined(CONFIG_SATA_AHCI_MODULE) |
5b66c829b
|
149 150 151 152 153 154 |
if (!marvell_pata_active(pdev)) { printk(KERN_INFO DRV_NAME ": PATA port not active, deferring to AHCI driver. "); return -ENODEV; } #endif |
1c5afdf7a
|
155 |
return ata_pci_bmdma_init_one(pdev, ppi, &marvell_sht, NULL, 0); |
75742cb41
|
156 157 158 159 |
} static const struct pci_device_id marvell_pci_tbl[] = { { PCI_DEVICE(0x11AB, 0x6101), }, |
d36ee189f
|
160 161 |
{ PCI_DEVICE(0x11AB, 0x6121), }, { PCI_DEVICE(0x11AB, 0x6123), }, |
75742cb41
|
162 |
{ PCI_DEVICE(0x11AB, 0x6145), }, |
f920fe1cb
|
163 164 |
{ PCI_DEVICE(0x1B4B, 0x91A0), }, { PCI_DEVICE(0x1B4B, 0x91A4), }, |
75742cb41
|
165 166 167 168 169 170 171 172 |
{ } /* terminate list */ }; static struct pci_driver marvell_pci_driver = { .name = DRV_NAME, .id_table = marvell_pci_tbl, .probe = marvell_init_one, .remove = ata_pci_remove_one, |
438ac6d5e
|
173 |
#ifdef CONFIG_PM |
30ced0f0d
|
174 175 |
.suspend = ata_pci_device_suspend, .resume = ata_pci_device_resume, |
438ac6d5e
|
176 |
#endif |
75742cb41
|
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
}; static int __init marvell_init(void) { return pci_register_driver(&marvell_pci_driver); } static void __exit marvell_exit(void) { pci_unregister_driver(&marvell_pci_driver); } module_init(marvell_init); module_exit(marvell_exit); MODULE_AUTHOR("Alan Cox"); MODULE_DESCRIPTION("SCSI low-level driver for Marvell ATA in legacy mode"); MODULE_LICENSE("GPL"); MODULE_DEVICE_TABLE(pci, marvell_pci_tbl); MODULE_VERSION(DRV_VERSION); |