pciide.c revision 1.1
11.1Scdi/*	$NetBSD: pciide.c,v 1.1 2003/06/25 17:24:22 cdi 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.1Scdiint
441.1Scdipciide_init(chp, unit)
451.1Scdi	struct channel_softc *chp;
461.1Scdi	u_int8_t *unit;
471.1Scdi{
481.1Scdi	u_long bpa, addr;
491.1Scdi	int 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.1Scdi	bpa = PCIIDE_COMPAT_CMD_BASE(compatchan);
651.1Scdi	addr = MIPS_PHYS_TO_KSEG1(bpa);
661.1Scdi	if (bpa < 0x10000000)
671.1Scdi		addr += 0x10000000;
681.1Scdi
691.1Scdi	chp->c_base = (u_int8_t*)addr;
701.1Scdi	chp->c_data = (u_int16_t*)(addr + wd_data);
711.1Scdi	return (0);
721.1Scdi}
73