alim15x3.c 14.6 KB
Newer Older
Linus Torvalds's avatar
Linus Torvalds committed
1 2 3 4 5 6 7
/*
 *  Copyright (C) 1998-2000 Michel Aubry, Maintainer
 *  Copyright (C) 1998-2000 Andrzej Krzysztofowicz, Maintainer
 *  Copyright (C) 1999-2000 CJ, cjtsai@ali.com.tw, Maintainer
 *
 *  Copyright (C) 1998-2000 Andre Hedrick (andre@linux-ide.org)
 *  May be copied or modified under the terms of the GNU General Public License
8
 *  Copyright (C) 2002 Alan Cox
Linus Torvalds's avatar
Linus Torvalds committed
9
 *  ALi (now ULi M5228) support by Clear Zhang <Clear.Zhang@ali.com.tw>
10
 *  Copyright (C) 2007 MontaVista Software, Inc. <source@mvista.com>
11
 *  Copyright (C) 2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Linus Torvalds's avatar
Linus Torvalds committed
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
 *
 *  (U)DMA capable version of ali 1533/1543(C), 1535(D)
 *
 **********************************************************************
 *  9/7/99 --Parts from the above author are included and need to be
 *  converted into standard interface, once I finish the thought.
 *
 *  Recent changes
 *	Don't use LBA48 mode on ALi <= 0xC4
 *	Don't poke 0x79 with a non ALi northbridge
 *	Don't flip undefined bits on newer chipsets (fix Fujitsu laptop hang)
 *	Allow UDMA6 on revisions > 0xC4
 *
 *  Documentation
 *	Chipset documentation available under NDA only
 *
 */

#include <linux/module.h>
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/pci.h>
#include <linux/ide.h>
#include <linux/init.h>
36
#include <linux/dmi.h>
Linus Torvalds's avatar
Linus Torvalds committed
37 38 39

#include <asm/io.h>

40 41
#define DRV_NAME "alim15x3"

42 43 44 45 46 47 48 49 50 51
/*
 * Allow UDMA on M1543C-E chipset for WDC disks that ignore CRC checking
 * (this is DANGEROUS and could result in data corruption).
 */
static int wdc_udma;

module_param(wdc_udma, bool, 0);
MODULE_PARM_DESC(wdc_udma,
		 "allow UDMA on M1543C-E chipset for WDC disks (DANGEROUS)");

Linus Torvalds's avatar
Linus Torvalds committed
52 53 54 55 56 57 58 59 60 61
/*
 *	ALi devices are not plug in. Otherwise these static values would
 *	need to go. They ought to go away anyway
 */
 
static u8 m5229_revision;
static u8 chip_is_1543c_e;
static struct pci_dev *isa_dev;

/**
62
 *	ali_set_pio_mode	-	set host controller for PIO mode
63 64
 *	@drive: drive
 *	@pio: PIO mode number
65
 *
66
 *	Program the controller for the given PIO mode.
Linus Torvalds's avatar
Linus Torvalds committed
67
 */
68

69
static void ali_set_pio_mode(ide_drive_t *drive, const u8 pio)
Linus Torvalds's avatar
Linus Torvalds committed
70
{
71
	ide_hwif_t *hwif = drive->hwif;
72
	struct pci_dev *dev = to_pci_dev(hwif->dev);
73 74
	struct ide_timing *t = ide_timing_find_mode(XFER_PIO_0 + pio);
	int s_time = t->setup, a_time = t->active, c_time = t->cycle;
Linus Torvalds's avatar
Linus Torvalds committed
75 76
	u8 s_clc, a_clc, r_clc;
	unsigned long flags;
77
	int bus_speed = ide_pci_clk ? ide_pci_clk : 33;
Linus Torvalds's avatar
Linus Torvalds committed
78 79
	int port = hwif->channel ? 0x5c : 0x58;
	int portFIFO = hwif->channel ? 0x55 : 0x54;
80
	u8 cd_dma_fifo = 0, unit = drive->dn & 1;
Linus Torvalds's avatar
Linus Torvalds committed
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113

	if ((s_clc = (s_time * bus_speed + 999) / 1000) >= 8)
		s_clc = 0;
	if ((a_clc = (a_time * bus_speed + 999) / 1000) >= 8)
		a_clc = 0;

	if (!(r_clc = (c_time * bus_speed + 999) / 1000 - a_clc - s_clc)) {
		r_clc = 1;
	} else {
		if (r_clc >= 16)
			r_clc = 0;
	}
	local_irq_save(flags);
	
	/* 
	 * PIO mode => ATA FIFO on, ATAPI FIFO off
	 */
	pci_read_config_byte(dev, portFIFO, &cd_dma_fifo);
	if (drive->media==ide_disk) {
		if (unit) {
			pci_write_config_byte(dev, portFIFO, (cd_dma_fifo & 0x0F) | 0x50);
		} else {
			pci_write_config_byte(dev, portFIFO, (cd_dma_fifo & 0xF0) | 0x05);
		}
	} else {
		if (unit) {
			pci_write_config_byte(dev, portFIFO, cd_dma_fifo & 0x0F);
		} else {
			pci_write_config_byte(dev, portFIFO, cd_dma_fifo & 0xF0);
		}
	}
	
	pci_write_config_byte(dev, port, s_clc);
114
	pci_write_config_byte(dev, port + unit + 2, (a_clc << 4) | r_clc);
Linus Torvalds's avatar
Linus Torvalds committed
115
	local_irq_restore(flags);
116 117
}

