blob: 9a2258270de9cb1e7e9d12b9b45b90f9092d3582 [file] [log] [blame]
Ben Dooks96ce2382006-06-18 23:06:41 +01001/* linux/arch/arm/mach-s3c2410/s3c244x.c
2 *
3 * Copyright (c) 2004-2006 Simtec Electronics
4 * Ben Dooks <ben@simtec.co.uk>
5 *
6 * Samsung S3C2440 and S3C2442 Mobile CPU support
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11*/
12
13#include <linux/kernel.h>
14#include <linux/types.h>
15#include <linux/interrupt.h>
16#include <linux/list.h>
17#include <linux/timer.h>
18#include <linux/init.h>
19#include <linux/platform_device.h>
20#include <linux/sysdev.h>
21#include <linux/clk.h>
22
23#include <asm/mach/arch.h>
24#include <asm/mach/map.h>
25#include <asm/mach/irq.h>
26
27#include <asm/hardware.h>
28#include <asm/io.h>
29#include <asm/irq.h>
30
31#include <asm/arch/regs-clock.h>
32#include <asm/arch/regs-serial.h>
33#include <asm/arch/regs-gpio.h>
34#include <asm/arch/regs-gpioj.h>
35#include <asm/arch/regs-dsc.h>
36
Ben Dooks99c13852006-06-22 22:18:20 +010037#include "s3c2410.h"
Ben Dooks96ce2382006-06-18 23:06:41 +010038#include "s3c2440.h"
39#include "s3c244x.h"
40#include "clock.h"
41#include "devs.h"
42#include "cpu.h"
43#include "pm.h"
44
45static struct map_desc s3c244x_iodesc[] __initdata = {
46 IODESC_ENT(CLKPWR),
47 IODESC_ENT(TIMER),
48 IODESC_ENT(WATCHDOG),
49 IODESC_ENT(LCD),
50 IODESC_ENT(ADC),
51 IODESC_ENT(USBHOST),
52};
53
54/* uart initialisation */
55
56void __init s3c244x_init_uarts(struct s3c2410_uartcfg *cfg, int no)
57{
58 s3c24xx_init_uartdevs("s3c2440-uart", s3c2410_uart_resources, cfg, no);
59}
60
61void __init s3c244x_map_io(struct map_desc *mach_desc, int size)
62{
63 /* register our io-tables */
64
65 iotable_init(s3c244x_iodesc, ARRAY_SIZE(s3c244x_iodesc));
66 iotable_init(mach_desc, size);
67
68 /* rename any peripherals used differing from the s3c2410 */
69
70 s3c_device_i2c.name = "s3c2440-i2c";
71 s3c_device_nand.name = "s3c2440-nand";
Ben Dooksb8ccca42006-06-27 22:53:03 +010072 s3c_device_usbgadget.name = "s3c2440-usbgadget";
Ben Dooks96ce2382006-06-18 23:06:41 +010073}
74
75void __init s3c244x_init_clocks(int xtal)
76{
77 unsigned long clkdiv;
78 unsigned long camdiv;
79 unsigned long hclk, fclk, pclk;
80 int hdiv = 1;
81
82 /* now we've got our machine bits initialised, work out what
83 * clocks we've got */
84
85 fclk = s3c2410_get_pll(__raw_readl(S3C2410_MPLLCON), xtal) * 2;
86
87 clkdiv = __raw_readl(S3C2410_CLKDIVN);
88 camdiv = __raw_readl(S3C2440_CAMDIVN);
89
90 /* work out clock scalings */
91
92 switch (clkdiv & S3C2440_CLKDIVN_HDIVN_MASK) {
93 case S3C2440_CLKDIVN_HDIVN_1:
94 hdiv = 1;
95 break;
96
97 case S3C2440_CLKDIVN_HDIVN_2:
98 hdiv = 2;
99 break;
100
101 case S3C2440_CLKDIVN_HDIVN_4_8:
102 hdiv = (camdiv & S3C2440_CAMDIVN_HCLK4_HALF) ? 8 : 4;
103 break;
104
105 case S3C2440_CLKDIVN_HDIVN_3_6:
106 hdiv = (camdiv & S3C2440_CAMDIVN_HCLK3_HALF) ? 6 : 3;
107 break;
108 }
109
110 hclk = fclk / hdiv;
111 pclk = hclk / ((clkdiv & S3C2440_CLKDIVN_PDIVN)? 2:1);
112
113 /* print brief summary of clocks, etc */
114
115 printk("S3C244X: core %ld.%03ld MHz, memory %ld.%03ld MHz, peripheral %ld.%03ld MHz\n",
116 print_mhz(fclk), print_mhz(hclk), print_mhz(pclk));
117
118 /* initialise the clocks here, to allow other things like the
119 * console to use them, and to add new ones after the initialisation
120 */
121
122 s3c24xx_setup_clocks(xtal, fclk, hclk, pclk);
Ben Dooks99c13852006-06-22 22:18:20 +0100123 s3c2410_baseclk_add();
Ben Dooks96ce2382006-06-18 23:06:41 +0100124}
125
126#ifdef CONFIG_PM
127
128static struct sleep_save s3c244x_sleep[] = {
129 SAVE_ITEM(S3C2440_DSC0),
130 SAVE_ITEM(S3C2440_DSC1),
131 SAVE_ITEM(S3C2440_GPJDAT),
132 SAVE_ITEM(S3C2440_GPJCON),
133 SAVE_ITEM(S3C2440_GPJUP)
134};
135
136static int s3c244x_suspend(struct sys_device *dev, pm_message_t state)
137{
138 s3c2410_pm_do_save(s3c244x_sleep, ARRAY_SIZE(s3c244x_sleep));
139 return 0;
140}
141
142static int s3c244x_resume(struct sys_device *dev)
143{
144 s3c2410_pm_do_restore(s3c244x_sleep, ARRAY_SIZE(s3c244x_sleep));
145 return 0;
146}
147
148#else
149#define s3c244x_suspend NULL
150#define s3c244x_resume NULL
151#endif
152
153/* Since the S3C2442 and S3C2440 share items, put both sysclasses here */
154
155struct sysdev_class s3c2440_sysclass = {
156 set_kset_name("s3c2440-core"),
157 .suspend = s3c244x_suspend,
158 .resume = s3c244x_resume
159};
160
161struct sysdev_class s3c2442_sysclass = {
162 set_kset_name("s3c2442-core"),
163 .suspend = s3c244x_suspend,
164 .resume = s3c244x_resume
165};
166
167/* need to register class before we actually register the device, and
168 * we also need to ensure that it has been initialised before any of the
169 * drivers even try to use it (even if not on an s3c2440 based system)
170 * as a driver which may support both 2410 and 2440 may try and use it.
171*/
172
173static int __init s3c2440_core_init(void)
174{
175 return sysdev_class_register(&s3c2440_sysclass);
176}
177
178core_initcall(s3c2440_core_init);
179
180static int __init s3c2442_core_init(void)
181{
182 return sysdev_class_register(&s3c2442_sysclass);
183}
184
185core_initcall(s3c2442_core_init);