1135669Scognet/* $NetBSD: i80321_mcu.c,v 1.2 2003/07/15 00:24:54 lukem Exp $ */ 2135669Scognet 3139735Simp/*- 4135669Scognet * Copyright (c) 2001, 2002 Wasabi Systems, Inc. 5135669Scognet * All rights reserved. 6135669Scognet * 7135669Scognet * Written by Jason R. Thorpe for Wasabi Systems, Inc. 8135669Scognet * 9135669Scognet * Redistribution and use in source and binary forms, with or without 10135669Scognet * modification, are permitted provided that the following conditions 11135669Scognet * are met: 12135669Scognet * 1. Redistributions of source code must retain the above copyright 13135669Scognet * notice, this list of conditions and the following disclaimer. 14135669Scognet * 2. Redistributions in binary form must reproduce the above copyright 15135669Scognet * notice, this list of conditions and the following disclaimer in the 16135669Scognet * documentation and/or other materials provided with the distribution. 17135669Scognet * 3. All advertising materials mentioning features or use of this software 18135669Scognet * must display the following acknowledgement: 19135669Scognet * This product includes software developed for the NetBSD Project by 20135669Scognet * Wasabi Systems, Inc. 21135669Scognet * 4. The name of Wasabi Systems, Inc. may not be used to endorse 22135669Scognet * or promote products derived from this software without specific prior 23135669Scognet * written permission. 24135669Scognet * 25135669Scognet * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND 26135669Scognet * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 27135669Scognet * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 28135669Scognet * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC 29135669Scognet * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30135669Scognet * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31135669Scognet * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32135669Scognet * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33135669Scognet * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34135669Scognet * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35135669Scognet * POSSIBILITY OF SUCH DAMAGE. 36135669Scognet */ 37135669Scognet 38135669Scognet/* 39135669Scognet * Intel i80321 I/O Processor memory controller support. 40135669Scognet */ 41135669Scognet 42135669Scognet#include <sys/cdefs.h> 43135669Scognet__FBSDID("$FreeBSD$"); 44135669Scognet 45135669Scognet#include <sys/param.h> 46135669Scognet#include <sys/systm.h> 47135669Scognet#include <sys/bus.h> 48135669Scognet 49135669Scognet#include <machine/bus.h> 50135669Scognet 51135669Scognet#include <arm/xscale/i80321/i80321reg.h> 52135669Scognet#include <arm/xscale/i80321/i80321var.h> 53135669Scognet 54135669Scognet/* 55135669Scognet * i80321_sdram_bounds: 56135669Scognet * 57135669Scognet * Retrieve the start and size of SDRAM. 58135669Scognet */ 59135669Scognetvoid 60135669Scogneti80321_sdram_bounds(bus_space_tag_t st, bus_space_handle_t sh, 61135669Scognet vm_paddr_t *start, vm_size_t *size) 62135669Scognet{ 63135669Scognet uint32_t sdbr, sbr0, sbr1; 64135669Scognet uint32_t bank0, bank1; 65135669Scognet 66135669Scognet sdbr = bus_space_read_4(st, sh, MCU_SDBR); 67135669Scognet sbr0 = bus_space_read_4(st, sh, MCU_SBR0); 68135669Scognet sbr1 = bus_space_read_4(st, sh, MCU_SBR1); 69135669Scognet 70135669Scognet#ifdef VERBOSE_INIT_ARM 71135669Scognet printf("i80321: SBDR = 0x%08x SBR0 = 0x%08x SBR1 = 0x%08x\n", 72135669Scognet sdbr, sbr0, sbr1); 73135669Scognet#endif 74135669Scognet 75135669Scognet *start = sdbr; 76135669Scognet 77135669Scognet sdbr = (sdbr >> 25) & 0x1f; 78135669Scognet 79135669Scognet sbr0 &= 0x3f; 80135669Scognet sbr1 &= 0x3f; 81135669Scognet 82135669Scognet bank0 = (sbr0 - sdbr) << 25; 83135669Scognet bank1 = (sbr1 - sbr0) << 25; 84135669Scognet 85135669Scognet#ifdef VERBOSE_INIT_ARM 86135669Scognet printf("i80321: BANK0 = 0x%08x BANK1 = 0x%08x\n", bank0, bank1); 87135669Scognet#endif 88135669Scognet 89135669Scognet *size = bank0 + bank1; 90135669Scognet} 91