Linus Torvalds's avatar
Linus Torvalds committed
118
/**
119 120
 *	ali_udma_filter		-	compute UDMA mask
 *	@drive: IDE device
Linus Torvalds's avatar
Linus Torvalds committed
121
 *
122 123 124
 *	Return available UDMA modes.
 *
 *	The actual rules for the ALi are:
Linus Torvalds's avatar
Linus Torvalds committed
125 126
 *		No UDMA on revisions <= 0x20
 *		Disk only for revisions < 0xC2
127
 *		Not WDC drives on M1543C-E (?)
Linus Torvalds's avatar
Linus Torvalds committed
128 129
 */

130
static u8 ali_udma_filter(ide_drive_t *drive)
Linus Torvalds's avatar
Linus Torvalds committed
131
{
132 133 134
	if (m5229_revision > 0x20 && m5229_revision < 0xC2) {
		if (drive->media != ide_disk)
			return 0;
135 136
		if (wdc_udma == 0 && chip_is_1543c_e &&
		    strstr((char *)&drive->id[ATA_ID_PROD], "WDC "))
137
			return 0;
Linus Torvalds's avatar
Linus Torvalds committed
138 139
	}

140
	return drive->hwif->ultra_mask;
Linus Torvalds's avatar
Linus Torvalds committed
141 142 143
}

/**
144 145 146
 *	ali_set_dma_mode	-	set host controller for DMA mode
 *	@drive: drive
 *	@speed: DMA mode
Linus Torvalds's avatar
Linus Torvalds committed
147 148 149
 *
 *	Configure the hardware for the desired IDE transfer mode.
 */
150

151
static void ali_set_dma_mode(ide_drive_t *drive, const u8 speed)
Linus Torvalds's avatar
Linus Torvalds committed
152
{
153
	ide_hwif_t *hwif	= drive->hwif;
154
	struct pci_dev *dev	= to_pci_dev(hwif->dev);
Linus Torvalds's avatar
Linus Torvalds committed
155
	u8 speed1		= speed;
156
	u8 unit			= drive->dn & 1;
Linus Torvalds's avatar
Linus Torvalds committed
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
	u8 tmpbyte		= 0x00;
	int m5229_udma		= (hwif->channel) ? 0x57 : 0x56;

	if (speed == XFER_UDMA_6)
		speed1 = 0x47;

	if (speed < XFER_UDMA_0) {
		u8 ultra_enable	= (unit) ? 0x7f : 0xf7;
		/*
		 * clear "ultra enable" bit
		 */
		pci_read_config_byte(dev, m5229_udma, &tmpbyte);
		tmpbyte &= ultra_enable;
		pci_write_config_byte(dev, m5229_udma, tmpbyte);

172 173 174
		/*
		 * FIXME: Oh, my... DMA timings are never set.
		 */
Linus Torvalds's avatar
Linus Torvalds committed
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
	} else {
		pci_read_config_byte(dev, m5229_udma, &tmpbyte);
		tmpbyte &= (0x0f << ((1-unit) << 2));
		/*
		 * enable ultra dma and set timing
		 */
		tmpbyte |= ((0x08 | ((4-speed1)&0x07)) << (unit << 2));
		pci_write_config_byte(dev, m5229_udma, tmpbyte);
		if (speed >= XFER_UDMA_3) {
			pci_read_config_byte(dev, 0x4b, &tmpbyte);
			tmpbyte |= 1;
			pci_write_config_byte(dev, 0x4b, tmpbyte);
		}
	}
}

