glantank.c (4757B)
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 <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> 32 33#include "hardware.h" 34#include "gpio-iop32x.h" 35#include "irqs.h" 36 37/* 38 * GLAN Tank timer tick configuration. 39 */ 40static void __init glantank_timer_init(void) 41{ 42 /* 33.333 MHz crystal. */ 43 iop_init_time(200000000); 44} 45 46 47/* 48 * GLAN Tank I/O. 49 */ 50static 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 56 }, 57}; 58 59void __init glantank_map_io(void) 60{ 61 iop3xx_map_io(); 62 iotable_init(glantank_io_desc, ARRAY_SIZE(glantank_io_desc)); 63} 64 65 66/* 67 * GLAN Tank PCI. 68 */ 69#define INTA IRQ_IOP32X_XINT0 70#define INTB IRQ_IOP32X_XINT1 71#define INTC IRQ_IOP32X_XINT2 72#define INTD IRQ_IOP32X_XINT3 73 74static int __init 75glantank_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) 76{ 77 static int pci_irq_table[][4] = { 78 /* 79 * PCI IDSEL/INTPIN->INTLINE 80 * A B C D 81 */ 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) */ 86 }; 87 88 BUG_ON(pin < 1 || pin > 4); 89 90 return pci_irq_table[slot % 4][pin - 1]; 91} 92 93static 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, 99}; 100 101static int __init glantank_pci_init(void) 102{ 103 if (machine_is_glantank()) 104 pci_common_init(&glantank_pci); 105 106 return 0; 107} 108 109subsys_initcall(glantank_pci_init); 110 111 112/* 113 * GLAN Tank machine initialization. 114 */ 115static struct physmap_flash_data glantank_flash_data = { 116 .width = 2, 117}; 118 119static struct resource glantank_flash_resource = { 120 .start = 0xf0000000, 121 .end = 0xf007ffff, 122 .flags = IORESOURCE_MEM, 123}; 124 125static struct platform_device glantank_flash_device = { 126 .name = "physmap-flash", 127 .id = 0, 128 .dev = { 129 .platform_data = &glantank_flash_data, 130 }, 131 .num_resources = 1, 132 .resource = &glantank_flash_resource, 133}; 134 135static struct plat_serial8250_port glantank_serial_port[] = { 136 { 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, 144 }, 145 { }, 146}; 147 148static struct resource glantank_uart_resource = { 149 .start = GLANTANK_UART, 150 .end = GLANTANK_UART + 7, 151 .flags = IORESOURCE_MEM, 152}; 153 154static struct platform_device glantank_serial_device = { 155 .name = "serial8250", 156 .id = PLAT8250_DEV_PLATFORM, 157 .dev = { 158 .platform_data = glantank_serial_port, 159 }, 160 .num_resources = 1, 161 .resource = &glantank_uart_resource, 162}; 163 164static struct f75375s_platform_data glantank_f75375s = { 165 .pwm = { 255, 255 }, 166 .pwm_enable = { 0, 0 }, 167}; 168 169static struct i2c_board_info __initdata glantank_i2c_devices[] = { 170 { 171 I2C_BOARD_INFO("rs5c372a", 0x32), 172 }, 173 { 174 I2C_BOARD_INFO("f75375", 0x2e), 175 .platform_data = &glantank_f75375s, 176 }, 177}; 178 179static void glantank_power_off(void) 180{ 181 __raw_writeb(0x01, IOMEM(0xfe8d0004)); 182 183 while (1) 184 ; 185} 186 187static void __init glantank_init_machine(void) 188{ 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); 198 199 i2c_register_board_info(0, glantank_i2c_devices, 200 ARRAY_SIZE(glantank_i2c_devices)); 201 202 pm_power_off = glantank_power_off; 203} 204 205MACHINE_START(GLANTANK, "GLAN Tank") 206 /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */ 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, 214MACHINE_END