pciide.c revision 1.4
11.4Stsutsui/* $NetBSD: pciide.c,v 1.4 2004/09/01 15:54:39 tsutsui Exp $ */ 21.1Scdi 31.1Scdi/*- 41.1Scdi * Copyright (c) 2003 The NetBSD Foundation, Inc. 51.1Scdi * All rights reserved. 61.1Scdi * 71.1Scdi * Redistribution and use in source and binary forms, with or without 81.1Scdi * modification, are permitted provided that the following conditions 91.1Scdi * are met: 101.1Scdi * 1. Redistributions of source code must retain the above copyright 111.1Scdi * notice, this list of conditions and the following disclaimer. 121.1Scdi * 2. Redistributions in binary form must reproduce the above copyright 131.1Scdi * notice, this list of conditions and the following disclaimer in the 141.1Scdi * documentation and/or other materials provided with the distribution. 151.1Scdi * 3. All advertising materials mentioning features or use of this software 161.1Scdi * must display the following acknowledgement: 171.1Scdi * This product includes software developed by the NetBSD 181.1Scdi * Foundation, Inc. and its contributors. 191.1Scdi * 4. Neither the name of The NetBSD Foundation nor the names of its 201.1Scdi * contributors may be used to endorse or promote products derived 211.1Scdi * from this software without specific prior written permission. 221.1Scdi * 231.1Scdi * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 241.1Scdi * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 251.1Scdi * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 261.1Scdi * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 271.1Scdi * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 281.1Scdi * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 291.1Scdi * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 301.1Scdi * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 311.1Scdi * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 321.1Scdi * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 331.1Scdi * POSSIBILITY OF SUCH DAMAGE. 341.1Scdi */ 351.1Scdi 361.1Scdi#include <sys/types.h> 371.1Scdi#include <lib/libsa/stand.h> 381.1Scdi#include <mips/cpuregs.h> 391.1Scdi 401.1Scdi#include "boot.h" 411.1Scdi#include "wdvar.h" 421.1Scdi 431.4Stsutsui#define COBALT_IO_SPACE_BASE 0x10000000 /* XXX VT82C586 ISA I/O space */ 441.4Stsutsui 451.1Scdiint 461.1Scdipciide_init(chp, unit) 471.3Sthorpej struct wdc_channel *chp; 481.2Stsutsui u_int *unit; 491.1Scdi{ 501.4Stsutsui u_int32_t cmdreg, ctlreg; 511.4Stsutsui int i, compatchan = 0; 521.1Scdi 531.1Scdi /* 541.1Scdi * two channels per chip, two drives per channel 551.1Scdi */ 561.1Scdi compatchan = *unit / PCIIDE_CHANNEL_NDEV; 571.1Scdi if (compatchan >= PCIIDE_NUM_CHANNELS) 581.1Scdi return (ENXIO); 591.1Scdi *unit %= PCIIDE_CHANNEL_NDEV; 601.1Scdi 611.1Scdi DPRINTF(("[pciide] unit: %d, channel: %d\n", *unit, compatchan)); 621.1Scdi 631.1Scdi /* 641.1Scdi * XXX map? 651.1Scdi */ 661.4Stsutsui cmdreg = MIPS_PHYS_TO_KSEG1(COBALT_IO_SPACE_BASE + 671.4Stsutsui PCIIDE_COMPAT_CMD_BASE(compatchan)); 681.4Stsutsui ctlreg = MIPS_PHYS_TO_KSEG1(COBALT_IO_SPACE_BASE + 691.4Stsutsui PCIIDE_COMPAT_CTL_BASE(compatchan)); 701.4Stsutsui 711.4Stsutsui /* set up cmd regsiters */ 721.4Stsutsui chp->c_cmdbase = (u_int8_t *)cmdreg; 731.4Stsutsui chp->c_data = (u_int16_t *)(cmdreg + wd_data); 741.4Stsutsui for (i = 0; i < WDC_NPORTS; i++) 751.4Stsutsui chp->c_cmdreg[i] = chp->c_cmdbase + i; 761.4Stsutsui /* set up shadow registers */ 771.4Stsutsui chp->c_cmdreg[wd_status] = chp->c_cmdreg[wd_command]; 781.4Stsutsui chp->c_cmdreg[wd_features] = chp->c_cmdreg[wd_precomp]; 791.4Stsutsui /* set up ctl registers */ 801.4Stsutsui chp->c_ctlbase = (u_int8_t *)ctlreg; 811.1Scdi 821.1Scdi return (0); 831.1Scdi} 84