blob: 38f99b38a5ea97a861e1a8cb2d1d27f324ea38cc [file] [log] [blame]
Jeff Garzik669a5db2006-08-29 18:12:40 -04001/*
2 * pata_netcell.c - Netcell PATA driver
3 *
4 * (c) 2006 Red Hat <alan@redhat.com>
5 */
6
7#include <linux/kernel.h>
8#include <linux/module.h>
9#include <linux/pci.h>
10#include <linux/init.h>
11#include <linux/blkdev.h>
12#include <linux/delay.h>
13#include <linux/device.h>
14#include <scsi/scsi_host.h>
15#include <linux/libata.h>
16#include <linux/ata.h>
17
18#define DRV_NAME "pata_netcell"
Alan30ced0f2006-11-22 16:57:36 +000019#define DRV_VERSION "0.1.6"
Jeff Garzik669a5db2006-08-29 18:12:40 -040020
21/**
22 * netcell_probe_init - check for 40/80 pin
23 * @ap: Port
24 *
25 * Cables are handled by the RAID controller. Report 80 pin.
26 */
Jeff Garzik85cd7252006-08-31 00:03:49 -040027
Jeff Garzik669a5db2006-08-29 18:12:40 -040028static int netcell_pre_reset(struct ata_port *ap)
29{
30 ap->cbl = ATA_CBL_PATA80;
31 return ata_std_prereset(ap);
32}
33
34/**
35 * netcell_probe_reset - Probe specified port on PATA host controller
36 * @ap: Port to probe
37 *
38 * LOCKING:
39 * None (inherited from caller).
40 */
41
42static void netcell_error_handler(struct ata_port *ap)
43{
44 return ata_bmdma_drive_eh(ap, netcell_pre_reset, ata_std_softreset, NULL, ata_std_postreset);
45}
46
47/* No PIO or DMA methods needed for this device */
48
49static struct scsi_host_template netcell_sht = {
50 .module = THIS_MODULE,
51 .name = DRV_NAME,
52 .ioctl = ata_scsi_ioctl,
53 .queuecommand = ata_scsi_queuecmd,
54 .can_queue = ATA_DEF_QUEUE,
55 .this_id = ATA_SHT_THIS_ID,
56 .sg_tablesize = LIBATA_MAX_PRD,
Jeff Garzik669a5db2006-08-29 18:12:40 -040057 .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
58 .emulated = ATA_SHT_EMULATED,
59 .use_clustering = ATA_SHT_USE_CLUSTERING,
60 .proc_name = DRV_NAME,
61 .dma_boundary = ATA_DMA_BOUNDARY,
62 .slave_configure = ata_scsi_slave_config,
Tejun Heoafdfe892006-11-29 11:26:47 +090063 .slave_destroy = ata_scsi_slave_destroy,
Jeff Garzik669a5db2006-08-29 18:12:40 -040064 /* Use standard CHS mapping rules */
65 .bios_param = ata_std_bios_param,
Tejun Heo438ac6d2007-03-02 17:31:26 +090066#ifdef CONFIG_PM
Alan30ced0f2006-11-22 16:57:36 +000067 .resume = ata_scsi_device_resume,
68 .suspend = ata_scsi_device_suspend,
Tejun Heo438ac6d2007-03-02 17:31:26 +090069#endif
Jeff Garzik669a5db2006-08-29 18:12:40 -040070};
71
72static const struct ata_port_operations netcell_ops = {
73 .port_disable = ata_port_disable,
74
75 /* Task file is PCI ATA format, use helpers */
76 .tf_load = ata_tf_load,
77 .tf_read = ata_tf_read,
78 .check_status = ata_check_status,
79 .exec_command = ata_exec_command,
80 .dev_select = ata_std_dev_select,
81
82 .freeze = ata_bmdma_freeze,
83 .thaw = ata_bmdma_thaw,
84 .error_handler = netcell_error_handler,
85 .post_internal_cmd = ata_bmdma_post_internal_cmd,
86
87 /* BMDMA handling is PCI ATA format, use helpers */
88 .bmdma_setup = ata_bmdma_setup,
89 .bmdma_start = ata_bmdma_start,
90 .bmdma_stop = ata_bmdma_stop,
91 .bmdma_status = ata_bmdma_status,
92 .qc_prep = ata_qc_prep,
93 .qc_issue = ata_qc_issue_prot,
Tejun Heo0d5ff562007-02-01 15:06:36 +090094 .data_xfer = ata_data_xfer,
Jeff Garzik669a5db2006-08-29 18:12:40 -040095
Jeff Garzikbda30282006-09-27 05:41:13 -040096 /* IRQ-related hooks */
Jeff Garzik669a5db2006-08-29 18:12:40 -040097 .irq_handler = ata_interrupt,
98 .irq_clear = ata_bmdma_irq_clear,
Akira Iguchi246ce3b2007-01-26 16:27:58 +090099 .irq_on = ata_irq_on,
100 .irq_ack = ata_irq_ack,
Jeff Garzik669a5db2006-08-29 18:12:40 -0400101
102 /* Generic PATA PCI ATA helpers */
103 .port_start = ata_port_start,
Jeff Garzik669a5db2006-08-29 18:12:40 -0400104};
105
106
107/**
108 * netcell_init_one - Register Netcell ATA PCI device with kernel services
109 * @pdev: PCI device to register
110 * @ent: Entry in netcell_pci_tbl matching with @pdev
111 *
112 * Called from kernel PCI layer.
113 *
114 * LOCKING:
115 * Inherited from PCI layer (may sleep).
116 *
117 * RETURNS:
118 * Zero on success, or -ERRNO value.
119 */
120
121static int netcell_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
122{
123 static int printed_version;
124 static struct ata_port_info info = {
125 .sht = &netcell_sht,
126 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
127 /* Actually we don't really care about these as the
128 firmware deals with it */
129 .pio_mask = 0x1f, /* pio0-4 */
130 .mwdma_mask = 0x07, /* mwdma0-2 */
131 .udma_mask = 0x3f, /* UDMA 133 */
132 .port_ops = &netcell_ops,
133 };
134 static struct ata_port_info *port_info[2] = { &info, &info };
135
136 if (!printed_version++)
137 dev_printk(KERN_DEBUG, &pdev->dev,
138 "version " DRV_VERSION "\n");
139
140 /* Any chip specific setup/optimisation/messages here */
141 ata_pci_clear_simplex(pdev);
Jeff Garzik85cd7252006-08-31 00:03:49 -0400142
Jeff Garzik669a5db2006-08-29 18:12:40 -0400143 /* And let the library code do the work */
144 return ata_pci_init_one(pdev, port_info, 2);
145}
146
147static const struct pci_device_id netcell_pci_tbl[] = {
Jeff Garzik2d2744f2006-09-28 20:21:59 -0400148 { PCI_VDEVICE(NETCELL, PCI_DEVICE_ID_REVOLUTION), },
149
Jeff Garzik669a5db2006-08-29 18:12:40 -0400150 { } /* terminate list */
151};
152
153static struct pci_driver netcell_pci_driver = {
154 .name = DRV_NAME,
155 .id_table = netcell_pci_tbl,
156 .probe = netcell_init_one,
157 .remove = ata_pci_remove_one,
Tejun Heo438ac6d2007-03-02 17:31:26 +0900158#ifdef CONFIG_PM
Alan30ced0f2006-11-22 16:57:36 +0000159 .suspend = ata_pci_device_suspend,
160 .resume = ata_pci_device_resume,
Tejun Heo438ac6d2007-03-02 17:31:26 +0900161#endif
Jeff Garzik669a5db2006-08-29 18:12:40 -0400162};
163
164static int __init netcell_init(void)
165{
166 return pci_register_driver(&netcell_pci_driver);
167}
168
169static void __exit netcell_exit(void)
170{
171 pci_unregister_driver(&netcell_pci_driver);
172}
173
174module_init(netcell_init);
175module_exit(netcell_exit);
176
177MODULE_AUTHOR("Alan Cox");
178MODULE_DESCRIPTION("SCSI low-level driver for Netcell PATA RAID");
179MODULE_LICENSE("GPL");
180MODULE_DEVICE_TABLE(pci, netcell_pci_tbl);
181MODULE_VERSION(DRV_VERSION);
182