1 // SPDX-License-Identifier: GPL-2.0-only
3 * arch/arm/mach-iop32x/em7210.c
5 * Board support code for the Lanner EM7210 platforms.
7 * Based on arch/arm/mach-iop32x/iq31244.c file.
9 * Copyright (C) 2007 Arnaud Patard <arnaud.patard@rtp-net.org>
13 #include <linux/init.h>
14 #include <linux/kernel.h>
15 #include <linux/pci.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>
21 #include <linux/i2c.h>
22 #include <linux/gpio.h>
23 #include <linux/gpio/machine.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>
33 #include "gpio-iop32x.h"
36 static void __init em7210_timer_init(void)
38 /* http://www.kwaak.net/fotos/fotos-nas/slide_24.html */
39 /* 33.333 MHz crystal. */
40 iop_init_time(200000000);
46 static struct i2c_board_info __initdata em7210_i2c_devices[] = {
48 I2C_BOARD_INFO("rs5c372a", 0x32),
55 static struct map_desc em7210_io_desc[] __initdata = {
56 { /* on-board devices */
57 .virtual = IQ31244_UART,
58 .pfn = __phys_to_pfn(IQ31244_UART),
64 void __init em7210_map_io(void)
67 iotable_init(em7210_io_desc, ARRAY_SIZE(em7210_io_desc));
74 #define INTA IRQ_IOP32X_XINT0
75 #define INTB IRQ_IOP32X_XINT1
76 #define INTC IRQ_IOP32X_XINT2
77 #define INTD IRQ_IOP32X_XINT3
80 em7210_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
82 static int pci_irq_table[][4] = {
84 * PCI IDSEL/INTPIN->INTLINE
87 {INTB, INTB, INTB, INTB}, /* console / uart */
88 {INTA, INTA, INTA, INTA}, /* 1st 82541 */
89 {INTD, INTD, INTD, INTD}, /* 2nd 82541 */
90 {INTC, INTC, INTC, INTC}, /* GD31244 */
91 {INTD, INTA, INTA, INTA}, /* mini-PCI */
92 {INTD, INTC, INTA, INTA}, /* NEC USB */
95 if (pin < 1 || pin > 4)
98 return pci_irq_table[slot % 6][pin - 1];
101 static struct hw_pci em7210_pci __initdata = {
104 .setup = iop3xx_pci_setup,
105 .preinit = iop3xx_pci_preinit,
106 .map_irq = em7210_pci_map_irq,
109 static int __init em7210_pci_init(void)
111 if (machine_is_em7210())
112 pci_common_init(&em7210_pci);
117 subsys_initcall(em7210_pci_init);
123 static struct physmap_flash_data em7210_flash_data = {
127 static struct resource em7210_flash_resource = {
130 .flags = IORESOURCE_MEM,
133 static struct platform_device em7210_flash_device = {
134 .name = "physmap-flash",
137 .platform_data = &em7210_flash_data,
140 .resource = &em7210_flash_resource,
146 * The physical address of the serial port is 0xfe800000,
147 * so it can be used for physical and virtual address.
149 static struct plat_serial8250_port em7210_serial_port[] = {
151 .mapbase = IQ31244_UART,
152 .membase = (char *)IQ31244_UART,
153 .irq = IRQ_IOP32X_XINT1,
154 .flags = UPF_SKIP_TEST,
162 static struct resource em7210_uart_resource = {
163 .start = IQ31244_UART,
164 .end = IQ31244_UART + 7,
165 .flags = IORESOURCE_MEM,
168 static struct platform_device em7210_serial_device = {
169 .name = "serial8250",
170 .id = PLAT8250_DEV_PLATFORM,
172 .platform_data = em7210_serial_port,
175 .resource = &em7210_uart_resource,
178 #define EM7210_HARDWARE_POWER 0
180 void em7210_power_off(void)
184 ret = gpio_direction_output(EM7210_HARDWARE_POWER, 1);
186 pr_crit("could not drive power off GPIO high\n");
189 static int __init em7210_request_gpios(void)
193 if (!machine_is_em7210())
196 ret = gpio_request(EM7210_HARDWARE_POWER, "power");
198 pr_err("could not request power off GPIO\n");
202 pm_power_off = em7210_power_off;
206 device_initcall(em7210_request_gpios);
208 static void __init em7210_init_machine(void)
210 register_iop32x_gpio();
211 platform_device_register(&em7210_serial_device);
212 gpiod_add_lookup_table(&iop3xx_i2c0_gpio_lookup);
213 gpiod_add_lookup_table(&iop3xx_i2c1_gpio_lookup);
214 platform_device_register(&iop3xx_i2c0_device);
215 platform_device_register(&iop3xx_i2c1_device);
216 platform_device_register(&em7210_flash_device);
217 platform_device_register(&iop3xx_dma_0_channel);
218 platform_device_register(&iop3xx_dma_1_channel);
220 i2c_register_board_info(0, em7210_i2c_devices,
221 ARRAY_SIZE(em7210_i2c_devices));
224 MACHINE_START(EM7210, "Lanner EM7210")
225 .atag_offset = 0x100,
226 .map_io = em7210_map_io,
227 .init_irq = iop32x_init_irq,
228 .init_time = em7210_timer_init,
229 .init_machine = em7210_init_machine,
230 .restart = iop3xx_restart,