1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * arch/arm/mach-iop32x/glantank.c
5 * Board support code for the GLAN Tank.
12 #include <linux/init.h>
13 #include <linux/f75375s.h>
14 #include <linux/kernel.h>
15 #include <linux/pci.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>
24 #include <linux/gpio/machine.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>
34 #include "gpio-iop32x.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);
50 static struct map_desc glantank_io_desc[] __initdata = {
51 { /* on-board devices */
52 .virtual = GLANTANK_UART,
53 .pfn = __phys_to_pfn(GLANTANK_UART),
59 void __init glantank_map_io(void)
62 iotable_init(glantank_io_desc, ARRAY_SIZE(glantank_io_desc));
69 #define INTA IRQ_IOP32X_XINT0
70 #define INTB IRQ_IOP32X_XINT1
71 #define INTC IRQ_IOP32X_XINT2
72 #define INTD IRQ_IOP32X_XINT3
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
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 = {
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);
109 subsys_initcall(glantank_pci_init);
113 * GLAN Tank machine initialization.
115 static struct physmap_flash_data glantank_flash_data = {
119 static struct resource glantank_flash_resource = {
122 .flags = IORESOURCE_MEM,
125 static struct platform_device glantank_flash_device = {
126 .name = "physmap-flash",
129 .platform_data = &glantank_flash_data,
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,
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,
158 .platform_data = glantank_serial_port,
161 .resource = &glantank_uart_resource,
164 static struct f75375s_platform_data glantank_f75375s = {
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));
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")
207 .atag_offset = 0x100,
208 .nr_irqs = IOP32X_NR_IRQS,
209 .map_io = glantank_map_io,
210 .init_irq = iop32x_init_irq,
211 .init_time = glantank_timer_init,
212 .init_machine = glantank_init_machine,
213 .restart = iop3xx_restart,