xref: /openbmc/linux/drivers/ata/pata_netcell.c (revision d3ae33ef)
1669a5db4SJeff Garzik /*
2669a5db4SJeff Garzik  *    pata_netcell.c - Netcell PATA driver
3669a5db4SJeff Garzik  *
4ab771630SAlan Cox  *	(c) 2006 Red Hat
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 
23d3ae33efSAlan Cox static unsigned int netcell_read_id(struct ata_device *adev,
24d3ae33efSAlan Cox 					struct ata_taskfile *tf, u16 *id)
25d3ae33efSAlan Cox {
26d3ae33efSAlan Cox 	unsigned int err_mask = ata_do_dev_read_id(adev, tf, id);
27d3ae33efSAlan Cox 	/* Firmware forgets to mark words 85-87 valid */
28d3ae33efSAlan Cox 	if (err_mask == 0)
29d3ae33efSAlan Cox 		id[ATA_ID_CSF_DEFAULT] |= 0x0400;
30d3ae33efSAlan Cox 	return err_mask;
31d3ae33efSAlan Cox }
32d3ae33efSAlan Cox 
33669a5db4SJeff Garzik static struct scsi_host_template netcell_sht = {
3468d1d07bSTejun Heo 	ATA_BMDMA_SHT(DRV_NAME),
35669a5db4SJeff Garzik };
36669a5db4SJeff Garzik 
37029cfd6bSTejun Heo static struct ata_port_operations netcell_ops = {
38029cfd6bSTejun Heo 	.inherits	= &ata_bmdma_port_ops,
393b4ba591SAlan Cox 	.cable_detect	= ata_cable_80wire,
40d3ae33efSAlan Cox 	.read_id	= netcell_read_id,
41669a5db4SJeff Garzik };
42669a5db4SJeff Garzik 
43669a5db4SJeff Garzik 
44669a5db4SJeff Garzik /**
45669a5db4SJeff Garzik  *	netcell_init_one - Register Netcell ATA PCI device with kernel services
46669a5db4SJeff Garzik  *	@pdev: PCI device to register
47669a5db4SJeff Garzik  *	@ent: Entry in netcell_pci_tbl matching with @pdev
48669a5db4SJeff Garzik  *
49669a5db4SJeff Garzik  *	Called from kernel PCI layer.
50669a5db4SJeff Garzik  *
51669a5db4SJeff Garzik  *	LOCKING:
52669a5db4SJeff Garzik  *	Inherited from PCI layer (may sleep).
53669a5db4SJeff Garzik  *
54669a5db4SJeff Garzik  *	RETURNS:
55669a5db4SJeff Garzik  *	Zero on success, or -ERRNO value.
56669a5db4SJeff Garzik  */
57669a5db4SJeff Garzik 
58669a5db4SJeff Garzik static int netcell_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
59669a5db4SJeff Garzik {
60669a5db4SJeff Garzik 	static int printed_version;
611626aeb8STejun Heo 	static const struct ata_port_info info = {
621d2808fdSJeff Garzik 		.flags		= ATA_FLAG_SLAVE_POSS,
63669a5db4SJeff Garzik 		/* Actually we don't really care about these as the
64669a5db4SJeff Garzik 		   firmware deals with it */
6514bdef98SErik Inge Bolsø 		.pio_mask	= ATA_PIO4,
6614bdef98SErik Inge Bolsø 		.mwdma_mask	= ATA_MWDMA2,
67bf6263a8SJeff Garzik 		.udma_mask 	= ATA_UDMA5, /* UDMA 133 */
68669a5db4SJeff Garzik 		.port_ops	= &netcell_ops,
69669a5db4SJeff Garzik 	};
701626aeb8STejun Heo 	const struct ata_port_info *port_info[] = { &info, NULL };
71f08048e9STejun Heo 	int rc;
72669a5db4SJeff Garzik 
73669a5db4SJeff Garzik 	if (!printed_version++)
74669a5db4SJeff Garzik 		dev_printk(KERN_DEBUG, &pdev->dev,
75669a5db4SJeff Garzik 			   "version " DRV_VERSION "\n");
76669a5db4SJeff Garzik 
77f08048e9STejun Heo 	rc = pcim_enable_device(pdev);
78f08048e9STejun Heo 	if (rc)
79f08048e9STejun Heo 		return rc;
80f08048e9STejun Heo 
81669a5db4SJeff Garzik 	/* Any chip specific setup/optimisation/messages here */
829363c382STejun Heo 	ata_pci_bmdma_clear_simplex(pdev);
83669a5db4SJeff Garzik 
84669a5db4SJeff Garzik 	/* And let the library code do the work */
859363c382STejun Heo 	return ata_pci_sff_init_one(pdev, port_info, &netcell_sht, NULL);
86669a5db4SJeff Garzik }
87669a5db4SJeff Garzik 
88669a5db4SJeff Garzik static const struct pci_device_id netcell_pci_tbl[] = {
892d2744fcSJeff Garzik 	{ PCI_VDEVICE(NETCELL, PCI_DEVICE_ID_REVOLUTION), },
902d2744fcSJeff Garzik 
91669a5db4SJeff Garzik 	{ }	/* terminate list */
92669a5db4SJeff Garzik };
93669a5db4SJeff Garzik 
94669a5db4SJeff Garzik static struct pci_driver netcell_pci_driver = {
95669a5db4SJeff Garzik 	.name			= DRV_NAME,
96669a5db4SJeff Garzik 	.id_table		= netcell_pci_tbl,
97669a5db4SJeff Garzik 	.probe			= netcell_init_one,
98669a5db4SJeff Garzik 	.remove			= ata_pci_remove_one,
99438ac6d5STejun Heo #ifdef CONFIG_PM
10030ced0f0SAlan 	.suspend		= ata_pci_device_suspend,
10130ced0f0SAlan 	.resume			= ata_pci_device_resume,
102438ac6d5STejun Heo #endif
103669a5db4SJeff Garzik };
104669a5db4SJeff Garzik 
105669a5db4SJeff Garzik static int __init netcell_init(void)
106669a5db4SJeff Garzik {
107669a5db4SJeff Garzik 	return pci_register_driver(&netcell_pci_driver);
108669a5db4SJeff Garzik }
109669a5db4SJeff Garzik 
110669a5db4SJeff Garzik static void __exit netcell_exit(void)
111669a5db4SJeff Garzik {
112669a5db4SJeff Garzik 	pci_unregister_driver(&netcell_pci_driver);
113669a5db4SJeff Garzik }
114669a5db4SJeff Garzik 
115669a5db4SJeff Garzik module_init(netcell_init);
116669a5db4SJeff Garzik module_exit(netcell_exit);
117669a5db4SJeff Garzik 
118669a5db4SJeff Garzik MODULE_AUTHOR("Alan Cox");
119669a5db4SJeff Garzik MODULE_DESCRIPTION("SCSI low-level driver for Netcell PATA RAID");
120669a5db4SJeff Garzik MODULE_LICENSE("GPL");
121669a5db4SJeff Garzik MODULE_DEVICE_TABLE(pci, netcell_pci_tbl);
122669a5db4SJeff Garzik MODULE_VERSION(DRV_VERSION);
123669a5db4SJeff Garzik 
124