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