Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * common tx4927 memory interface
0003  *
0004  * Author: MontaVista Software, Inc.
0005  *     source@mvista.com
0006  *
0007  * Copyright 2001-2002 MontaVista Software Inc.
0008  *
0009  *  This program is free software; you can redistribute it and/or modify it
0010  *  under the terms of the GNU General Public License as published by the
0011  *  Free Software Foundation; either version 2 of the License, or (at your
0012  *  option) any later version.
0013  *
0014  *  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
0015  *  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
0016  *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
0017  *  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
0018  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
0019  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
0020  *  OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
0021  *  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
0022  *  TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
0023  *  USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0024  *
0025  *  You should have received a copy of the GNU General Public License along
0026  *  with this program; if not, write to the Free Software Foundation, Inc.,
0027  *  675 Mass Ave, Cambridge, MA 02139, USA.
0028  */
0029 
0030 #include <linux/init.h>
0031 #include <linux/types.h>
0032 #include <linux/io.h>
0033 #include <asm/txx9/tx4927.h>
0034 
0035 static unsigned int __init tx4927_process_sdccr(u64 __iomem *addr)
0036 {
0037     u64 val;
0038     unsigned int sdccr_ce;
0039     unsigned int sdccr_bs;
0040     unsigned int sdccr_rs;
0041     unsigned int sdccr_cs;
0042     unsigned int sdccr_mw;
0043     unsigned int bs = 0;
0044     unsigned int rs = 0;
0045     unsigned int cs = 0;
0046     unsigned int mw = 0;
0047 
0048     val = __raw_readq(addr);
0049 
0050     /* MVMCP -- need #defs for these bits masks */
0051     sdccr_ce = ((val & (1 << 10)) >> 10);
0052     sdccr_bs = ((val & (1 << 8)) >> 8);
0053     sdccr_rs = ((val & (3 << 5)) >> 5);
0054     sdccr_cs = ((val & (7 << 2)) >> 2);
0055     sdccr_mw = ((val & (1 << 0)) >> 0);
0056 
0057     if (sdccr_ce) {
0058         bs = 2 << sdccr_bs;
0059         rs = 2048 << sdccr_rs;
0060         cs = 256 << sdccr_cs;
0061         mw = 8 >> sdccr_mw;
0062     }
0063 
0064     return rs * cs * mw * bs;
0065 }
0066 
0067 unsigned int __init tx4927_get_mem_size(void)
0068 {
0069     unsigned int total = 0;
0070     int i;
0071 
0072     for (i = 0; i < ARRAY_SIZE(tx4927_sdramcptr->cr); i++)
0073         total += tx4927_process_sdccr(&tx4927_sdramcptr->cr[i]);
0074     return total;
0075 }