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, |
| 45 | .offset = iop_gettimeoffset, |
| 46 | }; |
| 47 | |
Arnaud Patard | fe885fa | 2007-07-18 21:04:00 +0100 | [diff] [blame] | 48 | /* |
| 49 | * EM7210 RTC |
| 50 | */ |
| 51 | static struct i2c_board_info __initdata em7210_i2c_devices[] = { |
| 52 | { |
Jean Delvare | 3760f73 | 2008-04-29 23:11:40 +0200 | [diff] [blame] | 53 | I2C_BOARD_INFO("rs5c372a", 0x32), |
Arnaud Patard | fe885fa | 2007-07-18 21:04:00 +0100 | [diff] [blame] | 54 | }, |
| 55 | }; |
Arnaud Patard | a8135fc | 2007-07-15 20:12:23 +0100 | [diff] [blame] | 56 | |
| 57 | /* |
| 58 | * EM7210 I/O |
| 59 | */ |
| 60 | static struct map_desc em7210_io_desc[] __initdata = { |
| 61 | { /* on-board devices */ |
| 62 | .virtual = IQ31244_UART, |
| 63 | .pfn = __phys_to_pfn(IQ31244_UART), |
| 64 | .length = 0x00100000, |
| 65 | .type = MT_DEVICE, |
| 66 | }, |
| 67 | }; |
| 68 | |
| 69 | void __init em7210_map_io(void) |
| 70 | { |
| 71 | iop3xx_map_io(); |
| 72 | iotable_init(em7210_io_desc, ARRAY_SIZE(em7210_io_desc)); |
| 73 | } |
| 74 | |
| 75 | |
| 76 | /* |
| 77 | * EM7210 PCI |
| 78 | */ |
| 79 | #define INTA IRQ_IOP32X_XINT0 |
| 80 | #define INTB IRQ_IOP32X_XINT1 |
| 81 | #define INTC IRQ_IOP32X_XINT2 |
| 82 | #define INTD IRQ_IOP32X_XINT3 |
| 83 | |
| 84 | static int __init |
| 85 | em7210_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin) |
| 86 | { |
| 87 | static int pci_irq_table[][4] = { |
| 88 | /* |
| 89 | * PCI IDSEL/INTPIN->INTLINE |
| 90 | * A B C D |
| 91 | */ |
| 92 | {INTB, INTB, INTB, INTB}, /* console / uart */ |
| 93 | {INTA, INTA, INTA, INTA}, /* 1st 82541 */ |
| 94 | {INTD, INTD, INTD, INTD}, /* 2nd 82541 */ |
| 95 | {INTC, INTC, INTC, INTC}, /* GD31244 */ |
| 96 | {INTD, INTA, INTA, INTA}, /* mini-PCI */ |
| 97 | {INTD, INTC, INTA, INTA}, /* NEC USB */ |
| 98 | }; |
| 99 | |
| 100 | if (pin < 1 || pin > 4) |
| 101 | return -1; |
| 102 | |
| 103 | return pci_irq_table[slot % 6][pin - 1]; |
| 104 | } |
| 105 | |
| 106 | static struct hw_pci em7210_pci __initdata = { |
| 107 | .swizzle = pci_std_swizzle, |
| 108 | .nr_controllers = 1, |
| 109 | .setup = iop3xx_pci_setup, |
| 110 | .preinit = iop3xx_pci_preinit, |
| 111 | .scan = iop3xx_pci_scan_bus, |
| 112 | .map_irq = em7210_pci_map_irq, |
| 113 | }; |
| 114 | |
| 115 | static int __init em7210_pci_init(void) |
| 116 | { |
| 117 | if (machine_is_em7210()) |
| 118 | pci_common_init(&em7210_pci); |
| 119 | |
| 120 | return 0; |
| 121 | } |
| 122 | |
| 123 | subsys_initcall(em7210_pci_init); |
| 124 | |
| 125 | |
| 126 | /* |
| 127 | * EM7210 Flash |
| 128 | */ |
| 129 | static struct physmap_flash_data em7210_flash_data = { |
| 130 | .width = 2, |
| 131 | }; |
| 132 | |
| 133 | static struct resource em7210_flash_resource = { |
| 134 | .start = 0xf0000000, |
| 135 | .end = 0xf1ffffff, |
| 136 | .flags = IORESOURCE_MEM, |
| 137 | }; |
| 138 | |
| 139 | static struct platform_device em7210_flash_device = { |
| 140 | .name = "physmap-flash", |
| 141 | .id = 0, |
| 142 | .dev = { |
| 143 | .platform_data = &em7210_flash_data, |
| 144 | }, |
| 145 | .num_resources = 1, |
| 146 | .resource = &em7210_flash_resource, |
| 147 | }; |
| 148 | |
| 149 | |
| 150 | /* |
| 151 | * EM7210 UART |
| 152 | * The physical address of the serial port is 0xfe800000, |
| 153 | * so it can be used for physical and virtual address. |
| 154 | */ |
| 155 | static struct plat_serial8250_port em7210_serial_port[] = { |
| 156 | { |
| 157 | .mapbase = IQ31244_UART, |
| 158 | .membase = (char *)IQ31244_UART, |
| 159 | .irq = IRQ_IOP32X_XINT1, |
| 160 | .flags = UPF_SKIP_TEST, |
| 161 | .iotype = UPIO_MEM, |
| 162 | .regshift = 0, |
| 163 | .uartclk = 1843200, |
| 164 | }, |
| 165 | { }, |
| 166 | }; |
| 167 | |
| 168 | static struct resource em7210_uart_resource = { |
| 169 | .start = IQ31244_UART, |
| 170 | .end = IQ31244_UART + 7, |
| 171 | .flags = IORESOURCE_MEM, |
| 172 | }; |
| 173 | |
| 174 | static struct platform_device em7210_serial_device = { |
| 175 | .name = "serial8250", |
| 176 | .id = PLAT8250_DEV_PLATFORM, |
| 177 | .dev = { |
| 178 | .platform_data = em7210_serial_port, |
| 179 | }, |
| 180 | .num_resources = 1, |
| 181 | .resource = &em7210_uart_resource, |
| 182 | }; |
| 183 | |
| 184 | void em7210_power_off(void) |
| 185 | { |
| 186 | *IOP3XX_GPOE &= 0xfe; |
| 187 | *IOP3XX_GPOD |= 0x01; |
| 188 | } |
| 189 | |
| 190 | static void __init em7210_init_machine(void) |
| 191 | { |
| 192 | platform_device_register(&em7210_serial_device); |
| 193 | platform_device_register(&iop3xx_i2c0_device); |
| 194 | platform_device_register(&iop3xx_i2c1_device); |
| 195 | platform_device_register(&em7210_flash_device); |
| 196 | platform_device_register(&iop3xx_dma_0_channel); |
| 197 | platform_device_register(&iop3xx_dma_1_channel); |
| 198 | |
Arnaud Patard | fe885fa | 2007-07-18 21:04:00 +0100 | [diff] [blame] | 199 | i2c_register_board_info(0, em7210_i2c_devices, |
| 200 | ARRAY_SIZE(em7210_i2c_devices)); |
| 201 | |
Arnaud Patard | a8135fc | 2007-07-15 20:12:23 +0100 | [diff] [blame] | 202 | |
| 203 | pm_power_off = em7210_power_off; |
| 204 | } |
| 205 | |
| 206 | MACHINE_START(EM7210, "Lanner EM7210") |
| 207 | .phys_io = IQ31244_UART, |
| 208 | .io_pg_offst = ((IQ31244_UART) >> 18) & 0xfffc, |
| 209 | .boot_params = 0xa0000100, |
| 210 | .map_io = em7210_map_io, |
| 211 | .init_irq = iop32x_init_irq, |
| 212 | .timer = &em7210_timer, |
| 213 | .init_machine = em7210_init_machine, |
| 214 | MACHINE_END |