Lennert Buytenhek | 0c92e83 | 2006-09-21 02:46:03 +0100 | [diff] [blame] | 1 | /* |
| 2 | * arch/arm/mach-iop32x/glantank.c |
| 3 | * |
| 4 | * Board support code for the GLAN Tank. |
| 5 | * |
Martin Michlmayr | bd7b885 | 2007-12-27 14:09:07 +0100 | [diff] [blame] | 6 | * Copyright (C) 2006, 2007 Martin Michlmayr <tbm@cyrius.com> |
Lennert Buytenhek | 0c92e83 | 2006-09-21 02:46:03 +0100 | [diff] [blame] | 7 | * Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org> |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify it |
| 10 | * under the terms of the GNU General Public License as published by the |
| 11 | * Free Software Foundation; either version 2 of the License, or (at your |
| 12 | * option) any later version. |
| 13 | */ |
| 14 | |
| 15 | #include <linux/mm.h> |
| 16 | #include <linux/init.h> |
Gordon Farquharson | 4e7ffb6 | 2008-03-14 04:07:46 +0100 | [diff] [blame] | 17 | #include <linux/f75375s.h> |
Lennert Buytenhek | 0c92e83 | 2006-09-21 02:46:03 +0100 | [diff] [blame] | 18 | #include <linux/kernel.h> |
| 19 | #include <linux/pci.h> |
Gordon Farquharson | 4e7ffb6 | 2008-03-14 04:07:46 +0100 | [diff] [blame] | 20 | #include <linux/pm.h> |
Lennert Buytenhek | 0c92e83 | 2006-09-21 02:46:03 +0100 | [diff] [blame] | 21 | #include <linux/string.h> |
Lennert Buytenhek | 0c92e83 | 2006-09-21 02:46:03 +0100 | [diff] [blame] | 22 | #include <linux/serial_core.h> |
| 23 | #include <linux/serial_8250.h> |
| 24 | #include <linux/mtd/physmap.h> |
Martin Michlmayr | bd7b885 | 2007-12-27 14:09:07 +0100 | [diff] [blame] | 25 | #include <linux/i2c.h> |
Lennert Buytenhek | 0c92e83 | 2006-09-21 02:46:03 +0100 | [diff] [blame] | 26 | #include <linux/platform_device.h> |
Russell King | fced80c | 2008-09-06 12:10:45 +0100 | [diff] [blame] | 27 | #include <linux/io.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 28 | #include <mach/hardware.h> |
Lennert Buytenhek | 0c92e83 | 2006-09-21 02:46:03 +0100 | [diff] [blame] | 29 | #include <asm/irq.h> |
| 30 | #include <asm/mach/arch.h> |
| 31 | #include <asm/mach/map.h> |
| 32 | #include <asm/mach/pci.h> |
| 33 | #include <asm/mach/time.h> |
| 34 | #include <asm/mach-types.h> |
| 35 | #include <asm/page.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 36 | #include <mach/time.h> |
Linus Walleij | 7b85b86 | 2013-09-09 16:39:51 +0200 | [diff] [blame] | 37 | #include "gpio-iop32x.h" |
Lennert Buytenhek | 0c92e83 | 2006-09-21 02:46:03 +0100 | [diff] [blame] | 38 | |
| 39 | /* |
| 40 | * GLAN Tank timer tick configuration. |
| 41 | */ |
| 42 | static void __init glantank_timer_init(void) |
| 43 | { |
| 44 | /* 33.333 MHz crystal. */ |
Dan Williams | 3668b45 | 2007-02-13 17:13:34 +0100 | [diff] [blame] | 45 | iop_init_time(200000000); |
Lennert Buytenhek | 0c92e83 | 2006-09-21 02:46:03 +0100 | [diff] [blame] | 46 | } |
| 47 | |
Lennert Buytenhek | 0c92e83 | 2006-09-21 02:46:03 +0100 | [diff] [blame] | 48 | |
| 49 | /* |
| 50 | * GLAN Tank I/O. |
| 51 | */ |
| 52 | static struct map_desc glantank_io_desc[] __initdata = { |
| 53 | { /* on-board devices */ |
| 54 | .virtual = GLANTANK_UART, |
| 55 | .pfn = __phys_to_pfn(GLANTANK_UART), |
| 56 | .length = 0x00100000, |
| 57 | .type = MT_DEVICE |
| 58 | }, |
| 59 | }; |
| 60 | |
| 61 | void __init glantank_map_io(void) |
| 62 | { |
| 63 | iop3xx_map_io(); |
| 64 | iotable_init(glantank_io_desc, ARRAY_SIZE(glantank_io_desc)); |
| 65 | } |
| 66 | |
| 67 | |
| 68 | /* |
| 69 | * GLAN Tank PCI. |
| 70 | */ |
| 71 | #define INTA IRQ_IOP32X_XINT0 |
| 72 | #define INTB IRQ_IOP32X_XINT1 |
| 73 | #define INTC IRQ_IOP32X_XINT2 |
| 74 | #define INTD IRQ_IOP32X_XINT3 |
| 75 | |
Dan Williams | d73d801 | 2007-05-15 01:03:36 +0100 | [diff] [blame] | 76 | static int __init |
Ralf Baechle | d534194 | 2011-06-10 15:30:21 +0100 | [diff] [blame] | 77 | glantank_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) |
Lennert Buytenhek | 0c92e83 | 2006-09-21 02:46:03 +0100 | [diff] [blame] | 78 | { |
| 79 | static int pci_irq_table[][4] = { |
| 80 | /* |
| 81 | * PCI IDSEL/INTPIN->INTLINE |
| 82 | * A B C D |
| 83 | */ |
| 84 | {INTD, INTD, INTD, INTD}, /* UART (8250) */ |
| 85 | {INTA, INTA, INTA, INTA}, /* Ethernet (E1000) */ |
| 86 | {INTB, INTB, INTB, INTB}, /* IDE (AEC6280R) */ |
| 87 | {INTC, INTC, INTC, INTC}, /* USB (NEC) */ |
| 88 | }; |
| 89 | |
| 90 | BUG_ON(pin < 1 || pin > 4); |
| 91 | |
| 92 | return pci_irq_table[slot % 4][pin - 1]; |
| 93 | } |
| 94 | |
| 95 | static struct hw_pci glantank_pci __initdata = { |
Lennert Buytenhek | 0c92e83 | 2006-09-21 02:46:03 +0100 | [diff] [blame] | 96 | .nr_controllers = 1, |
Russell King | c23bfc3 | 2012-03-10 12:49:16 +0000 | [diff] [blame] | 97 | .ops = &iop3xx_ops, |
Lennert Buytenhek | 0c92e83 | 2006-09-21 02:46:03 +0100 | [diff] [blame] | 98 | .setup = iop3xx_pci_setup, |
| 99 | .preinit = iop3xx_pci_preinit, |
Lennert Buytenhek | 0c92e83 | 2006-09-21 02:46:03 +0100 | [diff] [blame] | 100 | .map_irq = glantank_pci_map_irq, |
| 101 | }; |
| 102 | |
| 103 | static int __init glantank_pci_init(void) |
| 104 | { |
| 105 | if (machine_is_glantank()) |
| 106 | pci_common_init(&glantank_pci); |
| 107 | |
| 108 | return 0; |
| 109 | } |
| 110 | |
| 111 | subsys_initcall(glantank_pci_init); |
| 112 | |
| 113 | |
| 114 | /* |
| 115 | * GLAN Tank machine initialization. |
| 116 | */ |
| 117 | static struct physmap_flash_data glantank_flash_data = { |
Gordon Farquharson | b696b6b | 2008-01-26 08:35:44 +0100 | [diff] [blame] | 118 | .width = 2, |
Lennert Buytenhek | 0c92e83 | 2006-09-21 02:46:03 +0100 | [diff] [blame] | 119 | }; |
| 120 | |
| 121 | static struct resource glantank_flash_resource = { |
| 122 | .start = 0xf0000000, |
| 123 | .end = 0xf007ffff, |
| 124 | .flags = IORESOURCE_MEM, |
| 125 | }; |
| 126 | |
| 127 | static struct platform_device glantank_flash_device = { |
| 128 | .name = "physmap-flash", |
| 129 | .id = 0, |
| 130 | .dev = { |
| 131 | .platform_data = &glantank_flash_data, |
| 132 | }, |
| 133 | .num_resources = 1, |
| 134 | .resource = &glantank_flash_resource, |
| 135 | }; |
| 136 | |
| 137 | static struct plat_serial8250_port glantank_serial_port[] = { |
| 138 | { |
| 139 | .mapbase = GLANTANK_UART, |
| 140 | .membase = (char *)GLANTANK_UART, |
| 141 | .irq = IRQ_IOP32X_XINT3, |
| 142 | .flags = UPF_SKIP_TEST, |
| 143 | .iotype = UPIO_MEM, |
| 144 | .regshift = 0, |
| 145 | .uartclk = 1843200, |
| 146 | }, |
| 147 | { }, |
| 148 | }; |
| 149 | |
| 150 | static struct resource glantank_uart_resource = { |
| 151 | .start = GLANTANK_UART, |
| 152 | .end = GLANTANK_UART + 7, |
| 153 | .flags = IORESOURCE_MEM, |
| 154 | }; |
| 155 | |
| 156 | static struct platform_device glantank_serial_device = { |
| 157 | .name = "serial8250", |
| 158 | .id = PLAT8250_DEV_PLATFORM, |
| 159 | .dev = { |
| 160 | .platform_data = glantank_serial_port, |
| 161 | }, |
| 162 | .num_resources = 1, |
| 163 | .resource = &glantank_uart_resource, |
| 164 | }; |
| 165 | |
Gordon Farquharson | 4e7ffb6 | 2008-03-14 04:07:46 +0100 | [diff] [blame] | 166 | static struct f75375s_platform_data glantank_f75375s = { |
| 167 | .pwm = { 255, 255 }, |
| 168 | .pwm_enable = { 0, 0 }, |
| 169 | }; |
| 170 | |
Martin Michlmayr | bd7b885 | 2007-12-27 14:09:07 +0100 | [diff] [blame] | 171 | static struct i2c_board_info __initdata glantank_i2c_devices[] = { |
| 172 | { |
Jean Delvare | 3760f73 | 2008-04-29 23:11:40 +0200 | [diff] [blame] | 173 | I2C_BOARD_INFO("rs5c372a", 0x32), |
Martin Michlmayr | bd7b885 | 2007-12-27 14:09:07 +0100 | [diff] [blame] | 174 | }, |
Gordon Farquharson | 4e7ffb6 | 2008-03-14 04:07:46 +0100 | [diff] [blame] | 175 | { |
| 176 | I2C_BOARD_INFO("f75375", 0x2e), |
Gordon Farquharson | 4e7ffb6 | 2008-03-14 04:07:46 +0100 | [diff] [blame] | 177 | .platform_data = &glantank_f75375s, |
| 178 | }, |
Martin Michlmayr | bd7b885 | 2007-12-27 14:09:07 +0100 | [diff] [blame] | 179 | }; |
| 180 | |
Lennert Buytenhek | 0c92e83 | 2006-09-21 02:46:03 +0100 | [diff] [blame] | 181 | static void glantank_power_off(void) |
| 182 | { |
Arnd Bergmann | 3c65c6b | 2012-09-14 20:19:04 +0000 | [diff] [blame] | 183 | __raw_writeb(0x01, IOMEM(0xfe8d0004)); |
Lennert Buytenhek | 0c92e83 | 2006-09-21 02:46:03 +0100 | [diff] [blame] | 184 | |
| 185 | while (1) |
| 186 | ; |
| 187 | } |
| 188 | |
| 189 | static void __init glantank_init_machine(void) |
| 190 | { |
Linus Walleij | 7b85b86 | 2013-09-09 16:39:51 +0200 | [diff] [blame] | 191 | register_iop32x_gpio(); |
Lennert Buytenhek | 0c92e83 | 2006-09-21 02:46:03 +0100 | [diff] [blame] | 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); |
Dan Williams | 2492c84 | 2007-01-02 13:52:31 -0700 | [diff] [blame] | 196 | platform_device_register(&iop3xx_dma_0_channel); |
| 197 | platform_device_register(&iop3xx_dma_1_channel); |
Lennert Buytenhek | 0c92e83 | 2006-09-21 02:46:03 +0100 | [diff] [blame] | 198 | |
Martin Michlmayr | bd7b885 | 2007-12-27 14:09:07 +0100 | [diff] [blame] | 199 | i2c_register_board_info(0, glantank_i2c_devices, |
| 200 | ARRAY_SIZE(glantank_i2c_devices)); |
| 201 | |
Lennert Buytenhek | 0c92e83 | 2006-09-21 02:46:03 +0100 | [diff] [blame] | 202 | pm_power_off = glantank_power_off; |
| 203 | } |
| 204 | |
| 205 | MACHINE_START(GLANTANK, "GLAN Tank") |
| 206 | /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */ |
Nicolas Pitre | 1896746 | 2011-07-05 22:38:12 -0400 | [diff] [blame] | 207 | .atag_offset = 0x100, |
Lennert Buytenhek | 0c92e83 | 2006-09-21 02:46:03 +0100 | [diff] [blame] | 208 | .map_io = glantank_map_io, |
| 209 | .init_irq = iop32x_init_irq, |
Stephen Warren | 6bb27d7 | 2012-11-08 12:40:59 -0700 | [diff] [blame] | 210 | .init_time = glantank_timer_init, |
Lennert Buytenhek | 0c92e83 | 2006-09-21 02:46:03 +0100 | [diff] [blame] | 211 | .init_machine = glantank_init_machine, |
Russell King | bec92b1 | 2011-11-05 11:26:32 +0000 | [diff] [blame] | 212 | .restart = iop3xx_restart, |
Lennert Buytenhek | 0c92e83 | 2006-09-21 02:46:03 +0100 | [diff] [blame] | 213 | MACHINE_END |