18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * arch/arm/mach-iop32x/iq80321.c 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Board support code for the Intel IQ80321 platform. 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * Author: Rory Bolt <rorybolt@pacbell.net> 88c2ecf20Sopenharmony_ci * Copyright (C) 2002 Rory Bolt 98c2ecf20Sopenharmony_ci * Copyright (C) 2004 Intel Corp. 108c2ecf20Sopenharmony_ci */ 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#include <linux/mm.h> 138c2ecf20Sopenharmony_ci#include <linux/init.h> 148c2ecf20Sopenharmony_ci#include <linux/kernel.h> 158c2ecf20Sopenharmony_ci#include <linux/pci.h> 168c2ecf20Sopenharmony_ci#include <linux/string.h> 178c2ecf20Sopenharmony_ci#include <linux/serial_core.h> 188c2ecf20Sopenharmony_ci#include <linux/serial_8250.h> 198c2ecf20Sopenharmony_ci#include <linux/mtd/physmap.h> 208c2ecf20Sopenharmony_ci#include <linux/platform_device.h> 218c2ecf20Sopenharmony_ci#include <linux/io.h> 228c2ecf20Sopenharmony_ci#include <linux/gpio/machine.h> 238c2ecf20Sopenharmony_ci#include <asm/irq.h> 248c2ecf20Sopenharmony_ci#include <asm/mach/arch.h> 258c2ecf20Sopenharmony_ci#include <asm/mach/map.h> 268c2ecf20Sopenharmony_ci#include <asm/mach/pci.h> 278c2ecf20Sopenharmony_ci#include <asm/mach/time.h> 288c2ecf20Sopenharmony_ci#include <asm/mach-types.h> 298c2ecf20Sopenharmony_ci#include <asm/page.h> 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci#include "hardware.h" 328c2ecf20Sopenharmony_ci#include "irqs.h" 338c2ecf20Sopenharmony_ci#include "gpio-iop32x.h" 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci/* 368c2ecf20Sopenharmony_ci * IQ80321 timer tick configuration. 378c2ecf20Sopenharmony_ci */ 388c2ecf20Sopenharmony_cistatic void __init iq80321_timer_init(void) 398c2ecf20Sopenharmony_ci{ 408c2ecf20Sopenharmony_ci /* 33.333 MHz crystal. */ 418c2ecf20Sopenharmony_ci iop_init_time(200000000); 428c2ecf20Sopenharmony_ci} 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci/* 468c2ecf20Sopenharmony_ci * IQ80321 I/O. 478c2ecf20Sopenharmony_ci */ 488c2ecf20Sopenharmony_cistatic struct map_desc iq80321_io_desc[] __initdata = { 498c2ecf20Sopenharmony_ci { /* on-board devices */ 508c2ecf20Sopenharmony_ci .virtual = IQ80321_UART, 518c2ecf20Sopenharmony_ci .pfn = __phys_to_pfn(IQ80321_UART), 528c2ecf20Sopenharmony_ci .length = 0x00100000, 538c2ecf20Sopenharmony_ci .type = MT_DEVICE, 548c2ecf20Sopenharmony_ci }, 558c2ecf20Sopenharmony_ci}; 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_civoid __init iq80321_map_io(void) 588c2ecf20Sopenharmony_ci{ 598c2ecf20Sopenharmony_ci iop3xx_map_io(); 608c2ecf20Sopenharmony_ci iotable_init(iq80321_io_desc, ARRAY_SIZE(iq80321_io_desc)); 618c2ecf20Sopenharmony_ci} 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci/* 658c2ecf20Sopenharmony_ci * IQ80321 PCI. 668c2ecf20Sopenharmony_ci */ 678c2ecf20Sopenharmony_cistatic int __init 688c2ecf20Sopenharmony_ciiq80321_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) 698c2ecf20Sopenharmony_ci{ 708c2ecf20Sopenharmony_ci int irq; 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_ci if ((slot == 2 || slot == 6) && pin == 1) { 738c2ecf20Sopenharmony_ci /* PCI-X Slot INTA */ 748c2ecf20Sopenharmony_ci irq = IRQ_IOP32X_XINT2; 758c2ecf20Sopenharmony_ci } else if ((slot == 2 || slot == 6) && pin == 2) { 768c2ecf20Sopenharmony_ci /* PCI-X Slot INTA */ 778c2ecf20Sopenharmony_ci irq = IRQ_IOP32X_XINT3; 788c2ecf20Sopenharmony_ci } else if ((slot == 2 || slot == 6) && pin == 3) { 798c2ecf20Sopenharmony_ci /* PCI-X Slot INTA */ 808c2ecf20Sopenharmony_ci irq = IRQ_IOP32X_XINT0; 818c2ecf20Sopenharmony_ci } else if ((slot == 2 || slot == 6) && pin == 4) { 828c2ecf20Sopenharmony_ci /* PCI-X Slot INTA */ 838c2ecf20Sopenharmony_ci irq = IRQ_IOP32X_XINT1; 848c2ecf20Sopenharmony_ci } else if (slot == 4 || slot == 8) { 858c2ecf20Sopenharmony_ci /* Gig-E */ 868c2ecf20Sopenharmony_ci irq = IRQ_IOP32X_XINT0; 878c2ecf20Sopenharmony_ci } else { 888c2ecf20Sopenharmony_ci printk(KERN_ERR "iq80321_pci_map_irq() called for unknown " 898c2ecf20Sopenharmony_ci "device PCI:%d:%d:%d\n", dev->bus->number, 908c2ecf20Sopenharmony_ci PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn)); 918c2ecf20Sopenharmony_ci irq = -1; 928c2ecf20Sopenharmony_ci } 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_ci return irq; 958c2ecf20Sopenharmony_ci} 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_cistatic struct hw_pci iq80321_pci __initdata = { 988c2ecf20Sopenharmony_ci .nr_controllers = 1, 998c2ecf20Sopenharmony_ci .ops = &iop3xx_ops, 1008c2ecf20Sopenharmony_ci .setup = iop3xx_pci_setup, 1018c2ecf20Sopenharmony_ci .preinit = iop3xx_pci_preinit_cond, 1028c2ecf20Sopenharmony_ci .map_irq = iq80321_pci_map_irq, 1038c2ecf20Sopenharmony_ci}; 1048c2ecf20Sopenharmony_ci 1058c2ecf20Sopenharmony_cistatic int __init iq80321_pci_init(void) 1068c2ecf20Sopenharmony_ci{ 1078c2ecf20Sopenharmony_ci if ((iop3xx_get_init_atu() == IOP3XX_INIT_ATU_ENABLE) && 1088c2ecf20Sopenharmony_ci machine_is_iq80321()) 1098c2ecf20Sopenharmony_ci pci_common_init(&iq80321_pci); 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_ci return 0; 1128c2ecf20Sopenharmony_ci} 1138c2ecf20Sopenharmony_ci 1148c2ecf20Sopenharmony_cisubsys_initcall(iq80321_pci_init); 1158c2ecf20Sopenharmony_ci 1168c2ecf20Sopenharmony_ci 1178c2ecf20Sopenharmony_ci/* 1188c2ecf20Sopenharmony_ci * IQ80321 machine initialisation. 1198c2ecf20Sopenharmony_ci */ 1208c2ecf20Sopenharmony_cistatic struct physmap_flash_data iq80321_flash_data = { 1218c2ecf20Sopenharmony_ci .width = 1, 1228c2ecf20Sopenharmony_ci}; 1238c2ecf20Sopenharmony_ci 1248c2ecf20Sopenharmony_cistatic struct resource iq80321_flash_resource = { 1258c2ecf20Sopenharmony_ci .start = 0xf0000000, 1268c2ecf20Sopenharmony_ci .end = 0xf07fffff, 1278c2ecf20Sopenharmony_ci .flags = IORESOURCE_MEM, 1288c2ecf20Sopenharmony_ci}; 1298c2ecf20Sopenharmony_ci 1308c2ecf20Sopenharmony_cistatic struct platform_device iq80321_flash_device = { 1318c2ecf20Sopenharmony_ci .name = "physmap-flash", 1328c2ecf20Sopenharmony_ci .id = 0, 1338c2ecf20Sopenharmony_ci .dev = { 1348c2ecf20Sopenharmony_ci .platform_data = &iq80321_flash_data, 1358c2ecf20Sopenharmony_ci }, 1368c2ecf20Sopenharmony_ci .num_resources = 1, 1378c2ecf20Sopenharmony_ci .resource = &iq80321_flash_resource, 1388c2ecf20Sopenharmony_ci}; 1398c2ecf20Sopenharmony_ci 1408c2ecf20Sopenharmony_cistatic struct plat_serial8250_port iq80321_serial_port[] = { 1418c2ecf20Sopenharmony_ci { 1428c2ecf20Sopenharmony_ci .mapbase = IQ80321_UART, 1438c2ecf20Sopenharmony_ci .membase = (char *)IQ80321_UART, 1448c2ecf20Sopenharmony_ci .irq = IRQ_IOP32X_XINT1, 1458c2ecf20Sopenharmony_ci .flags = UPF_SKIP_TEST, 1468c2ecf20Sopenharmony_ci .iotype = UPIO_MEM, 1478c2ecf20Sopenharmony_ci .regshift = 0, 1488c2ecf20Sopenharmony_ci .uartclk = 1843200, 1498c2ecf20Sopenharmony_ci }, 1508c2ecf20Sopenharmony_ci { }, 1518c2ecf20Sopenharmony_ci}; 1528c2ecf20Sopenharmony_ci 1538c2ecf20Sopenharmony_cistatic struct resource iq80321_uart_resource = { 1548c2ecf20Sopenharmony_ci .start = IQ80321_UART, 1558c2ecf20Sopenharmony_ci .end = IQ80321_UART + 7, 1568c2ecf20Sopenharmony_ci .flags = IORESOURCE_MEM, 1578c2ecf20Sopenharmony_ci}; 1588c2ecf20Sopenharmony_ci 1598c2ecf20Sopenharmony_cistatic struct platform_device iq80321_serial_device = { 1608c2ecf20Sopenharmony_ci .name = "serial8250", 1618c2ecf20Sopenharmony_ci .id = PLAT8250_DEV_PLATFORM, 1628c2ecf20Sopenharmony_ci .dev = { 1638c2ecf20Sopenharmony_ci .platform_data = iq80321_serial_port, 1648c2ecf20Sopenharmony_ci }, 1658c2ecf20Sopenharmony_ci .num_resources = 1, 1668c2ecf20Sopenharmony_ci .resource = &iq80321_uart_resource, 1678c2ecf20Sopenharmony_ci}; 1688c2ecf20Sopenharmony_ci 1698c2ecf20Sopenharmony_cistatic void __init iq80321_init_machine(void) 1708c2ecf20Sopenharmony_ci{ 1718c2ecf20Sopenharmony_ci register_iop32x_gpio(); 1728c2ecf20Sopenharmony_ci gpiod_add_lookup_table(&iop3xx_i2c0_gpio_lookup); 1738c2ecf20Sopenharmony_ci gpiod_add_lookup_table(&iop3xx_i2c1_gpio_lookup); 1748c2ecf20Sopenharmony_ci platform_device_register(&iop3xx_i2c0_device); 1758c2ecf20Sopenharmony_ci platform_device_register(&iop3xx_i2c1_device); 1768c2ecf20Sopenharmony_ci platform_device_register(&iq80321_flash_device); 1778c2ecf20Sopenharmony_ci platform_device_register(&iq80321_serial_device); 1788c2ecf20Sopenharmony_ci platform_device_register(&iop3xx_dma_0_channel); 1798c2ecf20Sopenharmony_ci platform_device_register(&iop3xx_dma_1_channel); 1808c2ecf20Sopenharmony_ci platform_device_register(&iop3xx_aau_channel); 1818c2ecf20Sopenharmony_ci} 1828c2ecf20Sopenharmony_ci 1838c2ecf20Sopenharmony_ciMACHINE_START(IQ80321, "Intel IQ80321") 1848c2ecf20Sopenharmony_ci /* Maintainer: Intel Corp. */ 1858c2ecf20Sopenharmony_ci .atag_offset = 0x100, 1868c2ecf20Sopenharmony_ci .map_io = iq80321_map_io, 1878c2ecf20Sopenharmony_ci .init_irq = iop32x_init_irq, 1888c2ecf20Sopenharmony_ci .init_time = iq80321_timer_init, 1898c2ecf20Sopenharmony_ci .init_machine = iq80321_init_machine, 1908c2ecf20Sopenharmony_ci .restart = iop3xx_restart, 1918c2ecf20Sopenharmony_ciMACHINE_END 192