MIPS: Malta: fix alignment of the devicetree buffer
[linux-2.6-microblaze.git] / arch / arm / mach-ixp4xx / avila-setup.c
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 <linux/platform_data/pata_ixp4xx_cf.h>
23 #include <asm/types.h>
24 #include <asm/setup.h>
25 #include <asm/memory.h>
26 #include <mach/hardware.h>
27 #include <asm/mach-types.h>
28 #include <asm/irq.h>
29 #include <asm/mach/arch.h>
30 #include <asm/mach/flash.h>
31
32 #include "irqs.h"
33
34 #define AVILA_SDA_PIN   7
35 #define AVILA_SCL_PIN   6
36
37 static struct flash_platform_data avila_flash_data = {
38         .map_name       = "cfi_probe",
39         .width          = 2,
40 };
41
42 static struct resource avila_flash_resource = {
43         .flags          = IORESOURCE_MEM,
44 };
45
46 static struct platform_device avila_flash = {
47         .name           = "IXP4XX-Flash",
48         .id             = 0,
49         .dev            = {
50                 .platform_data = &avila_flash_data,
51         },
52         .num_resources  = 1,
53         .resource       = &avila_flash_resource,
54 };
55
56 static struct gpiod_lookup_table avila_i2c_gpiod_table = {
57         .dev_id         = "i2c-gpio.0",
58         .table          = {
59                 GPIO_LOOKUP_IDX("IXP4XX_GPIO_CHIP", AVILA_SDA_PIN,
60                                 NULL, 0, GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN),
61                 GPIO_LOOKUP_IDX("IXP4XX_GPIO_CHIP", AVILA_SCL_PIN,
62                                 NULL, 1, GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN),
63         },
64 };
65
66 static struct platform_device avila_i2c_gpio = {
67         .name           = "i2c-gpio",
68         .id             = 0,
69         .dev     = {
70                 .platform_data  = NULL,
71         },
72 };
73
74 static struct resource avila_uart_resources[] = {
75         {
76                 .start          = IXP4XX_UART1_BASE_PHYS,
77                 .end            = IXP4XX_UART1_BASE_PHYS + 0x0fff,
78                 .flags          = IORESOURCE_MEM
79         },
80         {
81                 .start          = IXP4XX_UART2_BASE_PHYS,
82                 .end            = IXP4XX_UART2_BASE_PHYS + 0x0fff,
83                 .flags          = IORESOURCE_MEM
84         }
85 };
86
87 static struct plat_serial8250_port avila_uart_data[] = {
88         {
89                 .mapbase        = IXP4XX_UART1_BASE_PHYS,
90                 .membase        = (char *)IXP4XX_UART1_BASE_VIRT + REG_OFFSET,
91                 .irq            = IRQ_IXP4XX_UART1,
92                 .flags          = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
93                 .iotype         = UPIO_MEM,
94                 .regshift       = 2,
95                 .uartclk        = IXP4XX_UART_XTAL,
96         },
97         {
98                 .mapbase        = IXP4XX_UART2_BASE_PHYS,
99                 .membase        = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET,
100                 .irq            = IRQ_IXP4XX_UART2,
101                 .flags          = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
102                 .iotype         = UPIO_MEM,
103                 .regshift       = 2,
104                 .uartclk        = IXP4XX_UART_XTAL,
105         },
106         { },
107 };
108
109 static struct platform_device avila_uart = {
110         .name                   = "serial8250",
111         .id                     = PLAT8250_DEV_PLATFORM,
112         .dev.platform_data      = avila_uart_data,
113         .num_resources          = 2,
114         .resource               = avila_uart_resources
115 };
116
117 static struct resource avila_pata_resources[] = {
118         {
119                 .flags  = IORESOURCE_MEM
120         },
121         {
122                 .flags  = IORESOURCE_MEM,
123         },
124         {
125                 .name   = "intrq",
126                 .start  = IRQ_IXP4XX_GPIO12,
127                 .end    = IRQ_IXP4XX_GPIO12,
128                 .flags  = IORESOURCE_IRQ,
129         },
130 };
131
132 static struct ixp4xx_pata_data avila_pata_data = {
133         .cs0_bits       = 0xbfff0043,
134         .cs1_bits       = 0xbfff0043,
135 };
136
137 static struct platform_device avila_pata = {
138         .name                   = "pata_ixp4xx_cf",
139         .id                     = 0,
140         .dev.platform_data      = &avila_pata_data,
141         .num_resources          = ARRAY_SIZE(avila_pata_resources),
142         .resource               = avila_pata_resources,
143 };
144
145 static struct platform_device *avila_devices[] __initdata = {
146         &avila_i2c_gpio,
147         &avila_flash,
148         &avila_uart
149 };
150
151 static void __init avila_init(void)
152 {
153         ixp4xx_sys_init();
154
155         avila_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
156         avila_flash_resource.end =
157                 IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
158
159         gpiod_add_lookup_table(&avila_i2c_gpiod_table);
160
161         platform_add_devices(avila_devices, ARRAY_SIZE(avila_devices));
162
163         avila_pata_resources[0].start = IXP4XX_EXP_BUS_BASE(1);
164         avila_pata_resources[0].end = IXP4XX_EXP_BUS_END(1);
165
166         avila_pata_resources[1].start = IXP4XX_EXP_BUS_BASE(2);
167         avila_pata_resources[1].end = IXP4XX_EXP_BUS_END(2);
168
169         avila_pata_data.cs0_cfg = IXP4XX_EXP_CS1;
170         avila_pata_data.cs1_cfg = IXP4XX_EXP_CS2;
171
172         platform_device_register(&avila_pata);
173
174 }
175
176 MACHINE_START(AVILA, "Gateworks Avila Network Platform")
177         /* Maintainer: Deepak Saxena <dsaxena@plexity.net> */
178         .map_io         = ixp4xx_map_io,
179         .init_early     = ixp4xx_init_early,
180         .init_irq       = ixp4xx_init_irq,
181         .init_time      = ixp4xx_timer_init,
182         .atag_offset    = 0x100,
183         .init_machine   = avila_init,
184 #if defined(CONFIG_PCI)
185         .dma_zone_size  = SZ_64M,
186 #endif
187         .restart        = ixp4xx_restart,
188 MACHINE_END
189
190  /*
191   * Loft is functionally equivalent to Avila except that it has a
192   * different number for the maximum PCI devices.  The MACHINE
193   * structure below is identical to Avila except for the comment.
194   */
195 #ifdef CONFIG_MACH_LOFT
196 MACHINE_START(LOFT, "Giant Shoulder Inc Loft board")
197         /* Maintainer: Tom Billman <kernel@giantshoulderinc.com> */
198         .map_io         = ixp4xx_map_io,
199         .init_early     = ixp4xx_init_early,
200         .init_irq       = ixp4xx_init_irq,
201         .init_time      = ixp4xx_timer_init,
202         .atag_offset    = 0x100,
203         .init_machine   = avila_init,
204 #if defined(CONFIG_PCI)
205         .dma_zone_size  = SZ_64M,
206 #endif
207         .restart        = ixp4xx_restart,
208 MACHINE_END
209 #endif
210