1171626Scognet/*- 2171626Scognet * Copyright (c) 2006 Olivier Houchard 3171626Scognet * All rights reserved. 4171626Scognet * 5171626Scognet * Redistribution and use in source and binary forms, with or without 6171626Scognet * modification, are permitted provided that the following conditions 7171626Scognet * are met: 8171626Scognet * 1. Redistributions of source code must retain the above copyright 9171626Scognet * notice, this list of conditions and the following disclaimer. 10171626Scognet * 2. Redistributions in binary form must reproduce the above copyright 11171626Scognet * notice, this list of conditions and the following disclaimer in the 12171626Scognet * documentation and/or other materials provided with the distribution. 13171626Scognet * 14171626Scognet * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND 15171626Scognet * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 16171626Scognet * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17171626Scognet * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR 18171626Scognet * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19171626Scognet * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20171626Scognet * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21171626Scognet * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22171626Scognet * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23171626Scognet * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24171626Scognet * POSSIBILITY OF SUCH DAMAGE. 25171626Scognet */ 26171626Scognet 27171626Scognet#include <sys/cdefs.h> 28171626Scognet__FBSDID("$FreeBSD$"); 29171626Scognet 30171626Scognet#include <sys/param.h> 31171626Scognet#include <sys/systm.h> 32171626Scognet#include <sys/bus.h> 33171626Scognet#include <sys/kernel.h> 34171626Scognet#include <sys/module.h> 35171626Scognet 36171626Scognet#include <machine/bus.h> 37171626Scognet#include <arm/xscale/i8134x/i81342reg.h> 38171626Scognet#include <arm/xscale/i8134x/i81342var.h> 39171626Scognet 40171626Scognetvoid 41236987Simpi81342_sdram_bounds(bus_space_tag_t bt, bus_space_handle_t bh, 42171626Scognet vm_paddr_t *start, vm_size_t *size) 43171626Scognet{ 44171626Scognet uint32_t reg; 45171626Scognet int bank_nb; 46171626Scognet 47171626Scognet reg = bus_space_read_4(bt, bh, SMC_SDBR); 48171626Scognet *start = (reg & SMC_SDBR_BASEADDR_MASK); 49171626Scognet reg = bus_space_read_4(bt, bh, SMC_SBSR); 50171626Scognet if (reg & SMC_SBSR_BANK_NB) 51171626Scognet bank_nb = 1; 52171626Scognet else 53171626Scognet bank_nb = 2; 54171626Scognet 55171626Scognet *size = (reg & SMC_SBSR_BANK_SZ_MASK) * bank_nb; 56171626Scognet} 57