xref: /openbmc/linux/drivers/ata/pata_netcell.c (revision 1d2808fd)
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 	.port_disable		= ata_port_disable,
44669a5db4SJeff Garzik 
45669a5db4SJeff Garzik 	/* Task file is PCI ATA format, use helpers */
46669a5db4SJeff Garzik 	.tf_load		= ata_tf_load,
47669a5db4SJeff Garzik 	.tf_read		= ata_tf_read,
48669a5db4SJeff Garzik 	.check_status		= ata_check_status,
49669a5db4SJeff Garzik 	.exec_command		= ata_exec_command,
50669a5db4SJeff Garzik 	.dev_select		= ata_std_dev_select,
51669a5db4SJeff Garzik 
52669a5db4SJeff Garzik 	.freeze			= ata_bmdma_freeze,
53669a5db4SJeff Garzik 	.thaw			= ata_bmdma_thaw,
543b4ba591SAlan Cox 	.error_handler		= ata_bmdma_error_handler,
55669a5db4SJeff Garzik 	.post_internal_cmd	= ata_bmdma_post_internal_cmd,
563b4ba591SAlan Cox 	.cable_detect		= ata_cable_80wire,
57669a5db4SJeff Garzik 
58669a5db4SJeff Garzik 	/* BMDMA handling is PCI ATA format, use helpers */
59669a5db4SJeff Garzik 	.bmdma_setup		= ata_bmdma_setup,
60669a5db4SJeff Garzik 	.bmdma_start		= ata_bmdma_start,
61669a5db4SJeff Garzik 	.bmdma_stop		= ata_bmdma_stop,
62669a5db4SJeff Garzik 	.bmdma_status		= ata_bmdma_status,
63669a5db4SJeff Garzik 	.qc_prep		= ata_qc_prep,
64669a5db4SJeff Garzik 	.qc_issue		= ata_qc_issue_prot,
650d5ff566STejun Heo 	.data_xfer		= ata_data_xfer,
66669a5db4SJeff Garzik 
67bda30288SJeff Garzik 	/* IRQ-related hooks */
68669a5db4SJeff Garzik 	.irq_handler		= ata_interrupt,
69669a5db4SJeff Garzik 	.irq_clear		= ata_bmdma_irq_clear,
70246ce3b6SAkira Iguchi 	.irq_on			= ata_irq_on,
71246ce3b6SAkira Iguchi 	.irq_ack		= ata_irq_ack,
72669a5db4SJeff Garzik 
73669a5db4SJeff Garzik 	/* Generic PATA PCI ATA helpers */
74669a5db4SJeff Garzik 	.port_start		= ata_port_start,
75669a5db4SJeff Garzik };
76669a5db4SJeff Garzik 
77669a5db4SJeff Garzik 
78669a5db4SJeff Garzik /**
79669a5db4SJeff Garzik  *	netcell_init_one - Register Netcell ATA PCI device with kernel services
80669a5db4SJeff Garzik  *	@pdev: PCI device to register
81669a5db4SJeff Garzik  *	@ent: Entry in netcell_pci_tbl matching with @pdev
82669a5db4SJeff Garzik  *
83669a5db4SJeff Garzik  *	Called from kernel PCI layer.
84669a5db4SJeff Garzik  *
85669a5db4SJeff Garzik  *	LOCKING:
86669a5db4SJeff Garzik  *	Inherited from PCI layer (may sleep).
87669a5db4SJeff Garzik  *
88669a5db4SJeff Garzik  *	RETURNS:
89669a5db4SJeff Garzik  *	Zero on success, or -ERRNO value.
90669a5db4SJeff Garzik  */
91669a5db4SJeff Garzik 
92669a5db4SJeff Garzik static int netcell_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
93669a5db4SJeff Garzik {
94669a5db4SJeff Garzik 	static int printed_version;
951626aeb8STejun Heo 	static const struct ata_port_info info = {
96669a5db4SJeff Garzik 		.sht		= &netcell_sht,
971d2808fdSJeff Garzik 		.flags		= ATA_FLAG_SLAVE_POSS,
98669a5db4SJeff Garzik 		/* Actually we don't really care about these as the
99669a5db4SJeff Garzik 		   firmware deals with it */
100669a5db4SJeff Garzik 		.pio_mask	= 0x1f,	/* pio0-4 */
101669a5db4SJeff Garzik 		.mwdma_mask	= 0x07, /* mwdma0-2 */
102669a5db4SJeff Garzik 		.udma_mask 	= 0x3f, /* UDMA 133 */
103669a5db4SJeff Garzik 		.port_ops	= &netcell_ops,
104669a5db4SJeff Garzik 	};
1051626aeb8STejun Heo 	const struct ata_port_info *port_info[] = { &info, NULL };
106669a5db4SJeff Garzik 
107669a5db4SJeff Garzik 	if (!printed_version++)
108669a5db4SJeff Garzik 		dev_printk(KERN_DEBUG, &pdev->dev,
109669a5db4SJeff Garzik 			   "version " DRV_VERSION "\n");
110669a5db4SJeff Garzik 
111669a5db4SJeff Garzik 	/* Any chip specific setup/optimisation/messages here */
112669a5db4SJeff Garzik 	ata_pci_clear_simplex(pdev);
113669a5db4SJeff Garzik 
114669a5db4SJeff Garzik 	/* And let the library code do the work */
1151626aeb8STejun Heo 	return ata_pci_init_one(pdev, port_info);
116669a5db4SJeff Garzik }
117669a5db4SJeff Garzik 
118669a5db4SJeff Garzik static const struct pci_device_id netcell_pci_tbl[] = {
1192d2744fcSJeff Garzik 	{ PCI_VDEVICE(NETCELL, PCI_DEVICE_ID_REVOLUTION), },
1202d2744fcSJeff Garzik 
121669a5db4SJeff Garzik 	{ }	/* terminate list */
122669a5db4SJeff Garzik };
123669a5db4SJeff Garzik 
124669a5db4SJeff Garzik static struct pci_driver netcell_pci_driver = {
125669a5db4SJeff Garzik 	.name			= DRV_NAME,
126669a5db4SJeff Garzik 	.id_table		= netcell_pci_tbl,
127669a5db4SJeff Garzik 	.probe			= netcell_init_one,
128669a5db4SJeff Garzik 	.remove			= ata_pci_remove_one,
129438ac6d5STejun Heo #ifdef CONFIG_PM
13030ced0f0SAlan 	.suspend		= ata_pci_device_suspend,
13130ced0f0SAlan 	.resume			= ata_pci_device_resume,
132438ac6d5STejun Heo #endif
133669a5db4SJeff Garzik };
134669a5db4SJeff Garzik 
135669a5db4SJeff Garzik static int __init netcell_init(void)
136669a5db4SJeff Garzik {
137669a5db4SJeff Garzik 	return pci_register_driver(&netcell_pci_driver);
138669a5db4SJeff Garzik }
139669a5db4SJeff Garzik 
140669a5db4SJeff Garzik static void __exit netcell_exit(void)
141669a5db4SJeff Garzik {
142669a5db4SJeff Garzik 	pci_unregister_driver(&netcell_pci_driver);
143669a5db4SJeff Garzik }
144669a5db4SJeff Garzik 
145669a5db4SJeff Garzik module_init(netcell_init);
146669a5db4SJeff Garzik module_exit(netcell_exit);
147669a5db4SJeff Garzik 
148669a5db4SJeff Garzik MODULE_AUTHOR("Alan Cox");
149669a5db4SJeff Garzik MODULE_DESCRIPTION("SCSI low-level driver for Netcell PATA RAID");
150669a5db4SJeff Garzik MODULE_LICENSE("GPL");
151669a5db4SJeff Garzik MODULE_DEVICE_TABLE(pci, netcell_pci_tbl);
152669a5db4SJeff Garzik MODULE_VERSION(DRV_VERSION);
153669a5db4SJeff Garzik 
154