xref: /openbmc/linux/drivers/ata/pata_rdc.c (revision 6b406782ad0408f9cb480c2e1b543d194e8206d0)
1*6b406782SAlan Cox /*
2*6b406782SAlan Cox  *  pata_rdc		-	Driver for later RDC PATA controllers
3*6b406782SAlan Cox  *
4*6b406782SAlan Cox  *  This is actually a driver for hardware meeting
5*6b406782SAlan Cox  *  INCITS 370-2004 (1510D): ATA Host Adapter Standards
6*6b406782SAlan Cox  *
7*6b406782SAlan Cox  *  Based on ata_piix.
8*6b406782SAlan Cox  *
9*6b406782SAlan Cox  *  This program is free software; you can redistribute it and/or modify
10*6b406782SAlan Cox  *  it under the terms of the GNU General Public License as published by
11*6b406782SAlan Cox  *  the Free Software Foundation; either version 2, or (at your option)
12*6b406782SAlan Cox  *  any later version.
13*6b406782SAlan Cox  *
14*6b406782SAlan Cox  *  This program is distributed in the hope that it will be useful,
15*6b406782SAlan Cox  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16*6b406782SAlan Cox  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17*6b406782SAlan Cox  *  GNU General Public License for more details.
18*6b406782SAlan Cox  *
19*6b406782SAlan Cox  *  You should have received a copy of the GNU General Public License
20*6b406782SAlan Cox  *  along with this program; see the file COPYING.  If not, write to
21*6b406782SAlan Cox  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
22*6b406782SAlan Cox  */
23*6b406782SAlan Cox 
24*6b406782SAlan Cox #include <linux/kernel.h>
25*6b406782SAlan Cox #include <linux/module.h>
26*6b406782SAlan Cox #include <linux/pci.h>
27*6b406782SAlan Cox #include <linux/init.h>
28*6b406782SAlan Cox #include <linux/blkdev.h>
29*6b406782SAlan Cox #include <linux/delay.h>
30*6b406782SAlan Cox #include <linux/device.h>
31*6b406782SAlan Cox #include <scsi/scsi_host.h>
32*6b406782SAlan Cox #include <linux/libata.h>
33*6b406782SAlan Cox #include <linux/dmi.h>
34*6b406782SAlan Cox 
35*6b406782SAlan Cox #define DRV_NAME	"pata_rdc"
36*6b406782SAlan Cox #define DRV_VERSION	"0.01"
37*6b406782SAlan Cox 
38*6b406782SAlan Cox struct rdc_host_priv {
39*6b406782SAlan Cox 	u32 saved_iocfg;
40*6b406782SAlan Cox };
41*6b406782SAlan Cox 
42*6b406782SAlan Cox /**
43*6b406782SAlan Cox  *	rdc_pata_cable_detect - Probe host controller cable detect info
44*6b406782SAlan Cox  *	@ap: Port for which cable detect info is desired
45*6b406782SAlan Cox  *
46*6b406782SAlan Cox  *	Read 80c cable indicator from ATA PCI device's PCI config
47*6b406782SAlan Cox  *	register.  This register is normally set by firmware (BIOS).
48*6b406782SAlan Cox  *
49*6b406782SAlan Cox  *	LOCKING:
50*6b406782SAlan Cox  *	None (inherited from caller).
51*6b406782SAlan Cox  */
52*6b406782SAlan Cox 
53*6b406782SAlan Cox static int rdc_pata_cable_detect(struct ata_port *ap)
54*6b406782SAlan Cox {
55*6b406782SAlan Cox 	struct rdc_host_priv *hpriv = ap->host->private_data;
56*6b406782SAlan Cox 	u8 mask;
57*6b406782SAlan Cox 
58*6b406782SAlan Cox 	/* check BIOS cable detect results */
59*6b406782SAlan Cox 	mask = 0x30 << (2 * ap->port_no);
60*6b406782SAlan Cox 	if ((hpriv->saved_iocfg & mask) == 0)
61*6b406782SAlan Cox 		return ATA_CBL_PATA40;
62*6b406782SAlan Cox 	return ATA_CBL_PATA80;
63*6b406782SAlan Cox }
64*6b406782SAlan Cox 
65*6b406782SAlan Cox /**
66*6b406782SAlan Cox  *	rdc_pata_prereset - prereset for PATA host controller
67*6b406782SAlan Cox  *	@link: Target link
68*6b406782SAlan Cox  *	@deadline: deadline jiffies for the operation
69*6b406782SAlan Cox  *
70*6b406782SAlan Cox  *	LOCKING:
71*6b406782SAlan Cox  *	None (inherited from caller).
72*6b406782SAlan Cox  */
73*6b406782SAlan Cox static int rdc_pata_prereset(struct ata_link *link, unsigned long deadline)
74*6b406782SAlan Cox {
75*6b406782SAlan Cox 	struct ata_port *ap = link->ap;
76*6b406782SAlan Cox 	struct pci_dev *pdev = to_pci_dev(ap->host->dev);
77*6b406782SAlan Cox 
78*6b406782SAlan Cox 	static const struct pci_bits rdc_enable_bits[] = {
79*6b406782SAlan Cox 		{ 0x41U, 1U, 0x80UL, 0x80UL },	/* port 0 */
80*6b406782SAlan Cox 		{ 0x43U, 1U, 0x80UL, 0x80UL },	/* port 1 */
81*6b406782SAlan Cox 	};
82*6b406782SAlan Cox 
83*6b406782SAlan Cox 	if (!pci_test_config_bits(pdev, &rdc_enable_bits[ap->port_no]))
84*6b406782SAlan Cox 		return -ENOENT;
85*6b406782SAlan Cox 	return ata_sff_prereset(link, deadline);
86*6b406782SAlan Cox }
87*6b406782SAlan Cox 
88*6b406782SAlan Cox /**
89*6b406782SAlan Cox  *	rdc_set_piomode - Initialize host controller PATA PIO timings
90*6b406782SAlan Cox  *	@ap: Port whose timings we are configuring
91*6b406782SAlan Cox  *	@adev: um
92*6b406782SAlan Cox  *
93*6b406782SAlan Cox  *	Set PIO mode for device, in host controller PCI config space.
94*6b406782SAlan Cox  *
95*6b406782SAlan Cox  *	LOCKING:
96*6b406782SAlan Cox  *	None (inherited from caller).
97*6b406782SAlan Cox  */
98*6b406782SAlan Cox 
99*6b406782SAlan Cox static void rdc_set_piomode(struct ata_port *ap, struct ata_device *adev)
100*6b406782SAlan Cox {
101*6b406782SAlan Cox 	unsigned int pio	= adev->pio_mode - XFER_PIO_0;
102*6b406782SAlan Cox 	struct pci_dev *dev	= to_pci_dev(ap->host->dev);
103*6b406782SAlan Cox 	unsigned int is_slave	= (adev->devno != 0);
104*6b406782SAlan Cox 	unsigned int master_port= ap->port_no ? 0x42 : 0x40;
105*6b406782SAlan Cox 	unsigned int slave_port	= 0x44;
106*6b406782SAlan Cox 	u16 master_data;
107*6b406782SAlan Cox 	u8 slave_data;
108*6b406782SAlan Cox 	u8 udma_enable;
109*6b406782SAlan Cox 	int control = 0;
110*6b406782SAlan Cox 
111*6b406782SAlan Cox 	static const	 /* ISP  RTC */
112*6b406782SAlan Cox 	u8 timings[][2]	= { { 0, 0 },
113*6b406782SAlan Cox 			    { 0, 0 },
114*6b406782SAlan Cox 			    { 1, 0 },
115*6b406782SAlan Cox 			    { 2, 1 },
116*6b406782SAlan Cox 			    { 2, 3 }, };
117*6b406782SAlan Cox 
118*6b406782SAlan Cox 	if (pio >= 2)
119*6b406782SAlan Cox 		control |= 1;	/* TIME1 enable */
120*6b406782SAlan Cox 	if (ata_pio_need_iordy(adev))
121*6b406782SAlan Cox 		control |= 2;	/* IE enable */
122*6b406782SAlan Cox 
123*6b406782SAlan Cox 	if (adev->class == ATA_DEV_ATA)
124*6b406782SAlan Cox 		control |= 4;	/* PPE enable */
125*6b406782SAlan Cox 
126*6b406782SAlan Cox 	/* PIO configuration clears DTE unconditionally.  It will be
127*6b406782SAlan Cox 	 * programmed in set_dmamode which is guaranteed to be called
128*6b406782SAlan Cox 	 * after set_piomode if any DMA mode is available.
129*6b406782SAlan Cox 	 */
130*6b406782SAlan Cox 	pci_read_config_word(dev, master_port, &master_data);
131*6b406782SAlan Cox 	if (is_slave) {
132*6b406782SAlan Cox 		/* clear TIME1|IE1|PPE1|DTE1 */
133*6b406782SAlan Cox 		master_data &= 0xff0f;
134*6b406782SAlan Cox 		/* Enable SITRE (separate slave timing register) */
135*6b406782SAlan Cox 		master_data |= 0x4000;
136*6b406782SAlan Cox 		/* enable PPE1, IE1 and TIME1 as needed */
137*6b406782SAlan Cox 		master_data |= (control << 4);
138*6b406782SAlan Cox 		pci_read_config_byte(dev, slave_port, &slave_data);
139*6b406782SAlan Cox 		slave_data &= (ap->port_no ? 0x0f : 0xf0);
140*6b406782SAlan Cox 		/* Load the timing nibble for this slave */
141*6b406782SAlan Cox 		slave_data |= ((timings[pio][0] << 2) | timings[pio][1])
142*6b406782SAlan Cox 						<< (ap->port_no ? 4 : 0);
143*6b406782SAlan Cox 	} else {
144*6b406782SAlan Cox 		/* clear ISP|RCT|TIME0|IE0|PPE0|DTE0 */
145*6b406782SAlan Cox 		master_data &= 0xccf0;
146*6b406782SAlan Cox 		/* Enable PPE, IE and TIME as appropriate */
147*6b406782SAlan Cox 		master_data |= control;
148*6b406782SAlan Cox 		/* load ISP and RCT */
149*6b406782SAlan Cox 		master_data |=
150*6b406782SAlan Cox 			(timings[pio][0] << 12) |
151*6b406782SAlan Cox 			(timings[pio][1] << 8);
152*6b406782SAlan Cox 	}
153*6b406782SAlan Cox 	pci_write_config_word(dev, master_port, master_data);
154*6b406782SAlan Cox 	if (is_slave)
155*6b406782SAlan Cox 		pci_write_config_byte(dev, slave_port, slave_data);
156*6b406782SAlan Cox 
157*6b406782SAlan Cox 	/* Ensure the UDMA bit is off - it will be turned back on if
158*6b406782SAlan Cox 	   UDMA is selected */
159*6b406782SAlan Cox 
160*6b406782SAlan Cox 	pci_read_config_byte(dev, 0x48, &udma_enable);
161*6b406782SAlan Cox 	udma_enable &= ~(1 << (2 * ap->port_no + adev->devno));
162*6b406782SAlan Cox 	pci_write_config_byte(dev, 0x48, udma_enable);
163*6b406782SAlan Cox }
164*6b406782SAlan Cox 
165*6b406782SAlan Cox /**
166*6b406782SAlan Cox  *	rdc_set_dmamode - Initialize host controller PATA PIO timings
167*6b406782SAlan Cox  *	@ap: Port whose timings we are configuring
168*6b406782SAlan Cox  *	@adev: Drive in question
169*6b406782SAlan Cox  *
170*6b406782SAlan Cox  *	Set UDMA mode for device, in host controller PCI config space.
171*6b406782SAlan Cox  *
172*6b406782SAlan Cox  *	LOCKING:
173*6b406782SAlan Cox  *	None (inherited from caller).
174*6b406782SAlan Cox  */
175*6b406782SAlan Cox 
176*6b406782SAlan Cox static void rdc_set_dmamode(struct ata_port *ap, struct ata_device *adev)
177*6b406782SAlan Cox {
178*6b406782SAlan Cox 	struct pci_dev *dev	= to_pci_dev(ap->host->dev);
179*6b406782SAlan Cox 	u8 master_port		= ap->port_no ? 0x42 : 0x40;
180*6b406782SAlan Cox 	u16 master_data;
181*6b406782SAlan Cox 	u8 speed		= adev->dma_mode;
182*6b406782SAlan Cox 	int devid		= adev->devno + 2 * ap->port_no;
183*6b406782SAlan Cox 	u8 udma_enable		= 0;
184*6b406782SAlan Cox 
185*6b406782SAlan Cox 	static const	 /* ISP  RTC */
186*6b406782SAlan Cox 	u8 timings[][2]	= { { 0, 0 },
187*6b406782SAlan Cox 			    { 0, 0 },
188*6b406782SAlan Cox 			    { 1, 0 },
189*6b406782SAlan Cox 			    { 2, 1 },
190*6b406782SAlan Cox 			    { 2, 3 }, };
191*6b406782SAlan Cox 
192*6b406782SAlan Cox 	pci_read_config_word(dev, master_port, &master_data);
193*6b406782SAlan Cox 	pci_read_config_byte(dev, 0x48, &udma_enable);
194*6b406782SAlan Cox 
195*6b406782SAlan Cox 	if (speed >= XFER_UDMA_0) {
196*6b406782SAlan Cox 		unsigned int udma = adev->dma_mode - XFER_UDMA_0;
197*6b406782SAlan Cox 		u16 udma_timing;
198*6b406782SAlan Cox 		u16 ideconf;
199*6b406782SAlan Cox 		int u_clock, u_speed;
200*6b406782SAlan Cox 
201*6b406782SAlan Cox 		/*
202*6b406782SAlan Cox 		 * UDMA is handled by a combination of clock switching and
203*6b406782SAlan Cox 		 * selection of dividers
204*6b406782SAlan Cox 		 *
205*6b406782SAlan Cox 		 * Handy rule: Odd modes are UDMATIMx 01, even are 02
206*6b406782SAlan Cox 		 *	       except UDMA0 which is 00
207*6b406782SAlan Cox 		 */
208*6b406782SAlan Cox 		u_speed = min(2 - (udma & 1), udma);
209*6b406782SAlan Cox 		if (udma == 5)
210*6b406782SAlan Cox 			u_clock = 0x1000;	/* 100Mhz */
211*6b406782SAlan Cox 		else if (udma > 2)
212*6b406782SAlan Cox 			u_clock = 1;		/* 66Mhz */
213*6b406782SAlan Cox 		else
214*6b406782SAlan Cox 			u_clock = 0;		/* 33Mhz */
215*6b406782SAlan Cox 
216*6b406782SAlan Cox 		udma_enable |= (1 << devid);
217*6b406782SAlan Cox 
218*6b406782SAlan Cox 		/* Load the CT/RP selection */
219*6b406782SAlan Cox 		pci_read_config_word(dev, 0x4A, &udma_timing);
220*6b406782SAlan Cox 		udma_timing &= ~(3 << (4 * devid));
221*6b406782SAlan Cox 		udma_timing |= u_speed << (4 * devid);
222*6b406782SAlan Cox 		pci_write_config_word(dev, 0x4A, udma_timing);
223*6b406782SAlan Cox 
224*6b406782SAlan Cox 		/* Select a 33/66/100Mhz clock */
225*6b406782SAlan Cox 		pci_read_config_word(dev, 0x54, &ideconf);
226*6b406782SAlan Cox 		ideconf &= ~(0x1001 << devid);
227*6b406782SAlan Cox 		ideconf |= u_clock << devid;
228*6b406782SAlan Cox 		pci_write_config_word(dev, 0x54, ideconf);
229*6b406782SAlan Cox 	} else {
230*6b406782SAlan Cox 		/*
231*6b406782SAlan Cox 		 * MWDMA is driven by the PIO timings. We must also enable
232*6b406782SAlan Cox 		 * IORDY unconditionally along with TIME1. PPE has already
233*6b406782SAlan Cox 		 * been set when the PIO timing was set.
234*6b406782SAlan Cox 		 */
235*6b406782SAlan Cox 		unsigned int mwdma	= adev->dma_mode - XFER_MW_DMA_0;
236*6b406782SAlan Cox 		unsigned int control;
237*6b406782SAlan Cox 		u8 slave_data;
238*6b406782SAlan Cox 		const unsigned int needed_pio[3] = {
239*6b406782SAlan Cox 			XFER_PIO_0, XFER_PIO_3, XFER_PIO_4
240*6b406782SAlan Cox 		};
241*6b406782SAlan Cox 		int pio = needed_pio[mwdma] - XFER_PIO_0;
242*6b406782SAlan Cox 
243*6b406782SAlan Cox 		control = 3;	/* IORDY|TIME1 */
244*6b406782SAlan Cox 
245*6b406782SAlan Cox 		/* If the drive MWDMA is faster than it can do PIO then
246*6b406782SAlan Cox 		   we must force PIO into PIO0 */
247*6b406782SAlan Cox 
248*6b406782SAlan Cox 		if (adev->pio_mode < needed_pio[mwdma])
249*6b406782SAlan Cox 			/* Enable DMA timing only */
250*6b406782SAlan Cox 			control |= 8;	/* PIO cycles in PIO0 */
251*6b406782SAlan Cox 
252*6b406782SAlan Cox 		if (adev->devno) {	/* Slave */
253*6b406782SAlan Cox 			master_data &= 0xFF4F;  /* Mask out IORDY|TIME1|DMAONLY */
254*6b406782SAlan Cox 			master_data |= control << 4;
255*6b406782SAlan Cox 			pci_read_config_byte(dev, 0x44, &slave_data);
256*6b406782SAlan Cox 			slave_data &= (ap->port_no ? 0x0f : 0xf0);
257*6b406782SAlan Cox 			/* Load the matching timing */
258*6b406782SAlan Cox 			slave_data |= ((timings[pio][0] << 2) | timings[pio][1]) << (ap->port_no ? 4 : 0);
259*6b406782SAlan Cox 			pci_write_config_byte(dev, 0x44, slave_data);
260*6b406782SAlan Cox 		} else { 	/* Master */
261*6b406782SAlan Cox 			master_data &= 0xCCF4;	/* Mask out IORDY|TIME1|DMAONLY
262*6b406782SAlan Cox 						   and master timing bits */
263*6b406782SAlan Cox 			master_data |= control;
264*6b406782SAlan Cox 			master_data |=
265*6b406782SAlan Cox 				(timings[pio][0] << 12) |
266*6b406782SAlan Cox 				(timings[pio][1] << 8);
267*6b406782SAlan Cox 		}
268*6b406782SAlan Cox 
269*6b406782SAlan Cox 		udma_enable &= ~(1 << devid);
270*6b406782SAlan Cox 		pci_write_config_word(dev, master_port, master_data);
271*6b406782SAlan Cox 	}
272*6b406782SAlan Cox 	pci_write_config_byte(dev, 0x48, udma_enable);
273*6b406782SAlan Cox }
274*6b406782SAlan Cox 
275*6b406782SAlan Cox static struct ata_port_operations rdc_pata_ops = {
276*6b406782SAlan Cox 	.inherits		= &ata_bmdma32_port_ops,
277*6b406782SAlan Cox 	.cable_detect		= rdc_pata_cable_detect,
278*6b406782SAlan Cox 	.set_piomode		= rdc_set_piomode,
279*6b406782SAlan Cox 	.set_dmamode		= rdc_set_dmamode,
280*6b406782SAlan Cox 	.prereset		= rdc_pata_prereset,
281*6b406782SAlan Cox };
282*6b406782SAlan Cox 
283*6b406782SAlan Cox static struct ata_port_info rdc_port_info = {
284*6b406782SAlan Cox 
285*6b406782SAlan Cox 	.flags		= ATA_FLAG_SLAVE_POSS,
286*6b406782SAlan Cox 	.pio_mask	= ATA_PIO4,
287*6b406782SAlan Cox 	.mwdma_mask	= ATA_MWDMA2,
288*6b406782SAlan Cox 	.udma_mask	= ATA_UDMA5,
289*6b406782SAlan Cox 	.port_ops	= &rdc_pata_ops,
290*6b406782SAlan Cox };
291*6b406782SAlan Cox 
292*6b406782SAlan Cox static struct scsi_host_template rdc_sht = {
293*6b406782SAlan Cox 	ATA_BMDMA_SHT(DRV_NAME),
294*6b406782SAlan Cox };
295*6b406782SAlan Cox 
296*6b406782SAlan Cox /**
297*6b406782SAlan Cox  *	rdc_init_one - Register PIIX ATA PCI device with kernel services
298*6b406782SAlan Cox  *	@pdev: PCI device to register
299*6b406782SAlan Cox  *	@ent: Entry in rdc_pci_tbl matching with @pdev
300*6b406782SAlan Cox  *
301*6b406782SAlan Cox  *	Called from kernel PCI layer.  We probe for combined mode (sigh),
302*6b406782SAlan Cox  *	and then hand over control to libata, for it to do the rest.
303*6b406782SAlan Cox  *
304*6b406782SAlan Cox  *	LOCKING:
305*6b406782SAlan Cox  *	Inherited from PCI layer (may sleep).
306*6b406782SAlan Cox  *
307*6b406782SAlan Cox  *	RETURNS:
308*6b406782SAlan Cox  *	Zero on success, or -ERRNO value.
309*6b406782SAlan Cox  */
310*6b406782SAlan Cox 
311*6b406782SAlan Cox static int __devinit rdc_init_one(struct pci_dev *pdev,
312*6b406782SAlan Cox 				   const struct pci_device_id *ent)
313*6b406782SAlan Cox {
314*6b406782SAlan Cox 	static int printed_version;
315*6b406782SAlan Cox 	struct device *dev = &pdev->dev;
316*6b406782SAlan Cox 	struct ata_port_info port_info[2];
317*6b406782SAlan Cox 	const struct ata_port_info *ppi[] = { &port_info[0], &port_info[1] };
318*6b406782SAlan Cox 	unsigned long port_flags;
319*6b406782SAlan Cox 	struct ata_host *host;
320*6b406782SAlan Cox 	struct rdc_host_priv *hpriv;
321*6b406782SAlan Cox 	int rc;
322*6b406782SAlan Cox 
323*6b406782SAlan Cox 	if (!printed_version++)
324*6b406782SAlan Cox 		dev_printk(KERN_DEBUG, &pdev->dev,
325*6b406782SAlan Cox 			   "version " DRV_VERSION "\n");
326*6b406782SAlan Cox 
327*6b406782SAlan Cox 	port_info[0] = rdc_port_info;
328*6b406782SAlan Cox 	port_info[1] = rdc_port_info;
329*6b406782SAlan Cox 
330*6b406782SAlan Cox 	port_flags = port_info[0].flags;
331*6b406782SAlan Cox 
332*6b406782SAlan Cox 	/* enable device and prepare host */
333*6b406782SAlan Cox 	rc = pcim_enable_device(pdev);
334*6b406782SAlan Cox 	if (rc)
335*6b406782SAlan Cox 		return rc;
336*6b406782SAlan Cox 
337*6b406782SAlan Cox 	hpriv = devm_kzalloc(dev, sizeof(*hpriv), GFP_KERNEL);
338*6b406782SAlan Cox 	if (!hpriv)
339*6b406782SAlan Cox 		return -ENOMEM;
340*6b406782SAlan Cox 
341*6b406782SAlan Cox 	/* Save IOCFG, this will be used for cable detection, quirk
342*6b406782SAlan Cox 	 * detection and restoration on detach.
343*6b406782SAlan Cox 	 */
344*6b406782SAlan Cox 	pci_read_config_dword(pdev, 0x54, &hpriv->saved_iocfg);
345*6b406782SAlan Cox 
346*6b406782SAlan Cox 	rc = ata_pci_sff_prepare_host(pdev, ppi, &host);
347*6b406782SAlan Cox 	if (rc)
348*6b406782SAlan Cox 		return rc;
349*6b406782SAlan Cox 	host->private_data = hpriv;
350*6b406782SAlan Cox 
351*6b406782SAlan Cox 	pci_intx(pdev, 1);
352*6b406782SAlan Cox 
353*6b406782SAlan Cox 	host->flags |= ATA_HOST_PARALLEL_SCAN;
354*6b406782SAlan Cox 
355*6b406782SAlan Cox 	pci_set_master(pdev);
356*6b406782SAlan Cox 	return ata_pci_sff_activate_host(host, ata_sff_interrupt, &rdc_sht);
357*6b406782SAlan Cox }
358*6b406782SAlan Cox 
359*6b406782SAlan Cox static void rdc_remove_one(struct pci_dev *pdev)
360*6b406782SAlan Cox {
361*6b406782SAlan Cox 	struct ata_host *host = dev_get_drvdata(&pdev->dev);
362*6b406782SAlan Cox 	struct rdc_host_priv *hpriv = host->private_data;
363*6b406782SAlan Cox 
364*6b406782SAlan Cox 	pci_write_config_dword(pdev, 0x54, hpriv->saved_iocfg);
365*6b406782SAlan Cox 
366*6b406782SAlan Cox 	ata_pci_remove_one(pdev);
367*6b406782SAlan Cox }
368*6b406782SAlan Cox 
369*6b406782SAlan Cox static const struct pci_device_id rdc_pci_tbl[] = {
370*6b406782SAlan Cox 	{ PCI_DEVICE(0x17F3, 0x1011), },
371*6b406782SAlan Cox 	{ PCI_DEVICE(0x17F3, 0x1012), },
372*6b406782SAlan Cox 	{ }	/* terminate list */
373*6b406782SAlan Cox };
374*6b406782SAlan Cox 
375*6b406782SAlan Cox static struct pci_driver rdc_pci_driver = {
376*6b406782SAlan Cox 	.name			= DRV_NAME,
377*6b406782SAlan Cox 	.id_table		= rdc_pci_tbl,
378*6b406782SAlan Cox 	.probe			= rdc_init_one,
379*6b406782SAlan Cox 	.remove			= rdc_remove_one,
380*6b406782SAlan Cox };
381*6b406782SAlan Cox 
382*6b406782SAlan Cox 
383*6b406782SAlan Cox static int __init rdc_init(void)
384*6b406782SAlan Cox {
385*6b406782SAlan Cox 	return pci_register_driver(&rdc_pci_driver);
386*6b406782SAlan Cox }
387*6b406782SAlan Cox 
388*6b406782SAlan Cox static void __exit rdc_exit(void)
389*6b406782SAlan Cox {
390*6b406782SAlan Cox 	pci_unregister_driver(&rdc_pci_driver);
391*6b406782SAlan Cox }
392*6b406782SAlan Cox 
393*6b406782SAlan Cox module_init(rdc_init);
394*6b406782SAlan Cox module_exit(rdc_exit);
395*6b406782SAlan Cox 
396*6b406782SAlan Cox MODULE_AUTHOR("Alan Cox (based on ata_piix)");
397*6b406782SAlan Cox MODULE_DESCRIPTION("SCSI low-level driver for RDC PATA controllers");
398*6b406782SAlan Cox MODULE_LICENSE("GPL");
399*6b406782SAlan Cox MODULE_DEVICE_TABLE(pci, rdc_pci_tbl);
400*6b406782SAlan Cox MODULE_VERSION(DRV_VERSION);
401