libata: make ata_pci_init_one() not use ops->irq_handler and pi->sht
[deliverable/linux.git] / drivers / ata / pata_marvell.c
CommitLineData
75742cb4
AC
1/*
2 * Marvell PATA driver.
3 *
4 * For the moment we drive the PATA port in legacy mode. That
5 * isn't making full use of the device functionality but it is
6 * easy to get working.
7 *
8 * (c) 2006 Red Hat <alan@redhat.com>
9 */
10
11#include <linux/kernel.h>
12#include <linux/module.h>
13#include <linux/pci.h>
14#include <linux/init.h>
15#include <linux/blkdev.h>
16#include <linux/delay.h>
17#include <linux/device.h>
18#include <scsi/scsi_host.h>
19#include <linux/libata.h>
20#include <linux/ata.h>
21
22#define DRV_NAME "pata_marvell"
307c6054 23#define DRV_VERSION "0.1.4"
75742cb4
AC
24
25/**
26 * marvell_pre_reset - check for 40/80 pin
cc0680a5 27 * @link: link
d4b2bab4 28 * @deadline: deadline jiffies for the operation
75742cb4
AC
29 *
30 * Perform the PATA port setup we need.
31 */
32
cc0680a5 33static int marvell_pre_reset(struct ata_link *link, unsigned long deadline)
75742cb4 34{
cc0680a5 35 struct ata_port *ap = link->ap;
75742cb4
AC
36 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
37 u32 devices;
75742cb4
AC
38 void __iomem *barp;
39 int i;
40
41 /* Check if our port is enabled */
42
6e9d8629 43 barp = pci_iomap(pdev, 5, 0x10);
75742cb4
AC
44 if (barp == NULL)
45 return -ENOMEM;
46 printk("BAR5:");
47 for(i = 0; i <= 0x0F; i++)
90925d30 48 printk("%02X:%02X ", i, ioread8(barp + i));
75742cb4 49 printk("\n");
f20b16ff 50
90925d30 51 devices = ioread32(barp + 0x0C);
6e9d8629 52 pci_iounmap(pdev, barp);
f20b16ff 53
6e9d8629
JG
54 if ((pdev->device == 0x6145) && (ap->port_no == 0) &&
55 (!(devices & 0x10))) /* PATA enable ? */
75742cb4 56 return -ENOENT;
27c78b37 57
cc0680a5 58 return ata_std_prereset(link, deadline);
307c6054 59}
75742cb4 60
307c6054
AC
61static int marvell_cable_detect(struct ata_port *ap)
62{
75742cb4
AC
63 /* Cable type */
64 switch(ap->port_no)
65 {
6e9d8629 66 case 0:
0d5ff566 67 if (ioread8(ap->ioaddr.bmdma_addr + 1) & 1)
307c6054
AC
68 return ATA_CBL_PATA40;
69 return ATA_CBL_PATA80;
6e9d8629 70 case 1: /* Legacy SATA port */
307c6054 71 return ATA_CBL_SATA;
75742cb4 72 }
d4b2bab4 73
307c6054
AC
74 BUG();
75 return 0; /* Our BUG macro needs the right markup */
75742cb4
AC
76}
77
78/**
79 * marvell_error_handler - Setup and error handler
80 * @ap: Port to handle
81 *
82 * LOCKING:
83 * None (inherited from caller).
84 */
85
86static void marvell_error_handler(struct ata_port *ap)
87{
42268e26
HH
88 ata_bmdma_drive_eh(ap, marvell_pre_reset, ata_std_softreset, NULL,
89 ata_std_postreset);
75742cb4
AC
90}
91
92/* No PIO or DMA methods needed for this device */
93
94static struct scsi_host_template marvell_sht = {
68d1d07b 95 ATA_BMDMA_SHT(DRV_NAME),
75742cb4
AC
96};
97
029cfd6b
TH
98static struct ata_port_operations marvell_ops = {
99 .inherits = &ata_bmdma_port_ops,
307c6054 100 .cable_detect = marvell_cable_detect,
029cfd6b 101 .error_handler = marvell_error_handler,
75742cb4
AC
102};
103
104
105/**
106 * marvell_init_one - Register Marvell ATA PCI device with kernel services
107 * @pdev: PCI device to register
108 * @ent: Entry in marvell_pci_tbl matching with @pdev
109 *
110 * Called from kernel PCI layer.
111 *
112 * LOCKING:
113 * Inherited from PCI layer (may sleep).
114 *
115 * RETURNS:
116 * Zero on success, or -ERRNO value.
117 */
118
119static int marvell_init_one (struct pci_dev *pdev, const struct pci_device_id *id)
120{
1626aeb8 121 static const struct ata_port_info info = {
1d2808fd 122 .flags = ATA_FLAG_SLAVE_POSS,
75742cb4
AC
123
124 .pio_mask = 0x1f,
125 .mwdma_mask = 0x07,
bf6263a8 126 .udma_mask = ATA_UDMA5,
75742cb4
AC
127
128 .port_ops = &marvell_ops,
129 };
1626aeb8 130 static const struct ata_port_info info_sata = {
75742cb4 131 /* Slave possible as its magically mapped not real */
1d2808fd 132 .flags = ATA_FLAG_SLAVE_POSS,
75742cb4
AC
133
134 .pio_mask = 0x1f,
135 .mwdma_mask = 0x07,
bf6263a8 136 .udma_mask = ATA_UDMA6,
75742cb4
AC
137
138 .port_ops = &marvell_ops,
139 };
1626aeb8 140 const struct ata_port_info *ppi[] = { &info, &info_sata };
6e9d8629 141
75742cb4 142 if (pdev->device == 0x6101)
1626aeb8 143 ppi[1] = &ata_dummy_port_info;
6e9d8629 144
1bd5b715 145 return ata_pci_init_one(pdev, ppi, &marvell_sht);
75742cb4
AC
146}
147
148static const struct pci_device_id marvell_pci_tbl[] = {
149 { PCI_DEVICE(0x11AB, 0x6101), },
d36ee189
AC
150 { PCI_DEVICE(0x11AB, 0x6121), },
151 { PCI_DEVICE(0x11AB, 0x6123), },
75742cb4
AC
152 { PCI_DEVICE(0x11AB, 0x6145), },
153 { } /* terminate list */
154};
155
156static struct pci_driver marvell_pci_driver = {
157 .name = DRV_NAME,
158 .id_table = marvell_pci_tbl,
159 .probe = marvell_init_one,
160 .remove = ata_pci_remove_one,
438ac6d5 161#ifdef CONFIG_PM
30ced0f0
A
162 .suspend = ata_pci_device_suspend,
163 .resume = ata_pci_device_resume,
438ac6d5 164#endif
75742cb4
AC
165};
166
167static int __init marvell_init(void)
168{
169 return pci_register_driver(&marvell_pci_driver);
170}
171
172static void __exit marvell_exit(void)
173{
174 pci_unregister_driver(&marvell_pci_driver);
175}
176
177module_init(marvell_init);
178module_exit(marvell_exit);
179
180MODULE_AUTHOR("Alan Cox");
181MODULE_DESCRIPTION("SCSI low-level driver for Marvell ATA in legacy mode");
182MODULE_LICENSE("GPL");
183MODULE_DEVICE_TABLE(pci, marvell_pci_tbl);
184MODULE_VERSION(DRV_VERSION);
185
This page took 0.182642 seconds and 5 git commands to generate.