/**
192
 *	ali_dma_check	-	DMA check
Linus Torvalds's avatar
Linus Torvalds committed
193
 *	@drive:	target device
194
 *	@cmd: command
Linus Torvalds's avatar
Linus Torvalds committed
195 196 197 198
 *
 *	Returns 1 if the DMA cannot be performed, zero on success.
 */

199
static int ali_dma_check(ide_drive_t *drive, struct ide_cmd *cmd)
Linus Torvalds's avatar
Linus Torvalds committed
200 201
{
	if (m5229_revision < 0xC2 && drive->media != ide_disk) {
202
		if (cmd->tf_flags & IDE_TFLAG_WRITE)
Linus Torvalds's avatar
Linus Torvalds committed
203 204
			return 1;	/* try PIO instead of DMA */
	}
205
	return 0;
Linus Torvalds's avatar
Linus Torvalds committed
206 207 208 209 210 211 212 213 214
}

/**
 *	init_chipset_ali15x3	-	Initialise an ALi IDE controller
 *	@dev: PCI device
 *
 *	This function initializes the ALI IDE controller and where 
 *	appropriate also sets up the 1533 southbridge.
 */
215

216
static int init_chipset_ali15x3(struct pci_dev *dev)
Linus Torvalds's avatar
Linus Torvalds committed
217 218 219
{
	unsigned long flags;
	u8 tmpbyte;
220
	struct pci_dev *north = pci_get_slot(dev->bus, PCI_DEVFN(0,0));
Linus Torvalds's avatar
Linus Torvalds committed
221

222
	m5229_revision = dev->revision;
Linus Torvalds's avatar
Linus Torvalds committed
223

224
	isa_dev = pci_get_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, NULL);
Linus Torvalds's avatar
Linus Torvalds committed
225 226 227 228 229 230 231 232 233 234 235 236 237 238

	local_irq_save(flags);

	if (m5229_revision < 0xC2) {
		/*
		 * revision 0x20 (1543-E, 1543-F)
		 * revision 0xC0, 0xC1 (1543C-C, 1543C-D, 1543C-E)
		 * clear CD-ROM DMA write bit, m5229, 0x4b, bit 7
		 */
		pci_read_config_byte(dev, 0x4b, &tmpbyte);
		/*
		 * clear bit 7
		 */
		pci_write_config_byte(dev, 0x4b, tmpbyte & 0x7F);
239 240 241 242 243 244 245
		/*
		 * check m1533, 0x5e, bit 1~4 == 1001 => & 00011110 = 00010010
		 */
		if (m5229_revision >= 0x20 && isa_dev) {
			pci_read_config_byte(isa_dev, 0x5e, &tmpbyte);
			chip_is_1543c_e = ((tmpbyte & 0x1e) == 0x12) ? 1: 0;
		}
246
		goto out;
Linus Torvalds's avatar
Linus Torvalds committed
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268
	}

	/*
	 * 1543C-B?, 1535, 1535D, 1553
	 * Note 1: not all "motherboard" support this detection
	 * Note 2: if no udma 66 device, the detection may "error".
	 *         but in this case, we will not set the device to
	 *         ultra 66, the detection result is not important
	 */

	/*
	 * enable "Cable Detection", m5229, 0x4b, bit3
	 */
	pci_read_config_byte(dev, 0x4b, &tmpbyte);
	pci_write_config_byte(dev, 0x4b, tmpbyte | 0x08);

	/*
	 * We should only tune the 1533 enable if we are using an ALi
	 * North bridge. We might have no north found on some zany
	 * box without a device at 0:0.0. The ALi bridge will be at
	 * 0:0.0 so if we didn't find one we know what is cooking.
	 */
269 270
	if (north && north->vendor != PCI_VENDOR_ID_AL)
		goto out;
Linus Torvalds's avatar
Linus Torvalds committed
271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290

	if (m5229_revision < 0xC5 && isa_dev)
	{	
		/*
		 * set south-bridge's enable bit, m1533, 0x79
		 */

		pci_read_config_byte(isa_dev, 0x79, &tmpbyte);
		if (m5229_revision == 0xC2) {
			/*
			 * 1543C-B0 (m1533, 0x79, bit 2)
			 */
			pci_write_config_byte(isa_dev, 0x79, tmpbyte | 0x04);
		} else if (m5229_revision >= 0xC3) {
			/*
			 * 1553/1535 (m1533, 0x79, bit 1)
			 */
			pci_write_config_byte(isa_dev, 0x79, tmpbyte | 0x02);
		}
	}
