Path: blob/master/arch/mips/txx9/generic/mem_tx4927.c
10818 views
/*1* common tx4927 memory interface2*3* Author: MontaVista Software, Inc.4* [email protected]5*6* Copyright 2001-2002 MontaVista Software Inc.7*8* This program is free software; you can redistribute it and/or modify it9* under the terms of the GNU General Public License as published by the10* Free Software Foundation; either version 2 of the License, or (at your11* option) any later version.12*13* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED14* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF15* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.16* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,17* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,18* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS19* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND20* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR21* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE22* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.23*24* You should have received a copy of the GNU General Public License along25* with this program; if not, write to the Free Software Foundation, Inc.,26* 675 Mass Ave, Cambridge, MA 02139, USA.27*/2829#include <linux/init.h>30#include <linux/types.h>31#include <linux/io.h>32#include <asm/txx9/tx4927.h>3334static unsigned int __init tx4927_process_sdccr(u64 __iomem *addr)35{36u64 val;37unsigned int sdccr_ce;38unsigned int sdccr_bs;39unsigned int sdccr_rs;40unsigned int sdccr_cs;41unsigned int sdccr_mw;42unsigned int bs = 0;43unsigned int rs = 0;44unsigned int cs = 0;45unsigned int mw = 0;4647val = __raw_readq(addr);4849/* MVMCP -- need #defs for these bits masks */50sdccr_ce = ((val & (1 << 10)) >> 10);51sdccr_bs = ((val & (1 << 8)) >> 8);52sdccr_rs = ((val & (3 << 5)) >> 5);53sdccr_cs = ((val & (7 << 2)) >> 2);54sdccr_mw = ((val & (1 << 0)) >> 0);5556if (sdccr_ce) {57bs = 2 << sdccr_bs;58rs = 2048 << sdccr_rs;59cs = 256 << sdccr_cs;60mw = 8 >> sdccr_mw;61}6263return rs * cs * mw * bs;64}6566unsigned int __init tx4927_get_mem_size(void)67{68unsigned int total = 0;69int i;7071for (i = 0; i < ARRAY_SIZE(tx4927_sdramcptr->cr); i++)72total += tx4927_process_sdccr(&tx4927_sdramcptr->cr[i]);73return total;74}757677