blob: a80cbea40496937fa9667de3646e72c5755d8bdb [file] [log] [blame]
Haojian Zhuang2f7e8fa2009-12-04 09:41:28 -05001/*
2 * linux/arch/arm/mach-mmp/mmp2.c
3 *
4 * code name MMP2
5 *
6 * Copyright (C) 2009 Marvell International Ltd.
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/module.h>
14#include <linux/kernel.h>
15#include <linux/init.h>
16#include <linux/io.h>
17
Haojian Zhuang66b19642010-04-28 10:59:45 -040018#include <asm/hardware/cache-tauros2.h>
19
Eric Miao4d4a3392010-07-15 21:54:20 +080020#include <asm/mach/time.h>
Haojian Zhuang2f7e8fa2009-12-04 09:41:28 -050021#include <mach/addr-map.h>
22#include <mach/regs-apbc.h>
23#include <mach/regs-apmu.h>
24#include <mach/cputype.h>
25#include <mach/irqs.h>
Haojian Zhuangf4557872010-04-28 15:24:24 -040026#include <mach/dma.h>
Haojian Zhuang2f7e8fa2009-12-04 09:41:28 -050027#include <mach/mfp.h>
Haojian Zhuang16144bf2010-01-25 06:03:54 -050028#include <mach/gpio.h>
Haojian Zhuang2f7e8fa2009-12-04 09:41:28 -050029#include <mach/devices.h>
Eric Miao27287012010-07-15 22:22:33 +080030#include <mach/mmp2.h>
Haojian Zhuang2f7e8fa2009-12-04 09:41:28 -050031
32#include "common.h"
33#include "clock.h"
34
35#define MFPR_VIRT_BASE (APB_VIRT_BASE + 0x1e000)
36
Haojian Zhuang16144bf2010-01-25 06:03:54 -050037#define APMASK(i) (GPIO_REGS_VIRT + BANK_OFF(i) + 0x9c)
38
Haojian Zhuang247b4592010-01-25 06:03:25 -050039static struct mfp_addr_map mmp2_addr_map[] __initdata = {
Haojian Zhuang7f394032010-04-28 15:18:59 -040040
41 MFP_ADDR_X(GPIO0, GPIO58, 0x54),
42 MFP_ADDR_X(GPIO59, GPIO73, 0x280),
43 MFP_ADDR_X(GPIO74, GPIO101, 0x170),
44
45 MFP_ADDR(GPIO102, 0x0),
46 MFP_ADDR(GPIO103, 0x4),
47 MFP_ADDR(GPIO104, 0x1fc),
48 MFP_ADDR(GPIO105, 0x1f8),
49 MFP_ADDR(GPIO106, 0x1f4),
50 MFP_ADDR(GPIO107, 0x1f0),
51 MFP_ADDR(GPIO108, 0x21c),
52 MFP_ADDR(GPIO109, 0x218),
53 MFP_ADDR(GPIO110, 0x214),
54 MFP_ADDR(GPIO111, 0x200),
55 MFP_ADDR(GPIO112, 0x244),
56 MFP_ADDR(GPIO113, 0x25c),
57 MFP_ADDR(GPIO114, 0x164),
58 MFP_ADDR_X(GPIO115, GPIO122, 0x260),
59
60 MFP_ADDR(GPIO123, 0x148),
61 MFP_ADDR_X(GPIO124, GPIO141, 0xc),
62
63 MFP_ADDR(GPIO142, 0x8),
64 MFP_ADDR_X(GPIO143, GPIO151, 0x220),
65 MFP_ADDR_X(GPIO152, GPIO153, 0x248),
66 MFP_ADDR_X(GPIO154, GPIO155, 0x254),
67 MFP_ADDR_X(GPIO156, GPIO159, 0x14c),
68
69 MFP_ADDR(GPIO160, 0x250),
70 MFP_ADDR(GPIO161, 0x210),
71 MFP_ADDR(GPIO162, 0x20c),
72 MFP_ADDR(GPIO163, 0x208),
73 MFP_ADDR(GPIO164, 0x204),
74 MFP_ADDR(GPIO165, 0x1ec),
75 MFP_ADDR(GPIO166, 0x1e8),
76 MFP_ADDR(GPIO167, 0x1e4),
77 MFP_ADDR(GPIO168, 0x1e0),
78
79 MFP_ADDR_X(TWSI1_SCL, TWSI1_SDA, 0x140),
80 MFP_ADDR_X(TWSI4_SCL, TWSI4_SDA, 0x2bc),
81
Haojian Zhuang247b4592010-01-25 06:03:25 -050082 MFP_ADDR(PMIC_INT, 0x2c4),
Haojian Zhuang7f394032010-04-28 15:18:59 -040083 MFP_ADDR(CLK_REQ, 0x160),
Haojian Zhuang247b4592010-01-25 06:03:25 -050084
85 MFP_ADDR_END,
86};
87
Haojian Zhuangdf0c3822010-02-03 10:01:18 -050088void mmp2_clear_pmic_int(void)
89{
Arnd Bergmann97b09da2011-10-01 22:03:45 +020090 void __iomem *mfpr_pmic;
91 unsigned long data;
Haojian Zhuangdf0c3822010-02-03 10:01:18 -050092
93 mfpr_pmic = APB_VIRT_BASE + 0x1e000 + 0x2c4;
94 data = __raw_readl(mfpr_pmic);
95 __raw_writel(data | (1 << 6), mfpr_pmic);
96 __raw_writel(data, mfpr_pmic);
97}
98
Haojian Zhuang16144bf2010-01-25 06:03:54 -050099static void __init mmp2_init_gpio(void)
100{
101 int i;
102
103 /* enable GPIO clock */
104 __raw_writel(APBC_APBCLK | APBC_FNCLK, APBC_MMP2_GPIO);
105
106 /* unmask GPIO edge detection for all 6 banks -- APMASKx */
107 for (i = 0; i < 6; i++)
108 __raw_writel(0xffffffff, APMASK(i));
109
110 pxa_init_gpio(IRQ_MMP2_GPIO, 0, 167, NULL);
111}
112
113void __init mmp2_init_irq(void)
114{
115 mmp2_init_icu();
116 mmp2_init_gpio();
117}
118
Zhangfei Gao5382f412010-09-29 16:18:51 -0400119static void sdhc_clk_enable(struct clk *clk)
120{
121 uint32_t clk_rst;
122
123 clk_rst = __raw_readl(clk->clk_rst);
124 clk_rst |= clk->enable_val;
125 __raw_writel(clk_rst, clk->clk_rst);
126}
127
128static void sdhc_clk_disable(struct clk *clk)
129{
130 uint32_t clk_rst;
131
132 clk_rst = __raw_readl(clk->clk_rst);
133 clk_rst &= ~clk->enable_val;
134 __raw_writel(clk_rst, clk->clk_rst);
135}
136
137struct clkops sdhc_clk_ops = {
138 .enable = sdhc_clk_enable,
139 .disable = sdhc_clk_disable,
140};
141
Haojian Zhuang2f7e8fa2009-12-04 09:41:28 -0500142/* APB peripheral clocks */
143static APBC_CLK(uart1, MMP2_UART1, 1, 26000000);
144static APBC_CLK(uart2, MMP2_UART2, 1, 26000000);
145static APBC_CLK(uart3, MMP2_UART3, 1, 26000000);
146static APBC_CLK(uart4, MMP2_UART4, 1, 26000000);
147static APBC_CLK(twsi1, MMP2_TWSI1, 0, 26000000);
148static APBC_CLK(twsi2, MMP2_TWSI2, 0, 26000000);
149static APBC_CLK(twsi3, MMP2_TWSI3, 0, 26000000);
150static APBC_CLK(twsi4, MMP2_TWSI4, 0, 26000000);
151static APBC_CLK(twsi5, MMP2_TWSI5, 0, 26000000);
152static APBC_CLK(twsi6, MMP2_TWSI6, 0, 26000000);
Haojian Zhuang2f7e8fa2009-12-04 09:41:28 -0500153
154static APMU_CLK(nand, NAND, 0xbf, 100000000);
Zhangfei Gao5382f412010-09-29 16:18:51 -0400155static APMU_CLK_OPS(sdh0, SDH0, 0x1b, 200000000, &sdhc_clk_ops);
156static APMU_CLK_OPS(sdh1, SDH1, 0x1b, 200000000, &sdhc_clk_ops);
157static APMU_CLK_OPS(sdh2, SDH2, 0x1b, 200000000, &sdhc_clk_ops);
158static APMU_CLK_OPS(sdh3, SDH3, 0x1b, 200000000, &sdhc_clk_ops);
Haojian Zhuang2f7e8fa2009-12-04 09:41:28 -0500159
160static struct clk_lookup mmp2_clkregs[] = {
161 INIT_CLKREG(&clk_uart1, "pxa2xx-uart.0", NULL),
162 INIT_CLKREG(&clk_uart2, "pxa2xx-uart.1", NULL),
163 INIT_CLKREG(&clk_uart3, "pxa2xx-uart.2", NULL),
164 INIT_CLKREG(&clk_uart4, "pxa2xx-uart.3", NULL),
165 INIT_CLKREG(&clk_twsi1, "pxa2xx-i2c.0", NULL),
166 INIT_CLKREG(&clk_twsi2, "pxa2xx-i2c.1", NULL),
167 INIT_CLKREG(&clk_twsi3, "pxa2xx-i2c.2", NULL),
168 INIT_CLKREG(&clk_twsi4, "pxa2xx-i2c.3", NULL),
169 INIT_CLKREG(&clk_twsi5, "pxa2xx-i2c.4", NULL),
170 INIT_CLKREG(&clk_twsi6, "pxa2xx-i2c.5", NULL),
171 INIT_CLKREG(&clk_nand, "pxa3xx-nand", NULL),
Zhangfei Gao6f984f32011-06-08 17:41:59 +0800172 INIT_CLKREG(&clk_sdh0, "sdhci-pxav3.0", "PXA-SDHCLK"),
173 INIT_CLKREG(&clk_sdh1, "sdhci-pxav3.1", "PXA-SDHCLK"),
174 INIT_CLKREG(&clk_sdh2, "sdhci-pxav3.2", "PXA-SDHCLK"),
175 INIT_CLKREG(&clk_sdh3, "sdhci-pxav3.3", "PXA-SDHCLK"),
Haojian Zhuang2f7e8fa2009-12-04 09:41:28 -0500176};
177
178static int __init mmp2_init(void)
179{
180 if (cpu_is_mmp2()) {
Haojian Zhuang66b19642010-04-28 10:59:45 -0400181#ifdef CONFIG_CACHE_TAUROS2
182 tauros2_init();
183#endif
Haojian Zhuang2f7e8fa2009-12-04 09:41:28 -0500184 mfp_init_base(MFPR_VIRT_BASE);
Haojian Zhuang247b4592010-01-25 06:03:25 -0500185 mfp_init_addr(mmp2_addr_map);
Haojian Zhuangf4557872010-04-28 15:24:24 -0400186 pxa_init_dma(IRQ_MMP2_DMA_RIQ, 16);
Haojian Zhuange5988632010-04-28 10:48:24 -0400187 clkdev_add_table(ARRAY_AND_SIZE(mmp2_clkregs));
Haojian Zhuang2f7e8fa2009-12-04 09:41:28 -0500188 }
189
190 return 0;
191}
192postcore_initcall(mmp2_init);
193
Eric Miao4d4a3392010-07-15 21:54:20 +0800194static void __init mmp2_timer_init(void)
195{
196 unsigned long clk_rst;
197
198 __raw_writel(APBC_APBCLK | APBC_RST, APBC_MMP2_TIMERS);
199
200 /*
201 * enable bus/functional clock, enable 6.5MHz (divider 4),
202 * release reset
203 */
204 clk_rst = APBC_APBCLK | APBC_FNCLK | APBC_FNCLKSEL(1);
205 __raw_writel(clk_rst, APBC_MMP2_TIMERS);
206
207 timer_init(IRQ_MMP2_TIMER1);
208}
209
210struct sys_timer mmp2_timer = {
211 .init = mmp2_timer_init,
212};
213
Haojian Zhuang2f7e8fa2009-12-04 09:41:28 -0500214/* on-chip devices */
215MMP2_DEVICE(uart1, "pxa2xx-uart", 0, UART1, 0xd4030000, 0x30, 4, 5);
216MMP2_DEVICE(uart2, "pxa2xx-uart", 1, UART2, 0xd4017000, 0x30, 20, 21);
217MMP2_DEVICE(uart3, "pxa2xx-uart", 2, UART3, 0xd4018000, 0x30, 22, 23);
218MMP2_DEVICE(uart4, "pxa2xx-uart", 3, UART4, 0xd4016000, 0x30, 18, 19);
219MMP2_DEVICE(twsi1, "pxa2xx-i2c", 0, TWSI1, 0xd4011000, 0x70);
220MMP2_DEVICE(twsi2, "pxa2xx-i2c", 1, TWSI2, 0xd4031000, 0x70);
221MMP2_DEVICE(twsi3, "pxa2xx-i2c", 2, TWSI3, 0xd4032000, 0x70);
222MMP2_DEVICE(twsi4, "pxa2xx-i2c", 3, TWSI4, 0xd4033000, 0x70);
223MMP2_DEVICE(twsi5, "pxa2xx-i2c", 4, TWSI5, 0xd4033800, 0x70);
224MMP2_DEVICE(twsi6, "pxa2xx-i2c", 5, TWSI6, 0xd4034000, 0x70);
225MMP2_DEVICE(nand, "pxa3xx-nand", -1, NAND, 0xd4283000, 0x100, 28, 29);
Zhangfei Gao6f984f32011-06-08 17:41:59 +0800226MMP2_DEVICE(sdh0, "sdhci-pxav3", 0, MMC, 0xd4280000, 0x120);
227MMP2_DEVICE(sdh1, "sdhci-pxav3", 1, MMC2, 0xd4280800, 0x120);
228MMP2_DEVICE(sdh2, "sdhci-pxav3", 2, MMC3, 0xd4281000, 0x120);
229MMP2_DEVICE(sdh3, "sdhci-pxav3", 3, MMC4, 0xd4281800, 0x120);
Haojian Zhuang2f7e8fa2009-12-04 09:41:28 -0500230