xref: /kernel/linux/linux-5.10/drivers/ide/trm290.c (revision 8c2ecf20)
18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci *  Copyright (c) 1997-1998  Mark Lord
38c2ecf20Sopenharmony_ci *  Copyright (c) 2007       MontaVista Software, Inc. <source@mvista.com>
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci *  May be copied or modified under the terms of the GNU General Public License
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci *  June 22, 2004 - get rid of check_region
88c2ecf20Sopenharmony_ci *                   - Jesper Juhl
98c2ecf20Sopenharmony_ci *
108c2ecf20Sopenharmony_ci */
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci/*
138c2ecf20Sopenharmony_ci * This module provides support for the bus-master IDE DMA function
148c2ecf20Sopenharmony_ci * of the Tekram TRM290 chip, used on a variety of PCI IDE add-on boards,
158c2ecf20Sopenharmony_ci * including a "Precision Instruments" board.  The TRM290 pre-dates
168c2ecf20Sopenharmony_ci * the sff-8038 standard (ide-dma.c) by a few months, and differs
178c2ecf20Sopenharmony_ci * significantly enough to warrant separate routines for some functions,
188c2ecf20Sopenharmony_ci * while re-using others from ide-dma.c.
198c2ecf20Sopenharmony_ci *
208c2ecf20Sopenharmony_ci * EXPERIMENTAL!  It works for me (a sample of one).
218c2ecf20Sopenharmony_ci *
228c2ecf20Sopenharmony_ci * Works reliably for me in DMA mode (READs only),
238c2ecf20Sopenharmony_ci * DMA WRITEs are disabled by default (see #define below);
248c2ecf20Sopenharmony_ci *
258c2ecf20Sopenharmony_ci * DMA is not enabled automatically for this chipset,
268c2ecf20Sopenharmony_ci * but can be turned on manually (with "hdparm -d1") at run time.
278c2ecf20Sopenharmony_ci *
288c2ecf20Sopenharmony_ci * I need volunteers with "spare" drives for further testing
298c2ecf20Sopenharmony_ci * and development, and maybe to help figure out the peculiarities.
308c2ecf20Sopenharmony_ci * Even knowing the registers (below), some things behave strangely.
318c2ecf20Sopenharmony_ci */
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci#define TRM290_NO_DMA_WRITES	/* DMA writes seem unreliable sometimes */
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci/*
368c2ecf20Sopenharmony_ci * TRM-290 PCI-IDE2 Bus Master Chip
378c2ecf20Sopenharmony_ci * ================================
388c2ecf20Sopenharmony_ci * The configuration registers are addressed in normal I/O port space
398c2ecf20Sopenharmony_ci * and are used as follows:
408c2ecf20Sopenharmony_ci *
418c2ecf20Sopenharmony_ci * trm290_base depends on jumper settings, and is probed for by ide-dma.c
428c2ecf20Sopenharmony_ci *
438c2ecf20Sopenharmony_ci * trm290_base+2 when WRITTEN: chiptest register (byte, write-only)
448c2ecf20Sopenharmony_ci *	bit7 must always be written as "1"
458c2ecf20Sopenharmony_ci *	bits6-2 undefined
468c2ecf20Sopenharmony_ci *	bit1 1=legacy_compatible_mode, 0=native_pci_mode
478c2ecf20Sopenharmony_ci *	bit0 1=test_mode, 0=normal(default)
488c2ecf20Sopenharmony_ci *
498c2ecf20Sopenharmony_ci * trm290_base+2 when READ: status register (byte, read-only)
508c2ecf20Sopenharmony_ci *	bits7-2 undefined
518c2ecf20Sopenharmony_ci *	bit1 channel0 busmaster interrupt status 0=none, 1=asserted
528c2ecf20Sopenharmony_ci *	bit0 channel0 interrupt status 0=none, 1=asserted
538c2ecf20Sopenharmony_ci *
548c2ecf20Sopenharmony_ci * trm290_base+3 Interrupt mask register
558c2ecf20Sopenharmony_ci *	bits7-5 undefined
568c2ecf20Sopenharmony_ci *	bit4 legacy_header: 1=present, 0=absent
578c2ecf20Sopenharmony_ci *	bit3 channel1 busmaster interrupt status 0=none, 1=asserted (read only)
588c2ecf20Sopenharmony_ci *	bit2 channel1 interrupt status 0=none, 1=asserted (read only)
598c2ecf20Sopenharmony_ci *	bit1 channel1 interrupt mask: 1=masked, 0=unmasked(default)
608c2ecf20Sopenharmony_ci *	bit0 channel0 interrupt mask: 1=masked, 0=unmasked(default)
618c2ecf20Sopenharmony_ci *
628c2ecf20Sopenharmony_ci * trm290_base+1 "CPR" Config Pointer Register (byte)
638c2ecf20Sopenharmony_ci *	bit7 1=autoincrement CPR bits 2-0 after each access of CDR
648c2ecf20Sopenharmony_ci *	bit6 1=min. 1 wait-state posted write cycle (default), 0=0 wait-state
658c2ecf20Sopenharmony_ci *	bit5 0=enabled master burst access (default), 1=disable  (write only)
668c2ecf20Sopenharmony_ci *	bit4 PCI DEVSEL# timing select: 1=medium(default), 0=fast
678c2ecf20Sopenharmony_ci *	bit3 0=primary IDE channel, 1=secondary IDE channel
688c2ecf20Sopenharmony_ci *	bits2-0 register index for accesses through CDR port
698c2ecf20Sopenharmony_ci *
708c2ecf20Sopenharmony_ci * trm290_base+0 "CDR" Config Data Register (word)
718c2ecf20Sopenharmony_ci *	two sets of seven config registers,
728c2ecf20Sopenharmony_ci *	selected by CPR bit 3 (channel) and CPR bits 2-0 (index 0 to 6),
738c2ecf20Sopenharmony_ci *	each index defined below:
748c2ecf20Sopenharmony_ci *
758c2ecf20Sopenharmony_ci * Index-0 Base address register for command block (word)
768c2ecf20Sopenharmony_ci *	defaults: 0x1f0 for primary, 0x170 for secondary
778c2ecf20Sopenharmony_ci *
788c2ecf20Sopenharmony_ci * Index-1 general config register (byte)
798c2ecf20Sopenharmony_ci *	bit7 1=DMA enable, 0=DMA disable
808c2ecf20Sopenharmony_ci *	bit6 1=activate IDE_RESET, 0=no action (default)
818c2ecf20Sopenharmony_ci *	bit5 1=enable IORDY, 0=disable IORDY (default)
828c2ecf20Sopenharmony_ci *	bit4 0=16-bit data port(default), 1=8-bit (XT) data port
838c2ecf20Sopenharmony_ci *	bit3 interrupt polarity: 1=active_low, 0=active_high(default)
848c2ecf20Sopenharmony_ci *	bit2 power-saving-mode(?): 1=enable, 0=disable(default) (write only)
858c2ecf20Sopenharmony_ci *	bit1 bus_master_mode(?): 1=enable, 0=disable(default)
868c2ecf20Sopenharmony_ci *	bit0 enable_io_ports: 1=enable(default), 0=disable
878c2ecf20Sopenharmony_ci *
888c2ecf20Sopenharmony_ci * Index-2 read-ahead counter preload bits 0-7 (byte, write only)
898c2ecf20Sopenharmony_ci *	bits7-0 bits7-0 of readahead count
908c2ecf20Sopenharmony_ci *
918c2ecf20Sopenharmony_ci * Index-3 read-ahead config register (byte, write only)
928c2ecf20Sopenharmony_ci *	bit7 1=enable_readahead, 0=disable_readahead(default)
938c2ecf20Sopenharmony_ci *	bit6 1=clear_FIFO, 0=no_action
948c2ecf20Sopenharmony_ci *	bit5 undefined
958c2ecf20Sopenharmony_ci *	bit4 mode4 timing control: 1=enable, 0=disable(default)
968c2ecf20Sopenharmony_ci *	bit3 undefined
978c2ecf20Sopenharmony_ci *	bit2 undefined
988c2ecf20Sopenharmony_ci *	bits1-0 bits9-8 of read-ahead count
998c2ecf20Sopenharmony_ci *
1008c2ecf20Sopenharmony_ci * Index-4 base address register for control block (word)
1018c2ecf20Sopenharmony_ci *	defaults: 0x3f6 for primary, 0x376 for secondary
1028c2ecf20Sopenharmony_ci *
1038c2ecf20Sopenharmony_ci * Index-5 data port timings (shared by both drives) (byte)
1048c2ecf20Sopenharmony_ci *	standard PCI "clk" (clock) counts, default value = 0xf5
1058c2ecf20Sopenharmony_ci *
1068c2ecf20Sopenharmony_ci *	bits7-6 setup time:  00=1clk, 01=2clk, 10=3clk, 11=4clk
1078c2ecf20Sopenharmony_ci *	bits5-3 hold time:	000=1clk, 001=2clk, 010=3clk,
1088c2ecf20Sopenharmony_ci *				011=4clk, 100=5clk, 101=6clk,
1098c2ecf20Sopenharmony_ci *				110=8clk, 111=12clk
1108c2ecf20Sopenharmony_ci *	bits2-0 active time:	000=2clk, 001=3clk, 010=4clk,
1118c2ecf20Sopenharmony_ci *				011=5clk, 100=6clk, 101=8clk,
1128c2ecf20Sopenharmony_ci *				110=12clk, 111=16clk
1138c2ecf20Sopenharmony_ci *
1148c2ecf20Sopenharmony_ci * Index-6 command/control port timings (shared by both drives) (byte)
1158c2ecf20Sopenharmony_ci *	same layout as Index-5, default value = 0xde
1168c2ecf20Sopenharmony_ci *
1178c2ecf20Sopenharmony_ci * Suggested CDR programming for PIO mode0 (600ns):
1188c2ecf20Sopenharmony_ci *	0x01f0,0x21,0xff,0x80,0x03f6,0xf5,0xde	; primary
1198c2ecf20Sopenharmony_ci *	0x0170,0x21,0xff,0x80,0x0376,0xf5,0xde	; secondary
1208c2ecf20Sopenharmony_ci *
1218c2ecf20Sopenharmony_ci * Suggested CDR programming for PIO mode3 (180ns):
1228c2ecf20Sopenharmony_ci *	0x01f0,0x21,0xff,0x80,0x03f6,0x09,0xde	; primary
1238c2ecf20Sopenharmony_ci *	0x0170,0x21,0xff,0x80,0x0376,0x09,0xde	; secondary
1248c2ecf20Sopenharmony_ci *
1258c2ecf20Sopenharmony_ci * Suggested CDR programming for PIO mode4 (120ns):
1268c2ecf20Sopenharmony_ci *	0x01f0,0x21,0xff,0x80,0x03f6,0x00,0xde	; primary
1278c2ecf20Sopenharmony_ci *	0x0170,0x21,0xff,0x80,0x0376,0x00,0xde	; secondary
1288c2ecf20Sopenharmony_ci *
1298c2ecf20Sopenharmony_ci */
1308c2ecf20Sopenharmony_ci
1318c2ecf20Sopenharmony_ci#include <linux/types.h>
1328c2ecf20Sopenharmony_ci#include <linux/module.h>
1338c2ecf20Sopenharmony_ci#include <linux/kernel.h>
1348c2ecf20Sopenharmony_ci#include <linux/ioport.h>
1358c2ecf20Sopenharmony_ci#include <linux/interrupt.h>
1368c2ecf20Sopenharmony_ci#include <linux/blkdev.h>
1378c2ecf20Sopenharmony_ci#include <linux/init.h>
1388c2ecf20Sopenharmony_ci#include <linux/pci.h>
1398c2ecf20Sopenharmony_ci#include <linux/ide.h>
1408c2ecf20Sopenharmony_ci
1418c2ecf20Sopenharmony_ci#include <asm/io.h>
1428c2ecf20Sopenharmony_ci
1438c2ecf20Sopenharmony_ci#define DRV_NAME "trm290"
1448c2ecf20Sopenharmony_ci
1458c2ecf20Sopenharmony_cistatic void trm290_prepare_drive (ide_drive_t *drive, unsigned int use_dma)
1468c2ecf20Sopenharmony_ci{
1478c2ecf20Sopenharmony_ci	ide_hwif_t *hwif = drive->hwif;
1488c2ecf20Sopenharmony_ci	u16 reg = 0;
1498c2ecf20Sopenharmony_ci	unsigned long flags;
1508c2ecf20Sopenharmony_ci
1518c2ecf20Sopenharmony_ci	/* select PIO or DMA */
1528c2ecf20Sopenharmony_ci	reg = use_dma ? (0x21 | 0x82) : (0x21 & ~0x82);
1538c2ecf20Sopenharmony_ci
1548c2ecf20Sopenharmony_ci	local_irq_save(flags);
1558c2ecf20Sopenharmony_ci
1568c2ecf20Sopenharmony_ci	if (reg != hwif->select_data) {
1578c2ecf20Sopenharmony_ci		hwif->select_data = reg;
1588c2ecf20Sopenharmony_ci		/* set PIO/DMA */
1598c2ecf20Sopenharmony_ci		outb(0x51 | (hwif->channel << 3), hwif->config_data + 1);
1608c2ecf20Sopenharmony_ci		outw(reg & 0xff, hwif->config_data);
1618c2ecf20Sopenharmony_ci	}
1628c2ecf20Sopenharmony_ci
1638c2ecf20Sopenharmony_ci	/* enable IRQ if not probing */
1648c2ecf20Sopenharmony_ci	if (drive->dev_flags & IDE_DFLAG_PRESENT) {
1658c2ecf20Sopenharmony_ci		reg = inw(hwif->config_data + 3);
1668c2ecf20Sopenharmony_ci		reg &= 0x13;
1678c2ecf20Sopenharmony_ci		reg &= ~(1 << hwif->channel);
1688c2ecf20Sopenharmony_ci		outw(reg, hwif->config_data + 3);
1698c2ecf20Sopenharmony_ci	}
1708c2ecf20Sopenharmony_ci
1718c2ecf20Sopenharmony_ci	local_irq_restore(flags);
1728c2ecf20Sopenharmony_ci}
1738c2ecf20Sopenharmony_ci
1748c2ecf20Sopenharmony_cistatic void trm290_dev_select(ide_drive_t *drive)
1758c2ecf20Sopenharmony_ci{
1768c2ecf20Sopenharmony_ci	trm290_prepare_drive(drive, !!(drive->dev_flags & IDE_DFLAG_USING_DMA));
1778c2ecf20Sopenharmony_ci
1788c2ecf20Sopenharmony_ci	outb(drive->select | ATA_DEVICE_OBS, drive->hwif->io_ports.device_addr);
1798c2ecf20Sopenharmony_ci}
1808c2ecf20Sopenharmony_ci
1818c2ecf20Sopenharmony_cistatic int trm290_dma_check(ide_drive_t *drive, struct ide_cmd *cmd)
1828c2ecf20Sopenharmony_ci{
1838c2ecf20Sopenharmony_ci	if (cmd->tf_flags & IDE_TFLAG_WRITE) {
1848c2ecf20Sopenharmony_ci#ifdef TRM290_NO_DMA_WRITES
1858c2ecf20Sopenharmony_ci		/* always use PIO for writes */
1868c2ecf20Sopenharmony_ci		return 1;
1878c2ecf20Sopenharmony_ci#endif
1888c2ecf20Sopenharmony_ci	}
1898c2ecf20Sopenharmony_ci	return 0;
1908c2ecf20Sopenharmony_ci}
1918c2ecf20Sopenharmony_ci
1928c2ecf20Sopenharmony_cistatic int trm290_dma_setup(ide_drive_t *drive, struct ide_cmd *cmd)
1938c2ecf20Sopenharmony_ci{
1948c2ecf20Sopenharmony_ci	ide_hwif_t *hwif = drive->hwif;
1958c2ecf20Sopenharmony_ci	unsigned int count, rw = (cmd->tf_flags & IDE_TFLAG_WRITE) ? 1 : 2;
1968c2ecf20Sopenharmony_ci
1978c2ecf20Sopenharmony_ci	count = ide_build_dmatable(drive, cmd);
1988c2ecf20Sopenharmony_ci	if (count == 0)
1998c2ecf20Sopenharmony_ci		/* try PIO instead of DMA */
2008c2ecf20Sopenharmony_ci		return 1;
2018c2ecf20Sopenharmony_ci
2028c2ecf20Sopenharmony_ci	outl(hwif->dmatable_dma | rw, hwif->dma_base);
2038c2ecf20Sopenharmony_ci	/* start DMA */
2048c2ecf20Sopenharmony_ci	outw(count * 2 - 1, hwif->dma_base + 2);
2058c2ecf20Sopenharmony_ci
2068c2ecf20Sopenharmony_ci	return 0;
2078c2ecf20Sopenharmony_ci}
2088c2ecf20Sopenharmony_ci
2098c2ecf20Sopenharmony_cistatic void trm290_dma_start(ide_drive_t *drive)
2108c2ecf20Sopenharmony_ci{
2118c2ecf20Sopenharmony_ci	trm290_prepare_drive(drive, 1);
2128c2ecf20Sopenharmony_ci}
2138c2ecf20Sopenharmony_ci
2148c2ecf20Sopenharmony_cistatic int trm290_dma_end(ide_drive_t *drive)
2158c2ecf20Sopenharmony_ci{
2168c2ecf20Sopenharmony_ci	u16 status = inw(drive->hwif->dma_base + 2);
2178c2ecf20Sopenharmony_ci
2188c2ecf20Sopenharmony_ci	trm290_prepare_drive(drive, 0);
2198c2ecf20Sopenharmony_ci
2208c2ecf20Sopenharmony_ci	return status != 0x00ff;
2218c2ecf20Sopenharmony_ci}
2228c2ecf20Sopenharmony_ci
2238c2ecf20Sopenharmony_cistatic int trm290_dma_test_irq(ide_drive_t *drive)
2248c2ecf20Sopenharmony_ci{
2258c2ecf20Sopenharmony_ci	u16 status = inw(drive->hwif->dma_base + 2);
2268c2ecf20Sopenharmony_ci
2278c2ecf20Sopenharmony_ci	return status == 0x00ff;
2288c2ecf20Sopenharmony_ci}
2298c2ecf20Sopenharmony_ci
2308c2ecf20Sopenharmony_cistatic void trm290_dma_host_set(ide_drive_t *drive, int on)
2318c2ecf20Sopenharmony_ci{
2328c2ecf20Sopenharmony_ci}
2338c2ecf20Sopenharmony_ci
2348c2ecf20Sopenharmony_cistatic void init_hwif_trm290(ide_hwif_t *hwif)
2358c2ecf20Sopenharmony_ci{
2368c2ecf20Sopenharmony_ci	struct pci_dev *dev	= to_pci_dev(hwif->dev);
2378c2ecf20Sopenharmony_ci	unsigned int  cfg_base	= pci_resource_start(dev, 4);
2388c2ecf20Sopenharmony_ci	unsigned long flags;
2398c2ecf20Sopenharmony_ci	u8 reg = 0;
2408c2ecf20Sopenharmony_ci
2418c2ecf20Sopenharmony_ci	if ((dev->class & 5) && cfg_base)
2428c2ecf20Sopenharmony_ci		printk(KERN_INFO DRV_NAME " %s: chip", pci_name(dev));
2438c2ecf20Sopenharmony_ci	else {
2448c2ecf20Sopenharmony_ci		cfg_base = 0x3df0;
2458c2ecf20Sopenharmony_ci		printk(KERN_INFO DRV_NAME " %s: using default", pci_name(dev));
2468c2ecf20Sopenharmony_ci	}
2478c2ecf20Sopenharmony_ci	printk(KERN_CONT " config base at 0x%04x\n", cfg_base);
2488c2ecf20Sopenharmony_ci	hwif->config_data = cfg_base;
2498c2ecf20Sopenharmony_ci	hwif->dma_base = (cfg_base + 4) ^ (hwif->channel ? 0x80 : 0);
2508c2ecf20Sopenharmony_ci
2518c2ecf20Sopenharmony_ci	printk(KERN_INFO "    %s: BM-DMA at 0x%04lx-0x%04lx\n",
2528c2ecf20Sopenharmony_ci	       hwif->name, hwif->dma_base, hwif->dma_base + 3);
2538c2ecf20Sopenharmony_ci
2548c2ecf20Sopenharmony_ci	if (ide_allocate_dma_engine(hwif))
2558c2ecf20Sopenharmony_ci		return;
2568c2ecf20Sopenharmony_ci
2578c2ecf20Sopenharmony_ci	local_irq_save(flags);
2588c2ecf20Sopenharmony_ci	/* put config reg into first byte of hwif->select_data */
2598c2ecf20Sopenharmony_ci	outb(0x51 | (hwif->channel << 3), hwif->config_data + 1);
2608c2ecf20Sopenharmony_ci	/* select PIO as default */
2618c2ecf20Sopenharmony_ci	hwif->select_data = 0x21;
2628c2ecf20Sopenharmony_ci	outb(hwif->select_data, hwif->config_data);
2638c2ecf20Sopenharmony_ci	/* get IRQ info */
2648c2ecf20Sopenharmony_ci	reg = inb(hwif->config_data + 3);
2658c2ecf20Sopenharmony_ci	/* mask IRQs for both ports */
2668c2ecf20Sopenharmony_ci	reg = (reg & 0x10) | 0x03;
2678c2ecf20Sopenharmony_ci	outb(reg, hwif->config_data + 3);
2688c2ecf20Sopenharmony_ci	local_irq_restore(flags);
2698c2ecf20Sopenharmony_ci
2708c2ecf20Sopenharmony_ci	if (reg & 0x10)
2718c2ecf20Sopenharmony_ci		/* legacy mode */
2728c2ecf20Sopenharmony_ci		hwif->irq = hwif->channel ? 15 : 14;
2738c2ecf20Sopenharmony_ci
2748c2ecf20Sopenharmony_ci#if 1
2758c2ecf20Sopenharmony_ci	{
2768c2ecf20Sopenharmony_ci	/*
2778c2ecf20Sopenharmony_ci	 * My trm290-based card doesn't seem to work with all possible values
2788c2ecf20Sopenharmony_ci	 * for the control basereg, so this kludge ensures that we use only
2798c2ecf20Sopenharmony_ci	 * values that are known to work.  Ugh.		-ml
2808c2ecf20Sopenharmony_ci	 */
2818c2ecf20Sopenharmony_ci		u16 new, old, compat = hwif->channel ? 0x374 : 0x3f4;
2828c2ecf20Sopenharmony_ci		static u16 next_offset = 0;
2838c2ecf20Sopenharmony_ci		u8 old_mask;
2848c2ecf20Sopenharmony_ci
2858c2ecf20Sopenharmony_ci		outb(0x54 | (hwif->channel << 3), hwif->config_data + 1);
2868c2ecf20Sopenharmony_ci		old = inw(hwif->config_data);
2878c2ecf20Sopenharmony_ci		old &= ~1;
2888c2ecf20Sopenharmony_ci		old_mask = inb(old + 2);
2898c2ecf20Sopenharmony_ci		if (old != compat && old_mask == 0xff) {
2908c2ecf20Sopenharmony_ci			/* leave lower 10 bits untouched */
2918c2ecf20Sopenharmony_ci			compat += (next_offset += 0x400);
2928c2ecf20Sopenharmony_ci			hwif->io_ports.ctl_addr = compat + 2;
2938c2ecf20Sopenharmony_ci			outw(compat | 1, hwif->config_data);
2948c2ecf20Sopenharmony_ci			new = inw(hwif->config_data);
2958c2ecf20Sopenharmony_ci			printk(KERN_INFO "%s: control basereg workaround: "
2968c2ecf20Sopenharmony_ci				"old=0x%04x, new=0x%04x\n",
2978c2ecf20Sopenharmony_ci				hwif->name, old, new & ~1);
2988c2ecf20Sopenharmony_ci		}
2998c2ecf20Sopenharmony_ci	}
3008c2ecf20Sopenharmony_ci#endif
3018c2ecf20Sopenharmony_ci}
3028c2ecf20Sopenharmony_ci
3038c2ecf20Sopenharmony_cistatic const struct ide_tp_ops trm290_tp_ops = {
3048c2ecf20Sopenharmony_ci	.exec_command		= ide_exec_command,
3058c2ecf20Sopenharmony_ci	.read_status		= ide_read_status,
3068c2ecf20Sopenharmony_ci	.read_altstatus		= ide_read_altstatus,
3078c2ecf20Sopenharmony_ci	.write_devctl		= ide_write_devctl,
3088c2ecf20Sopenharmony_ci
3098c2ecf20Sopenharmony_ci	.dev_select		= trm290_dev_select,
3108c2ecf20Sopenharmony_ci	.tf_load		= ide_tf_load,
3118c2ecf20Sopenharmony_ci	.tf_read		= ide_tf_read,
3128c2ecf20Sopenharmony_ci
3138c2ecf20Sopenharmony_ci	.input_data		= ide_input_data,
3148c2ecf20Sopenharmony_ci	.output_data		= ide_output_data,
3158c2ecf20Sopenharmony_ci};
3168c2ecf20Sopenharmony_ci
3178c2ecf20Sopenharmony_cistatic const struct ide_dma_ops trm290_dma_ops = {
3188c2ecf20Sopenharmony_ci	.dma_host_set		= trm290_dma_host_set,
3198c2ecf20Sopenharmony_ci	.dma_setup 		= trm290_dma_setup,
3208c2ecf20Sopenharmony_ci	.dma_start 		= trm290_dma_start,
3218c2ecf20Sopenharmony_ci	.dma_end		= trm290_dma_end,
3228c2ecf20Sopenharmony_ci	.dma_test_irq		= trm290_dma_test_irq,
3238c2ecf20Sopenharmony_ci	.dma_lost_irq		= ide_dma_lost_irq,
3248c2ecf20Sopenharmony_ci	.dma_check		= trm290_dma_check,
3258c2ecf20Sopenharmony_ci};
3268c2ecf20Sopenharmony_ci
3278c2ecf20Sopenharmony_cistatic const struct ide_port_info trm290_chipset = {
3288c2ecf20Sopenharmony_ci	.name		= DRV_NAME,
3298c2ecf20Sopenharmony_ci	.init_hwif	= init_hwif_trm290,
3308c2ecf20Sopenharmony_ci	.tp_ops 	= &trm290_tp_ops,
3318c2ecf20Sopenharmony_ci	.dma_ops	= &trm290_dma_ops,
3328c2ecf20Sopenharmony_ci	.host_flags	= IDE_HFLAG_TRM290 |
3338c2ecf20Sopenharmony_ci			  IDE_HFLAG_NO_ATAPI_DMA |
3348c2ecf20Sopenharmony_ci#if 0 /* play it safe for now */
3358c2ecf20Sopenharmony_ci			  IDE_HFLAG_TRUST_BIOS_FOR_DMA |
3368c2ecf20Sopenharmony_ci#endif
3378c2ecf20Sopenharmony_ci			  IDE_HFLAG_NO_AUTODMA |
3388c2ecf20Sopenharmony_ci			  IDE_HFLAG_NO_LBA48,
3398c2ecf20Sopenharmony_ci};
3408c2ecf20Sopenharmony_ci
3418c2ecf20Sopenharmony_cistatic int trm290_init_one(struct pci_dev *dev, const struct pci_device_id *id)
3428c2ecf20Sopenharmony_ci{
3438c2ecf20Sopenharmony_ci	return ide_pci_init_one(dev, &trm290_chipset, NULL);
3448c2ecf20Sopenharmony_ci}
3458c2ecf20Sopenharmony_ci
3468c2ecf20Sopenharmony_cistatic const struct pci_device_id trm290_pci_tbl[] = {
3478c2ecf20Sopenharmony_ci	{ PCI_VDEVICE(TEKRAM, PCI_DEVICE_ID_TEKRAM_DC290), 0 },
3488c2ecf20Sopenharmony_ci	{ 0, },
3498c2ecf20Sopenharmony_ci};
3508c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(pci, trm290_pci_tbl);
3518c2ecf20Sopenharmony_ci
3528c2ecf20Sopenharmony_cistatic struct pci_driver trm290_pci_driver = {
3538c2ecf20Sopenharmony_ci	.name		= "TRM290_IDE",
3548c2ecf20Sopenharmony_ci	.id_table	= trm290_pci_tbl,
3558c2ecf20Sopenharmony_ci	.probe		= trm290_init_one,
3568c2ecf20Sopenharmony_ci	.remove		= ide_pci_remove,
3578c2ecf20Sopenharmony_ci};
3588c2ecf20Sopenharmony_ci
3598c2ecf20Sopenharmony_cistatic int __init trm290_ide_init(void)
3608c2ecf20Sopenharmony_ci{
3618c2ecf20Sopenharmony_ci	return ide_pci_register_driver(&trm290_pci_driver);
3628c2ecf20Sopenharmony_ci}
3638c2ecf20Sopenharmony_ci
3648c2ecf20Sopenharmony_cistatic void __exit trm290_ide_exit(void)
3658c2ecf20Sopenharmony_ci{
3668c2ecf20Sopenharmony_ci	pci_unregister_driver(&trm290_pci_driver);
3678c2ecf20Sopenharmony_ci}
3688c2ecf20Sopenharmony_ci
3698c2ecf20Sopenharmony_cimodule_init(trm290_ide_init);
3708c2ecf20Sopenharmony_cimodule_exit(trm290_ide_exit);
3718c2ecf20Sopenharmony_ci
3728c2ecf20Sopenharmony_ciMODULE_AUTHOR("Mark Lord");
3738c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("PCI driver module for Tekram TRM290 IDE");
3748c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL");
375