blob: b455d707329628544a16155b82185d154a077efe [file] [log] [blame]
Thomas Gleixner2874c5f2019-05-27 08:55:01 +02001// SPDX-License-Identifier: GPL-2.0-or-later
Lennert Buytenhekc680b772006-09-18 23:24:52 +01002/*
3 * arch/arm/mach-iop32x/iq80321.c
4 *
5 * Board support code for the Intel IQ80321 platform.
6 *
7 * Author: Rory Bolt <rorybolt@pacbell.net>
8 * Copyright (C) 2002 Rory Bolt
9 * Copyright (C) 2004 Intel Corp.
Lennert Buytenhekc680b772006-09-18 23:24:52 +010010 */
11
12#include <linux/mm.h>
13#include <linux/init.h>
14#include <linux/kernel.h>
15#include <linux/pci.h>
16#include <linux/string.h>
Lennert Buytenhekc680b772006-09-18 23:24:52 +010017#include <linux/serial_core.h>
18#include <linux/serial_8250.h>
19#include <linux/mtd/physmap.h>
20#include <linux/platform_device.h>
Russell Kingfced80c2008-09-06 12:10:45 +010021#include <linux/io.h>
Linus Walleijfdb7e882019-06-01 00:37:56 +020022#include <linux/gpio/machine.h>
Lennert Buytenhekc680b772006-09-18 23:24:52 +010023#include <asm/irq.h>
24#include <asm/mach/arch.h>
25#include <asm/mach/map.h>
26#include <asm/mach/pci.h>
27#include <asm/mach/time.h>
28#include <asm/mach-types.h>
29#include <asm/page.h>
Arnd Bergmanna1f487d2019-08-09 18:33:21 +020030
31#include "hardware.h"
32#include "irqs.h"
Linus Walleij7b85b862013-09-09 16:39:51 +020033#include "gpio-iop32x.h"
Lennert Buytenhekc680b772006-09-18 23:24:52 +010034
35/*
36 * IQ80321 timer tick configuration.
37 */
38static void __init iq80321_timer_init(void)
39{
40 /* 33.333 MHz crystal. */
Dan Williams3668b452007-02-13 17:13:34 +010041 iop_init_time(200000000);
Lennert Buytenhekc680b772006-09-18 23:24:52 +010042}
43
Lennert Buytenhekc680b772006-09-18 23:24:52 +010044
45/*
46 * IQ80321 I/O.
47 */
48static struct map_desc iq80321_io_desc[] __initdata = {
49 { /* on-board devices */
50 .virtual = IQ80321_UART,
51 .pfn = __phys_to_pfn(IQ80321_UART),
52 .length = 0x00100000,
53 .type = MT_DEVICE,
54 },
55};
56
57void __init iq80321_map_io(void)
58{
59 iop3xx_map_io();
60 iotable_init(iq80321_io_desc, ARRAY_SIZE(iq80321_io_desc));
61}
62
63
64/*
65 * IQ80321 PCI.
66 */
Dan Williamsd73d8012007-05-15 01:03:36 +010067static int __init
Ralf Baechled5341942011-06-10 15:30:21 +010068iq80321_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
Lennert Buytenhekc680b772006-09-18 23:24:52 +010069{
70 int irq;
71
72 if ((slot == 2 || slot == 6) && pin == 1) {
73 /* PCI-X Slot INTA */
Lennert Buytenhekc852ac82006-09-18 23:26:25 +010074 irq = IRQ_IOP32X_XINT2;
Lennert Buytenhekc680b772006-09-18 23:24:52 +010075 } else if ((slot == 2 || slot == 6) && pin == 2) {
76 /* PCI-X Slot INTA */
Lennert Buytenhekc852ac82006-09-18 23:26:25 +010077 irq = IRQ_IOP32X_XINT3;
Lennert Buytenhekc680b772006-09-18 23:24:52 +010078 } else if ((slot == 2 || slot == 6) && pin == 3) {
79 /* PCI-X Slot INTA */
Lennert Buytenhekc852ac82006-09-18 23:26:25 +010080 irq = IRQ_IOP32X_XINT0;
Lennert Buytenhekc680b772006-09-18 23:24:52 +010081 } else if ((slot == 2 || slot == 6) && pin == 4) {
82 /* PCI-X Slot INTA */
Lennert Buytenhekc852ac82006-09-18 23:26:25 +010083 irq = IRQ_IOP32X_XINT1;
Lennert Buytenhekc680b772006-09-18 23:24:52 +010084 } else if (slot == 4 || slot == 8) {
85 /* Gig-E */
Lennert Buytenhekc852ac82006-09-18 23:26:25 +010086 irq = IRQ_IOP32X_XINT0;
Lennert Buytenhekc680b772006-09-18 23:24:52 +010087 } else {
88 printk(KERN_ERR "iq80321_pci_map_irq() called for unknown "
89 "device PCI:%d:%d:%d\n", dev->bus->number,
90 PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
91 irq = -1;
92 }
93
94 return irq;
95}
96
97static struct hw_pci iq80321_pci __initdata = {
Lennert Buytenhekc680b772006-09-18 23:24:52 +010098 .nr_controllers = 1,
Russell Kingc23bfc32012-03-10 12:49:16 +000099 .ops = &iop3xx_ops,
Lennert Buytenhekc680b772006-09-18 23:24:52 +0100100 .setup = iop3xx_pci_setup,
Dan Williamsc34002c2008-03-26 19:12:38 -0700101 .preinit = iop3xx_pci_preinit_cond,
Lennert Buytenhekc680b772006-09-18 23:24:52 +0100102 .map_irq = iq80321_pci_map_irq,
103};
104
105static int __init iq80321_pci_init(void)
106{
Dan Williamse90ddd82007-05-02 17:59:44 +0100107 if ((iop3xx_get_init_atu() == IOP3XX_INIT_ATU_ENABLE) &&
108 machine_is_iq80321())
Lennert Buytenhekc680b772006-09-18 23:24:52 +0100109 pci_common_init(&iq80321_pci);
110
111 return 0;
112}
113
114subsys_initcall(iq80321_pci_init);
115
116
117/*
118 * IQ80321 machine initialisation.
119 */
120static struct physmap_flash_data iq80321_flash_data = {
121 .width = 1,
122};
123
124static struct resource iq80321_flash_resource = {
125 .start = 0xf0000000,
126 .end = 0xf07fffff,
127 .flags = IORESOURCE_MEM,
128};
129
130static struct platform_device iq80321_flash_device = {
131 .name = "physmap-flash",
132 .id = 0,
133 .dev = {
134 .platform_data = &iq80321_flash_data,
135 },
136 .num_resources = 1,
137 .resource = &iq80321_flash_resource,
138};
139
140static struct plat_serial8250_port iq80321_serial_port[] = {
141 {
142 .mapbase = IQ80321_UART,
143 .membase = (char *)IQ80321_UART,
Lennert Buytenhekc852ac82006-09-18 23:26:25 +0100144 .irq = IRQ_IOP32X_XINT1,
Lennert Buytenhekc680b772006-09-18 23:24:52 +0100145 .flags = UPF_SKIP_TEST,
146 .iotype = UPIO_MEM,
147 .regshift = 0,
148 .uartclk = 1843200,
149 },
150 { },
151};
152
153static struct resource iq80321_uart_resource = {
154 .start = IQ80321_UART,
155 .end = IQ80321_UART + 7,
156 .flags = IORESOURCE_MEM,
157};
158
159static struct platform_device iq80321_serial_device = {
160 .name = "serial8250",
161 .id = PLAT8250_DEV_PLATFORM,
162 .dev = {
163 .platform_data = iq80321_serial_port,
164 },
165 .num_resources = 1,
166 .resource = &iq80321_uart_resource,
167};
168
169static void __init iq80321_init_machine(void)
170{
Linus Walleij7b85b862013-09-09 16:39:51 +0200171 register_iop32x_gpio();
Linus Walleijfdb7e882019-06-01 00:37:56 +0200172 gpiod_add_lookup_table(&iop3xx_i2c0_gpio_lookup);
173 gpiod_add_lookup_table(&iop3xx_i2c1_gpio_lookup);
Lennert Buytenhekc680b772006-09-18 23:24:52 +0100174 platform_device_register(&iop3xx_i2c0_device);
175 platform_device_register(&iop3xx_i2c1_device);
176 platform_device_register(&iq80321_flash_device);
177 platform_device_register(&iq80321_serial_device);
Dan Williams2492c842007-01-02 13:52:31 -0700178 platform_device_register(&iop3xx_dma_0_channel);
179 platform_device_register(&iop3xx_dma_1_channel);
180 platform_device_register(&iop3xx_aau_channel);
Lennert Buytenhekc680b772006-09-18 23:24:52 +0100181}
182
183MACHINE_START(IQ80321, "Intel IQ80321")
184 /* Maintainer: Intel Corp. */
Nicolas Pitre18967462011-07-05 22:38:12 -0400185 .atag_offset = 0x100,
Lennert Buytenhekc680b772006-09-18 23:24:52 +0100186 .map_io = iq80321_map_io,
Lennert Buytenhekc852ac82006-09-18 23:26:25 +0100187 .init_irq = iop32x_init_irq,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700188 .init_time = iq80321_timer_init,
Lennert Buytenhekc680b772006-09-18 23:24:52 +0100189 .init_machine = iq80321_init_machine,
Russell Kingbec92b12011-11-05 11:26:32 +0000190 .restart = iop3xx_restart,
Lennert Buytenhekc680b772006-09-18 23:24:52 +0100191MACHINE_END