18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * common tx4927 memory interface 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Author: MontaVista Software, Inc. 58c2ecf20Sopenharmony_ci * source@mvista.com 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * Copyright 2001-2002 MontaVista Software Inc. 88c2ecf20Sopenharmony_ci * 98c2ecf20Sopenharmony_ci * This program is free software; you can redistribute it and/or modify it 108c2ecf20Sopenharmony_ci * under the terms of the GNU General Public License as published by the 118c2ecf20Sopenharmony_ci * Free Software Foundation; either version 2 of the License, or (at your 128c2ecf20Sopenharmony_ci * option) any later version. 138c2ecf20Sopenharmony_ci * 148c2ecf20Sopenharmony_ci * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED 158c2ecf20Sopenharmony_ci * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 168c2ecf20Sopenharmony_ci * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 178c2ecf20Sopenharmony_ci * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 188c2ecf20Sopenharmony_ci * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 198c2ecf20Sopenharmony_ci * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 208c2ecf20Sopenharmony_ci * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 218c2ecf20Sopenharmony_ci * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 228c2ecf20Sopenharmony_ci * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 238c2ecf20Sopenharmony_ci * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 248c2ecf20Sopenharmony_ci * 258c2ecf20Sopenharmony_ci * You should have received a copy of the GNU General Public License along 268c2ecf20Sopenharmony_ci * with this program; if not, write to the Free Software Foundation, Inc., 278c2ecf20Sopenharmony_ci * 675 Mass Ave, Cambridge, MA 02139, USA. 288c2ecf20Sopenharmony_ci */ 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci#include <linux/init.h> 318c2ecf20Sopenharmony_ci#include <linux/types.h> 328c2ecf20Sopenharmony_ci#include <linux/io.h> 338c2ecf20Sopenharmony_ci#include <asm/txx9/tx4927.h> 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_cistatic unsigned int __init tx4927_process_sdccr(u64 __iomem *addr) 368c2ecf20Sopenharmony_ci{ 378c2ecf20Sopenharmony_ci u64 val; 388c2ecf20Sopenharmony_ci unsigned int sdccr_ce; 398c2ecf20Sopenharmony_ci unsigned int sdccr_bs; 408c2ecf20Sopenharmony_ci unsigned int sdccr_rs; 418c2ecf20Sopenharmony_ci unsigned int sdccr_cs; 428c2ecf20Sopenharmony_ci unsigned int sdccr_mw; 438c2ecf20Sopenharmony_ci unsigned int bs = 0; 448c2ecf20Sopenharmony_ci unsigned int rs = 0; 458c2ecf20Sopenharmony_ci unsigned int cs = 0; 468c2ecf20Sopenharmony_ci unsigned int mw = 0; 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ci val = __raw_readq(addr); 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ci /* MVMCP -- need #defs for these bits masks */ 518c2ecf20Sopenharmony_ci sdccr_ce = ((val & (1 << 10)) >> 10); 528c2ecf20Sopenharmony_ci sdccr_bs = ((val & (1 << 8)) >> 8); 538c2ecf20Sopenharmony_ci sdccr_rs = ((val & (3 << 5)) >> 5); 548c2ecf20Sopenharmony_ci sdccr_cs = ((val & (7 << 2)) >> 2); 558c2ecf20Sopenharmony_ci sdccr_mw = ((val & (1 << 0)) >> 0); 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ci if (sdccr_ce) { 588c2ecf20Sopenharmony_ci bs = 2 << sdccr_bs; 598c2ecf20Sopenharmony_ci rs = 2048 << sdccr_rs; 608c2ecf20Sopenharmony_ci cs = 256 << sdccr_cs; 618c2ecf20Sopenharmony_ci mw = 8 >> sdccr_mw; 628c2ecf20Sopenharmony_ci } 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci return rs * cs * mw * bs; 658c2ecf20Sopenharmony_ci} 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_ciunsigned int __init tx4927_get_mem_size(void) 688c2ecf20Sopenharmony_ci{ 698c2ecf20Sopenharmony_ci unsigned int total = 0; 708c2ecf20Sopenharmony_ci int i; 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(tx4927_sdramcptr->cr); i++) 738c2ecf20Sopenharmony_ci total += tx4927_process_sdccr(&tx4927_sdramcptr->cr[i]); 748c2ecf20Sopenharmony_ci return total; 758c2ecf20Sopenharmony_ci} 76