summaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-samsung/mem-s3c24x0.c
blob: bf65150cab5413ffa9ec8e44f42e2802dcad909e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*
 * See file CREDITS for list of people who contributed to this
 * project.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 */
/**
 * @file
 * @brief Basic clock, sdram and timer handling for S3C24xx CPUs
 */

#include <config.h>
#include <common.h>
#include <init.h>
#include <clock.h>
#include <io.h>
#include <linux/sizes.h>
#include <mach/s3c-iomap.h>
#include <mach/s3c-generic.h>
#include <mach/s3c-busctl.h>
#include <mach/s3c24xx-gpio.h>

/**
 * Calculate the amount of connected and available memory
 * @return Memory size in bytes
 */
uint32_t s3c24xx_get_memory_size(void)
{
	uint32_t reg, size;

	/*
	 * detect the current memory size
	 */
	reg = readl(S3C_BANKSIZE);

	switch (reg & 0x7) {
	case 0:
		size = SZ_32M;
		break;
	case 1:
		size = SZ_64M;
		break;
	case 2:
		size = SZ_128M;
		break;
	case 4:
		size = SZ_2M;
		break;
	case 5:
		size = SZ_4M;
		break;
	case 6:
		size = SZ_8M;
		break;
	default:
		size = SZ_16M;
		break;
	}

	/*
	 * Is bank7 also configured for SDRAM usage?
	 */
	if ((readl(S3C_BANKCON7) & (0x3 << 15)) == (0x3 << 15))
		size <<= 1;	/* also count this bank */

	return size;
}

void s3c24xx_disable_second_sdram_bank(void)
{
	writel(readl(S3C_BANKCON7) & ~(0x3 << 15), S3C_BANKCON7);
	writel(readl(S3C_MISCCR) | (1 << 18), S3C_MISCCR); /* disable its clock */
}