122b1d707SAtsushi Nemoto /* 2*255033a9SAtsushi Nemoto * linux/arch/mips/txx9/generic/mem_tx4927.c 322b1d707SAtsushi Nemoto * 422b1d707SAtsushi Nemoto * common tx4927 memory interface 522b1d707SAtsushi Nemoto * 622b1d707SAtsushi Nemoto * Author: MontaVista Software, Inc. 722b1d707SAtsushi Nemoto * source@mvista.com 822b1d707SAtsushi Nemoto * 922b1d707SAtsushi Nemoto * Copyright 2001-2002 MontaVista Software Inc. 1022b1d707SAtsushi Nemoto * 1122b1d707SAtsushi Nemoto * This program is free software; you can redistribute it and/or modify it 1222b1d707SAtsushi Nemoto * under the terms of the GNU General Public License as published by the 1322b1d707SAtsushi Nemoto * Free Software Foundation; either version 2 of the License, or (at your 1422b1d707SAtsushi Nemoto * option) any later version. 1522b1d707SAtsushi Nemoto * 1622b1d707SAtsushi Nemoto * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED 1722b1d707SAtsushi Nemoto * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 1822b1d707SAtsushi Nemoto * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 1922b1d707SAtsushi Nemoto * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 2022b1d707SAtsushi Nemoto * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 2122b1d707SAtsushi Nemoto * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 2222b1d707SAtsushi Nemoto * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 2322b1d707SAtsushi Nemoto * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 2422b1d707SAtsushi Nemoto * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 2522b1d707SAtsushi Nemoto * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2622b1d707SAtsushi Nemoto * 2722b1d707SAtsushi Nemoto * You should have received a copy of the GNU General Public License along 2822b1d707SAtsushi Nemoto * with this program; if not, write to the Free Software Foundation, Inc., 2922b1d707SAtsushi Nemoto * 675 Mass Ave, Cambridge, MA 02139, USA. 3022b1d707SAtsushi Nemoto */ 3122b1d707SAtsushi Nemoto 3222b1d707SAtsushi Nemoto #include <linux/init.h> 3322b1d707SAtsushi Nemoto #include <linux/types.h> 3422b1d707SAtsushi Nemoto #include <linux/io.h> 35*255033a9SAtsushi Nemoto #include <asm/txx9/tx4927.h> 3622b1d707SAtsushi Nemoto 37*255033a9SAtsushi Nemoto static unsigned int __init tx4927_process_sdccr(u64 __iomem *addr) 3822b1d707SAtsushi Nemoto { 3922b1d707SAtsushi Nemoto u64 val; 4022b1d707SAtsushi Nemoto unsigned int sdccr_ce; 4122b1d707SAtsushi Nemoto unsigned int sdccr_bs; 4222b1d707SAtsushi Nemoto unsigned int sdccr_rs; 4322b1d707SAtsushi Nemoto unsigned int sdccr_cs; 4422b1d707SAtsushi Nemoto unsigned int sdccr_mw; 4522b1d707SAtsushi Nemoto unsigned int bs = 0; 4622b1d707SAtsushi Nemoto unsigned int rs = 0; 4722b1d707SAtsushi Nemoto unsigned int cs = 0; 4822b1d707SAtsushi Nemoto unsigned int mw = 0; 4922b1d707SAtsushi Nemoto 50*255033a9SAtsushi Nemoto val = __raw_readq(addr); 5122b1d707SAtsushi Nemoto 5222b1d707SAtsushi Nemoto /* MVMCP -- need #defs for these bits masks */ 5322b1d707SAtsushi Nemoto sdccr_ce = ((val & (1 << 10)) >> 10); 5422b1d707SAtsushi Nemoto sdccr_bs = ((val & (1 << 8)) >> 8); 5522b1d707SAtsushi Nemoto sdccr_rs = ((val & (3 << 5)) >> 5); 56*255033a9SAtsushi Nemoto sdccr_cs = ((val & (7 << 2)) >> 2); 5722b1d707SAtsushi Nemoto sdccr_mw = ((val & (1 << 0)) >> 0); 5822b1d707SAtsushi Nemoto 5922b1d707SAtsushi Nemoto if (sdccr_ce) { 60*255033a9SAtsushi Nemoto bs = 2 << sdccr_bs; 61*255033a9SAtsushi Nemoto rs = 2048 << sdccr_rs; 62*255033a9SAtsushi Nemoto cs = 256 << sdccr_cs; 63*255033a9SAtsushi Nemoto mw = 8 >> sdccr_mw; 6422b1d707SAtsushi Nemoto } 6522b1d707SAtsushi Nemoto 66*255033a9SAtsushi Nemoto return rs * cs * mw * bs; 6722b1d707SAtsushi Nemoto } 6822b1d707SAtsushi Nemoto 6922b1d707SAtsushi Nemoto unsigned int __init tx4927_get_mem_size(void) 7022b1d707SAtsushi Nemoto { 71*255033a9SAtsushi Nemoto unsigned int total = 0; 72*255033a9SAtsushi Nemoto int i; 7322b1d707SAtsushi Nemoto 74*255033a9SAtsushi Nemoto for (i = 0; i < ARRAY_SIZE(tx4927_sdramcptr->cr); i++) 75*255033a9SAtsushi Nemoto total += tx4927_process_sdccr(&tx4927_sdramcptr->cr[i]); 76*255033a9SAtsushi Nemoto return total; 7722b1d707SAtsushi Nemoto } 78