ata-micron.c revision 194893
1183724Ssos/*- 2183724Ssos * Copyright (c) 1998 - 2008 S�ren Schmidt <sos@FreeBSD.org> 3183724Ssos * All rights reserved. 4183724Ssos * 5183724Ssos * Redistribution and use in source and binary forms, with or without 6183724Ssos * modification, are permitted provided that the following conditions 7183724Ssos * are met: 8183724Ssos * 1. Redistributions of source code must retain the above copyright 9183724Ssos * notice, this list of conditions and the following disclaimer, 10183724Ssos * without modification, immediately at the beginning of the file. 11183724Ssos * 2. Redistributions in binary form must reproduce the above copyright 12183724Ssos * notice, this list of conditions and the following disclaimer in the 13183724Ssos * documentation and/or other materials provided with the distribution. 14183724Ssos * 15183724Ssos * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16183724Ssos * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17183724Ssos * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18183724Ssos * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19183724Ssos * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20183724Ssos * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21183724Ssos * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22183724Ssos * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23183724Ssos * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24183724Ssos * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25183724Ssos */ 26183724Ssos 27183724Ssos#include <sys/cdefs.h> 28183724Ssos__FBSDID("$FreeBSD: head/sys/dev/ata/chipsets/ata-micron.c 194893 2009-06-24 19:49:18Z mav $"); 29183724Ssos 30183724Ssos#include "opt_ata.h" 31183724Ssos#include <sys/param.h> 32183724Ssos#include <sys/module.h> 33183724Ssos#include <sys/systm.h> 34183724Ssos#include <sys/kernel.h> 35183724Ssos#include <sys/ata.h> 36183724Ssos#include <sys/bus.h> 37183724Ssos#include <sys/endian.h> 38183724Ssos#include <sys/malloc.h> 39183724Ssos#include <sys/lock.h> 40183724Ssos#include <sys/mutex.h> 41183724Ssos#include <sys/sema.h> 42183724Ssos#include <sys/taskqueue.h> 43183724Ssos#include <vm/uma.h> 44183724Ssos#include <machine/stdarg.h> 45183724Ssos#include <machine/resource.h> 46183724Ssos#include <machine/bus.h> 47183724Ssos#include <sys/rman.h> 48183724Ssos#include <dev/pci/pcivar.h> 49183724Ssos#include <dev/pci/pcireg.h> 50183724Ssos#include <dev/ata/ata-all.h> 51183724Ssos#include <dev/ata/ata-pci.h> 52183724Ssos#include <ata_if.h> 53183724Ssos 54183724Ssos/* local prototypes */ 55183724Ssosstatic int ata_micron_chipinit(device_t dev); 56183724Ssosstatic void ata_micron_setmode(device_t dev, int mode); 57183724Ssos 58183724Ssos 59183724Ssos/* 60183724Ssos * Cenatek chipset support functions 61183724Ssos */ 62183724Ssosstatic int 63183724Ssosata_micron_probe(device_t dev) 64183724Ssos{ 65183724Ssos struct ata_pci_controller *ctlr = device_get_softc(dev); 66183724Ssos 67183724Ssos if (pci_get_devid(dev) == ATA_MICRON_RZ1000 || 68183724Ssos pci_get_devid(dev) == ATA_MICRON_RZ1001) { 69183724Ssos device_set_desc(dev, 70183724Ssos "RZ 100? ATA controller !WARNING! data loss/corruption risk"); 71183724Ssos ctlr->chipinit = ata_micron_chipinit; 72194893Smav return (BUS_PROBE_DEFAULT); 73183724Ssos } 74183724Ssos else 75183724Ssos return ENXIO; 76183724Ssos} 77183724Ssos 78183724Ssosstatic int 79183724Ssosata_micron_chipinit(device_t dev) 80183724Ssos{ 81183724Ssos struct ata_pci_controller *ctlr = device_get_softc(dev); 82183724Ssos 83183724Ssos if (ata_setup_interrupt(dev, ata_generic_intr)) 84183724Ssos return ENXIO; 85183724Ssos 86183724Ssos ctlr->setmode = ata_micron_setmode; 87183724Ssos return 0; 88183724Ssos} 89183724Ssos 90183724Ssosstatic void 91183724Ssosata_micron_setmode(device_t dev, int mode) 92183724Ssos{ 93183724Ssos struct ata_device *atadev = device_get_softc(dev); 94183724Ssos 95183724Ssos mode = ata_limit_mode(dev, mode, ATA_UDMA2); 96183724Ssos mode = ata_check_80pin(dev, mode); 97183724Ssos if (!ata_controlcmd(dev, ATA_SETFEATURES, ATA_SF_SETXFER, 0, mode)) 98183724Ssos atadev->mode = mode; 99183724Ssos} 100183724Ssos 101183724SsosATA_DECLARE_DRIVER(ata_micron); 102