1 // SPDX-License-Identifier: GPL-2.0
2 /*
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>
21 #include <linux/gpio/machine.h>
22 #include <asm/types.h>
23 #include <asm/setup.h>
24 #include <asm/memory.h>
25 #include <mach/hardware.h>
26 #include <asm/mach-types.h>
27 #include <asm/irq.h>
28 #include <asm/mach/arch.h>
29 #include <asm/mach/flash.h>
30 
31 #define AVILA_SDA_PIN	7
32 #define AVILA_SCL_PIN	6
33 
34 static struct flash_platform_data avila_flash_data = {
35 	.map_name	= "cfi_probe",
36 	.width		= 2,
37 };
38 
39 static struct resource avila_flash_resource = {
40 	.flags		= IORESOURCE_MEM,
41 };
42 
43 static 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 
53 static struct gpiod_lookup_table avila_i2c_gpiod_table = {
54 	.dev_id		= "i2c-gpio.0",
55 	.table		= {
56 		GPIO_LOOKUP_IDX("IXP4XX_GPIO_CHIP", AVILA_SDA_PIN,
57 				NULL, 0, GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN),
58 		GPIO_LOOKUP_IDX("IXP4XX_GPIO_CHIP", AVILA_SCL_PIN,
59 				NULL, 1, GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN),
60 	},
61 };
62 
63 static struct platform_device avila_i2c_gpio = {
64 	.name		= "i2c-gpio",
65 	.id		= 0,
66 	.dev	 = {
67 		.platform_data	= NULL,
68 	},
69 };
70 
71 static 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 
84 static 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 
106 static 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 
114 static 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 
129 static struct ixp4xx_pata_data avila_pata_data = {
130 	.cs0_bits	= 0xbfff0043,
131 	.cs1_bits	= 0xbfff0043,
132 };
133 
134 static 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 
142 static struct platform_device *avila_devices[] __initdata = {
143 	&avila_i2c_gpio,
144 	&avila_flash,
145 	&avila_uart
146 };
147 
avila_init(void)148 static 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 
156 	gpiod_add_lookup_table(&avila_i2c_gpiod_table);
157 
158 	platform_add_devices(avila_devices, ARRAY_SIZE(avila_devices));
159 
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 
171 }
172 
173 MACHINE_START(AVILA, "Gateworks Avila Network Platform")
174 	/* Maintainer: Deepak Saxena <dsaxena@plexity.net> */
175 	.map_io		= ixp4xx_map_io,
176 	.init_early	= ixp4xx_init_early,
177 	.init_irq	= ixp4xx_init_irq,
178 	.init_time	= ixp4xx_timer_init,
179 	.atag_offset	= 0x100,
180 	.init_machine	= avila_init,
181 #if defined(CONFIG_PCI)
182 	.dma_zone_size	= SZ_64M,
183 #endif
184 	.restart	= ixp4xx_restart,
185 MACHINE_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
193 MACHINE_START(LOFT, "Giant Shoulder Inc Loft board")
194 	/* Maintainer: Tom Billman <kernel@giantshoulderinc.com> */
195 	.map_io		= ixp4xx_map_io,
196 	.init_early	= ixp4xx_init_early,
197 	.init_irq	= ixp4xx_init_irq,
198 	.init_time	= ixp4xx_timer_init,
199 	.atag_offset	= 0x100,
200 	.init_machine	= avila_init,
201 #if defined(CONFIG_PCI)
202 	.dma_zone_size	= SZ_64M,
203 #endif
204 	.restart	= ixp4xx_restart,
205 MACHINE_END
206 #endif
207 
208