291

292
out:
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314
	/*
	 * CD_ROM DMA on (m5229, 0x53, bit0)
	 *      Enable this bit even if we want to use PIO.
	 * PIO FIFO off (m5229, 0x53, bit1)
	 *      The hardware will use 0x54h and 0x55h to control PIO FIFO.
	 *	(Not on later devices it seems)
	 *
	 *	0x53 changes meaning on later revs - we must no touch
	 *	bit 1 on them.  Need to check if 0x20 is the right break.
	 */
	if (m5229_revision >= 0x20) {
		pci_read_config_byte(dev, 0x53, &tmpbyte);

		if (m5229_revision <= 0x20)
			tmpbyte = (tmpbyte & (~0x02)) | 0x01;
		else if (m5229_revision == 0xc7 || m5229_revision == 0xc8)
			tmpbyte |= 0x03;
		else
			tmpbyte |= 0x01;

		pci_write_config_byte(dev, 0x53, tmpbyte);
	}
315 316
	pci_dev_put(north);
	pci_dev_put(isa_dev);
Linus Torvalds's avatar
Linus Torvalds committed
317 318 319 320
	local_irq_restore(flags);
	return 0;
}

321 322 323 324
/*
 *	Cable special cases
 */

325
static const struct dmi_system_id cable_dmi_table[] = {
326 327 328 329
	{
		.ident = "HP Pavilion N5430",
		.matches = {
			DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"),
330
			DMI_MATCH(DMI_BOARD_VERSION, "OmniBook N32N-736"),
331 332
		},
	},
333 334 335 336 337 338 339
	{
		.ident = "Toshiba Satellite S1800-814",
		.matches = {
			DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
			DMI_MATCH(DMI_PRODUCT_NAME, "S1800-814"),
		},
	},
340 341 342 343 344 345 346 347 348 349
	{ }
};

static int ali_cable_override(struct pci_dev *pdev)
{
	/* Fujitsu P2000 */
	if (pdev->subsystem_vendor == 0x10CF &&
	    pdev->subsystem_device == 0x10AF)
		return 1;

350 351 352 353 354
	/* Mitac 8317 (Winbook-A) and relatives */
	if (pdev->subsystem_vendor == 0x1071 &&
	    pdev->subsystem_device == 0x8317)
		return 1;

355 356 357 358 359 360 361
	/* Systems by DMI */
	if (dmi_check_system(cable_dmi_table))
		return 1;

	return 0;
}

Linus Torvalds's avatar
Linus Torvalds committed
362
/**
363
 *	ali_cable_detect	-	cable detection
Linus Torvalds's avatar
Linus Torvalds committed
364 365 366 367 368 369 370 371 372
 *	@hwif: IDE interface
 *
 *	This checks if the controller and the cable are capable
 *	of UDMA66 transfers. It doesn't check the drives.
 *	But see note 2 below!
 *
 *	FIXME: frobs bits that are not defined on newer ALi devicea
 */

373
static u8 ali_cable_detect(ide_hwif_t *hwif)
Linus Torvalds's avatar
Linus Torvalds committed
374
{
375
	struct pci_dev *dev = to_pci_dev(hwif->dev);
Linus Torvalds's avatar
Linus Torvalds committed
376
	unsigned long flags;
377
	u8 cbl = ATA_CBL_PATA40, tmpbyte;
Linus Torvalds's avatar
Linus Torvalds committed
378 379 380 381 382

	local_irq_save(flags);

	if (m5229_revision >= 0xC2) {
		/*
383 384 385 386 387 388 389
		 * m5229 80-pin cable detection (from Host View)
		 *
		 * 0x4a bit0 is 0 => primary channel has 80-pin
		 * 0x4a bit1 is 0 => secondary channel has 80-pin
		 *
		 * Certain laptops use short but suitable cables
		 * and don't implement the detect logic.
Linus Torvalds's avatar
Linus Torvalds committed
390
		 */
391 392 393 394 395 396 397
		if (ali_cable_override(dev))
			cbl = ATA_CBL_PATA40_SHORT;
		else {
			pci_read_config_byte(dev, 0x4a, &tmpbyte);
			if ((tmpbyte & (1 << hwif->channel)) == 0)
				cbl = ATA_CBL_PATA80;
		}
Linus Torvalds's avatar
Linus Torvalds committed
398 399 400 401
	}

	local_irq_restore(flags);

402
	return cbl;
Linus Torvalds's avatar
Linus Torvalds committed
403 404
}

