Changes in 4.9.215 x86/vdso: Use RDPID in preference to LSL when available KVM: x86: emulate RDPID ALSA: hda: Use scnprintf() for printing texts for sysfs/procfs ecryptfs: fix a memory leak bug in parse_tag_1_packet() ecryptfs: fix a memory leak bug in ecryptfs_init_messaging() ALSA: usb-audio: Apply sample rate quirk for Audioengine D1 ext4: don't assume that mmp_nodename/bdevname have NUL ext4: fix checksum errors with indexed dirs ext4: improve explanation of a mount failure caused by a misconfigured kernel Btrfs: fix race between using extent maps and merging them btrfs: log message when rw remount is attempted with unclean tree-log perf/x86/amd: Add missing L2 misses event spec to AMD Family 17h's event map padata: Remove broken queue flushing s390/time: Fix clk type in get_tod_clock perf/x86/intel: Fix inaccurate period in context switch for auto-reload hwmon: (pmbus/ltc2978) Fix PMBus polling of MFR_COMMON definitions. jbd2: move the clearing of b_modified flag to the journal_unmap_buffer() jbd2: do not clear the BH_Mapped flag when forgetting a metadata buffer btrfs: print message when tree-log replay starts scsi: qla2xxx: fix a potential NULL pointer dereference Revert "KVM: VMX: Add non-canonical check on writes to RTIT address MSRs" drm/gma500: Fixup fbdev stolen size usage evaluation cpu/hotplug, stop_machine: Fix stop_machine vs hotplug order brcmfmac: Fix use after free in brcmf_sdio_readframes() gianfar: Fix TX timestamping with a stacked DSA driver pinctrl: sh-pfc: sh7264: Fix CAN function GPIOs pxa168fb: Fix the function used to release some memory in an error handling path media: i2c: mt9v032: fix enum mbus codes and frame sizes powerpc/powernv/iov: Ensure the pdn for VFs always contains a valid PE number gpio: gpio-grgpio: fix possible sleep-in-atomic-context bugs in grgpio_irq_map/unmap() media: sti: bdisp: fix a possible sleep-in-atomic-context bug in bdisp_device_run() pinctrl: baytrail: Do not clear IRQ flags on direct-irq enabled pins efi/x86: Map the entire EFI vendor string before copying it MIPS: Loongson: Fix potential NULL dereference in loongson3_platform_init() sparc: Add .exit.data section. uio: fix a sleep-in-atomic-context bug in uio_dmem_genirq_irqcontrol() usb: gadget: udc: fix possible sleep-in-atomic-context bugs in gr_probe() jbd2: clear JBD2_ABORT flag before journal_reset to update log tail info when load journal x86/sysfb: Fix check for bad VRAM size tracing: Fix tracing_stat return values in error handling paths tracing: Fix very unlikely race of registering two stat tracers ext4, jbd2: ensure panic when aborting with zero errno kconfig: fix broken dependency in randconfig-generated .config clk: qcom: rcg2: Don't crash if our parent can't be found; return an error drm/amdgpu: remove 4 set but not used variable in amdgpu_atombios_get_connector_info_from_object_table regulator: rk808: Lower log level on optional GPIOs being not available net/wan/fsl_ucc_hdlc: reject muram offsets above 64K PCI/IOV: Fix memory leak in pci_iov_add_virtfn() NFC: port100: Convert cpu_to_le16(le16_to_cpu(E1) + E2) to use le16_add_cpu(). media: v4l2-device.h: Explicitly compare grp{id,mask} to zero in v4l2_device macros reiserfs: Fix spurious unlock in reiserfs_fill_super() error handling ALSA: usx2y: Adjust indentation in snd_usX2Y_hwdep_dsp_status b43legacy: Fix -Wcast-function-type ipw2x00: Fix -Wcast-function-type iwlegacy: Fix -Wcast-function-type rtlwifi: rtl_pci: Fix -Wcast-function-type orinoco: avoid assertion in case of NULL pointer ACPICA: Disassembler: create buffer fields in ACPI_PARSE_LOAD_PASS1 scsi: aic7xxx: Adjust indentation in ahc_find_syncrate drm/mediatek: handle events when enabling/disabling crtc ARM: dts: r8a7779: Add device node for ARM global timer x86/vdso: Provide missing include file PM / devfreq: rk3399_dmc: Add COMPILE_TEST and HAVE_ARM_SMCCC dependency pinctrl: sh-pfc: sh7269: Fix CAN function GPIOs RDMA/rxe: Fix error type of mmap_offset ALSA: sh: Fix compile warning wrt const tools lib api fs: Fix gcc9 stringop-truncation compilation error usbip: Fix unsafe unaligned pointer usage udf: Fix free space reporting for metadata and virtual partitions soc/tegra: fuse: Correct straps' address for older Tegra124 device trees rcu: Use WRITE_ONCE() for assignments to ->pprev for hlist_nulls Input: edt-ft5x06 - work around first register access error wan: ixp4xx_hss: fix compile-testing on 64-bit ASoC: atmel: fix build error with CONFIG_SND_ATMEL_SOC_DMA=m tty: synclinkmp: Adjust indentation in several functions tty: synclink_gt: Adjust indentation in several functions driver core: platform: Prevent resouce overflow from causing infinite loops driver core: Print device when resources present in really_probe() vme: bridges: reduce stack usage drm/nouveau/gr/gk20a,gm200-: add terminators to method lists read from fw drm/nouveau: Fix copy-paste error in nouveau_fence_wait_uevent_handler drm/vmwgfx: prevent memory leak in vmw_cmdbuf_res_add usb: musb: omap2430: Get rid of musb .set_vbus for omap2430 glue iommu/arm-smmu-v3: Use WRITE_ONCE() when changing validity of an STE scsi: iscsi: Don't destroy session if there are outstanding connections arm64: fix alternatives with LLVM's integrated assembler pwm: omap-dmtimer: Remove PWM chip in .remove before making it unfunctional cmd64x: potential buffer overflow in cmd64x_program_timings() ide: serverworks: potential overflow in svwks_set_pio_mode() remoteproc: Initialize rproc_class before use x86/decoder: Add TEST opcode to Group3-2 s390/ftrace: generate traced function stack frame driver core: platform: fix u32 greater or equal to zero comparison ALSA: hda - Add docking station support for Lenovo Thinkpad T420s powerpc/sriov: Remove VF eeh_dev state when disabling SR-IOV jbd2: switch to use jbd2_journal_abort() when failed to submit the commit record ARM: 8951/1: Fix Kexec compilation issue. hostap: Adjust indentation in prism2_hostapd_add_sta iwlegacy: ensure loop counter addr does not wrap and cause an infinite loop cifs: fix NULL dereference in match_prepath irqchip/gic-v3: Only provision redistributors that are enabled in ACPI drm/nouveau/disp/nv50-: prevent oops when no channel method map provided ftrace: fpid_next() should increase position index trigger_next should increase position index radeon: insert 10ms sleep in dce5_crtc_load_lut ocfs2: fix a NULL pointer dereference when call ocfs2_update_inode_fsync_trans() lib/scatterlist.c: adjust indentation in __sg_alloc_table reiserfs: prevent NULL pointer dereference in reiserfs_insert_item() bcache: explicity type cast in bset_bkey_last() irqchip/gic-v3-its: Reference to its_invall_cmd descriptor when building INVALL iwlwifi: mvm: Fix thermal zone registration microblaze: Prevent the overflow of the start brd: check and limit max_part par help_next should increase position index selinux: ensure we cleanup the internal AVC counters on error in avc_update() enic: prevent waking up stopped tx queues over watchdog reset net/sched: matchall: add missing validation of TCA_MATCHALL_FLAGS net/sched: flower: add missing validation of TCA_FLOWER_FLAGS floppy: check FDC index for errors before assigning it vt: selection, handle pending signals in paste_selection staging: android: ashmem: Disallow ashmem memory from being remapped staging: vt6656: fix sign of rx_dbm to bb_pre_ed_rssi. xhci: Force Maximum Packet size for Full-speed bulk devices to valid range. usb: uas: fix a plug & unplug racing USB: Fix novation SourceControl XL after suspend USB: hub: Don't record a connect-change event during reset-resume staging: rtl8188eu: Fix potential security hole staging: rtl8188eu: Fix potential overuse of kernel memory x86/mce/amd: Publish the bank pointer only after setup has succeeded x86/mce/amd: Fix kobject lifetime tty/serial: atmel: manage shutdown in case of RS485 or ISO7816 mode tty: serial: imx: setup the correct sg entry for tx dma Revert "ipc,sem: remove uneeded sem_undo_list lock usage in exit_sem()" xhci: apply XHCI_PME_STUCK_QUIRK to Intel Comet Lake platforms KVM: x86: don't notify userspace IOAPIC on edge-triggered interrupt EOI VT_RESIZEX: get rid of field-by-field copyin vt: vt_ioctl: fix race in VT_RESIZEX lib/stackdepot.c: fix global out-of-bounds in stack_slabs KVM: nVMX: Don't emulate instructions in guest mode netfilter: xt_bpf: add overflow checks ext4: fix a data race in EXT4_I(inode)->i_disksize ext4: add cond_resched() to __ext4_find_entry() ext4: fix mount failure with quota configured as module ext4: rename s_journal_flag_rwsem to s_writepages_rwsem ext4: fix race between writepages and enabling EXT4_EXTENTS_FL KVM: nVMX: Refactor IO bitmap checks into helper function KVM: nVMX: Check IO instruction VM-exit conditions KVM: apic: avoid calculating pending eoi from an uninitialized val Btrfs: fix btrfs_wait_ordered_range() so that it waits for all ordered extents scsi: Revert "RDMA/isert: Fix a recently introduced regression related to logout" scsi: Revert "target: iscsi: Wait for all commands to finish before freeing a session" usb: gadget: composite: Fix bMaxPower for SuperSpeedPlus staging: greybus: use after free in gb_audio_manager_remove_all() ecryptfs: replace BUG_ON with error handling code ALSA: rawmidi: Avoid bit fields for state flags ALSA: seq: Avoid concurrent access to queue flags ALSA: seq: Fix concurrent access to queue current tick/time netfilter: xt_hashlimit: limit the max size of hashtable ata: ahci: Add shutdown to freeze hardware resources of ahci xen: Enable interrupts when calling _cond_resched() s390/mm: Explicitly compare PAGE_DEFAULT_KEY against zero in storage_key_init_range Linux 4.9.215 Signed-off-by: Greg Kroah-Hartman <gregkh@google.com> Change-Id: I4c663321dde48cd2a324e59acb70c99f75f9344e
452 lines
12 KiB
C
452 lines
12 KiB
C
/*
|
|
* cmd64x.c: Enable interrupts at initialization time on Ultra/PCI machines.
|
|
* Due to massive hardware bugs, UltraDMA is only supported
|
|
* on the 646U2 and not on the 646U.
|
|
*
|
|
* Copyright (C) 1998 Eddie C. Dost (ecd@skynet.be)
|
|
* Copyright (C) 1998 David S. Miller (davem@redhat.com)
|
|
*
|
|
* Copyright (C) 1999-2002 Andre Hedrick <andre@linux-ide.org>
|
|
* Copyright (C) 2007-2010 Bartlomiej Zolnierkiewicz
|
|
* Copyright (C) 2007,2009 MontaVista Software, Inc. <source@mvista.com>
|
|
*/
|
|
|
|
#include <linux/module.h>
|
|
#include <linux/types.h>
|
|
#include <linux/pci.h>
|
|
#include <linux/ide.h>
|
|
#include <linux/init.h>
|
|
|
|
#include <asm/io.h>
|
|
|
|
#define DRV_NAME "cmd64x"
|
|
|
|
/*
|
|
* CMD64x specific registers definition.
|
|
*/
|
|
#define CFR 0x50
|
|
#define CFR_INTR_CH0 0x04
|
|
|
|
#define CMDTIM 0x52
|
|
#define ARTTIM0 0x53
|
|
#define DRWTIM0 0x54
|
|
#define ARTTIM1 0x55
|
|
#define DRWTIM1 0x56
|
|
#define ARTTIM23 0x57
|
|
#define ARTTIM23_DIS_RA2 0x04
|
|
#define ARTTIM23_DIS_RA3 0x08
|
|
#define ARTTIM23_INTR_CH1 0x10
|
|
#define DRWTIM2 0x58
|
|
#define BRST 0x59
|
|
#define DRWTIM3 0x5b
|
|
|
|
#define BMIDECR0 0x70
|
|
#define MRDMODE 0x71
|
|
#define MRDMODE_INTR_CH0 0x04
|
|
#define MRDMODE_INTR_CH1 0x08
|
|
#define UDIDETCR0 0x73
|
|
#define DTPR0 0x74
|
|
#define BMIDECR1 0x78
|
|
#define BMIDECSR 0x79
|
|
#define UDIDETCR1 0x7B
|
|
#define DTPR1 0x7C
|
|
|
|
static void cmd64x_program_timings(ide_drive_t *drive, u8 mode)
|
|
{
|
|
ide_hwif_t *hwif = drive->hwif;
|
|
struct pci_dev *dev = to_pci_dev(drive->hwif->dev);
|
|
int bus_speed = ide_pci_clk ? ide_pci_clk : 33;
|
|
const unsigned long T = 1000000 / bus_speed;
|
|
static const u8 recovery_values[] =
|
|
{15, 15, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0};
|
|
static const u8 setup_values[] = {0x40, 0x40, 0x40, 0x80, 0, 0xc0};
|
|
static const u8 arttim_regs[4] = {ARTTIM0, ARTTIM1, ARTTIM23, ARTTIM23};
|
|
static const u8 drwtim_regs[4] = {DRWTIM0, DRWTIM1, DRWTIM2, DRWTIM3};
|
|
struct ide_timing t;
|
|
u8 arttim = 0;
|
|
|
|
if (drive->dn >= ARRAY_SIZE(drwtim_regs))
|
|
return;
|
|
|
|
ide_timing_compute(drive, mode, &t, T, 0);
|
|
|
|
/*
|
|
* In case we've got too long recovery phase, try to lengthen
|
|
* the active phase
|
|
*/
|
|
if (t.recover > 16) {
|
|
t.active += t.recover - 16;
|
|
t.recover = 16;
|
|
}
|
|
if (t.active > 16) /* shouldn't actually happen... */
|
|
t.active = 16;
|
|
|
|
/*
|
|
* Convert values to internal chipset representation
|
|
*/
|
|
t.recover = recovery_values[t.recover];
|
|
t.active &= 0x0f;
|
|
|
|
/* Program the active/recovery counts into the DRWTIM register */
|
|
pci_write_config_byte(dev, drwtim_regs[drive->dn],
|
|
(t.active << 4) | t.recover);
|
|
|
|
/*
|
|
* The primary channel has individual address setup timing registers
|
|
* for each drive and the hardware selects the slowest timing itself.
|
|
* The secondary channel has one common register and we have to select
|
|
* the slowest address setup timing ourselves.
|
|
*/
|
|
if (hwif->channel) {
|
|
ide_drive_t *pair = ide_get_pair_dev(drive);
|
|
|
|
if (pair) {
|
|
struct ide_timing tp;
|
|
|
|
ide_timing_compute(pair, pair->pio_mode, &tp, T, 0);
|
|
ide_timing_merge(&t, &tp, &t, IDE_TIMING_SETUP);
|
|
if (pair->dma_mode) {
|
|
ide_timing_compute(pair, pair->dma_mode,
|
|
&tp, T, 0);
|
|
ide_timing_merge(&tp, &t, &t, IDE_TIMING_SETUP);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (t.setup > 5) /* shouldn't actually happen... */
|
|
t.setup = 5;
|
|
|
|
/*
|
|
* Program the address setup clocks into the ARTTIM registers.
|
|
* Avoid clearing the secondary channel's interrupt bit.
|
|
*/
|
|
(void) pci_read_config_byte (dev, arttim_regs[drive->dn], &arttim);
|
|
if (hwif->channel)
|
|
arttim &= ~ARTTIM23_INTR_CH1;
|
|
arttim &= ~0xc0;
|
|
arttim |= setup_values[t.setup];
|
|
(void) pci_write_config_byte(dev, arttim_regs[drive->dn], arttim);
|
|
}
|
|
|
|
/*
|
|
* Attempts to set drive's PIO mode.
|
|
* Special cases are 8: prefetch off, 9: prefetch on (both never worked)
|
|
*/
|
|
|
|
static void cmd64x_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
|
|
{
|
|
const u8 pio = drive->pio_mode - XFER_PIO_0;
|
|
|
|
/*
|
|
* Filter out the prefetch control values
|
|
* to prevent PIO5 from being programmed
|
|
*/
|
|
if (pio == 8 || pio == 9)
|
|
return;
|
|
|
|
cmd64x_program_timings(drive, XFER_PIO_0 + pio);
|
|
}
|
|
|
|
static void cmd64x_set_dma_mode(ide_hwif_t *hwif, ide_drive_t *drive)
|
|
{
|
|
struct pci_dev *dev = to_pci_dev(hwif->dev);
|
|
u8 unit = drive->dn & 0x01;
|
|
u8 regU = 0, pciU = hwif->channel ? UDIDETCR1 : UDIDETCR0;
|
|
const u8 speed = drive->dma_mode;
|
|
|
|
pci_read_config_byte(dev, pciU, ®U);
|
|
regU &= ~(unit ? 0xCA : 0x35);
|
|
|
|
switch(speed) {
|
|
case XFER_UDMA_5:
|
|
regU |= unit ? 0x0A : 0x05;
|
|
break;
|
|
case XFER_UDMA_4:
|
|
regU |= unit ? 0x4A : 0x15;
|
|
break;
|
|
case XFER_UDMA_3:
|
|
regU |= unit ? 0x8A : 0x25;
|
|
break;
|
|
case XFER_UDMA_2:
|
|
regU |= unit ? 0x42 : 0x11;
|
|
break;
|
|
case XFER_UDMA_1:
|
|
regU |= unit ? 0x82 : 0x21;
|
|
break;
|
|
case XFER_UDMA_0:
|
|
regU |= unit ? 0xC2 : 0x31;
|
|
break;
|
|
case XFER_MW_DMA_2:
|
|
case XFER_MW_DMA_1:
|
|
case XFER_MW_DMA_0:
|
|
cmd64x_program_timings(drive, speed);
|
|
break;
|
|
}
|
|
|
|
pci_write_config_byte(dev, pciU, regU);
|
|
}
|
|
|
|
static void cmd648_clear_irq(ide_drive_t *drive)
|
|
{
|
|
ide_hwif_t *hwif = drive->hwif;
|
|
struct pci_dev *dev = to_pci_dev(hwif->dev);
|
|
unsigned long base = pci_resource_start(dev, 4);
|
|
u8 irq_mask = hwif->channel ? MRDMODE_INTR_CH1 :
|
|
MRDMODE_INTR_CH0;
|
|
u8 mrdmode = inb(base + 1);
|
|
|
|
/* clear the interrupt bit */
|
|
outb((mrdmode & ~(MRDMODE_INTR_CH0 | MRDMODE_INTR_CH1)) | irq_mask,
|
|
base + 1);
|
|
}
|
|
|
|
static void cmd64x_clear_irq(ide_drive_t *drive)
|
|
{
|
|
ide_hwif_t *hwif = drive->hwif;
|
|
struct pci_dev *dev = to_pci_dev(hwif->dev);
|
|
int irq_reg = hwif->channel ? ARTTIM23 : CFR;
|
|
u8 irq_mask = hwif->channel ? ARTTIM23_INTR_CH1 :
|
|
CFR_INTR_CH0;
|
|
u8 irq_stat = 0;
|
|
|
|
(void) pci_read_config_byte(dev, irq_reg, &irq_stat);
|
|
/* clear the interrupt bit */
|
|
(void) pci_write_config_byte(dev, irq_reg, irq_stat | irq_mask);
|
|
}
|
|
|
|
static int cmd648_test_irq(ide_hwif_t *hwif)
|
|
{
|
|
struct pci_dev *dev = to_pci_dev(hwif->dev);
|
|
unsigned long base = pci_resource_start(dev, 4);
|
|
u8 irq_mask = hwif->channel ? MRDMODE_INTR_CH1 :
|
|
MRDMODE_INTR_CH0;
|
|
u8 mrdmode = inb(base + 1);
|
|
|
|
pr_debug("%s: mrdmode: 0x%02x irq_mask: 0x%02x\n",
|
|
hwif->name, mrdmode, irq_mask);
|
|
|
|
return (mrdmode & irq_mask) ? 1 : 0;
|
|
}
|
|
|
|
static int cmd64x_test_irq(ide_hwif_t *hwif)
|
|
{
|
|
struct pci_dev *dev = to_pci_dev(hwif->dev);
|
|
int irq_reg = hwif->channel ? ARTTIM23 : CFR;
|
|
u8 irq_mask = hwif->channel ? ARTTIM23_INTR_CH1 :
|
|
CFR_INTR_CH0;
|
|
u8 irq_stat = 0;
|
|
|
|
(void) pci_read_config_byte(dev, irq_reg, &irq_stat);
|
|
|
|
pr_debug("%s: irq_stat: 0x%02x irq_mask: 0x%02x\n",
|
|
hwif->name, irq_stat, irq_mask);
|
|
|
|
return (irq_stat & irq_mask) ? 1 : 0;
|
|
}
|
|
|
|
/*
|
|
* ASUS P55T2P4D with CMD646 chipset revision 0x01 requires the old
|
|
* event order for DMA transfers.
|
|
*/
|
|
|
|
static int cmd646_1_dma_end(ide_drive_t *drive)
|
|
{
|
|
ide_hwif_t *hwif = drive->hwif;
|
|
u8 dma_stat = 0, dma_cmd = 0;
|
|
|
|
/* get DMA status */
|
|
dma_stat = inb(hwif->dma_base + ATA_DMA_STATUS);
|
|
/* read DMA command state */
|
|
dma_cmd = inb(hwif->dma_base + ATA_DMA_CMD);
|
|
/* stop DMA */
|
|
outb(dma_cmd & ~1, hwif->dma_base + ATA_DMA_CMD);
|
|
/* clear the INTR & ERROR bits */
|
|
outb(dma_stat | 6, hwif->dma_base + ATA_DMA_STATUS);
|
|
/* verify good DMA status */
|
|
return (dma_stat & 7) != 4;
|
|
}
|
|
|
|
static int init_chipset_cmd64x(struct pci_dev *dev)
|
|
{
|
|
u8 mrdmode = 0;
|
|
|
|
/* Set a good latency timer and cache line size value. */
|
|
(void) pci_write_config_byte(dev, PCI_LATENCY_TIMER, 64);
|
|
/* FIXME: pci_set_master() to ensure a good latency timer value */
|
|
|
|
/*
|
|
* Enable interrupts, select MEMORY READ LINE for reads.
|
|
*
|
|
* NOTE: although not mentioned in the PCI0646U specs,
|
|
* bits 0-1 are write only and won't be read back as
|
|
* set or not -- PCI0646U2 specs clarify this point.
|
|
*/
|
|
(void) pci_read_config_byte (dev, MRDMODE, &mrdmode);
|
|
mrdmode &= ~0x30;
|
|
(void) pci_write_config_byte(dev, MRDMODE, (mrdmode | 0x02));
|
|
|
|
return 0;
|
|
}
|
|
|
|
static u8 cmd64x_cable_detect(ide_hwif_t *hwif)
|
|
{
|
|
struct pci_dev *dev = to_pci_dev(hwif->dev);
|
|
u8 bmidecsr = 0, mask = hwif->channel ? 0x02 : 0x01;
|
|
|
|
switch (dev->device) {
|
|
case PCI_DEVICE_ID_CMD_648:
|
|
case PCI_DEVICE_ID_CMD_649:
|
|
pci_read_config_byte(dev, BMIDECSR, &bmidecsr);
|
|
return (bmidecsr & mask) ? ATA_CBL_PATA80 : ATA_CBL_PATA40;
|
|
default:
|
|
return ATA_CBL_PATA40;
|
|
}
|
|
}
|
|
|
|
static const struct ide_port_ops cmd64x_port_ops = {
|
|
.set_pio_mode = cmd64x_set_pio_mode,
|
|
.set_dma_mode = cmd64x_set_dma_mode,
|
|
.clear_irq = cmd64x_clear_irq,
|
|
.test_irq = cmd64x_test_irq,
|
|
.cable_detect = cmd64x_cable_detect,
|
|
};
|
|
|
|
static const struct ide_port_ops cmd648_port_ops = {
|
|
.set_pio_mode = cmd64x_set_pio_mode,
|
|
.set_dma_mode = cmd64x_set_dma_mode,
|
|
.clear_irq = cmd648_clear_irq,
|
|
.test_irq = cmd648_test_irq,
|
|
.cable_detect = cmd64x_cable_detect,
|
|
};
|
|
|
|
static const struct ide_dma_ops cmd646_rev1_dma_ops = {
|
|
.dma_host_set = ide_dma_host_set,
|
|
.dma_setup = ide_dma_setup,
|
|
.dma_start = ide_dma_start,
|
|
.dma_end = cmd646_1_dma_end,
|
|
.dma_test_irq = ide_dma_test_irq,
|
|
.dma_lost_irq = ide_dma_lost_irq,
|
|
.dma_timer_expiry = ide_dma_sff_timer_expiry,
|
|
.dma_sff_read_status = ide_dma_sff_read_status,
|
|
};
|
|
|
|
static const struct ide_port_info cmd64x_chipsets[] = {
|
|
{ /* 0: CMD643 */
|
|
.name = DRV_NAME,
|
|
.init_chipset = init_chipset_cmd64x,
|
|
.enablebits = {{0x00,0x00,0x00}, {0x51,0x08,0x08}},
|
|
.port_ops = &cmd64x_port_ops,
|
|
.host_flags = IDE_HFLAG_CLEAR_SIMPLEX |
|
|
IDE_HFLAG_ABUSE_PREFETCH |
|
|
IDE_HFLAG_SERIALIZE,
|
|
.pio_mask = ATA_PIO5,
|
|
.mwdma_mask = ATA_MWDMA2,
|
|
.udma_mask = 0x00, /* no udma */
|
|
},
|
|
{ /* 1: CMD646 */
|
|
.name = DRV_NAME,
|
|
.init_chipset = init_chipset_cmd64x,
|
|
.enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}},
|
|
.port_ops = &cmd648_port_ops,
|
|
.host_flags = IDE_HFLAG_ABUSE_PREFETCH |
|
|
IDE_HFLAG_SERIALIZE,
|
|
.pio_mask = ATA_PIO5,
|
|
.mwdma_mask = ATA_MWDMA2,
|
|
.udma_mask = ATA_UDMA2,
|
|
},
|
|
{ /* 2: CMD648 */
|
|
.name = DRV_NAME,
|
|
.init_chipset = init_chipset_cmd64x,
|
|
.enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}},
|
|
.port_ops = &cmd648_port_ops,
|
|
.host_flags = IDE_HFLAG_ABUSE_PREFETCH,
|
|
.pio_mask = ATA_PIO5,
|
|
.mwdma_mask = ATA_MWDMA2,
|
|
.udma_mask = ATA_UDMA4,
|
|
},
|
|
{ /* 3: CMD649 */
|
|
.name = DRV_NAME,
|
|
.init_chipset = init_chipset_cmd64x,
|
|
.enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}},
|
|
.port_ops = &cmd648_port_ops,
|
|
.host_flags = IDE_HFLAG_ABUSE_PREFETCH,
|
|
.pio_mask = ATA_PIO5,
|
|
.mwdma_mask = ATA_MWDMA2,
|
|
.udma_mask = ATA_UDMA5,
|
|
}
|
|
};
|
|
|
|
static int cmd64x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
|
|
{
|
|
struct ide_port_info d;
|
|
u8 idx = id->driver_data;
|
|
|
|
d = cmd64x_chipsets[idx];
|
|
|
|
if (idx == 1) {
|
|
/*
|
|
* UltraDMA only supported on PCI646U and PCI646U2, which
|
|
* correspond to revisions 0x03, 0x05 and 0x07 respectively.
|
|
* Actually, although the CMD tech support people won't
|
|
* tell me the details, the 0x03 revision cannot support
|
|
* UDMA correctly without hardware modifications, and even
|
|
* then it only works with Quantum disks due to some
|
|
* hold time assumptions in the 646U part which are fixed
|
|
* in the 646U2.
|
|
*
|
|
* So we only do UltraDMA on revision 0x05 and 0x07 chipsets.
|
|
*/
|
|
if (dev->revision < 5) {
|
|
d.udma_mask = 0x00;
|
|
/*
|
|
* The original PCI0646 didn't have the primary
|
|
* channel enable bit, it appeared starting with
|
|
* PCI0646U (i.e. revision ID 3).
|
|
*/
|
|
if (dev->revision < 3) {
|
|
d.enablebits[0].reg = 0;
|
|
d.port_ops = &cmd64x_port_ops;
|
|
if (dev->revision == 1)
|
|
d.dma_ops = &cmd646_rev1_dma_ops;
|
|
}
|
|
}
|
|
}
|
|
|
|
return ide_pci_init_one(dev, &d, NULL);
|
|
}
|
|
|
|
static const struct pci_device_id cmd64x_pci_tbl[] = {
|
|
{ PCI_VDEVICE(CMD, PCI_DEVICE_ID_CMD_643), 0 },
|
|
{ PCI_VDEVICE(CMD, PCI_DEVICE_ID_CMD_646), 1 },
|
|
{ PCI_VDEVICE(CMD, PCI_DEVICE_ID_CMD_648), 2 },
|
|
{ PCI_VDEVICE(CMD, PCI_DEVICE_ID_CMD_649), 3 },
|
|
{ 0, },
|
|
};
|
|
MODULE_DEVICE_TABLE(pci, cmd64x_pci_tbl);
|
|
|
|
static struct pci_driver cmd64x_pci_driver = {
|
|
.name = "CMD64x_IDE",
|
|
.id_table = cmd64x_pci_tbl,
|
|
.probe = cmd64x_init_one,
|
|
.remove = ide_pci_remove,
|
|
.suspend = ide_pci_suspend,
|
|
.resume = ide_pci_resume,
|
|
};
|
|
|
|
static int __init cmd64x_ide_init(void)
|
|
{
|
|
return ide_pci_register_driver(&cmd64x_pci_driver);
|
|
}
|
|
|
|
static void __exit cmd64x_ide_exit(void)
|
|
{
|
|
pci_unregister_driver(&cmd64x_pci_driver);
|
|
}
|
|
|
|
module_init(cmd64x_ide_init);
|
|
module_exit(cmd64x_ide_exit);
|
|
|
|
MODULE_AUTHOR("Eddie Dost, David Miller, Andre Hedrick, Bartlomiej Zolnierkiewicz");
|
|
MODULE_DESCRIPTION("PCI driver module for CMD64x IDE");
|
|
MODULE_LICENSE("GPL");
|