Michael-Luke Jones | 0f18597 | 2006-12-16 23:04:05 +0100 | [diff] [blame] | 1 | /* |
| 2 | * arch/arm/mach-ixp4xx/avila-setup.c |
| 3 | * |
| 4 | * Gateworks Avila board-setup |
| 5 | * |
| 6 | * Author: Michael-Luke Jones <mlj28@cam.ac.uk> |
| 7 | * |
| 8 | * Based on ixdp-setup.c |
| 9 | * Copyright (C) 2003-2005 MontaVista Software, Inc. |
| 10 | * |
| 11 | * Author: Deepak Saxena <dsaxena@plexity.net> |
| 12 | */ |
| 13 | |
| 14 | #include <linux/kernel.h> |
| 15 | #include <linux/init.h> |
| 16 | #include <linux/device.h> |
| 17 | #include <linux/serial.h> |
| 18 | #include <linux/tty.h> |
| 19 | #include <linux/serial_8250.h> |
Linus Walleij | b2e6355 | 2017-09-10 01:30:46 +0200 | [diff] [blame^] | 20 | #include <linux/gpio/machine.h> |
Michael-Luke Jones | 0f18597 | 2006-12-16 23:04:05 +0100 | [diff] [blame] | 21 | #include <asm/types.h> |
| 22 | #include <asm/setup.h> |
| 23 | #include <asm/memory.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 24 | #include <mach/hardware.h> |
Michael-Luke Jones | 0f18597 | 2006-12-16 23:04:05 +0100 | [diff] [blame] | 25 | #include <asm/mach-types.h> |
| 26 | #include <asm/irq.h> |
| 27 | #include <asm/mach/arch.h> |
| 28 | #include <asm/mach/flash.h> |
| 29 | |
Krzysztof HaĆasa | ec66969 | 2009-11-16 15:39:11 +0100 | [diff] [blame] | 30 | #define AVILA_SDA_PIN 7 |
| 31 | #define AVILA_SCL_PIN 6 |
| 32 | |
Michael-Luke Jones | 0f18597 | 2006-12-16 23:04:05 +0100 | [diff] [blame] | 33 | static struct flash_platform_data avila_flash_data = { |
| 34 | .map_name = "cfi_probe", |
| 35 | .width = 2, |
| 36 | }; |
| 37 | |
| 38 | static struct resource avila_flash_resource = { |
| 39 | .flags = IORESOURCE_MEM, |
| 40 | }; |
| 41 | |
| 42 | static struct platform_device avila_flash = { |
| 43 | .name = "IXP4XX-Flash", |
| 44 | .id = 0, |
| 45 | .dev = { |
| 46 | .platform_data = &avila_flash_data, |
| 47 | }, |
| 48 | .num_resources = 1, |
| 49 | .resource = &avila_flash_resource, |
| 50 | }; |
| 51 | |
Linus Walleij | b2e6355 | 2017-09-10 01:30:46 +0200 | [diff] [blame^] | 52 | static struct gpiod_lookup_table avila_i2c_gpiod_table = { |
| 53 | .dev_id = "i2c-gpio", |
| 54 | .table = { |
| 55 | GPIO_LOOKUP_IDX("IXP4XX_GPIO_CHIP", AVILA_SDA_PIN, |
| 56 | NULL, 0, GPIO_ACTIVE_HIGH), |
| 57 | GPIO_LOOKUP_IDX("IXP4XX_GPIO_CHIP", AVILA_SCL_PIN, |
| 58 | NULL, 1, GPIO_ACTIVE_HIGH), |
| 59 | }, |
Michael-Luke Jones | 0f18597 | 2006-12-16 23:04:05 +0100 | [diff] [blame] | 60 | }; |
| 61 | |
Michael-Luke Jones | 5a4a238 | 2008-01-27 18:14:46 +0100 | [diff] [blame] | 62 | static struct platform_device avila_i2c_gpio = { |
| 63 | .name = "i2c-gpio", |
Michael-Luke Jones | 0f18597 | 2006-12-16 23:04:05 +0100 | [diff] [blame] | 64 | .id = 0, |
Michael-Luke Jones | 5a4a238 | 2008-01-27 18:14:46 +0100 | [diff] [blame] | 65 | .dev = { |
Linus Walleij | b2e6355 | 2017-09-10 01:30:46 +0200 | [diff] [blame^] | 66 | .platform_data = NULL, |
Michael-Luke Jones | 0f18597 | 2006-12-16 23:04:05 +0100 | [diff] [blame] | 67 | }, |
Michael-Luke Jones | 0f18597 | 2006-12-16 23:04:05 +0100 | [diff] [blame] | 68 | }; |
| 69 | |
| 70 | static struct resource avila_uart_resources[] = { |
| 71 | { |
| 72 | .start = IXP4XX_UART1_BASE_PHYS, |
| 73 | .end = IXP4XX_UART1_BASE_PHYS + 0x0fff, |
| 74 | .flags = IORESOURCE_MEM |
| 75 | }, |
| 76 | { |
| 77 | .start = IXP4XX_UART2_BASE_PHYS, |
| 78 | .end = IXP4XX_UART2_BASE_PHYS + 0x0fff, |
| 79 | .flags = IORESOURCE_MEM |
| 80 | } |
| 81 | }; |
| 82 | |
| 83 | static struct plat_serial8250_port avila_uart_data[] = { |
| 84 | { |
| 85 | .mapbase = IXP4XX_UART1_BASE_PHYS, |
| 86 | .membase = (char *)IXP4XX_UART1_BASE_VIRT + REG_OFFSET, |
| 87 | .irq = IRQ_IXP4XX_UART1, |
| 88 | .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST, |
| 89 | .iotype = UPIO_MEM, |
| 90 | .regshift = 2, |
| 91 | .uartclk = IXP4XX_UART_XTAL, |
| 92 | }, |
| 93 | { |
| 94 | .mapbase = IXP4XX_UART2_BASE_PHYS, |
| 95 | .membase = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET, |
| 96 | .irq = IRQ_IXP4XX_UART2, |
| 97 | .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST, |
| 98 | .iotype = UPIO_MEM, |
| 99 | .regshift = 2, |
| 100 | .uartclk = IXP4XX_UART_XTAL, |
| 101 | }, |
| 102 | { }, |
| 103 | }; |
| 104 | |
| 105 | static struct platform_device avila_uart = { |
| 106 | .name = "serial8250", |
| 107 | .id = PLAT8250_DEV_PLATFORM, |
| 108 | .dev.platform_data = avila_uart_data, |
| 109 | .num_resources = 2, |
| 110 | .resource = avila_uart_resources |
| 111 | }; |
| 112 | |
Michael-Luke Jones | 946acb1 | 2006-12-16 23:02:00 +0100 | [diff] [blame] | 113 | static struct resource avila_pata_resources[] = { |
| 114 | { |
| 115 | .flags = IORESOURCE_MEM |
| 116 | }, |
| 117 | { |
| 118 | .flags = IORESOURCE_MEM, |
| 119 | }, |
| 120 | { |
| 121 | .name = "intrq", |
| 122 | .start = IRQ_IXP4XX_GPIO12, |
| 123 | .end = IRQ_IXP4XX_GPIO12, |
| 124 | .flags = IORESOURCE_IRQ, |
| 125 | }, |
| 126 | }; |
| 127 | |
| 128 | static struct ixp4xx_pata_data avila_pata_data = { |
| 129 | .cs0_bits = 0xbfff0043, |
| 130 | .cs1_bits = 0xbfff0043, |
| 131 | }; |
| 132 | |
| 133 | static struct platform_device avila_pata = { |
| 134 | .name = "pata_ixp4xx_cf", |
| 135 | .id = 0, |
| 136 | .dev.platform_data = &avila_pata_data, |
| 137 | .num_resources = ARRAY_SIZE(avila_pata_resources), |
| 138 | .resource = avila_pata_resources, |
| 139 | }; |
| 140 | |
Michael-Luke Jones | 0f18597 | 2006-12-16 23:04:05 +0100 | [diff] [blame] | 141 | static struct platform_device *avila_devices[] __initdata = { |
Michael-Luke Jones | 5a4a238 | 2008-01-27 18:14:46 +0100 | [diff] [blame] | 142 | &avila_i2c_gpio, |
Michael-Luke Jones | 0f18597 | 2006-12-16 23:04:05 +0100 | [diff] [blame] | 143 | &avila_flash, |
| 144 | &avila_uart |
| 145 | }; |
| 146 | |
| 147 | static void __init avila_init(void) |
| 148 | { |
| 149 | ixp4xx_sys_init(); |
| 150 | |
| 151 | avila_flash_resource.start = IXP4XX_EXP_BUS_BASE(0); |
| 152 | avila_flash_resource.end = |
| 153 | IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1; |
| 154 | |
Linus Walleij | b2e6355 | 2017-09-10 01:30:46 +0200 | [diff] [blame^] | 155 | gpiod_add_lookup_table(&avila_i2c_gpiod_table); |
| 156 | |
Michael-Luke Jones | 0f18597 | 2006-12-16 23:04:05 +0100 | [diff] [blame] | 157 | platform_add_devices(avila_devices, ARRAY_SIZE(avila_devices)); |
Michael-Luke Jones | 946acb1 | 2006-12-16 23:02:00 +0100 | [diff] [blame] | 158 | |
| 159 | avila_pata_resources[0].start = IXP4XX_EXP_BUS_BASE(1); |
| 160 | avila_pata_resources[0].end = IXP4XX_EXP_BUS_END(1); |
| 161 | |
| 162 | avila_pata_resources[1].start = IXP4XX_EXP_BUS_BASE(2); |
| 163 | avila_pata_resources[1].end = IXP4XX_EXP_BUS_END(2); |
| 164 | |
| 165 | avila_pata_data.cs0_cfg = IXP4XX_EXP_CS1; |
| 166 | avila_pata_data.cs1_cfg = IXP4XX_EXP_CS2; |
| 167 | |
| 168 | platform_device_register(&avila_pata); |
| 169 | |
Michael-Luke Jones | 0f18597 | 2006-12-16 23:04:05 +0100 | [diff] [blame] | 170 | } |
| 171 | |
| 172 | MACHINE_START(AVILA, "Gateworks Avila Network Platform") |
| 173 | /* Maintainer: Deepak Saxena <dsaxena@plexity.net> */ |
Michael-Luke Jones | 0f18597 | 2006-12-16 23:04:05 +0100 | [diff] [blame] | 174 | .map_io = ixp4xx_map_io, |
Rob Herring | f449588 | 2012-03-06 15:01:53 -0600 | [diff] [blame] | 175 | .init_early = ixp4xx_init_early, |
Michael-Luke Jones | 0f18597 | 2006-12-16 23:04:05 +0100 | [diff] [blame] | 176 | .init_irq = ixp4xx_init_irq, |
Stephen Warren | 6bb27d7 | 2012-11-08 12:40:59 -0700 | [diff] [blame] | 177 | .init_time = ixp4xx_timer_init, |
Nicolas Pitre | e022c72 | 2011-07-05 22:38:13 -0400 | [diff] [blame] | 178 | .atag_offset = 0x100, |
Michael-Luke Jones | 0f18597 | 2006-12-16 23:04:05 +0100 | [diff] [blame] | 179 | .init_machine = avila_init, |
Nicolas Pitre | 7553ee7 | 2011-07-05 22:28:09 -0400 | [diff] [blame] | 180 | #if defined(CONFIG_PCI) |
| 181 | .dma_zone_size = SZ_64M, |
| 182 | #endif |
Russell King | d1b860f | 2011-11-05 12:10:55 +0000 | [diff] [blame] | 183 | .restart = ixp4xx_restart, |
Michael-Luke Jones | 0f18597 | 2006-12-16 23:04:05 +0100 | [diff] [blame] | 184 | MACHINE_END |
| 185 | |
| 186 | /* |
| 187 | * Loft is functionally equivalent to Avila except that it has a |
| 188 | * different number for the maximum PCI devices. The MACHINE |
| 189 | * structure below is identical to Avila except for the comment. |
| 190 | */ |
| 191 | #ifdef CONFIG_MACH_LOFT |
| 192 | MACHINE_START(LOFT, "Giant Shoulder Inc Loft board") |
| 193 | /* Maintainer: Tom Billman <kernel@giantshoulderinc.com> */ |
Michael-Luke Jones | 0f18597 | 2006-12-16 23:04:05 +0100 | [diff] [blame] | 194 | .map_io = ixp4xx_map_io, |
Rob Herring | f449588 | 2012-03-06 15:01:53 -0600 | [diff] [blame] | 195 | .init_early = ixp4xx_init_early, |
Michael-Luke Jones | 0f18597 | 2006-12-16 23:04:05 +0100 | [diff] [blame] | 196 | .init_irq = ixp4xx_init_irq, |
Stephen Warren | 6bb27d7 | 2012-11-08 12:40:59 -0700 | [diff] [blame] | 197 | .init_time = ixp4xx_timer_init, |
Nicolas Pitre | e022c72 | 2011-07-05 22:38:13 -0400 | [diff] [blame] | 198 | .atag_offset = 0x100, |
Michael-Luke Jones | 0f18597 | 2006-12-16 23:04:05 +0100 | [diff] [blame] | 199 | .init_machine = avila_init, |
Nicolas Pitre | 7553ee7 | 2011-07-05 22:28:09 -0400 | [diff] [blame] | 200 | #if defined(CONFIG_PCI) |
| 201 | .dma_zone_size = SZ_64M, |
| 202 | #endif |
Russell King | d1b860f | 2011-11-05 12:10:55 +0000 | [diff] [blame] | 203 | .restart = ixp4xx_restart, |
Michael-Luke Jones | 0f18597 | 2006-12-16 23:04:05 +0100 | [diff] [blame] | 204 | MACHINE_END |
| 205 | #endif |
| 206 | |