Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ba532011 authored by Russell King's avatar Russell King Committed by Russell King
Browse files

[ARM] Fix sa11x0 SDRAM selection



Avoid folk having to edit cpu-sa1110.c to select their RAM type;
instead, allow the SDRAM type to be selected via the kernel
command line.

Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
parent 8799ee9f
Loading
Loading
Loading
Loading
+76 −55
Original line number Diff line number Diff line
@@ -15,7 +15,10 @@
 *      SDRAM reads (rev A0, B0, B1)
 *
 * We ignore rev. A0 and B0 devices; I don't think they're worth supporting.
 *
 * The SDRAM type can be passed on the command line as cpu_sa1110.sdram=type
 */
#include <linux/moduleparam.h>
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/sched.h>
@@ -35,6 +38,7 @@
static struct cpufreq_driver sa1110_driver;

struct sdram_params {
	const char name[16];
	u_char  rows;		/* bits				 */
	u_char  cas_latency;	/* cycles			 */
	u_char  tck;		/* clock cycle time (ns)	 */
@@ -50,7 +54,9 @@ struct sdram_info {
	u_int	mdcas[3];
};

static struct sdram_params tc59sm716_cl2_params __initdata = {
static struct sdram_params sdram_tbl[] __initdata = {
	{	/* Toshiba TC59SM716 CL2 */
		.name		= "TC59SM716-CL2",
		.rows		= 12,
		.tck		= 10,
		.trcd		= 20,
@@ -58,9 +64,8 @@ static struct sdram_params tc59sm716_cl2_params __initdata = {
		.twr		= 10,
		.refresh	= 64000,
		.cas_latency	= 2,
};

static struct sdram_params tc59sm716_cl3_params __initdata = {
	}, {	/* Toshiba TC59SM716 CL3 */
		.name		= "TC59SM716-CL3",
		.rows		= 12,
		.tck		= 8,
		.trcd		= 20,
@@ -68,9 +73,8 @@ static struct sdram_params tc59sm716_cl3_params __initdata = {
		.twr		= 8,
		.refresh	= 64000,
		.cas_latency	= 3,
};

static struct sdram_params samsung_k4s641632d_tc75 __initdata = {
	}, {	/* Samsung K4S641632D TC75 */
		.name		= "K4S641632D",
		.rows		= 14,
		.tck		= 9,
		.trcd		= 27,
@@ -78,9 +82,8 @@ static struct sdram_params samsung_k4s641632d_tc75 __initdata = {
		.twr		= 9,
		.refresh	= 64000,
		.cas_latency	= 3,
};

static struct sdram_params samsung_km416s4030ct __initdata = {
	}, {	/* Samsung KM416S4030CT */
		.name		= "KM416S4030CT",
		.rows		= 13,
		.tck		= 8,
		.trcd		= 24,	/* 3 CLKs */
@@ -88,9 +91,8 @@ static struct sdram_params samsung_km416s4030ct __initdata = {
		.twr		= 16,	/* Trdl: 2 CLKs */
		.refresh	= 64000,
		.cas_latency	= 3,
};

static struct sdram_params wbond_w982516ah75l_cl3_params __initdata = {
	}, {	/* Winbond W982516AH75L CL3 */
		.name		= "W982516AH75L",
		.rows		= 16,
		.tck		= 8,
		.trcd		= 20,
@@ -98,6 +100,7 @@ static struct sdram_params wbond_w982516ah75l_cl3_params __initdata = {
		.twr		= 8,
		.refresh	= 64000,
		.cas_latency	= 3,
	},
};

static struct sdram_params sdram_params;
@@ -336,19 +339,36 @@ static struct cpufreq_driver sa1110_driver = {
	.name		= "sa1110",
};

static struct sdram_params *sa1110_find_sdram(const char *name)
{
	struct sdram_params *sdram;

	for (sdram = sdram_tbl; sdram < sdram_tbl + ARRAY_SIZE(sdram_tbl); sdram++)
		if (strcmp(name, sdram->name) == 0)
			return sdram;

	return NULL;
}

static char sdram_name[16];

static int __init sa1110_clk_init(void)
{
	struct sdram_params *sdram = NULL;
	struct sdram_params *sdram;
	const char *name = sdram_name;

	if (!name[0]) {
		if (machine_is_assabet())
		sdram = &tc59sm716_cl3_params;
			name = "TC59SM716-CL3";

		if (machine_is_pt_system3())
		sdram = &samsung_k4s641632d_tc75;
			name = "K4S641632D";

		if (machine_is_h3100())
		sdram = &samsung_km416s4030ct;
			name = "KM416S4030CT";
	}

	sdram = sa1110_find_sdram(name);
	if (sdram) {
		printk(KERN_DEBUG "SDRAM: tck: %d trcd: %d trp: %d"
			" twr: %d refresh: %d cas_latency: %d\n",
@@ -363,4 +383,5 @@ static int __init sa1110_clk_init(void)
	return 0;
}

module_param_string(sdram, sdram_name, sizeof(sdram_name), 0);
arch_initcall(sa1110_clk_init);