1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * arch/arm/mach-ixp4xx/gateway7001-setup.c
4  *
5  * Board setup for the Gateway 7001 board
6  *
7  * Copyright (C) 2007 Imre Kaloz <kaloz@openwrt.org>
8  *
9  * based on coyote-setup.c:
10  *      Copyright (C) 2003-2005 MontaVista Software, Inc.
11  *
12  * Author: Imre Kaloz <Kaloz@openwrt.org>
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 
22 #include <asm/types.h>
23 #include <asm/setup.h>
24 #include <asm/memory.h>
25 #include <mach/hardware.h>
26 #include <asm/irq.h>
27 #include <asm/mach-types.h>
28 #include <asm/mach/arch.h>
29 #include <asm/mach/flash.h>
30 
31 #include "irqs.h"
32 
33 static struct flash_platform_data gateway7001_flash_data = {
34 	.map_name	= "cfi_probe",
35 	.width		= 2,
36 };
37 
38 static struct resource gateway7001_flash_resource = {
39 	.flags		= IORESOURCE_MEM,
40 };
41 
42 static struct platform_device gateway7001_flash = {
43 	.name		= "IXP4XX-Flash",
44 	.id		= 0,
45 	.dev		= {
46 		.platform_data = &gateway7001_flash_data,
47 	},
48 	.num_resources	= 1,
49 	.resource	= &gateway7001_flash_resource,
50 };
51 
52 static struct resource gateway7001_uart_resource = {
53 	.start	= IXP4XX_UART2_BASE_PHYS,
54 	.end	= IXP4XX_UART2_BASE_PHYS + 0x0fff,
55 	.flags	= IORESOURCE_MEM,
56 };
57 
58 static struct plat_serial8250_port gateway7001_uart_data[] = {
59 	{
60 		.mapbase	= IXP4XX_UART2_BASE_PHYS,
61 		.membase	= (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET,
62 		.irq		= IRQ_IXP4XX_UART2,
63 		.flags		= UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
64 		.iotype		= UPIO_MEM,
65 		.regshift	= 2,
66 		.uartclk	= IXP4XX_UART_XTAL,
67 	},
68 	{ },
69 };
70 
71 static struct platform_device gateway7001_uart = {
72 	.name		= "serial8250",
73 	.id		= PLAT8250_DEV_PLATFORM,
74 	.dev			= {
75 		.platform_data	= gateway7001_uart_data,
76 	},
77 	.num_resources	= 1,
78 	.resource	= &gateway7001_uart_resource,
79 };
80 
81 static struct platform_device *gateway7001_devices[] __initdata = {
82 	&gateway7001_flash,
83 	&gateway7001_uart
84 };
85 
gateway7001_init(void)86 static void __init gateway7001_init(void)
87 {
88 	ixp4xx_sys_init();
89 
90 	gateway7001_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
91 	gateway7001_flash_resource.end = IXP4XX_EXP_BUS_BASE(0) + SZ_32M - 1;
92 
93 	*IXP4XX_EXP_CS0 |= IXP4XX_FLASH_WRITABLE;
94 	*IXP4XX_EXP_CS1 = *IXP4XX_EXP_CS0;
95 
96 	platform_add_devices(gateway7001_devices, ARRAY_SIZE(gateway7001_devices));
97 }
98 
99 #ifdef CONFIG_MACH_GATEWAY7001
100 MACHINE_START(GATEWAY7001, "Gateway 7001 AP")
101 	/* Maintainer: Imre Kaloz <kaloz@openwrt.org> */
102 	.map_io		= ixp4xx_map_io,
103 	.init_early	= ixp4xx_init_early,
104 	.init_irq	= ixp4xx_init_irq,
105 	.init_time	= ixp4xx_timer_init,
106 	.atag_offset	= 0x100,
107 	.init_machine	= gateway7001_init,
108 #if defined(CONFIG_PCI)
109 	.dma_zone_size	= SZ_64M,
110 #endif
111 	.restart	= ixp4xx_restart,
112 MACHINE_END
113 #endif
114