Haojian Zhuang | 2f7e8fa | 2009-12-04 09:41:28 -0500 | [diff] [blame] | 1 | /* |
| 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 Zhuang | 66b1964 | 2010-04-28 10:59:45 -0400 | [diff] [blame] | 18 | #include <asm/hardware/cache-tauros2.h> |
| 19 | |
Haojian Zhuang | 2f7e8fa | 2009-12-04 09:41:28 -0500 | [diff] [blame] | 20 | #include <mach/addr-map.h> |
| 21 | #include <mach/regs-apbc.h> |
| 22 | #include <mach/regs-apmu.h> |
| 23 | #include <mach/cputype.h> |
| 24 | #include <mach/irqs.h> |
Haojian Zhuang | f455787 | 2010-04-28 15:24:24 -0400 | [diff] [blame] | 25 | #include <mach/dma.h> |
Haojian Zhuang | 2f7e8fa | 2009-12-04 09:41:28 -0500 | [diff] [blame] | 26 | #include <mach/mfp.h> |
Haojian Zhuang | 16144bf | 2010-01-25 06:03:54 -0500 | [diff] [blame] | 27 | #include <mach/gpio.h> |
Haojian Zhuang | 2f7e8fa | 2009-12-04 09:41:28 -0500 | [diff] [blame] | 28 | #include <mach/devices.h> |
| 29 | |
| 30 | #include "common.h" |
| 31 | #include "clock.h" |
| 32 | |
| 33 | #define MFPR_VIRT_BASE (APB_VIRT_BASE + 0x1e000) |
| 34 | |
Haojian Zhuang | 16144bf | 2010-01-25 06:03:54 -0500 | [diff] [blame] | 35 | #define APMASK(i) (GPIO_REGS_VIRT + BANK_OFF(i) + 0x9c) |
| 36 | |
Haojian Zhuang | 247b459 | 2010-01-25 06:03:25 -0500 | [diff] [blame] | 37 | static struct mfp_addr_map mmp2_addr_map[] __initdata = { |
Haojian Zhuang | 7f39403 | 2010-04-28 15:18:59 -0400 | [diff] [blame] | 38 | |
| 39 | MFP_ADDR_X(GPIO0, GPIO58, 0x54), |
| 40 | MFP_ADDR_X(GPIO59, GPIO73, 0x280), |
| 41 | MFP_ADDR_X(GPIO74, GPIO101, 0x170), |
| 42 | |
| 43 | MFP_ADDR(GPIO102, 0x0), |
| 44 | MFP_ADDR(GPIO103, 0x4), |
| 45 | MFP_ADDR(GPIO104, 0x1fc), |
| 46 | MFP_ADDR(GPIO105, 0x1f8), |
| 47 | MFP_ADDR(GPIO106, 0x1f4), |
| 48 | MFP_ADDR(GPIO107, 0x1f0), |
| 49 | MFP_ADDR(GPIO108, 0x21c), |
| 50 | MFP_ADDR(GPIO109, 0x218), |
| 51 | MFP_ADDR(GPIO110, 0x214), |
| 52 | MFP_ADDR(GPIO111, 0x200), |
| 53 | MFP_ADDR(GPIO112, 0x244), |
| 54 | MFP_ADDR(GPIO113, 0x25c), |
| 55 | MFP_ADDR(GPIO114, 0x164), |
| 56 | MFP_ADDR_X(GPIO115, GPIO122, 0x260), |
| 57 | |
| 58 | MFP_ADDR(GPIO123, 0x148), |
| 59 | MFP_ADDR_X(GPIO124, GPIO141, 0xc), |
| 60 | |
| 61 | MFP_ADDR(GPIO142, 0x8), |
| 62 | MFP_ADDR_X(GPIO143, GPIO151, 0x220), |
| 63 | MFP_ADDR_X(GPIO152, GPIO153, 0x248), |
| 64 | MFP_ADDR_X(GPIO154, GPIO155, 0x254), |
| 65 | MFP_ADDR_X(GPIO156, GPIO159, 0x14c), |
| 66 | |
| 67 | MFP_ADDR(GPIO160, 0x250), |
| 68 | MFP_ADDR(GPIO161, 0x210), |
| 69 | MFP_ADDR(GPIO162, 0x20c), |
| 70 | MFP_ADDR(GPIO163, 0x208), |
| 71 | MFP_ADDR(GPIO164, 0x204), |
| 72 | MFP_ADDR(GPIO165, 0x1ec), |
| 73 | MFP_ADDR(GPIO166, 0x1e8), |
| 74 | MFP_ADDR(GPIO167, 0x1e4), |
| 75 | MFP_ADDR(GPIO168, 0x1e0), |
| 76 | |
| 77 | MFP_ADDR_X(TWSI1_SCL, TWSI1_SDA, 0x140), |
| 78 | MFP_ADDR_X(TWSI4_SCL, TWSI4_SDA, 0x2bc), |
| 79 | |
Haojian Zhuang | 247b459 | 2010-01-25 06:03:25 -0500 | [diff] [blame] | 80 | MFP_ADDR(PMIC_INT, 0x2c4), |
Haojian Zhuang | 7f39403 | 2010-04-28 15:18:59 -0400 | [diff] [blame] | 81 | MFP_ADDR(CLK_REQ, 0x160), |
Haojian Zhuang | 247b459 | 2010-01-25 06:03:25 -0500 | [diff] [blame] | 82 | |
| 83 | MFP_ADDR_END, |
| 84 | }; |
| 85 | |
Haojian Zhuang | df0c382 | 2010-02-03 10:01:18 -0500 | [diff] [blame] | 86 | void mmp2_clear_pmic_int(void) |
| 87 | { |
| 88 | unsigned long mfpr_pmic, data; |
| 89 | |
| 90 | mfpr_pmic = APB_VIRT_BASE + 0x1e000 + 0x2c4; |
| 91 | data = __raw_readl(mfpr_pmic); |
| 92 | __raw_writel(data | (1 << 6), mfpr_pmic); |
| 93 | __raw_writel(data, mfpr_pmic); |
| 94 | } |
| 95 | |
Haojian Zhuang | 16144bf | 2010-01-25 06:03:54 -0500 | [diff] [blame] | 96 | static void __init mmp2_init_gpio(void) |
| 97 | { |
| 98 | int i; |
| 99 | |
| 100 | /* enable GPIO clock */ |
| 101 | __raw_writel(APBC_APBCLK | APBC_FNCLK, APBC_MMP2_GPIO); |
| 102 | |
| 103 | /* unmask GPIO edge detection for all 6 banks -- APMASKx */ |
| 104 | for (i = 0; i < 6; i++) |
| 105 | __raw_writel(0xffffffff, APMASK(i)); |
| 106 | |
| 107 | pxa_init_gpio(IRQ_MMP2_GPIO, 0, 167, NULL); |
| 108 | } |
| 109 | |
| 110 | void __init mmp2_init_irq(void) |
| 111 | { |
| 112 | mmp2_init_icu(); |
| 113 | mmp2_init_gpio(); |
| 114 | } |
| 115 | |
Haojian Zhuang | 2f7e8fa | 2009-12-04 09:41:28 -0500 | [diff] [blame] | 116 | /* APB peripheral clocks */ |
| 117 | static APBC_CLK(uart1, MMP2_UART1, 1, 26000000); |
| 118 | static APBC_CLK(uart2, MMP2_UART2, 1, 26000000); |
| 119 | static APBC_CLK(uart3, MMP2_UART3, 1, 26000000); |
| 120 | static APBC_CLK(uart4, MMP2_UART4, 1, 26000000); |
| 121 | static APBC_CLK(twsi1, MMP2_TWSI1, 0, 26000000); |
| 122 | static APBC_CLK(twsi2, MMP2_TWSI2, 0, 26000000); |
| 123 | static APBC_CLK(twsi3, MMP2_TWSI3, 0, 26000000); |
| 124 | static APBC_CLK(twsi4, MMP2_TWSI4, 0, 26000000); |
| 125 | static APBC_CLK(twsi5, MMP2_TWSI5, 0, 26000000); |
| 126 | static APBC_CLK(twsi6, MMP2_TWSI6, 0, 26000000); |
| 127 | static APBC_CLK(rtc, MMP2_RTC, 0, 32768); |
| 128 | |
| 129 | static APMU_CLK(nand, NAND, 0xbf, 100000000); |
| 130 | |
| 131 | static struct clk_lookup mmp2_clkregs[] = { |
| 132 | INIT_CLKREG(&clk_uart1, "pxa2xx-uart.0", NULL), |
| 133 | INIT_CLKREG(&clk_uart2, "pxa2xx-uart.1", NULL), |
| 134 | INIT_CLKREG(&clk_uart3, "pxa2xx-uart.2", NULL), |
| 135 | INIT_CLKREG(&clk_uart4, "pxa2xx-uart.3", NULL), |
| 136 | INIT_CLKREG(&clk_twsi1, "pxa2xx-i2c.0", NULL), |
| 137 | INIT_CLKREG(&clk_twsi2, "pxa2xx-i2c.1", NULL), |
| 138 | INIT_CLKREG(&clk_twsi3, "pxa2xx-i2c.2", NULL), |
| 139 | INIT_CLKREG(&clk_twsi4, "pxa2xx-i2c.3", NULL), |
| 140 | INIT_CLKREG(&clk_twsi5, "pxa2xx-i2c.4", NULL), |
| 141 | INIT_CLKREG(&clk_twsi6, "pxa2xx-i2c.5", NULL), |
| 142 | INIT_CLKREG(&clk_nand, "pxa3xx-nand", NULL), |
| 143 | }; |
| 144 | |
| 145 | static int __init mmp2_init(void) |
| 146 | { |
| 147 | if (cpu_is_mmp2()) { |
Haojian Zhuang | 66b1964 | 2010-04-28 10:59:45 -0400 | [diff] [blame] | 148 | #ifdef CONFIG_CACHE_TAUROS2 |
| 149 | tauros2_init(); |
| 150 | #endif |
Haojian Zhuang | 2f7e8fa | 2009-12-04 09:41:28 -0500 | [diff] [blame] | 151 | mfp_init_base(MFPR_VIRT_BASE); |
Haojian Zhuang | 247b459 | 2010-01-25 06:03:25 -0500 | [diff] [blame] | 152 | mfp_init_addr(mmp2_addr_map); |
Haojian Zhuang | f455787 | 2010-04-28 15:24:24 -0400 | [diff] [blame] | 153 | pxa_init_dma(IRQ_MMP2_DMA_RIQ, 16); |
Haojian Zhuang | e598863 | 2010-04-28 10:48:24 -0400 | [diff] [blame] | 154 | clkdev_add_table(ARRAY_AND_SIZE(mmp2_clkregs)); |
Haojian Zhuang | 2f7e8fa | 2009-12-04 09:41:28 -0500 | [diff] [blame] | 155 | } |
| 156 | |
| 157 | return 0; |
| 158 | } |
| 159 | postcore_initcall(mmp2_init); |
| 160 | |
| 161 | /* on-chip devices */ |
| 162 | MMP2_DEVICE(uart1, "pxa2xx-uart", 0, UART1, 0xd4030000, 0x30, 4, 5); |
| 163 | MMP2_DEVICE(uart2, "pxa2xx-uart", 1, UART2, 0xd4017000, 0x30, 20, 21); |
| 164 | MMP2_DEVICE(uart3, "pxa2xx-uart", 2, UART3, 0xd4018000, 0x30, 22, 23); |
| 165 | MMP2_DEVICE(uart4, "pxa2xx-uart", 3, UART4, 0xd4016000, 0x30, 18, 19); |
| 166 | MMP2_DEVICE(twsi1, "pxa2xx-i2c", 0, TWSI1, 0xd4011000, 0x70); |
| 167 | MMP2_DEVICE(twsi2, "pxa2xx-i2c", 1, TWSI2, 0xd4031000, 0x70); |
| 168 | MMP2_DEVICE(twsi3, "pxa2xx-i2c", 2, TWSI3, 0xd4032000, 0x70); |
| 169 | MMP2_DEVICE(twsi4, "pxa2xx-i2c", 3, TWSI4, 0xd4033000, 0x70); |
| 170 | MMP2_DEVICE(twsi5, "pxa2xx-i2c", 4, TWSI5, 0xd4033800, 0x70); |
| 171 | MMP2_DEVICE(twsi6, "pxa2xx-i2c", 5, TWSI6, 0xd4034000, 0x70); |
| 172 | MMP2_DEVICE(nand, "pxa3xx-nand", -1, NAND, 0xd4283000, 0x100, 28, 29); |
| 173 | |