162306a36Sopenharmony_ci/* 262306a36Sopenharmony_ci * common tx4927 memory interface 362306a36Sopenharmony_ci * 462306a36Sopenharmony_ci * Author: MontaVista Software, Inc. 562306a36Sopenharmony_ci * source@mvista.com 662306a36Sopenharmony_ci * 762306a36Sopenharmony_ci * Copyright 2001-2002 MontaVista Software Inc. 862306a36Sopenharmony_ci * 962306a36Sopenharmony_ci * This program is free software; you can redistribute it and/or modify it 1062306a36Sopenharmony_ci * under the terms of the GNU General Public License as published by the 1162306a36Sopenharmony_ci * Free Software Foundation; either version 2 of the License, or (at your 1262306a36Sopenharmony_ci * option) any later version. 1362306a36Sopenharmony_ci * 1462306a36Sopenharmony_ci * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED 1562306a36Sopenharmony_ci * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 1662306a36Sopenharmony_ci * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 1762306a36Sopenharmony_ci * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 1862306a36Sopenharmony_ci * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 1962306a36Sopenharmony_ci * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 2062306a36Sopenharmony_ci * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 2162306a36Sopenharmony_ci * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 2262306a36Sopenharmony_ci * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 2362306a36Sopenharmony_ci * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2462306a36Sopenharmony_ci * 2562306a36Sopenharmony_ci * You should have received a copy of the GNU General Public License along 2662306a36Sopenharmony_ci * with this program; if not, write to the Free Software Foundation, Inc., 2762306a36Sopenharmony_ci * 675 Mass Ave, Cambridge, MA 02139, USA. 2862306a36Sopenharmony_ci */ 2962306a36Sopenharmony_ci 3062306a36Sopenharmony_ci#include <linux/init.h> 3162306a36Sopenharmony_ci#include <linux/types.h> 3262306a36Sopenharmony_ci#include <linux/io.h> 3362306a36Sopenharmony_ci#include <asm/txx9/tx4927.h> 3462306a36Sopenharmony_ci 3562306a36Sopenharmony_cistatic unsigned int __init tx4927_process_sdccr(u64 __iomem *addr) 3662306a36Sopenharmony_ci{ 3762306a36Sopenharmony_ci u64 val; 3862306a36Sopenharmony_ci unsigned int sdccr_ce; 3962306a36Sopenharmony_ci unsigned int sdccr_bs; 4062306a36Sopenharmony_ci unsigned int sdccr_rs; 4162306a36Sopenharmony_ci unsigned int sdccr_cs; 4262306a36Sopenharmony_ci unsigned int sdccr_mw; 4362306a36Sopenharmony_ci unsigned int bs = 0; 4462306a36Sopenharmony_ci unsigned int rs = 0; 4562306a36Sopenharmony_ci unsigned int cs = 0; 4662306a36Sopenharmony_ci unsigned int mw = 0; 4762306a36Sopenharmony_ci 4862306a36Sopenharmony_ci val = __raw_readq(addr); 4962306a36Sopenharmony_ci 5062306a36Sopenharmony_ci /* MVMCP -- need #defs for these bits masks */ 5162306a36Sopenharmony_ci sdccr_ce = ((val & (1 << 10)) >> 10); 5262306a36Sopenharmony_ci sdccr_bs = ((val & (1 << 8)) >> 8); 5362306a36Sopenharmony_ci sdccr_rs = ((val & (3 << 5)) >> 5); 5462306a36Sopenharmony_ci sdccr_cs = ((val & (7 << 2)) >> 2); 5562306a36Sopenharmony_ci sdccr_mw = ((val & (1 << 0)) >> 0); 5662306a36Sopenharmony_ci 5762306a36Sopenharmony_ci if (sdccr_ce) { 5862306a36Sopenharmony_ci bs = 2 << sdccr_bs; 5962306a36Sopenharmony_ci rs = 2048 << sdccr_rs; 6062306a36Sopenharmony_ci cs = 256 << sdccr_cs; 6162306a36Sopenharmony_ci mw = 8 >> sdccr_mw; 6262306a36Sopenharmony_ci } 6362306a36Sopenharmony_ci 6462306a36Sopenharmony_ci return rs * cs * mw * bs; 6562306a36Sopenharmony_ci} 6662306a36Sopenharmony_ci 6762306a36Sopenharmony_ciunsigned int __init tx4927_get_mem_size(void) 6862306a36Sopenharmony_ci{ 6962306a36Sopenharmony_ci unsigned int total = 0; 7062306a36Sopenharmony_ci int i; 7162306a36Sopenharmony_ci 7262306a36Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(tx4927_sdramcptr->cr); i++) 7362306a36Sopenharmony_ci total += tx4927_process_sdccr(&tx4927_sdramcptr->cr[i]); 7462306a36Sopenharmony_ci return total; 7562306a36Sopenharmony_ci} 76