blob: 77def6169f506a0134e2fd337b396b93747cccad [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001// SPDX-License-Identifier: GPL-2.0
Michael-Luke Jones0f185972006-12-16 23:04:05 +01002/*
3 * arch/arm/mach-ixp4xx/avila-setup.c
4 *
5 * Gateworks Avila board-setup
6 *
7 * Author: Michael-Luke Jones <mlj28@cam.ac.uk>
8 *
9 * Based on ixdp-setup.c
10 * Copyright (C) 2003-2005 MontaVista Software, Inc.
11 *
12 * Author: Deepak Saxena <dsaxena@plexity.net>
13 */
14
15#include <linux/kernel.h>
16#include <linux/init.h>
17#include <linux/device.h>
18#include <linux/serial.h>
19#include <linux/tty.h>
20#include <linux/serial_8250.h>
Linus Walleijb2e63552017-09-10 01:30:46 +020021#include <linux/gpio/machine.h>
Michael-Luke Jones0f185972006-12-16 23:04:05 +010022#include <asm/types.h>
23#include <asm/setup.h>
24#include <asm/memory.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010025#include <mach/hardware.h>
Michael-Luke Jones0f185972006-12-16 23:04:05 +010026#include <asm/mach-types.h>
27#include <asm/irq.h>
28#include <asm/mach/arch.h>
29#include <asm/mach/flash.h>
30
Krzysztof HaƂasaec669692009-11-16 15:39:11 +010031#define AVILA_SDA_PIN 7
32#define AVILA_SCL_PIN 6
33
Michael-Luke Jones0f185972006-12-16 23:04:05 +010034static struct flash_platform_data avila_flash_data = {
35 .map_name = "cfi_probe",
36 .width = 2,
37};
38
39static struct resource avila_flash_resource = {
40 .flags = IORESOURCE_MEM,
41};
42
43static struct platform_device avila_flash = {
44 .name = "IXP4XX-Flash",
45 .id = 0,
46 .dev = {
47 .platform_data = &avila_flash_data,
48 },
49 .num_resources = 1,
50 .resource = &avila_flash_resource,
51};
52
Linus Walleijb2e63552017-09-10 01:30:46 +020053static struct gpiod_lookup_table avila_i2c_gpiod_table = {
54 .dev_id = "i2c-gpio",
55 .table = {
56 GPIO_LOOKUP_IDX("IXP4XX_GPIO_CHIP", AVILA_SDA_PIN,
Linus Walleij4d0ce622017-09-10 23:03:32 +020057 NULL, 0, GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN),
Linus Walleijb2e63552017-09-10 01:30:46 +020058 GPIO_LOOKUP_IDX("IXP4XX_GPIO_CHIP", AVILA_SCL_PIN,
Linus Walleij4d0ce622017-09-10 23:03:32 +020059 NULL, 1, GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN),
Linus Walleijb2e63552017-09-10 01:30:46 +020060 },
Michael-Luke Jones0f185972006-12-16 23:04:05 +010061};
62
Michael-Luke Jones5a4a2382008-01-27 18:14:46 +010063static struct platform_device avila_i2c_gpio = {
64 .name = "i2c-gpio",
Michael-Luke Jones0f185972006-12-16 23:04:05 +010065 .id = 0,
Michael-Luke Jones5a4a2382008-01-27 18:14:46 +010066 .dev = {
Linus Walleijb2e63552017-09-10 01:30:46 +020067 .platform_data = NULL,
Michael-Luke Jones0f185972006-12-16 23:04:05 +010068 },
Michael-Luke Jones0f185972006-12-16 23:04:05 +010069};
70
71static struct resource avila_uart_resources[] = {
72 {
73 .start = IXP4XX_UART1_BASE_PHYS,
74 .end = IXP4XX_UART1_BASE_PHYS + 0x0fff,
75 .flags = IORESOURCE_MEM
76 },
77 {
78 .start = IXP4XX_UART2_BASE_PHYS,
79 .end = IXP4XX_UART2_BASE_PHYS + 0x0fff,
80 .flags = IORESOURCE_MEM
81 }
82};
83
84static struct plat_serial8250_port avila_uart_data[] = {
85 {
86 .mapbase = IXP4XX_UART1_BASE_PHYS,
87 .membase = (char *)IXP4XX_UART1_BASE_VIRT + REG_OFFSET,
88 .irq = IRQ_IXP4XX_UART1,
89 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
90 .iotype = UPIO_MEM,
91 .regshift = 2,
92 .uartclk = IXP4XX_UART_XTAL,
93 },
94 {
95 .mapbase = IXP4XX_UART2_BASE_PHYS,
96 .membase = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET,
97 .irq = IRQ_IXP4XX_UART2,
98 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
99 .iotype = UPIO_MEM,
100 .regshift = 2,
101 .uartclk = IXP4XX_UART_XTAL,
102 },
103 { },
104};
105
106static struct platform_device avila_uart = {
107 .name = "serial8250",
108 .id = PLAT8250_DEV_PLATFORM,
109 .dev.platform_data = avila_uart_data,
110 .num_resources = 2,
111 .resource = avila_uart_resources
112};
113
Michael-Luke Jones946acb12006-12-16 23:02:00 +0100114static struct resource avila_pata_resources[] = {
115 {
116 .flags = IORESOURCE_MEM
117 },
118 {
119 .flags = IORESOURCE_MEM,
120 },
121 {
122 .name = "intrq",
123 .start = IRQ_IXP4XX_GPIO12,
124 .end = IRQ_IXP4XX_GPIO12,
125 .flags = IORESOURCE_IRQ,
126 },
127};
128
129static struct ixp4xx_pata_data avila_pata_data = {
130 .cs0_bits = 0xbfff0043,
131 .cs1_bits = 0xbfff0043,
132};
133
134static struct platform_device avila_pata = {
135 .name = "pata_ixp4xx_cf",
136 .id = 0,
137 .dev.platform_data = &avila_pata_data,
138 .num_resources = ARRAY_SIZE(avila_pata_resources),
139 .resource = avila_pata_resources,
140};
141
Michael-Luke Jones0f185972006-12-16 23:04:05 +0100142static struct platform_device *avila_devices[] __initdata = {
Michael-Luke Jones5a4a2382008-01-27 18:14:46 +0100143 &avila_i2c_gpio,
Michael-Luke Jones0f185972006-12-16 23:04:05 +0100144 &avila_flash,
145 &avila_uart
146};
147
148static void __init avila_init(void)
149{
150 ixp4xx_sys_init();
151
152 avila_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
153 avila_flash_resource.end =
154 IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
155
Linus Walleijb2e63552017-09-10 01:30:46 +0200156 gpiod_add_lookup_table(&avila_i2c_gpiod_table);
157
Michael-Luke Jones0f185972006-12-16 23:04:05 +0100158 platform_add_devices(avila_devices, ARRAY_SIZE(avila_devices));
Michael-Luke Jones946acb12006-12-16 23:02:00 +0100159
160 avila_pata_resources[0].start = IXP4XX_EXP_BUS_BASE(1);
161 avila_pata_resources[0].end = IXP4XX_EXP_BUS_END(1);
162
163 avila_pata_resources[1].start = IXP4XX_EXP_BUS_BASE(2);
164 avila_pata_resources[1].end = IXP4XX_EXP_BUS_END(2);
165
166 avila_pata_data.cs0_cfg = IXP4XX_EXP_CS1;
167 avila_pata_data.cs1_cfg = IXP4XX_EXP_CS2;
168
169 platform_device_register(&avila_pata);
170
Michael-Luke Jones0f185972006-12-16 23:04:05 +0100171}
172
173MACHINE_START(AVILA, "Gateworks Avila Network Platform")
174 /* Maintainer: Deepak Saxena <dsaxena@plexity.net> */
Michael-Luke Jones0f185972006-12-16 23:04:05 +0100175 .map_io = ixp4xx_map_io,
Rob Herringf4495882012-03-06 15:01:53 -0600176 .init_early = ixp4xx_init_early,
Michael-Luke Jones0f185972006-12-16 23:04:05 +0100177 .init_irq = ixp4xx_init_irq,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700178 .init_time = ixp4xx_timer_init,
Nicolas Pitree022c722011-07-05 22:38:13 -0400179 .atag_offset = 0x100,
Michael-Luke Jones0f185972006-12-16 23:04:05 +0100180 .init_machine = avila_init,
Nicolas Pitre7553ee72011-07-05 22:28:09 -0400181#if defined(CONFIG_PCI)
182 .dma_zone_size = SZ_64M,
183#endif
Russell Kingd1b860f2011-11-05 12:10:55 +0000184 .restart = ixp4xx_restart,
Michael-Luke Jones0f185972006-12-16 23:04:05 +0100185MACHINE_END
186
187 /*
188 * Loft is functionally equivalent to Avila except that it has a
189 * different number for the maximum PCI devices. The MACHINE
190 * structure below is identical to Avila except for the comment.
191 */
192#ifdef CONFIG_MACH_LOFT
193MACHINE_START(LOFT, "Giant Shoulder Inc Loft board")
194 /* Maintainer: Tom Billman <kernel@giantshoulderinc.com> */
Michael-Luke Jones0f185972006-12-16 23:04:05 +0100195 .map_io = ixp4xx_map_io,
Rob Herringf4495882012-03-06 15:01:53 -0600196 .init_early = ixp4xx_init_early,
Michael-Luke Jones0f185972006-12-16 23:04:05 +0100197 .init_irq = ixp4xx_init_irq,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700198 .init_time = ixp4xx_timer_init,
Nicolas Pitree022c722011-07-05 22:38:13 -0400199 .atag_offset = 0x100,
Michael-Luke Jones0f185972006-12-16 23:04:05 +0100200 .init_machine = avila_init,
Nicolas Pitre7553ee72011-07-05 22:28:09 -0400201#if defined(CONFIG_PCI)
202 .dma_zone_size = SZ_64M,
203#endif
Russell Kingd1b860f2011-11-05 12:10:55 +0000204 .restart = ixp4xx_restart,
Michael-Luke Jones0f185972006-12-16 23:04:05 +0100205MACHINE_END
206#endif
207