1*f6e8a0a1SImre Vadasz# Copyright (c) 2004 - 2006 Søren Schmidt <sos@FreeBSD.org> 2c1b3d7c5SThomas E. Spanjaard# All rights reserved. 3c1b3d7c5SThomas E. Spanjaard# 4c1b3d7c5SThomas E. Spanjaard# Redistribution and use in source and binary forms, with or without 5c1b3d7c5SThomas E. Spanjaard# modification, are permitted provided that the following conditions 6c1b3d7c5SThomas E. Spanjaard# are met: 7c1b3d7c5SThomas E. Spanjaard# 1. Redistributions of source code must retain the above copyright 8c1b3d7c5SThomas E. Spanjaard# notice, this list of conditions and the following disclaimer, 9c1b3d7c5SThomas E. Spanjaard# without modification, immediately at the beginning of the file. 10c1b3d7c5SThomas E. Spanjaard# 2. Redistributions in binary form must reproduce the above copyright 11c1b3d7c5SThomas E. Spanjaard# notice, this list of conditions and the following disclaimer in the 12c1b3d7c5SThomas E. Spanjaard# documentation and/or other materials provided with the distribution. 13c1b3d7c5SThomas E. Spanjaard# 14c1b3d7c5SThomas E. Spanjaard# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15c1b3d7c5SThomas E. Spanjaard# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16c1b3d7c5SThomas E. Spanjaard# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17c1b3d7c5SThomas E. Spanjaard# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 18c1b3d7c5SThomas E. Spanjaard# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19c1b3d7c5SThomas E. Spanjaard# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20c1b3d7c5SThomas E. Spanjaard# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21c1b3d7c5SThomas E. Spanjaard# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22c1b3d7c5SThomas E. Spanjaard# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23c1b3d7c5SThomas E. Spanjaard# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24c1b3d7c5SThomas E. Spanjaard# 25c1b3d7c5SThomas E. Spanjaard# $FreeBSD: src/sys/dev/ata/ata_if.m,v 1.6 2006/01/05 21:27:19 sos Exp $ 26854fb363SThomas E. Spanjaard# $DragonFly: src/sys/dev/disk/nata/ata_if.m,v 1.2 2006/12/08 15:09:18 tgen Exp $ 27c1b3d7c5SThomas E. Spanjaard 28c1b3d7c5SThomas E. Spanjaard#include <sys/param.h> 29c1b3d7c5SThomas E. Spanjaard#include <sys/bus.h> 30c1b3d7c5SThomas E. Spanjaard#include <sys/nata.h> 31c1b3d7c5SThomas E. Spanjaard 32854fb363SThomas E. Spanjaard#include <dev/disk/nata/ata-all.h> 33c1b3d7c5SThomas E. Spanjaard 34c1b3d7c5SThomas E. SpanjaardINTERFACE ata; 35c1b3d7c5SThomas E. Spanjaard 36c1b3d7c5SThomas E. SpanjaardCODE { 37c1b3d7c5SThomas E. Spanjaard static int ata_null_locking(device_t dev, int mode) 38c1b3d7c5SThomas E. Spanjaard { 39c1b3d7c5SThomas E. Spanjaard struct ata_channel *ch = device_get_softc(dev); 40c1b3d7c5SThomas E. Spanjaard 41c1b3d7c5SThomas E. Spanjaard return ch->unit; 42c1b3d7c5SThomas E. Spanjaard } 43c1b3d7c5SThomas E. Spanjaard}; 44c1b3d7c5SThomas E. SpanjaardMETHOD int locking { 45c1b3d7c5SThomas E. Spanjaard device_t channel; 46c1b3d7c5SThomas E. Spanjaard int mode; 47c1b3d7c5SThomas E. Spanjaard} DEFAULT ata_null_locking; 48c1b3d7c5SThomas E. SpanjaardHEADER { 49c1b3d7c5SThomas E. Spanjaard#define ATA_LF_LOCK 0x0001 50c1b3d7c5SThomas E. Spanjaard#define ATA_LF_UNLOCK 0x0002 51c1b3d7c5SThomas E. Spanjaard#define ATA_LF_WHICH 0x0004 52c1b3d7c5SThomas E. Spanjaard}; 53c1b3d7c5SThomas E. Spanjaard 54c1b3d7c5SThomas E. SpanjaardCODE { 55c1b3d7c5SThomas E. Spanjaard static void ata_null_setmode(device_t parent, device_t dev) 56c1b3d7c5SThomas E. Spanjaard { 57c1b3d7c5SThomas E. Spanjaard struct ata_device *atadev = device_get_softc(dev); 58c1b3d7c5SThomas E. Spanjaard 59c1b3d7c5SThomas E. Spanjaard atadev->mode = ata_limit_mode(dev, atadev->mode, ATA_PIO_MAX); 60c1b3d7c5SThomas E. Spanjaard } 61c1b3d7c5SThomas E. Spanjaard}; 62c1b3d7c5SThomas E. SpanjaardMETHOD void setmode { 63c1b3d7c5SThomas E. Spanjaard device_t channel; 64c1b3d7c5SThomas E. Spanjaard device_t dev; 65c1b3d7c5SThomas E. Spanjaard} DEFAULT ata_null_setmode;; 66c1b3d7c5SThomas E. Spanjaard 67c1b3d7c5SThomas E. SpanjaardMETHOD void reset { 68c1b3d7c5SThomas E. Spanjaard device_t channel; 69c1b3d7c5SThomas E. Spanjaard} DEFAULT ata_generic_reset; 70c1b3d7c5SThomas E. Spanjaard 71c1b3d7c5SThomas E. SpanjaardMETHOD int reinit { 72c1b3d7c5SThomas E. Spanjaard device_t dev; 73c1b3d7c5SThomas E. Spanjaard}; 74