Linux 5.6.13
[linux/fpc-iii.git] / arch / arm / mach-iop32x / glantank.c
blob2fe0f77d1f1d15af4f0549523968aa97ac0fa265
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * arch/arm/mach-iop32x/glantank.c
5 * Board support code for the GLAN Tank.
7 * Copyright (C) 2006, 2007 Martin Michlmayr <tbm@cyrius.com>
8 * Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org>
9 */
11 #include <linux/mm.h>
12 #include <linux/init.h>
13 #include <linux/f75375s.h>
14 #include <linux/kernel.h>
15 #include <linux/pci.h>
16 #include <linux/pm.h>
17 #include <linux/string.h>
18 #include <linux/serial_core.h>
19 #include <linux/serial_8250.h>
20 #include <linux/mtd/physmap.h>
21 #include <linux/i2c.h>
22 #include <linux/platform_device.h>
23 #include <linux/io.h>
24 #include <linux/gpio/machine.h>
25 #include <asm/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>
31 #include <asm/page.h>
33 #include "hardware.h"
34 #include "gpio-iop32x.h"
35 #include "irqs.h"
38 * GLAN Tank timer tick configuration.
40 static void __init glantank_timer_init(void)
42 /* 33.333 MHz crystal. */
43 iop_init_time(200000000);
48 * GLAN Tank I/O.
50 static struct map_desc glantank_io_desc[] __initdata = {
51 { /* on-board devices */
52 .virtual = GLANTANK_UART,
53 .pfn = __phys_to_pfn(GLANTANK_UART),
54 .length = 0x00100000,
55 .type = MT_DEVICE
59 void __init glantank_map_io(void)
61 iop3xx_map_io();
62 iotable_init(glantank_io_desc, ARRAY_SIZE(glantank_io_desc));
67 * GLAN Tank PCI.
69 #define INTA IRQ_IOP32X_XINT0
70 #define INTB IRQ_IOP32X_XINT1
71 #define INTC IRQ_IOP32X_XINT2
72 #define INTD IRQ_IOP32X_XINT3
74 static int __init
75 glantank_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
77 static int pci_irq_table[][4] = {
79 * PCI IDSEL/INTPIN->INTLINE
80 * A B C D
82 {INTD, INTD, INTD, INTD}, /* UART (8250) */
83 {INTA, INTA, INTA, INTA}, /* Ethernet (E1000) */
84 {INTB, INTB, INTB, INTB}, /* IDE (AEC6280R) */
85 {INTC, INTC, INTC, INTC}, /* USB (NEC) */
88 BUG_ON(pin < 1 || pin > 4);
90 return pci_irq_table[slot % 4][pin - 1];
93 static struct hw_pci glantank_pci __initdata = {
94 .nr_controllers = 1,
95 .ops = &iop3xx_ops,
96 .setup = iop3xx_pci_setup,
97 .preinit = iop3xx_pci_preinit,
98 .map_irq = glantank_pci_map_irq,
101 static int __init glantank_pci_init(void)
103 if (machine_is_glantank())
104 pci_common_init(&glantank_pci);
106 return 0;
109 subsys_initcall(glantank_pci_init);
113 * GLAN Tank machine initialization.
115 static struct physmap_flash_data glantank_flash_data = {
116 .width = 2,
119 static struct resource glantank_flash_resource = {
120 .start = 0xf0000000,
121 .end = 0xf007ffff,
122 .flags = IORESOURCE_MEM,
125 static struct platform_device glantank_flash_device = {
126 .name = "physmap-flash",
127 .id = 0,
128 .dev = {
129 .platform_data = &glantank_flash_data,
131 .num_resources = 1,
132 .resource = &glantank_flash_resource,
135 static struct plat_serial8250_port glantank_serial_port[] = {
137 .mapbase = GLANTANK_UART,
138 .membase = (char *)GLANTANK_UART,
139 .irq = IRQ_IOP32X_XINT3,
140 .flags = UPF_SKIP_TEST,
141 .iotype = UPIO_MEM,
142 .regshift = 0,
143 .uartclk = 1843200,
145 { },
148 static struct resource glantank_uart_resource = {
149 .start = GLANTANK_UART,
150 .end = GLANTANK_UART + 7,
151 .flags = IORESOURCE_MEM,
154 static struct platform_device glantank_serial_device = {
155 .name = "serial8250",
156 .id = PLAT8250_DEV_PLATFORM,
157 .dev = {
158 .platform_data = glantank_serial_port,
160 .num_resources = 1,
161 .resource = &glantank_uart_resource,
164 static struct f75375s_platform_data glantank_f75375s = {
165 .pwm = { 255, 255 },
166 .pwm_enable = { 0, 0 },
169 static struct i2c_board_info __initdata glantank_i2c_devices[] = {
171 I2C_BOARD_INFO("rs5c372a", 0x32),
174 I2C_BOARD_INFO("f75375", 0x2e),
175 .platform_data = &glantank_f75375s,
179 static void glantank_power_off(void)
181 __raw_writeb(0x01, IOMEM(0xfe8d0004));
183 while (1)
187 static void __init glantank_init_machine(void)
189 register_iop32x_gpio();
190 gpiod_add_lookup_table(&iop3xx_i2c0_gpio_lookup);
191 gpiod_add_lookup_table(&iop3xx_i2c1_gpio_lookup);
192 platform_device_register(&iop3xx_i2c0_device);
193 platform_device_register(&iop3xx_i2c1_device);
194 platform_device_register(&glantank_flash_device);
195 platform_device_register(&glantank_serial_device);
196 platform_device_register(&iop3xx_dma_0_channel);
197 platform_device_register(&iop3xx_dma_1_channel);
199 i2c_register_board_info(0, glantank_i2c_devices,
200 ARRAY_SIZE(glantank_i2c_devices));
202 pm_power_off = glantank_power_off;
205 MACHINE_START(GLANTANK, "GLAN Tank")
206 /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
207 .atag_offset = 0x100,
208 .map_io = glantank_map_io,
209 .init_irq = iop32x_init_irq,
210 .init_time = glantank_timer_init,
211 .init_machine = glantank_init_machine,
212 .restart = iop3xx_restart,
213 MACHINE_END