ARM: integrator: restore static map on the CP
[deliverable/linux.git] / arch / arm / mach-iop32x / em7210.c
CommitLineData
a8135fcf
AP
1/*
2 * arch/arm/mach-iop32x/em7210.c
3 *
4 * Board support code for the Lanner EM7210 platforms.
5 *
6 * Based on arch/arm/mach-iop32x/iq31244.c file.
7 *
8 * Copyright (C) 2007 Arnaud Patard <arnaud.patard@rtp-net.org>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13 *
14 */
15
16#include <linux/mm.h>
17#include <linux/init.h>
18#include <linux/kernel.h>
19#include <linux/pci.h>
20#include <linux/pm.h>
21#include <linux/serial_core.h>
22#include <linux/serial_8250.h>
23#include <linux/mtd/physmap.h>
24#include <linux/platform_device.h>
fe885fa2 25#include <linux/i2c.h>
a09e64fb 26#include <mach/hardware.h>
a8135fcf
AP
27#include <linux/io.h>
28#include <linux/irq.h>
29#include <asm/mach/arch.h>
30#include <asm/mach/map.h>
31#include <asm/mach/pci.h>
32#include <asm/mach/time.h>
33#include <asm/mach-types.h>
a09e64fb 34#include <mach/time.h>
7b85b867 35#include "gpio-iop32x.h"
a8135fcf
AP
36
37static void __init em7210_timer_init(void)
38{
39 /* http://www.kwaak.net/fotos/fotos-nas/slide_24.html */
40 /* 33.333 MHz crystal. */
41 iop_init_time(200000000);
42}
43
fe885fa2
AP
44/*
45 * EM7210 RTC
46 */
47static struct i2c_board_info __initdata em7210_i2c_devices[] = {
48 {
3760f736 49 I2C_BOARD_INFO("rs5c372a", 0x32),
fe885fa2
AP
50 },
51};
a8135fcf
AP
52
53/*
54 * EM7210 I/O
55 */
56static struct map_desc em7210_io_desc[] __initdata = {
57 { /* on-board devices */
58 .virtual = IQ31244_UART,
59 .pfn = __phys_to_pfn(IQ31244_UART),
60 .length = 0x00100000,
61 .type = MT_DEVICE,
62 },
63};
64
65void __init em7210_map_io(void)
66{
67 iop3xx_map_io();
68 iotable_init(em7210_io_desc, ARRAY_SIZE(em7210_io_desc));
69}
70
71
72/*
73 * EM7210 PCI
74 */
75#define INTA IRQ_IOP32X_XINT0
76#define INTB IRQ_IOP32X_XINT1
77#define INTC IRQ_IOP32X_XINT2
78#define INTD IRQ_IOP32X_XINT3
79
80static int __init
d5341942 81em7210_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
a8135fcf
AP
82{
83 static int pci_irq_table[][4] = {
84 /*
85 * PCI IDSEL/INTPIN->INTLINE
86 * A B C D
87 */
88 {INTB, INTB, INTB, INTB}, /* console / uart */
89 {INTA, INTA, INTA, INTA}, /* 1st 82541 */
90 {INTD, INTD, INTD, INTD}, /* 2nd 82541 */
91 {INTC, INTC, INTC, INTC}, /* GD31244 */
92 {INTD, INTA, INTA, INTA}, /* mini-PCI */
93 {INTD, INTC, INTA, INTA}, /* NEC USB */
94 };
95
96 if (pin < 1 || pin > 4)
97 return -1;
98
99 return pci_irq_table[slot % 6][pin - 1];
100}
101
102static struct hw_pci em7210_pci __initdata = {
a8135fcf 103 .nr_controllers = 1,
c23bfc38 104 .ops = &iop3xx_ops,
a8135fcf
AP
105 .setup = iop3xx_pci_setup,
106 .preinit = iop3xx_pci_preinit,
a8135fcf
AP
107 .map_irq = em7210_pci_map_irq,
108};
109
110static int __init em7210_pci_init(void)
111{
112 if (machine_is_em7210())
113 pci_common_init(&em7210_pci);
114
115 return 0;
116}
117
118subsys_initcall(em7210_pci_init);
119
120
121/*
122 * EM7210 Flash
123 */
124static struct physmap_flash_data em7210_flash_data = {
125 .width = 2,
126};
127
128static struct resource em7210_flash_resource = {
129 .start = 0xf0000000,
130 .end = 0xf1ffffff,
131 .flags = IORESOURCE_MEM,
132};
133
134static struct platform_device em7210_flash_device = {
135 .name = "physmap-flash",
136 .id = 0,
137 .dev = {
138 .platform_data = &em7210_flash_data,
139 },
140 .num_resources = 1,
141 .resource = &em7210_flash_resource,
142};
143
144
145/*
146 * EM7210 UART
147 * The physical address of the serial port is 0xfe800000,
148 * so it can be used for physical and virtual address.
149 */
150static struct plat_serial8250_port em7210_serial_port[] = {
151 {
152 .mapbase = IQ31244_UART,
153 .membase = (char *)IQ31244_UART,
154 .irq = IRQ_IOP32X_XINT1,
155 .flags = UPF_SKIP_TEST,
156 .iotype = UPIO_MEM,
157 .regshift = 0,
158 .uartclk = 1843200,
159 },
160 { },
161};
162
163static struct resource em7210_uart_resource = {
164 .start = IQ31244_UART,
165 .end = IQ31244_UART + 7,
166 .flags = IORESOURCE_MEM,
167};
168
169static struct platform_device em7210_serial_device = {
170 .name = "serial8250",
171 .id = PLAT8250_DEV_PLATFORM,
172 .dev = {
173 .platform_data = em7210_serial_port,
174 },
175 .num_resources = 1,
176 .resource = &em7210_uart_resource,
177};
178
179void em7210_power_off(void)
180{
181 *IOP3XX_GPOE &= 0xfe;
182 *IOP3XX_GPOD |= 0x01;
183}
184
185static void __init em7210_init_machine(void)
186{
7b85b867 187 register_iop32x_gpio();
a8135fcf
AP
188 platform_device_register(&em7210_serial_device);
189 platform_device_register(&iop3xx_i2c0_device);
190 platform_device_register(&iop3xx_i2c1_device);
191 platform_device_register(&em7210_flash_device);
192 platform_device_register(&iop3xx_dma_0_channel);
193 platform_device_register(&iop3xx_dma_1_channel);
194
fe885fa2
AP
195 i2c_register_board_info(0, em7210_i2c_devices,
196 ARRAY_SIZE(em7210_i2c_devices));
197
a8135fcf
AP
198
199 pm_power_off = em7210_power_off;
200}
201
202MACHINE_START(EM7210, "Lanner EM7210")
1896746d 203 .atag_offset = 0x100,
a8135fcf
AP
204 .map_io = em7210_map_io,
205 .init_irq = iop32x_init_irq,
6bb27d73 206 .init_time = em7210_timer_init,
a8135fcf 207 .init_machine = em7210_init_machine,
bec92b1e 208 .restart = iop3xx_restart,
a8135fcf 209MACHINE_END
This page took 0.631202 seconds and 5 git commands to generate.