s3c2410.c 4.1 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
/* linux/arch/arm/mach-s3c2410/s3c2410.c
 *
 * Copyright (c) 2003-2005 Simtec Electronics
 *	Ben Dooks <ben@simtec.co.uk>
 *
 * http://www.simtec.co.uk/products/EB2410ITX/
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
*/

#include <linux/kernel.h>
#include <linux/types.h>
#include <linux/interrupt.h>
#include <linux/list.h>
#include <linux/timer.h>
#include <linux/init.h>
19
#include <linux/gpio.h>
20
#include <linux/clk.h>
21
#include <linux/sysdev.h>
22
#include <linux/serial_core.h>
23
#include <linux/platform_device.h>
24
#include <linux/io.h>
L
Linus Torvalds 已提交
25 26 27 28 29

#include <asm/mach/arch.h>
#include <asm/mach/map.h>
#include <asm/mach/irq.h>

30
#include <mach/hardware.h>
L
Linus Torvalds 已提交
31 32
#include <asm/irq.h>

33 34
#include <plat/cpu-freq.h>

35
#include <mach/regs-clock.h>
36
#include <plat/regs-serial.h>
L
Linus Torvalds 已提交
37

38 39 40
#include <plat/s3c2410.h>
#include <plat/cpu.h>
#include <plat/devs.h>
41
#include <plat/clock.h>
42
#include <plat/pll.h>
L
Linus Torvalds 已提交
43

44 45 46 47
#include <plat/gpio-core.h>
#include <plat/gpio-cfg.h>
#include <plat/gpio-cfg-helpers.h>

L
Linus Torvalds 已提交
48 49 50 51 52
/* Initial IO mappings */

static struct map_desc s3c2410_iodesc[] __initdata = {
	IODESC_ENT(CLKPWR),
	IODESC_ENT(TIMER),
53
	IODESC_ENT(WATCHDOG),
L
Linus Torvalds 已提交
54 55 56 57 58 59 60 61
};

/* our uart devices */

/* uart registration process */

void __init s3c2410_init_uarts(struct s3c2410_uartcfg *cfg, int no)
{
62
	s3c24xx_init_uartdevs("s3c2410-uart", s3c2410_uart_resources, cfg, no);
L
Linus Torvalds 已提交
63 64 65 66 67 68 69 70
}

/* s3c2410_map_io
 *
 * register the standard cpu IO areas, and any passed in from the
 * machine specific initialisation.
*/

71
void __init s3c2410_map_io(void)
L
Linus Torvalds 已提交
72
{
73 74 75
	s3c24xx_gpiocfg_default.set_pull = s3c_gpio_setpull_1up;
	s3c24xx_gpiocfg_default.get_pull = s3c_gpio_getpull_1up;

L
Linus Torvalds 已提交
76 77 78
	iotable_init(s3c2410_iodesc, ARRAY_SIZE(s3c2410_iodesc));
}

79
void __init_or_cpufreq s3c2410_setup_clocks(void)
L
Linus Torvalds 已提交
80
{
81
	struct clk *xtal_clk;
L
Linus Torvalds 已提交
82
	unsigned long tmp;
83
	unsigned long xtal;
L
Linus Torvalds 已提交
84 85 86 87
	unsigned long fclk;
	unsigned long hclk;
	unsigned long pclk;

88 89 90 91
	xtal_clk = clk_get(NULL, "xtal");
	xtal = clk_get_rate(xtal_clk);
	clk_put(xtal_clk);

L
Linus Torvalds 已提交
92 93 94
	/* now we've got our machine bits initialised, work out what
	 * clocks we've got */

95
	fclk = s3c24xx_get_pll(__raw_readl(S3C2410_MPLLCON), xtal);
L
Linus Torvalds 已提交
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112

	tmp = __raw_readl(S3C2410_CLKDIVN);

	/* work out clock scalings */

	hclk = fclk / ((tmp & S3C2410_CLKDIVN_HDIVN) ? 2 : 1);
	pclk = hclk / ((tmp & S3C2410_CLKDIVN_PDIVN) ? 2 : 1);

	/* print brieft summary of clocks, etc */

	printk("S3C2410: core %ld.%03ld MHz, memory %ld.%03ld MHz, peripheral %ld.%03ld MHz\n",
	       print_mhz(fclk), print_mhz(hclk), print_mhz(pclk));

	/* initialise the clocks here, to allow other things like the
	 * console to use them
	 */

113 114 115
	s3c24xx_setup_clocks(fclk, hclk, pclk);
}

116 117 118 119 120 121 122 123
/* fake ARMCLK for use with cpufreq, etc. */

static struct clk s3c2410_armclk = {
	.name	= "armclk",
	.parent	= &clk_f,
	.id	= -1,
};

124 125 126 127
void __init s3c2410_init_clocks(int xtal)
{
	s3c24xx_register_baseclocks(xtal);
	s3c2410_setup_clocks();
128
	s3c2410_baseclk_add();
129
	s3c24xx_register_clock(&s3c2410_armclk);
L
Linus Torvalds 已提交
130 131
}

132
struct sysdev_class s3c2410_sysclass = {
133
	.name = "s3c2410-core",
134 135
};

B
Ben Dooks 已提交
136 137 138 139 140 141 142
/* Note, we would have liked to name this s3c2410-core, but we cannot
 * register two sysdev_class with the same name.
 */
struct sysdev_class s3c2410a_sysclass = {
	.name = "s3c2410a-core",
};

143 144 145 146 147 148
static struct sys_device s3c2410_sysdev = {
	.cls		= &s3c2410_sysclass,
};

/* need to register class before we actually register the device, and
 * we also need to ensure that it has been initialised before any of the
149
 * drivers even try to use it (even if not on an s3c2410 based system)
150 151 152 153 154 155 156 157 158 159
 * as a driver which may support both 2410 and 2440 may try and use it.
*/

static int __init s3c2410_core_init(void)
{
	return sysdev_class_register(&s3c2410_sysclass);
}

core_initcall(s3c2410_core_init);

B
Ben Dooks 已提交
160 161 162 163 164 165 166
static int __init s3c2410a_core_init(void)
{
	return sysdev_class_register(&s3c2410a_sysclass);
}

core_initcall(s3c2410a_core_init);

L
Linus Torvalds 已提交
167 168 169 170
int __init s3c2410_init(void)
{
	printk("S3C2410: Initialising architecture\n");

171
	return sysdev_register(&s3c2410_sysdev);
L
Linus Torvalds 已提交
172
}
B
Ben Dooks 已提交
173 174 175 176 177 178

int __init s3c2410a_init(void)
{
	s3c2410_sysdev.cls = &s3c2410a_sysclass;
	return s3c2410_init();
}