Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * arch/arm/mach-ixp2000/ixdp2400.c |
| 3 | * |
| 4 | * IXDP2400 platform support |
| 5 | * |
| 6 | * Original Author: Naeem Afzal <naeem.m.afzal@intel.com> |
| 7 | * Maintainer: Deepak Saxena <dsaxena@plexity.net> |
| 8 | * |
| 9 | * Copyright (C) 2002 Intel Corp. |
| 10 | * Copyright (C) 2003-2004 MontaVista Software, Inc. |
| 11 | * |
| 12 | * This program is free software; you can redistribute it and/or modify it |
| 13 | * under the terms of the GNU General Public License as published by the |
| 14 | * Free Software Foundation; either version 2 of the License, or (at your |
| 15 | * option) any later version. |
| 16 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | #include <linux/kernel.h> |
| 18 | #include <linux/init.h> |
| 19 | #include <linux/mm.h> |
| 20 | #include <linux/sched.h> |
| 21 | #include <linux/interrupt.h> |
| 22 | #include <linux/device.h> |
| 23 | #include <linux/bitops.h> |
| 24 | #include <linux/pci.h> |
| 25 | #include <linux/ioport.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | #include <linux/delay.h> |
Russell King | fced80c | 2008-09-06 12:10:45 +0100 | [diff] [blame] | 27 | #include <linux/io.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | #include <asm/irq.h> |
| 30 | #include <asm/pgtable.h> |
| 31 | #include <asm/page.h> |
| 32 | #include <asm/system.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 33 | #include <mach/hardware.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | #include <asm/mach-types.h> |
| 35 | |
| 36 | #include <asm/mach/pci.h> |
| 37 | #include <asm/mach/map.h> |
| 38 | #include <asm/mach/irq.h> |
| 39 | #include <asm/mach/time.h> |
| 40 | #include <asm/mach/flash.h> |
| 41 | #include <asm/mach/arch.h> |
| 42 | |
| 43 | /************************************************************************* |
| 44 | * IXDP2400 timer tick |
| 45 | *************************************************************************/ |
| 46 | static void __init ixdp2400_timer_init(void) |
| 47 | { |
| 48 | int numerator, denominator; |
| 49 | int denom_array[] = {2, 4, 8, 16, 1, 2, 4, 8}; |
| 50 | |
| 51 | numerator = (*(IXDP2400_CPLD_SYS_CLK_M) & 0xFF) *2; |
| 52 | denominator = denom_array[(*(IXDP2400_CPLD_SYS_CLK_N) & 0x7)]; |
| 53 | |
| 54 | ixp2000_init_time(((3125000 * numerator) / (denominator)) / 2); |
| 55 | } |
| 56 | |
| 57 | static struct sys_timer ixdp2400_timer = { |
| 58 | .init = ixdp2400_timer_init, |
| 59 | .offset = ixp2000_gettimeoffset, |
| 60 | }; |
| 61 | |
| 62 | /************************************************************************* |
| 63 | * IXDP2400 PCI |
| 64 | *************************************************************************/ |
| 65 | void __init ixdp2400_pci_preinit(void) |
| 66 | { |
| 67 | ixp2000_reg_write(IXP2000_PCI_ADDR_EXT, 0x00100000); |
| 68 | ixp2000_pci_preinit(); |
Lennert Buytenhek | f8e5b28 | 2006-02-08 21:09:04 +0000 | [diff] [blame] | 69 | pcibios_setup("firmware"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | } |
| 71 | |
| 72 | int ixdp2400_pci_setup(int nr, struct pci_sys_data *sys) |
| 73 | { |
| 74 | sys->mem_offset = 0xe0000000; |
| 75 | |
| 76 | ixp2000_pci_setup(nr, sys); |
| 77 | |
| 78 | return 1; |
| 79 | } |
| 80 | |
Ralf Baechle | d534194 | 2011-06-10 15:30:21 +0100 | [diff] [blame] | 81 | static int __init ixdp2400_pci_map_irq(const struct pci_dev *dev, u8 slot, |
| 82 | u8 pin) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | { |
| 84 | if (ixdp2x00_master_npu()) { |
| 85 | |
| 86 | /* |
| 87 | * Root bus devices. Slave NPU is only one with interrupt. |
| 88 | * Everything else, we just return -1 b/c nothing else |
| 89 | * on the root bus has interrupts. |
| 90 | */ |
| 91 | if(!dev->bus->self) { |
| 92 | if(dev->devfn == IXDP2X00_SLAVE_NPU_DEVFN ) |
| 93 | return IRQ_IXDP2400_INGRESS_NPU; |
| 94 | |
| 95 | return -1; |
| 96 | } |
| 97 | |
| 98 | /* |
| 99 | * Bridge behind the PMC slot. |
| 100 | * NOTE: Only INTA from the PMC slot is routed. VERY BAD. |
| 101 | */ |
| 102 | if(dev->bus->self->devfn == IXDP2X00_PMC_DEVFN && |
| 103 | dev->bus->parent->self->devfn == IXDP2X00_P2P_DEVFN && |
| 104 | !dev->bus->parent->self->bus->parent) |
| 105 | return IRQ_IXDP2400_PMC; |
| 106 | |
| 107 | /* |
| 108 | * Device behind the first bridge |
| 109 | */ |
| 110 | if(dev->bus->self->devfn == IXDP2X00_P2P_DEVFN) { |
| 111 | switch(dev->devfn) { |
| 112 | case IXDP2400_MASTER_ENET_DEVFN: |
| 113 | return IRQ_IXDP2400_ENET; |
| 114 | |
| 115 | case IXDP2400_MEDIA_DEVFN: |
| 116 | return IRQ_IXDP2400_MEDIA_PCI; |
| 117 | |
| 118 | case IXDP2400_SWITCH_FABRIC_DEVFN: |
| 119 | return IRQ_IXDP2400_SF_PCI; |
| 120 | |
| 121 | case IXDP2X00_PMC_DEVFN: |
| 122 | return IRQ_IXDP2400_PMC; |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | return -1; |
| 127 | } else return IRQ_IXP2000_PCIB; /* Slave NIC interrupt */ |
| 128 | } |
| 129 | |
| 130 | |
| 131 | static void ixdp2400_pci_postinit(void) |
| 132 | { |
| 133 | struct pci_dev *dev; |
| 134 | |
| 135 | if (ixdp2x00_master_npu()) { |
Alan Cox | 7281c24 | 2006-10-16 16:49:50 +0100 | [diff] [blame] | 136 | dev = pci_get_bus_and_slot(1, IXDP2400_SLAVE_ENET_DEVFN); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | pci_remove_bus_device(dev); |
Russell King | cf610ca | 2006-10-20 20:16:24 +0100 | [diff] [blame] | 138 | pci_dev_put(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 | } else { |
Alan Cox | 7281c24 | 2006-10-16 16:49:50 +0100 | [diff] [blame] | 140 | dev = pci_get_bus_and_slot(1, IXDP2400_MASTER_ENET_DEVFN); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 141 | pci_remove_bus_device(dev); |
Russell King | cf610ca | 2006-10-20 20:16:24 +0100 | [diff] [blame] | 142 | pci_dev_put(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | |
| 144 | ixdp2x00_slave_pci_postinit(); |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | static struct hw_pci ixdp2400_pci __initdata = { |
| 149 | .nr_controllers = 1, |
| 150 | .setup = ixdp2400_pci_setup, |
| 151 | .preinit = ixdp2400_pci_preinit, |
| 152 | .postinit = ixdp2400_pci_postinit, |
| 153 | .scan = ixp2000_pci_scan_bus, |
| 154 | .map_irq = ixdp2400_pci_map_irq, |
| 155 | }; |
| 156 | |
| 157 | int __init ixdp2400_pci_init(void) |
| 158 | { |
| 159 | if (machine_is_ixdp2400()) |
| 160 | pci_common_init(&ixdp2400_pci); |
| 161 | |
| 162 | return 0; |
| 163 | } |
| 164 | |
| 165 | subsys_initcall(ixdp2400_pci_init); |
| 166 | |
Russell King | cdea460 | 2007-05-30 17:48:45 +0100 | [diff] [blame] | 167 | void __init ixdp2400_init_irq(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 168 | { |
| 169 | ixdp2x00_init_irq(IXDP2400_CPLD_INT_STAT, IXDP2400_CPLD_INT_MASK, IXDP2400_NR_IRQS); |
| 170 | } |
| 171 | |
| 172 | MACHINE_START(IXDP2400, "Intel IXDP2400 Development Platform") |
Russell King | e9dea0c | 2005-07-03 17:38:58 +0100 | [diff] [blame] | 173 | /* Maintainer: MontaVista Software, Inc. */ |
Nicolas Pitre | ade5931 | 2011-07-05 22:38:13 -0400 | [diff] [blame^] | 174 | .atag_offset = 0x100, |
Russell King | e9dea0c | 2005-07-03 17:38:58 +0100 | [diff] [blame] | 175 | .map_io = ixdp2x00_map_io, |
| 176 | .init_irq = ixdp2400_init_irq, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 177 | .timer = &ixdp2400_timer, |
Russell King | e9dea0c | 2005-07-03 17:38:58 +0100 | [diff] [blame] | 178 | .init_machine = ixdp2x00_init_machine, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 179 | MACHINE_END |
| 180 | |