Path: blob/master/arch/arm/mach-ixp23xx/ixdp2351.c
10817 views
/*1* arch/arm/mach-ixp23xx/ixdp2351.c2*3* IXDP2351 board-specific routines4*5* Author: Deepak Saxena <[email protected]>6*7* Copyright 2005 (c) MontaVista Software, Inc.8*9* Based on 2.4 code Copyright 2004 (c) Intel Corporation10*11* This file is licensed under the terms of the GNU General Public12* License version 2. This program is licensed "as is" without any13* warranty of any kind, whether express or implied.14*/1516#include <linux/kernel.h>17#include <linux/init.h>18#include <linux/spinlock.h>19#include <linux/sched.h>20#include <linux/interrupt.h>21#include <linux/irq.h>22#include <linux/serial.h>23#include <linux/tty.h>24#include <linux/bitops.h>25#include <linux/ioport.h>26#include <linux/serial_8250.h>27#include <linux/serial_core.h>28#include <linux/device.h>29#include <linux/mm.h>30#include <linux/pci.h>31#include <linux/mtd/physmap.h>3233#include <asm/types.h>34#include <asm/setup.h>35#include <asm/memory.h>36#include <mach/hardware.h>37#include <asm/mach-types.h>38#include <asm/system.h>39#include <asm/tlbflush.h>40#include <asm/pgtable.h>4142#include <asm/mach/map.h>43#include <asm/mach/irq.h>44#include <asm/mach/arch.h>45#include <asm/mach/pci.h>4647/*48* IXDP2351 Interrupt Handling49*/50static void ixdp2351_inta_mask(struct irq_data *d)51{52*IXDP2351_CPLD_INTA_MASK_SET_REG = IXDP2351_INTA_IRQ_MASK(d->irq);53}5455static void ixdp2351_inta_unmask(struct irq_data *d)56{57*IXDP2351_CPLD_INTA_MASK_CLR_REG = IXDP2351_INTA_IRQ_MASK(d->irq);58}5960static void ixdp2351_inta_handler(unsigned int irq, struct irq_desc *desc)61{62u16 ex_interrupt =63*IXDP2351_CPLD_INTA_STAT_REG & IXDP2351_INTA_IRQ_VALID;64int i;6566desc->irq_data.chip->irq_mask(&desc->irq_data);6768for (i = 0; i < IXDP2351_INTA_IRQ_NUM; i++) {69if (ex_interrupt & (1 << i)) {70int cpld_irq =71IXP23XX_MACH_IRQ(IXDP2351_INTA_IRQ_BASE + i);72generic_handle_irq(cpld_irq);73}74}7576desc->irq_data.chip->irq_unmask(&desc->irq_data);77}7879static struct irq_chip ixdp2351_inta_chip = {80.irq_ack = ixdp2351_inta_mask,81.irq_mask = ixdp2351_inta_mask,82.irq_unmask = ixdp2351_inta_unmask83};8485static void ixdp2351_intb_mask(struct irq_data *d)86{87*IXDP2351_CPLD_INTB_MASK_SET_REG = IXDP2351_INTB_IRQ_MASK(d->irq);88}8990static void ixdp2351_intb_unmask(struct irq_data *d)91{92*IXDP2351_CPLD_INTB_MASK_CLR_REG = IXDP2351_INTB_IRQ_MASK(d->irq);93}9495static void ixdp2351_intb_handler(unsigned int irq, struct irq_desc *desc)96{97u16 ex_interrupt =98*IXDP2351_CPLD_INTB_STAT_REG & IXDP2351_INTB_IRQ_VALID;99int i;100101desc->irq_data.chip->irq_ack(&desc->irq_data);102103for (i = 0; i < IXDP2351_INTB_IRQ_NUM; i++) {104if (ex_interrupt & (1 << i)) {105int cpld_irq =106IXP23XX_MACH_IRQ(IXDP2351_INTB_IRQ_BASE + i);107generic_handle_irq(cpld_irq);108}109}110111desc->irq_data.chip->irq_unmask(&desc->irq_data);112}113114static struct irq_chip ixdp2351_intb_chip = {115.irq_ack = ixdp2351_intb_mask,116.irq_mask = ixdp2351_intb_mask,117.irq_unmask = ixdp2351_intb_unmask118};119120void __init ixdp2351_init_irq(void)121{122int irq;123124/* Mask all interrupts from CPLD, disable simulation */125*IXDP2351_CPLD_INTA_MASK_SET_REG = (u16) -1;126*IXDP2351_CPLD_INTB_MASK_SET_REG = (u16) -1;127*IXDP2351_CPLD_INTA_SIM_REG = 0;128*IXDP2351_CPLD_INTB_SIM_REG = 0;129130ixp23xx_init_irq();131132for (irq = IXP23XX_MACH_IRQ(IXDP2351_INTA_IRQ_BASE);133irq <134IXP23XX_MACH_IRQ(IXDP2351_INTA_IRQ_BASE + IXDP2351_INTA_IRQ_NUM);135irq++) {136if (IXDP2351_INTA_IRQ_MASK(irq) & IXDP2351_INTA_IRQ_VALID) {137set_irq_flags(irq, IRQF_VALID);138irq_set_chip_and_handler(irq, &ixdp2351_inta_chip,139handle_level_irq);140}141}142143for (irq = IXP23XX_MACH_IRQ(IXDP2351_INTB_IRQ_BASE);144irq <145IXP23XX_MACH_IRQ(IXDP2351_INTB_IRQ_BASE + IXDP2351_INTB_IRQ_NUM);146irq++) {147if (IXDP2351_INTB_IRQ_MASK(irq) & IXDP2351_INTB_IRQ_VALID) {148set_irq_flags(irq, IRQF_VALID);149irq_set_chip_and_handler(irq, &ixdp2351_intb_chip,150handle_level_irq);151}152}153154irq_set_chained_handler(IRQ_IXP23XX_INTA, ixdp2351_inta_handler);155irq_set_chained_handler(IRQ_IXP23XX_INTB, ixdp2351_intb_handler);156}157158/*159* IXDP2351 PCI160*/161162/*163* This board does not do normal PCI IRQ routing, or any164* sort of swizzling, so we just need to check where on the165* bus the device is and figure out what CPLD pin it is166* being routed to.167*/168#define DEVPIN(dev, pin) ((pin) | ((dev) << 3))169170static int __init ixdp2351_map_irq(struct pci_dev *dev, u8 slot, u8 pin)171{172u8 bus = dev->bus->number;173u32 devpin = DEVPIN(PCI_SLOT(dev->devfn), pin);174struct pci_bus *tmp_bus = dev->bus;175176/* Primary bus, no interrupts here */177if (!bus)178return -1;179180/* Lookup first leaf in bus tree */181while ((tmp_bus->parent != NULL) && (tmp_bus->parent->parent != NULL))182tmp_bus = tmp_bus->parent;183184/* Select between known bridges */185switch (tmp_bus->self->devfn | (tmp_bus->self->bus->number << 8)) {186/* Device is located after first bridge */187case 0x0008:188if (tmp_bus == dev->bus) {189/* Device is located directy after first bridge */190switch (devpin) {191/* Onboard 82546 */192case DEVPIN(1, 1): /* Onboard 82546 ch 0 */193return IRQ_IXDP2351_INTA_82546;194case DEVPIN(1, 2): /* Onboard 82546 ch 1 */195return IRQ_IXDP2351_INTB_82546;196/* PMC SLOT */197case DEVPIN(0, 1): /* PMCP INTA# */198case DEVPIN(2, 4): /* PMCS INTD# */199return IRQ_IXDP2351_SPCI_PMC_INTA;200case DEVPIN(0, 2): /* PMCP INTB# */201case DEVPIN(2, 1): /* PMCS INTA# */202return IRQ_IXDP2351_SPCI_PMC_INTB;203case DEVPIN(0, 3): /* PMCP INTC# */204case DEVPIN(2, 2): /* PMCS INTB# */205return IRQ_IXDP2351_SPCI_PMC_INTC;206case DEVPIN(0, 4): /* PMCP INTD# */207case DEVPIN(2, 3): /* PMCS INTC# */208return IRQ_IXDP2351_SPCI_PMC_INTD;209}210} else {211/* Device is located indirectly after first bridge */212/* Not supported now */213return -1;214}215break;216case 0x0010:217if (tmp_bus == dev->bus) {218/* Device is located directy after second bridge */219/* Secondary bus of second bridge */220switch (devpin) {221case DEVPIN(0, 1): /* DB#0 */222case DEVPIN(0, 2):223case DEVPIN(0, 3):224case DEVPIN(0, 4):225return IRQ_IXDP2351_SPCI_DB_0;226case DEVPIN(1, 1): /* DB#1 */227case DEVPIN(1, 2):228case DEVPIN(1, 3):229case DEVPIN(1, 4):230return IRQ_IXDP2351_SPCI_DB_1;231case DEVPIN(2, 1): /* FIC1 */232case DEVPIN(2, 2):233case DEVPIN(2, 3):234case DEVPIN(2, 4):235case DEVPIN(3, 1): /* FIC2 */236case DEVPIN(3, 2):237case DEVPIN(3, 3):238case DEVPIN(3, 4):239return IRQ_IXDP2351_SPCI_FIC;240}241} else {242/* Device is located indirectly after second bridge */243/* Not supported now */244return -1;245}246break;247}248249return -1;250}251252struct hw_pci ixdp2351_pci __initdata = {253.nr_controllers = 1,254.preinit = ixp23xx_pci_preinit,255.setup = ixp23xx_pci_setup,256.scan = ixp23xx_pci_scan_bus,257.map_irq = ixdp2351_map_irq,258};259260int __init ixdp2351_pci_init(void)261{262if (machine_is_ixdp2351())263pci_common_init(&ixdp2351_pci);264265return 0;266}267268subsys_initcall(ixdp2351_pci_init);269270/*271* IXDP2351 Static Mapped I/O272*/273static struct map_desc ixdp2351_io_desc[] __initdata = {274{275.virtual = IXDP2351_NP_VIRT_BASE,276.pfn = __phys_to_pfn((u64)IXDP2351_NP_PHYS_BASE),277.length = IXDP2351_NP_PHYS_SIZE,278.type = MT_DEVICE279}, {280.virtual = IXDP2351_BB_BASE_VIRT,281.pfn = __phys_to_pfn((u64)IXDP2351_BB_BASE_PHYS),282.length = IXDP2351_BB_SIZE,283.type = MT_DEVICE284}285};286287static void __init ixdp2351_map_io(void)288{289ixp23xx_map_io();290iotable_init(ixdp2351_io_desc, ARRAY_SIZE(ixdp2351_io_desc));291}292293static struct physmap_flash_data ixdp2351_flash_data = {294.width = 1,295};296297static struct resource ixdp2351_flash_resource = {298.start = 0x90000000,299.end = 0x93ffffff,300.flags = IORESOURCE_MEM,301};302303static struct platform_device ixdp2351_flash = {304.name = "physmap-flash",305.id = 0,306.dev = {307.platform_data = &ixdp2351_flash_data,308},309.num_resources = 1,310.resource = &ixdp2351_flash_resource,311};312313static void __init ixdp2351_init(void)314{315platform_device_register(&ixdp2351_flash);316317/*318* Mark flash as writeable319*/320IXP23XX_EXP_CS0[0] |= IXP23XX_FLASH_WRITABLE;321IXP23XX_EXP_CS0[1] |= IXP23XX_FLASH_WRITABLE;322IXP23XX_EXP_CS0[2] |= IXP23XX_FLASH_WRITABLE;323IXP23XX_EXP_CS0[3] |= IXP23XX_FLASH_WRITABLE;324325ixp23xx_sys_init();326}327328MACHINE_START(IXDP2351, "Intel IXDP2351 Development Platform")329/* Maintainer: MontaVista Software, Inc. */330.map_io = ixdp2351_map_io,331.init_irq = ixdp2351_init_irq,332.timer = &ixp23xx_timer,333.boot_params = 0x00000100,334.init_machine = ixdp2351_init,335MACHINE_END336337338