]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/blob - arch/arm/mach-iop32x/glantank.c
treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152
[mirror_ubuntu-eoan-kernel.git] / arch / arm / mach-iop32x / glantank.c
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * arch/arm/mach-iop32x/glantank.c
4 *
5 * Board support code for the GLAN Tank.
6 *
7 * Copyright (C) 2006, 2007 Martin Michlmayr <tbm@cyrius.com>
8 * Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org>
9 */
10
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 <mach/hardware.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>
32 #include <mach/time.h>
33 #include "gpio-iop32x.h"
34
35 /*
36 * GLAN Tank timer tick configuration.
37 */
38 static void __init glantank_timer_init(void)
39 {
40 /* 33.333 MHz crystal. */
41 iop_init_time(200000000);
42 }
43
44
45 /*
46 * GLAN Tank I/O.
47 */
48 static struct map_desc glantank_io_desc[] __initdata = {
49 { /* on-board devices */
50 .virtual = GLANTANK_UART,
51 .pfn = __phys_to_pfn(GLANTANK_UART),
52 .length = 0x00100000,
53 .type = MT_DEVICE
54 },
55 };
56
57 void __init glantank_map_io(void)
58 {
59 iop3xx_map_io();
60 iotable_init(glantank_io_desc, ARRAY_SIZE(glantank_io_desc));
61 }
62
63
64 /*
65 * GLAN Tank PCI.
66 */
67 #define INTA IRQ_IOP32X_XINT0
68 #define INTB IRQ_IOP32X_XINT1
69 #define INTC IRQ_IOP32X_XINT2
70 #define INTD IRQ_IOP32X_XINT3
71
72 static int __init
73 glantank_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
74 {
75 static int pci_irq_table[][4] = {
76 /*
77 * PCI IDSEL/INTPIN->INTLINE
78 * A B C D
79 */
80 {INTD, INTD, INTD, INTD}, /* UART (8250) */
81 {INTA, INTA, INTA, INTA}, /* Ethernet (E1000) */
82 {INTB, INTB, INTB, INTB}, /* IDE (AEC6280R) */
83 {INTC, INTC, INTC, INTC}, /* USB (NEC) */
84 };
85
86 BUG_ON(pin < 1 || pin > 4);
87
88 return pci_irq_table[slot % 4][pin - 1];
89 }
90
91 static struct hw_pci glantank_pci __initdata = {
92 .nr_controllers = 1,
93 .ops = &iop3xx_ops,
94 .setup = iop3xx_pci_setup,
95 .preinit = iop3xx_pci_preinit,
96 .map_irq = glantank_pci_map_irq,
97 };
98
99 static int __init glantank_pci_init(void)
100 {
101 if (machine_is_glantank())
102 pci_common_init(&glantank_pci);
103
104 return 0;
105 }
106
107 subsys_initcall(glantank_pci_init);
108
109
110 /*
111 * GLAN Tank machine initialization.
112 */
113 static struct physmap_flash_data glantank_flash_data = {
114 .width = 2,
115 };
116
117 static struct resource glantank_flash_resource = {
118 .start = 0xf0000000,
119 .end = 0xf007ffff,
120 .flags = IORESOURCE_MEM,
121 };
122
123 static struct platform_device glantank_flash_device = {
124 .name = "physmap-flash",
125 .id = 0,
126 .dev = {
127 .platform_data = &glantank_flash_data,
128 },
129 .num_resources = 1,
130 .resource = &glantank_flash_resource,
131 };
132
133 static struct plat_serial8250_port glantank_serial_port[] = {
134 {
135 .mapbase = GLANTANK_UART,
136 .membase = (char *)GLANTANK_UART,
137 .irq = IRQ_IOP32X_XINT3,
138 .flags = UPF_SKIP_TEST,
139 .iotype = UPIO_MEM,
140 .regshift = 0,
141 .uartclk = 1843200,
142 },
143 { },
144 };
145
146 static struct resource glantank_uart_resource = {
147 .start = GLANTANK_UART,
148 .end = GLANTANK_UART + 7,
149 .flags = IORESOURCE_MEM,
150 };
151
152 static struct platform_device glantank_serial_device = {
153 .name = "serial8250",
154 .id = PLAT8250_DEV_PLATFORM,
155 .dev = {
156 .platform_data = glantank_serial_port,
157 },
158 .num_resources = 1,
159 .resource = &glantank_uart_resource,
160 };
161
162 static struct f75375s_platform_data glantank_f75375s = {
163 .pwm = { 255, 255 },
164 .pwm_enable = { 0, 0 },
165 };
166
167 static struct i2c_board_info __initdata glantank_i2c_devices[] = {
168 {
169 I2C_BOARD_INFO("rs5c372a", 0x32),
170 },
171 {
172 I2C_BOARD_INFO("f75375", 0x2e),
173 .platform_data = &glantank_f75375s,
174 },
175 };
176
177 static void glantank_power_off(void)
178 {
179 __raw_writeb(0x01, IOMEM(0xfe8d0004));
180
181 while (1)
182 ;
183 }
184
185 static void __init glantank_init_machine(void)
186 {
187 register_iop32x_gpio();
188 platform_device_register(&iop3xx_i2c0_device);
189 platform_device_register(&iop3xx_i2c1_device);
190 platform_device_register(&glantank_flash_device);
191 platform_device_register(&glantank_serial_device);
192 platform_device_register(&iop3xx_dma_0_channel);
193 platform_device_register(&iop3xx_dma_1_channel);
194
195 i2c_register_board_info(0, glantank_i2c_devices,
196 ARRAY_SIZE(glantank_i2c_devices));
197
198 pm_power_off = glantank_power_off;
199 }
200
201 MACHINE_START(GLANTANK, "GLAN Tank")
202 /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
203 .atag_offset = 0x100,
204 .map_io = glantank_map_io,
205 .init_irq = iop32x_init_irq,
206 .init_time = glantank_timer_init,
207 .init_machine = glantank_init_machine,
208 .restart = iop3xx_restart,
209 MACHINE_END