pciide.c revision 1.6
11.6Stsutsui/* $NetBSD: pciide.c,v 1.6 2007/08/03 13:15:56 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.6Stsutsuipciide_init(struct wdc_channel *chp, u_int *unit) 471.1Scdi{ 481.6Stsutsui uint32_t cmdreg, ctlreg; 491.4Stsutsui int i, compatchan = 0; 501.1Scdi 511.1Scdi /* 521.1Scdi * two channels per chip, two drives per channel 531.1Scdi */ 541.1Scdi compatchan = *unit / PCIIDE_CHANNEL_NDEV; 551.1Scdi if (compatchan >= PCIIDE_NUM_CHANNELS) 561.1Scdi return (ENXIO); 571.1Scdi *unit %= PCIIDE_CHANNEL_NDEV; 581.1Scdi 591.1Scdi DPRINTF(("[pciide] unit: %d, channel: %d\n", *unit, compatchan)); 601.1Scdi 611.1Scdi /* 621.1Scdi * XXX map? 631.1Scdi */ 641.4Stsutsui cmdreg = MIPS_PHYS_TO_KSEG1(COBALT_IO_SPACE_BASE + 651.4Stsutsui PCIIDE_COMPAT_CMD_BASE(compatchan)); 661.4Stsutsui ctlreg = MIPS_PHYS_TO_KSEG1(COBALT_IO_SPACE_BASE + 671.4Stsutsui PCIIDE_COMPAT_CTL_BASE(compatchan)); 681.4Stsutsui 691.4Stsutsui /* set up cmd regsiters */ 701.6Stsutsui chp->c_cmdbase = (uint8_t *)cmdreg; 711.6Stsutsui chp->c_data = (uint16_t *)(cmdreg + wd_data); 721.4Stsutsui for (i = 0; i < WDC_NPORTS; i++) 731.4Stsutsui chp->c_cmdreg[i] = chp->c_cmdbase + i; 741.4Stsutsui /* set up shadow registers */ 751.4Stsutsui chp->c_cmdreg[wd_status] = chp->c_cmdreg[wd_command]; 761.4Stsutsui chp->c_cmdreg[wd_features] = chp->c_cmdreg[wd_precomp]; 771.4Stsutsui /* set up ctl registers */ 781.6Stsutsui chp->c_ctlbase = (uint8_t *)ctlreg; 791.1Scdi 801.6Stsutsui return 0; 811.1Scdi} 82