xref: /openbmc/linux/drivers/ata/pata_netcell.c (revision 81ad1837)
1669a5db4SJeff Garzik /*
2669a5db4SJeff Garzik  *    pata_netcell.c - Netcell PATA driver
3669a5db4SJeff Garzik  *
4669a5db4SJeff Garzik  *	(c) 2006 Red Hat  <alan@redhat.com>
5669a5db4SJeff Garzik  */
6669a5db4SJeff Garzik 
7669a5db4SJeff Garzik #include <linux/kernel.h>
8669a5db4SJeff Garzik #include <linux/module.h>
9669a5db4SJeff Garzik #include <linux/pci.h>
10669a5db4SJeff Garzik #include <linux/init.h>
11669a5db4SJeff Garzik #include <linux/blkdev.h>
12669a5db4SJeff Garzik #include <linux/delay.h>
13669a5db4SJeff Garzik #include <linux/device.h>
14669a5db4SJeff Garzik #include <scsi/scsi_host.h>
15669a5db4SJeff Garzik #include <linux/libata.h>
16669a5db4SJeff Garzik #include <linux/ata.h>
17669a5db4SJeff Garzik 
18669a5db4SJeff Garzik #define DRV_NAME	"pata_netcell"
193b4ba591SAlan Cox #define DRV_VERSION	"0.1.7"
20669a5db4SJeff Garzik 
21669a5db4SJeff Garzik /* No PIO or DMA methods needed for this device */
22669a5db4SJeff Garzik 
23669a5db4SJeff Garzik static struct scsi_host_template netcell_sht = {
24669a5db4SJeff Garzik 	.module			= THIS_MODULE,
25669a5db4SJeff Garzik 	.name			= DRV_NAME,
26669a5db4SJeff Garzik 	.ioctl			= ata_scsi_ioctl,
27669a5db4SJeff Garzik 	.queuecommand		= ata_scsi_queuecmd,
28669a5db4SJeff Garzik 	.can_queue		= ATA_DEF_QUEUE,
29669a5db4SJeff Garzik 	.this_id		= ATA_SHT_THIS_ID,
30669a5db4SJeff Garzik 	.sg_tablesize		= LIBATA_MAX_PRD,
31669a5db4SJeff Garzik 	.cmd_per_lun		= ATA_SHT_CMD_PER_LUN,
32669a5db4SJeff Garzik 	.emulated		= ATA_SHT_EMULATED,
33669a5db4SJeff Garzik 	.use_clustering		= ATA_SHT_USE_CLUSTERING,
34669a5db4SJeff Garzik 	.proc_name		= DRV_NAME,
35669a5db4SJeff Garzik 	.dma_boundary		= ATA_DMA_BOUNDARY,
36669a5db4SJeff Garzik 	.slave_configure	= ata_scsi_slave_config,
37afdfe899STejun Heo 	.slave_destroy		= ata_scsi_slave_destroy,
38669a5db4SJeff Garzik 	/* Use standard CHS mapping rules */
39669a5db4SJeff Garzik 	.bios_param		= ata_std_bios_param,
40669a5db4SJeff Garzik };
41669a5db4SJeff Garzik 
42669a5db4SJeff Garzik static const struct ata_port_operations netcell_ops = {
43669a5db4SJeff Garzik 	/* Task file is PCI ATA format, use helpers */
44669a5db4SJeff Garzik 	.tf_load		= ata_tf_load,
45669a5db4SJeff Garzik 	.tf_read		= ata_tf_read,
46669a5db4SJeff Garzik 	.check_status		= ata_check_status,
47669a5db4SJeff Garzik 	.exec_command		= ata_exec_command,
48669a5db4SJeff Garzik 	.dev_select		= ata_std_dev_select,
49669a5db4SJeff Garzik 
50669a5db4SJeff Garzik 	.freeze			= ata_bmdma_freeze,
51669a5db4SJeff Garzik 	.thaw			= ata_bmdma_thaw,
523b4ba591SAlan Cox 	.error_handler		= ata_bmdma_error_handler,
53669a5db4SJeff Garzik 	.post_internal_cmd	= ata_bmdma_post_internal_cmd,
543b4ba591SAlan Cox 	.cable_detect		= ata_cable_80wire,
55669a5db4SJeff Garzik 
56669a5db4SJeff Garzik 	/* BMDMA handling is PCI ATA format, use helpers */
57669a5db4SJeff Garzik 	.bmdma_setup		= ata_bmdma_setup,
58669a5db4SJeff Garzik 	.bmdma_start		= ata_bmdma_start,
59669a5db4SJeff Garzik 	.bmdma_stop		= ata_bmdma_stop,
60669a5db4SJeff Garzik 	.bmdma_status		= ata_bmdma_status,
61669a5db4SJeff Garzik 	.qc_prep		= ata_qc_prep,
62669a5db4SJeff Garzik 	.qc_issue		= ata_qc_issue_prot,
630d5ff566STejun Heo 	.data_xfer		= ata_data_xfer,
64669a5db4SJeff Garzik 
65bda30288SJeff Garzik 	/* IRQ-related hooks */
66669a5db4SJeff Garzik 	.irq_handler		= ata_interrupt,
67669a5db4SJeff Garzik 	.irq_clear		= ata_bmdma_irq_clear,
68246ce3b6SAkira Iguchi 	.irq_on			= ata_irq_on,
69669a5db4SJeff Garzik 
70669a5db4SJeff Garzik 	/* Generic PATA PCI ATA helpers */
7181ad1837SAlan Cox 	.port_start		= ata_sff_port_start,
72669a5db4SJeff Garzik };
73669a5db4SJeff Garzik 
74669a5db4SJeff Garzik 
75669a5db4SJeff Garzik /**
76669a5db4SJeff Garzik  *	netcell_init_one - Register Netcell ATA PCI device with kernel services
77669a5db4SJeff Garzik  *	@pdev: PCI device to register
78669a5db4SJeff Garzik  *	@ent: Entry in netcell_pci_tbl matching with @pdev
79669a5db4SJeff Garzik  *
80669a5db4SJeff Garzik  *	Called from kernel PCI layer.
81669a5db4SJeff Garzik  *
82669a5db4SJeff Garzik  *	LOCKING:
83669a5db4SJeff Garzik  *	Inherited from PCI layer (may sleep).
84669a5db4SJeff Garzik  *
85669a5db4SJeff Garzik  *	RETURNS:
86669a5db4SJeff Garzik  *	Zero on success, or -ERRNO value.
87669a5db4SJeff Garzik  */
88669a5db4SJeff Garzik 
89669a5db4SJeff Garzik static int netcell_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
90669a5db4SJeff Garzik {
91669a5db4SJeff Garzik 	static int printed_version;
921626aeb8STejun Heo 	static const struct ata_port_info info = {
93669a5db4SJeff Garzik 		.sht		= &netcell_sht,
941d2808fdSJeff Garzik 		.flags		= ATA_FLAG_SLAVE_POSS,
95669a5db4SJeff Garzik 		/* Actually we don't really care about these as the
96669a5db4SJeff Garzik 		   firmware deals with it */
97669a5db4SJeff Garzik 		.pio_mask	= 0x1f,	/* pio0-4 */
98669a5db4SJeff Garzik 		.mwdma_mask	= 0x07, /* mwdma0-2 */
99bf6263a8SJeff Garzik 		.udma_mask 	= ATA_UDMA5, /* UDMA 133 */
100669a5db4SJeff Garzik 		.port_ops	= &netcell_ops,
101669a5db4SJeff Garzik 	};
1021626aeb8STejun Heo 	const struct ata_port_info *port_info[] = { &info, NULL };
103669a5db4SJeff Garzik 
104669a5db4SJeff Garzik 	if (!printed_version++)
105669a5db4SJeff Garzik 		dev_printk(KERN_DEBUG, &pdev->dev,
106669a5db4SJeff Garzik 			   "version " DRV_VERSION "\n");
107669a5db4SJeff Garzik 
108669a5db4SJeff Garzik 	/* Any chip specific setup/optimisation/messages here */
109669a5db4SJeff Garzik 	ata_pci_clear_simplex(pdev);
110669a5db4SJeff Garzik 
111669a5db4SJeff Garzik 	/* And let the library code do the work */
1121626aeb8STejun Heo 	return ata_pci_init_one(pdev, port_info);
113669a5db4SJeff Garzik }
114669a5db4SJeff Garzik 
115669a5db4SJeff Garzik static const struct pci_device_id netcell_pci_tbl[] = {
1162d2744fcSJeff Garzik 	{ PCI_VDEVICE(NETCELL, PCI_DEVICE_ID_REVOLUTION), },
1172d2744fcSJeff Garzik 
118669a5db4SJeff Garzik 	{ }	/* terminate list */
119669a5db4SJeff Garzik };
120669a5db4SJeff Garzik 
121669a5db4SJeff Garzik static struct pci_driver netcell_pci_driver = {
122669a5db4SJeff Garzik 	.name			= DRV_NAME,
123669a5db4SJeff Garzik 	.id_table		= netcell_pci_tbl,
124669a5db4SJeff Garzik 	.probe			= netcell_init_one,
125669a5db4SJeff Garzik 	.remove			= ata_pci_remove_one,
126438ac6d5STejun Heo #ifdef CONFIG_PM
12730ced0f0SAlan 	.suspend		= ata_pci_device_suspend,
12830ced0f0SAlan 	.resume			= ata_pci_device_resume,
129438ac6d5STejun Heo #endif
130669a5db4SJeff Garzik };
131669a5db4SJeff Garzik 
132669a5db4SJeff Garzik static int __init netcell_init(void)
133669a5db4SJeff Garzik {
134669a5db4SJeff Garzik 	return pci_register_driver(&netcell_pci_driver);
135669a5db4SJeff Garzik }
136669a5db4SJeff Garzik 
137669a5db4SJeff Garzik static void __exit netcell_exit(void)
138669a5db4SJeff Garzik {
139669a5db4SJeff Garzik 	pci_unregister_driver(&netcell_pci_driver);
140669a5db4SJeff Garzik }
141669a5db4SJeff Garzik 
142669a5db4SJeff Garzik module_init(netcell_init);
143669a5db4SJeff Garzik module_exit(netcell_exit);
144669a5db4SJeff Garzik 
145669a5db4SJeff Garzik MODULE_AUTHOR("Alan Cox");
146669a5db4SJeff Garzik MODULE_DESCRIPTION("SCSI low-level driver for Netcell PATA RAID");
147669a5db4SJeff Garzik MODULE_LICENSE("GPL");
148669a5db4SJeff Garzik MODULE_DEVICE_TABLE(pci, netcell_pci_tbl);
149669a5db4SJeff Garzik MODULE_VERSION(DRV_VERSION);
150669a5db4SJeff Garzik 
151