blob: 493de4fd8b2ef9c8d5c3362a779a0f6b857c3435 [file] [log] [blame]
Thomas Gleixnerd2912cb2019-06-04 10:11:33 +02001// SPDX-License-Identifier: GPL-2.0-only
Arnaud Patarda8135fc2007-07-15 20:12:23 +01002/*
3 * arch/arm/mach-iop32x/em7210.c
4 *
5 * Board support code for the Lanner EM7210 platforms.
6 *
7 * Based on arch/arm/mach-iop32x/iq31244.c file.
8 *
9 * Copyright (C) 2007 Arnaud Patard <arnaud.patard@rtp-net.org>
Arnaud Patarda8135fc2007-07-15 20:12:23 +010010 */
11
12#include <linux/mm.h>
13#include <linux/init.h>
14#include <linux/kernel.h>
15#include <linux/pci.h>
16#include <linux/pm.h>
17#include <linux/serial_core.h>
18#include <linux/serial_8250.h>
19#include <linux/mtd/physmap.h>
20#include <linux/platform_device.h>
Arnaud Patardfe885fa2007-07-18 21:04:00 +010021#include <linux/i2c.h>
Linus Walleijafbf1e12014-01-29 15:20:15 +010022#include <linux/gpio.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010023#include <mach/hardware.h>
Arnaud Patarda8135fc2007-07-15 20:12:23 +010024#include <linux/io.h>
25#include <linux/irq.h>
26#include <asm/mach/arch.h>
27#include <asm/mach/map.h>
28#include <asm/mach/pci.h>
29#include <asm/mach/time.h>
30#include <asm/mach-types.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010031#include <mach/time.h>
Linus Walleij7b85b862013-09-09 16:39:51 +020032#include "gpio-iop32x.h"
Arnaud Patarda8135fc2007-07-15 20:12:23 +010033
34static void __init em7210_timer_init(void)
35{
36 /* http://www.kwaak.net/fotos/fotos-nas/slide_24.html */
37 /* 33.333 MHz crystal. */
38 iop_init_time(200000000);
39}
40
Arnaud Patardfe885fa2007-07-18 21:04:00 +010041/*
42 * EM7210 RTC
43 */
44static struct i2c_board_info __initdata em7210_i2c_devices[] = {
45 {
Jean Delvare3760f732008-04-29 23:11:40 +020046 I2C_BOARD_INFO("rs5c372a", 0x32),
Arnaud Patardfe885fa2007-07-18 21:04:00 +010047 },
48};
Arnaud Patarda8135fc2007-07-15 20:12:23 +010049
50/*
51 * EM7210 I/O
52 */
53static struct map_desc em7210_io_desc[] __initdata = {
54 { /* on-board devices */
55 .virtual = IQ31244_UART,
56 .pfn = __phys_to_pfn(IQ31244_UART),
57 .length = 0x00100000,
58 .type = MT_DEVICE,
59 },
60};
61
62void __init em7210_map_io(void)
63{
64 iop3xx_map_io();
65 iotable_init(em7210_io_desc, ARRAY_SIZE(em7210_io_desc));
66}
67
68
69/*
70 * EM7210 PCI
71 */
72#define INTA IRQ_IOP32X_XINT0
73#define INTB IRQ_IOP32X_XINT1
74#define INTC IRQ_IOP32X_XINT2
75#define INTD IRQ_IOP32X_XINT3
76
77static int __init
Ralf Baechled5341942011-06-10 15:30:21 +010078em7210_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
Arnaud Patarda8135fc2007-07-15 20:12:23 +010079{
80 static int pci_irq_table[][4] = {
81 /*
82 * PCI IDSEL/INTPIN->INTLINE
83 * A B C D
84 */
85 {INTB, INTB, INTB, INTB}, /* console / uart */
86 {INTA, INTA, INTA, INTA}, /* 1st 82541 */
87 {INTD, INTD, INTD, INTD}, /* 2nd 82541 */
88 {INTC, INTC, INTC, INTC}, /* GD31244 */
89 {INTD, INTA, INTA, INTA}, /* mini-PCI */
90 {INTD, INTC, INTA, INTA}, /* NEC USB */
91 };
92
93 if (pin < 1 || pin > 4)
94 return -1;
95
96 return pci_irq_table[slot % 6][pin - 1];
97}
98
99static struct hw_pci em7210_pci __initdata = {
Arnaud Patarda8135fc2007-07-15 20:12:23 +0100100 .nr_controllers = 1,
Russell Kingc23bfc32012-03-10 12:49:16 +0000101 .ops = &iop3xx_ops,
Arnaud Patarda8135fc2007-07-15 20:12:23 +0100102 .setup = iop3xx_pci_setup,
103 .preinit = iop3xx_pci_preinit,
Arnaud Patarda8135fc2007-07-15 20:12:23 +0100104 .map_irq = em7210_pci_map_irq,
105};
106
107static int __init em7210_pci_init(void)
108{
109 if (machine_is_em7210())
110 pci_common_init(&em7210_pci);
111
112 return 0;
113}
114
115subsys_initcall(em7210_pci_init);
116
117
118/*
119 * EM7210 Flash
120 */
121static struct physmap_flash_data em7210_flash_data = {
122 .width = 2,
123};
124
125static struct resource em7210_flash_resource = {
126 .start = 0xf0000000,
127 .end = 0xf1ffffff,
128 .flags = IORESOURCE_MEM,
129};
130
131static struct platform_device em7210_flash_device = {
132 .name = "physmap-flash",
133 .id = 0,
134 .dev = {
135 .platform_data = &em7210_flash_data,
136 },
137 .num_resources = 1,
138 .resource = &em7210_flash_resource,
139};
140
141
142/*
143 * EM7210 UART
144 * The physical address of the serial port is 0xfe800000,
145 * so it can be used for physical and virtual address.
146 */
147static struct plat_serial8250_port em7210_serial_port[] = {
148 {
149 .mapbase = IQ31244_UART,
150 .membase = (char *)IQ31244_UART,
151 .irq = IRQ_IOP32X_XINT1,
152 .flags = UPF_SKIP_TEST,
153 .iotype = UPIO_MEM,
154 .regshift = 0,
155 .uartclk = 1843200,
156 },
157 { },
158};
159
160static struct resource em7210_uart_resource = {
161 .start = IQ31244_UART,
162 .end = IQ31244_UART + 7,
163 .flags = IORESOURCE_MEM,
164};
165
166static struct platform_device em7210_serial_device = {
167 .name = "serial8250",
168 .id = PLAT8250_DEV_PLATFORM,
169 .dev = {
170 .platform_data = em7210_serial_port,
171 },
172 .num_resources = 1,
173 .resource = &em7210_uart_resource,
174};
175
Linus Walleijafbf1e12014-01-29 15:20:15 +0100176#define EM7210_HARDWARE_POWER 0
177
Arnaud Patarda8135fc2007-07-15 20:12:23 +0100178void em7210_power_off(void)
179{
Linus Walleijafbf1e12014-01-29 15:20:15 +0100180 int ret;
181
182 ret = gpio_direction_output(EM7210_HARDWARE_POWER, 1);
183 if (ret)
184 pr_crit("could not drive power off GPIO high\n");
Arnaud Patarda8135fc2007-07-15 20:12:23 +0100185}
186
Linus Walleijafbf1e12014-01-29 15:20:15 +0100187static int __init em7210_request_gpios(void)
188{
189 int ret;
190
191 if (!machine_is_em7210())
192 return 0;
193
194 ret = gpio_request(EM7210_HARDWARE_POWER, "power");
195 if (ret) {
196 pr_err("could not request power off GPIO\n");
197 return 0;
198 }
199
200 pm_power_off = em7210_power_off;
201
202 return 0;
203}
204device_initcall(em7210_request_gpios);
205
Arnaud Patarda8135fc2007-07-15 20:12:23 +0100206static void __init em7210_init_machine(void)
207{
Linus Walleij7b85b862013-09-09 16:39:51 +0200208 register_iop32x_gpio();
Arnaud Patarda8135fc2007-07-15 20:12:23 +0100209 platform_device_register(&em7210_serial_device);
210 platform_device_register(&iop3xx_i2c0_device);
211 platform_device_register(&iop3xx_i2c1_device);
212 platform_device_register(&em7210_flash_device);
213 platform_device_register(&iop3xx_dma_0_channel);
214 platform_device_register(&iop3xx_dma_1_channel);
215
Arnaud Patardfe885fa2007-07-18 21:04:00 +0100216 i2c_register_board_info(0, em7210_i2c_devices,
217 ARRAY_SIZE(em7210_i2c_devices));
Arnaud Patarda8135fc2007-07-15 20:12:23 +0100218}
219
220MACHINE_START(EM7210, "Lanner EM7210")
Nicolas Pitre18967462011-07-05 22:38:12 -0400221 .atag_offset = 0x100,
Arnaud Patarda8135fc2007-07-15 20:12:23 +0100222 .map_io = em7210_map_io,
223 .init_irq = iop32x_init_irq,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700224 .init_time = em7210_timer_init,
Arnaud Patarda8135fc2007-07-15 20:12:23 +0100225 .init_machine = em7210_init_machine,
Russell Kingbec92b12011-11-05 11:26:32 +0000226 .restart = iop3xx_restart,
Arnaud Patarda8135fc2007-07-15 20:12:23 +0100227MACHINE_END