405
#ifndef CONFIG_SPARC64
Linus Torvalds's avatar
Linus Torvalds committed
406 407 408 409 410 411
/**
 *	init_hwif_ali15x3	-	Initialize the ALI IDE x86 stuff
 *	@hwif: interface to configure
 *
 *	Obtain the IRQ tables for an ALi based IDE solution on the PC
 *	class platforms. This part of the code isn't applicable to the
412
 *	Sparc systems.
Linus Torvalds's avatar
Linus Torvalds committed
413 414
 */

415
static void __devinit init_hwif_ali15x3 (ide_hwif_t *hwif)
Linus Torvalds's avatar
Linus Torvalds committed
416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451
{
	u8 ideic, inmir;
	s8 irq_routing_table[] = { -1,  9, 3, 10, 4,  5, 7,  6,
				      1, 11, 0, 12, 0, 14, 0, 15 };
	int irq = -1;

	if (isa_dev) {
		/*
		 * read IDE interface control
		 */
		pci_read_config_byte(isa_dev, 0x58, &ideic);

		/* bit0, bit1 */
		ideic = ideic & 0x03;

		/* get IRQ for IDE Controller */
		if ((hwif->channel && ideic == 0x03) ||
		    (!hwif->channel && !ideic)) {
			/*
			 * get SIRQ1 routing table
			 */
			pci_read_config_byte(isa_dev, 0x44, &inmir);
			inmir = inmir & 0x0f;
			irq = irq_routing_table[inmir];
		} else if (hwif->channel && !(ideic & 0x01)) {
			/*
			 * get SIRQ2 routing table
			 */
			pci_read_config_byte(isa_dev, 0x75, &inmir);
			inmir = inmir & 0x0f;
			irq = irq_routing_table[inmir];
		}
		if(irq >= 0)
			hwif->irq = irq;
	}
}
452 453
#else
#define init_hwif_ali15x3 NULL
454
#endif /* CONFIG_SPARC64 */
Linus Torvalds's avatar
Linus Torvalds committed
455 456 457 458

/**
 *	init_dma_ali15x3	-	set up DMA on ALi15x3
 *	@hwif: IDE interface
459
 *	@d: IDE port info
Linus Torvalds's avatar
Linus Torvalds committed
460
 *
461
 *	Set up the DMA functionality on the ALi 15x3.
Linus Torvalds's avatar
Linus Torvalds committed
462 463
 */

464 465
static int __devinit init_dma_ali15x3(ide_hwif_t *hwif,
				      const struct ide_port_info *d)
Linus Torvalds's avatar
Linus Torvalds committed
466
{
467 468 469
	struct pci_dev *dev = to_pci_dev(hwif->dev);
	unsigned long base = ide_pci_dma_base(hwif, d);

470 471 472 473 474 475 476 477 478
	if (base == 0)
		return -1;

	hwif->dma_base = base;

	if (ide_pci_check_simplex(hwif, d) < 0)
		return -1;

	if (ide_pci_set_master(dev, d->name) < 0)
479 480
		return -1;

481
	if (!hwif->channel)
482 483 484 485 486 487 488 489 490
		outb(inb(base + 2) & 0x60, base + 2);

	printk(KERN_INFO "    %s: BM-DMA at 0x%04lx-0x%04lx\n",
			 hwif->name, base, base + 7);

	if (ide_allocate_dma_engine(hwif))
		return -1;

	return 0;
Linus Torvalds's avatar
Linus Torvalds committed
491 492
}

493 494 495 496 497 498 499
static const struct ide_port_ops ali_port_ops = {
	.set_pio_mode		= ali_set_pio_mode,
	.set_dma_mode		= ali_set_dma_mode,
	.udma_filter		= ali_udma_filter,
	.cable_detect		= ali_cable_detect,
};

500 501
static const struct ide_dma_ops ali_dma_ops = {
	.dma_host_set		= ide_dma_host_set,
502
	.dma_setup		= ide_dma_setup,
503
	.dma_start		= ide_dma_start,
504
	.dma_end		= ide_dma_end,
505 506
	.dma_test_irq		= ide_dma_test_irq,
	.dma_lost_irq		= ide_dma_lost_irq,
507
	.dma_check		= ali_dma_check,
508
	.dma_timer_expiry	= ide_dma_sff_timer_expiry,
509
	.dma_sff_read_status	= ide_dma_sff_read_status,
510 511
};

