11.9Stsutsui/* $NetBSD: wdvar.h,v 1.9 2010/01/10 16:20:45 tsutsui Exp $ */ 21.1Scdi 31.1Scdi/*- 41.1Scdi * Copyright (c) 2003 The NetBSD Foundation, Inc. 51.1Scdi * Copyright (c) 2001 Dynarc AB, Sweden. All rights reserved. 61.1Scdi * 71.1Scdi * This code is derived from software written by Anders Magnusson, 81.1Scdi * ragge@ludd.luth.se 91.1Scdi * 101.1Scdi * Redistribution and use in source and binary forms, with or without 111.1Scdi * modification, are permitted provided that the following conditions 121.1Scdi * are met: 131.1Scdi * 1. Redistributions of source code must retain the above copyright 141.1Scdi * notice, this list of conditions and the following disclaimer. 151.1Scdi * 2. Redistributions in binary form must reproduce the above copyright 161.1Scdi * notice, this list of conditions and the following disclaimer in the 171.1Scdi * documentation and/or other materials provided with the distribution. 181.1Scdi * 3. The name of the author may not be used to endorse or promote products 191.1Scdi * derived from this software without specific prior written permission 201.1Scdi * 211.1Scdi * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 221.1Scdi * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 231.1Scdi * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 241.1Scdi * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 251.1Scdi * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 261.1Scdi * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 271.1Scdi * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 281.1Scdi * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 291.1Scdi * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 301.1Scdi * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 311.1Scdi */ 321.1Scdi 331.1Scdi#ifndef _STAND_WDVAR_H 341.1Scdi#define _STAND_WDVAR_H 351.1Scdi 361.1Scdi#include <dev/ic/wdcreg.h> 371.1Scdi#include <dev/ata/atareg.h> 381.1Scdi#include <dev/pci/pciidereg.h> 391.1Scdi 401.1Scdi#include <mips/cpuregs.h> 411.1Scdi 421.1Scdi#include <sys/disklabel.h> 431.2Slukem#include <sys/bootblock.h> 441.1Scdi 451.1Scdi#define WDC_TIMEOUT 2000000 461.1Scdi#define PCIIDE_CHANNEL_NDEV 2 471.1Scdi#define NUNITS (PCIIDE_CHANNEL_NDEV * PCIIDE_NUM_CHANNELS) 481.5Stsutsui#define WDC_NPORTS 8 /* XXX */ 491.5Stsutsui#define WDC_NSHADOWREG 2 /* XXX */ 501.1Scdi 511.4Sthorpejstruct wdc_channel { 521.7Stsutsui volatile uint8_t *c_cmdbase; 531.7Stsutsui volatile uint8_t *c_ctlbase; 541.7Stsutsui volatile uint8_t *c_cmdreg[WDC_NPORTS + WDC_NSHADOWREG]; 551.7Stsutsui volatile uint16_t *c_data; 561.1Scdi 571.7Stsutsui uint8_t compatchan; 581.1Scdi}; 591.1Scdi 601.5Stsutsui#define WDC_READ_REG(chp, reg) *(chp)->c_cmdreg[(reg)] 611.5Stsutsui#define WDC_WRITE_REG(chp, reg, val) *(chp)->c_cmdreg[(reg)] = (val) 621.5Stsutsui#define WDC_READ_CTLREG(chp, reg) (chp)->c_ctlbase[(reg)] 631.5Stsutsui#define WDC_WRITE_CTLREG(chp, reg, val) (chp)->c_ctlbase[(reg)] = (val) 641.5Stsutsui#define WDC_READ_DATA(chp) *(chp)->c_data 651.5Stsutsui 661.1Scdistruct wd_softc { 671.1Scdi#define WDF_LBA 0x0001 681.1Scdi#define WDF_LBA48 0x0002 691.7Stsutsui uint16_t sc_flags; 701.1Scdi 711.3Stsutsui u_int sc_part; 721.3Stsutsui u_int sc_unit; 731.1Scdi 741.7Stsutsui uint64_t sc_capacity; 751.9Stsutsui uint32_t sc_capacity28; 761.1Scdi 771.1Scdi struct ataparams sc_params; 781.1Scdi struct disklabel sc_label; 791.4Sthorpej struct wdc_channel sc_channel; 801.1Scdi}; 811.1Scdi 821.1Scdistruct wdc_command { 831.7Stsutsui uint8_t drive; /* drive id */ 841.1Scdi 851.7Stsutsui uint8_t r_command; /* Parameters to upload to registers */ 861.7Stsutsui uint8_t r_head; 871.7Stsutsui uint16_t r_cyl; 881.7Stsutsui uint8_t r_sector; 891.7Stsutsui uint8_t r_count; 901.9Stsutsui uint8_t r_features; 911.1Scdi 921.7Stsutsui uint16_t bcount; 931.1Scdi void *data; 941.1Scdi 951.7Stsutsui uint64_t r_blkno; 961.1Scdi}; 971.1Scdi 981.7Stsutsuiint wdc_init(struct wd_softc *, u_int *); 991.7Stsutsuiint wdccommand(struct wd_softc *, struct wdc_command *); 1001.7Stsutsuiint wdccommandext(struct wd_softc *, struct wdc_command *); 1011.7Stsutsuiint wdc_exec_read(struct wd_softc *, uint8_t, daddr_t, void *); 1021.7Stsutsuiint wdc_exec_identify(struct wd_softc *, void *); 1031.1Scdi 1041.7Stsutsuiint pciide_init(struct wdc_channel *, u_int *); 1051.1Scdi 1061.1Scdi#endif /* _STAND_WDVAR_H */ 107