Arnaud Patard | a8135fc | 2007-07-15 20:12:23 +0100 | [diff] [blame] | 1 | /* |
| 2 | * arch/arm/mach-iop32x/em7210.c |
| 3 | * |
| 4 | * Board support code for the Lanner EM7210 platforms. |
| 5 | * |
| 6 | * Based on arch/arm/mach-iop32x/iq31244.c file. |
| 7 | * |
| 8 | * Copyright (C) 2007 Arnaud Patard <arnaud.patard@rtp-net.org> |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU General Public License version 2 as |
| 12 | * published by the Free Software Foundation. |
| 13 | * |
| 14 | */ |
| 15 | |
| 16 | #include <linux/mm.h> |
| 17 | #include <linux/init.h> |
| 18 | #include <linux/kernel.h> |
| 19 | #include <linux/pci.h> |
| 20 | #include <linux/pm.h> |
| 21 | #include <linux/serial_core.h> |
| 22 | #include <linux/serial_8250.h> |
| 23 | #include <linux/mtd/physmap.h> |
| 24 | #include <linux/platform_device.h> |
Arnaud Patard | fe885fa | 2007-07-18 21:04:00 +0100 | [diff] [blame] | 25 | #include <linux/i2c.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 26 | #include <mach/hardware.h> |
Arnaud Patard | a8135fc | 2007-07-15 20:12:23 +0100 | [diff] [blame] | 27 | #include <linux/io.h> |
| 28 | #include <linux/irq.h> |
| 29 | #include <asm/mach/arch.h> |
| 30 | #include <asm/mach/map.h> |
| 31 | #include <asm/mach/pci.h> |
| 32 | #include <asm/mach/time.h> |
| 33 | #include <asm/mach-types.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 34 | #include <mach/time.h> |
Arnaud Patard | a8135fc | 2007-07-15 20:12:23 +0100 | [diff] [blame] | 35 | |
| 36 | static void __init em7210_timer_init(void) |
| 37 | { |
| 38 | /* http://www.kwaak.net/fotos/fotos-nas/slide_24.html */ |
| 39 | /* 33.333 MHz crystal. */ |
| 40 | iop_init_time(200000000); |
| 41 | } |
| 42 | |
| 43 | static struct sys_timer em7210_timer = { |
| 44 | .init = em7210_timer_init, |
Arnaud Patard | a8135fc | 2007-07-15 20:12:23 +0100 | [diff] [blame] | 45 | }; |
| 46 | |
Arnaud Patard | fe885fa | 2007-07-18 21:04:00 +0100 | [diff] [blame] | 47 | /* |
| 48 | * EM7210 RTC |
| 49 | */ |
| 50 | static struct i2c_board_info __initdata em7210_i2c_devices[] = { |
| 51 | { |
Jean Delvare | 3760f73 | 2008-04-29 23:11:40 +0200 | [diff] [blame] | 52 | I2C_BOARD_INFO("rs5c372a", 0x32), |
Arnaud Patard | fe885fa | 2007-07-18 21:04:00 +0100 | [diff] [blame] | 53 | }, |
| 54 | }; |
Arnaud Patard | a8135fc | 2007-07-15 20:12:23 +0100 | [diff] [blame] | 55 | |
| 56 | /* |
| 57 | * EM7210 I/O |
| 58 | */ |
| 59 | static struct map_desc em7210_io_desc[] __initdata = { |
| 60 | { /* on-board devices */ |
| 61 | .virtual = IQ31244_UART, |
| 62 | .pfn = __phys_to_pfn(IQ31244_UART), |
| 63 | .length = 0x00100000, |
| 64 | .type = MT_DEVICE, |
| 65 | }, |
| 66 | }; |
| 67 | |
| 68 | void __init em7210_map_io(void) |
| 69 | { |
| 70 | iop3xx_map_io(); |
| 71 | iotable_init(em7210_io_desc, ARRAY_SIZE(em7210_io_desc)); |
| 72 | } |
| 73 | |
| 74 | |
| 75 | /* |
| 76 | * EM7210 PCI |
| 77 | */ |
| 78 | #define INTA IRQ_IOP32X_XINT0 |
| 79 | #define INTB IRQ_IOP32X_XINT1 |
| 80 | #define INTC IRQ_IOP32X_XINT2 |
| 81 | #define INTD IRQ_IOP32X_XINT3 |
| 82 | |
| 83 | static int __init |
Ralf Baechle | d534194 | 2011-06-10 15:30:21 +0100 | [diff] [blame] | 84 | em7210_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) |
Arnaud Patard | a8135fc | 2007-07-15 20:12:23 +0100 | [diff] [blame] | 85 | { |
| 86 | static int pci_irq_table[][4] = { |
| 87 | /* |
| 88 | * PCI IDSEL/INTPIN->INTLINE |
| 89 | * A B C D |
| 90 | */ |
| 91 | {INTB, INTB, INTB, INTB}, /* console / uart */ |
| 92 | {INTA, INTA, INTA, INTA}, /* 1st 82541 */ |
| 93 | {INTD, INTD, INTD, INTD}, /* 2nd 82541 */ |
| 94 | {INTC, INTC, INTC, INTC}, /* GD31244 */ |
| 95 | {INTD, INTA, INTA, INTA}, /* mini-PCI */ |
| 96 | {INTD, INTC, INTA, INTA}, /* NEC USB */ |
| 97 | }; |
| 98 | |
| 99 | if (pin < 1 || pin > 4) |
| 100 | return -1; |
| 101 | |
| 102 | return pci_irq_table[slot % 6][pin - 1]; |
| 103 | } |
| 104 | |
| 105 | static struct hw_pci em7210_pci __initdata = { |
Arnaud Patard | a8135fc | 2007-07-15 20:12:23 +0100 | [diff] [blame] | 106 | .nr_controllers = 1, |
Russell King | c23bfc3 | 2012-03-10 12:49:16 +0000 | [diff] [blame] | 107 | .ops = &iop3xx_ops, |
Arnaud Patard | a8135fc | 2007-07-15 20:12:23 +0100 | [diff] [blame] | 108 | .setup = iop3xx_pci_setup, |
| 109 | .preinit = iop3xx_pci_preinit, |
Arnaud Patard | a8135fc | 2007-07-15 20:12:23 +0100 | [diff] [blame] | 110 | .map_irq = em7210_pci_map_irq, |
| 111 | }; |
| 112 | |
| 113 | static int __init em7210_pci_init(void) |
| 114 | { |
| 115 | if (machine_is_em7210()) |
| 116 | pci_common_init(&em7210_pci); |
| 117 | |
| 118 | return 0; |
| 119 | } |
| 120 | |
| 121 | subsys_initcall(em7210_pci_init); |
| 122 | |
| 123 | |
| 124 | /* |
| 125 | * EM7210 Flash |
| 126 | */ |
| 127 | static struct physmap_flash_data em7210_flash_data = { |
| 128 | .width = 2, |
| 129 | }; |
| 130 | |
| 131 | static struct resource em7210_flash_resource = { |
| 132 | .start = 0xf0000000, |
| 133 | .end = 0xf1ffffff, |
| 134 | .flags = IORESOURCE_MEM, |
| 135 | }; |
| 136 | |
| 137 | static struct platform_device em7210_flash_device = { |
| 138 | .name = "physmap-flash", |
| 139 | .id = 0, |
| 140 | .dev = { |
| 141 | .platform_data = &em7210_flash_data, |
| 142 | }, |
| 143 | .num_resources = 1, |
| 144 | .resource = &em7210_flash_resource, |
| 145 | }; |
| 146 | |
| 147 | |
| 148 | /* |
| 149 | * EM7210 UART |
| 150 | * The physical address of the serial port is 0xfe800000, |
| 151 | * so it can be used for physical and virtual address. |
| 152 | */ |
| 153 | static struct plat_serial8250_port em7210_serial_port[] = { |
| 154 | { |
| 155 | .mapbase = IQ31244_UART, |
| 156 | .membase = (char *)IQ31244_UART, |
| 157 | .irq = IRQ_IOP32X_XINT1, |
| 158 | .flags = UPF_SKIP_TEST, |
| 159 | .iotype = UPIO_MEM, |
| 160 | .regshift = 0, |
| 161 | .uartclk = 1843200, |
| 162 | }, |
| 163 | { }, |
| 164 | }; |
| 165 | |
| 166 | static struct resource em7210_uart_resource = { |
| 167 | .start = IQ31244_UART, |
| 168 | .end = IQ31244_UART + 7, |
| 169 | .flags = IORESOURCE_MEM, |
| 170 | }; |
| 171 | |
| 172 | static struct platform_device em7210_serial_device = { |
| 173 | .name = "serial8250", |
| 174 | .id = PLAT8250_DEV_PLATFORM, |
| 175 | .dev = { |
| 176 | .platform_data = em7210_serial_port, |
| 177 | }, |
| 178 | .num_resources = 1, |
| 179 | .resource = &em7210_uart_resource, |
| 180 | }; |
| 181 | |
| 182 | void em7210_power_off(void) |
| 183 | { |
| 184 | *IOP3XX_GPOE &= 0xfe; |
| 185 | *IOP3XX_GPOD |= 0x01; |
| 186 | } |
| 187 | |
| 188 | static void __init em7210_init_machine(void) |
| 189 | { |
| 190 | platform_device_register(&em7210_serial_device); |
| 191 | platform_device_register(&iop3xx_i2c0_device); |
| 192 | platform_device_register(&iop3xx_i2c1_device); |
| 193 | platform_device_register(&em7210_flash_device); |
| 194 | platform_device_register(&iop3xx_dma_0_channel); |
| 195 | platform_device_register(&iop3xx_dma_1_channel); |
| 196 | |
Arnaud Patard | fe885fa | 2007-07-18 21:04:00 +0100 | [diff] [blame] | 197 | i2c_register_board_info(0, em7210_i2c_devices, |
| 198 | ARRAY_SIZE(em7210_i2c_devices)); |
| 199 | |
Arnaud Patard | a8135fc | 2007-07-15 20:12:23 +0100 | [diff] [blame] | 200 | |
| 201 | pm_power_off = em7210_power_off; |
| 202 | } |
| 203 | |
| 204 | MACHINE_START(EM7210, "Lanner EM7210") |
Nicolas Pitre | 1896746 | 2011-07-05 22:38:12 -0400 | [diff] [blame] | 205 | .atag_offset = 0x100, |
Arnaud Patard | a8135fc | 2007-07-15 20:12:23 +0100 | [diff] [blame] | 206 | .map_io = em7210_map_io, |
| 207 | .init_irq = iop32x_init_irq, |
| 208 | .timer = &em7210_timer, |
| 209 | .init_machine = em7210_init_machine, |
Russell King | bec92b1 | 2011-11-05 11:26:32 +0000 | [diff] [blame] | 210 | .restart = iop3xx_restart, |
Arnaud Patard | a8135fc | 2007-07-15 20:12:23 +0100 | [diff] [blame] | 211 | MACHINE_END |