512
static const struct ide_port_info ali15x3_chipset __devinitdata = {
513
	.name		= DRV_NAME,
Linus Torvalds's avatar
Linus Torvalds committed
514 515 516
	.init_chipset	= init_chipset_ali15x3,
	.init_hwif	= init_hwif_ali15x3,
	.init_dma	= init_dma_ali15x3,
517
	.port_ops	= &ali_port_ops,
518
	.dma_ops	= &sff_dma_ops,
519
	.pio_mask	= ATA_PIO5,
520 521
	.swdma_mask	= ATA_SWDMA2,
	.mwdma_mask	= ATA_MWDMA2,
Linus Torvalds's avatar
Linus Torvalds committed
522 523 524 525 526 527 528 529 530 531 532 533
};

/**
 *	alim15x3_init_one	-	set up an ALi15x3 IDE controller
 *	@dev: PCI device to set up
 *
 *	Perform the actual set up for an ALi15x3 that has been found by the
 *	hot plug layer.
 */
 
static int __devinit alim15x3_init_one(struct pci_dev *dev, const struct pci_device_id *id)
{
534
	struct ide_port_info d = ali15x3_chipset;
535
	u8 rev = dev->revision, idx = id->driver_data;
Linus Torvalds's avatar
Linus Torvalds committed
536

537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552
	/* don't use LBA48 DMA on ALi devices before rev 0xC5 */
	if (rev <= 0xC4)
		d.host_flags |= IDE_HFLAG_NO_LBA48_DMA;

	if (rev >= 0x20) {
		if (rev == 0x20)
			d.host_flags |= IDE_HFLAG_NO_ATAPI_DMA;

		if (rev < 0xC2)
			d.udma_mask = ATA_UDMA2;
		else if (rev == 0xC2 || rev == 0xC3)
			d.udma_mask = ATA_UDMA4;
		else if (rev == 0xC4)
			d.udma_mask = ATA_UDMA5;
		else
			d.udma_mask = ATA_UDMA6;
553 554

		d.dma_ops = &ali_dma_ops;
555 556 557 558
	} else {
		d.host_flags |= IDE_HFLAG_NO_DMA;

		d.mwdma_mask = d.swdma_mask = 0;
559 560
	}

561 562 563
	if (idx == 0)
		d.host_flags |= IDE_HFLAG_CLEAR_SIMPLEX;

564
	return ide_pci_init_one(dev, &d, NULL);
Linus Torvalds's avatar
Linus Torvalds committed
565 566 567
}


568 569
static const struct pci_device_id alim15x3_pci_tbl[] = {
	{ PCI_VDEVICE(AL, PCI_DEVICE_ID_AL_M5229), 0 },
570
	{ PCI_VDEVICE(AL, PCI_DEVICE_ID_AL_M5228), 1 },
Linus Torvalds's avatar
Linus Torvalds committed
571 572 573 574
	{ 0, },
};
MODULE_DEVICE_TABLE(pci, alim15x3_pci_tbl);

575
static struct pci_driver alim15x3_pci_driver = {
Linus Torvalds's avatar
Linus Torvalds committed
576 577 578
	.name		= "ALI15x3_IDE",
	.id_table	= alim15x3_pci_tbl,
	.probe		= alim15x3_init_one,
579
	.remove		= ide_pci_remove,
580 581
	.suspend	= ide_pci_suspend,
	.resume		= ide_pci_resume,
Linus Torvalds's avatar
Linus Torvalds committed
582 583
};

584
static int __init ali15x3_ide_init(void)
Linus Torvalds's avatar
Linus Torvalds committed
585
{
586
	return ide_pci_register_driver(&alim15x3_pci_driver);
Linus Torvalds's avatar
Linus Torvalds committed
587 588
}

589 590
static void __exit ali15x3_ide_exit(void)
{
591
	pci_unregister_driver(&alim15x3_pci_driver);
592 593
}

Linus Torvalds's avatar
Linus Torvalds committed
594
module_init(ali15x3_ide_init);
595
module_exit(ali15x3_ide_exit);
Linus Torvalds's avatar
Linus Torvalds committed
596 597 598 599

MODULE_AUTHOR("Michael Aubry, Andrzej Krzysztofowicz, CJ, Andre Hedrick, Alan Cox");
MODULE_DESCRIPTION("PCI driver module for ALi 15x3 IDE");
MODULE_LICENSE("GPL");