Merge branch 'drm-patches' of git://git.kernel.org/pub/scm/linux/kernel/git/airlied...
[sfrench/cifs-2.6.git] / arch / ppc / syslib / ibm440sp_common.c
1 /*
2  * PPC440SP/PPC440SPe system library
3  *
4  * Matt Porter <mporter@kernel.crashing.org>
5  * Copyright 2002-2005 MontaVista Software Inc.
6  *
7  * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net>
8  * Copyright (c) 2003, 2004 Zultys Technologies
9  *
10  * This program is free software; you can redistribute  it and/or modify it
11  * under  the terms of  the GNU General  Public License as published by the
12  * Free Software Foundation;  either version 2 of the  License, or (at your
13  * option) any later version.
14  *
15  */
16 #include <linux/config.h>
17 #include <linux/types.h>
18 #include <linux/serial.h>
19
20 #include <asm/param.h>
21 #include <asm/ibm44x.h>
22 #include <asm/mmu.h>
23 #include <asm/machdep.h>
24 #include <asm/time.h>
25 #include <asm/ppc4xx_pic.h>
26
27 /*
28  * Read the 440SP memory controller to get size of system memory.
29  */
30 unsigned long __init ibm440sp_find_end_of_memory(void)
31 {
32         u32 i;
33         u32 mem_size = 0;
34
35         /* Read two bank sizes and sum */
36         for (i=0; i< MQ0_NUM_BANKS; i++)
37                 switch (mfdcr(DCRN_MQ0_BS0BAS + i) & MQ0_CONFIG_SIZE_MASK) {
38                         case MQ0_CONFIG_SIZE_8M:
39                                 mem_size += PPC44x_MEM_SIZE_8M;
40                                 break;
41                         case MQ0_CONFIG_SIZE_16M:
42                                 mem_size += PPC44x_MEM_SIZE_16M;
43                                 break;
44                         case MQ0_CONFIG_SIZE_32M:
45                                 mem_size += PPC44x_MEM_SIZE_32M;
46                                 break;
47                         case MQ0_CONFIG_SIZE_64M:
48                                 mem_size += PPC44x_MEM_SIZE_64M;
49                                 break;
50                         case MQ0_CONFIG_SIZE_128M:
51                                 mem_size += PPC44x_MEM_SIZE_128M;
52                                 break;
53                         case MQ0_CONFIG_SIZE_256M:
54                                 mem_size += PPC44x_MEM_SIZE_256M;
55                                 break;
56                         case MQ0_CONFIG_SIZE_512M:
57                                 mem_size += PPC44x_MEM_SIZE_512M;
58                                 break;
59                         case MQ0_CONFIG_SIZE_1G:
60                                 mem_size += PPC44x_MEM_SIZE_1G;
61                                 break;
62                         case MQ0_CONFIG_SIZE_2G:
63                                 mem_size += PPC44x_MEM_SIZE_2G;
64                                 break;
65                         default:
66                                 break;
67                 }
68         return mem_size;
69 }