ixdp2400.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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. */
  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>
  26. #include <linux/delay.h>
  27. #include <linux/io.h>
  28. #include <asm/irq.h>
  29. #include <asm/pgtable.h>
  30. #include <asm/page.h>
  31. #include <asm/system.h>
  32. #include <mach/hardware.h>
  33. #include <asm/mach-types.h>
  34. #include <asm/mach/pci.h>
  35. #include <asm/mach/map.h>
  36. #include <asm/mach/irq.h>
  37. #include <asm/mach/time.h>
  38. #include <asm/mach/flash.h>
  39. #include <asm/mach/arch.h>
  40. /*************************************************************************
  41. * IXDP2400 timer tick
  42. *************************************************************************/
  43. static void __init ixdp2400_timer_init(void)
  44. {
  45. int numerator, denominator;
  46. int denom_array[] = {2, 4, 8, 16, 1, 2, 4, 8};
  47. numerator = (*(IXDP2400_CPLD_SYS_CLK_M) & 0xFF) *2;
  48. denominator = denom_array[(*(IXDP2400_CPLD_SYS_CLK_N) & 0x7)];
  49. ixp2000_init_time(((3125000 * numerator) / (denominator)) / 2);
  50. }
  51. static struct sys_timer ixdp2400_timer = {
  52. .init = ixdp2400_timer_init,
  53. .offset = ixp2000_gettimeoffset,
  54. };
  55. /*************************************************************************
  56. * IXDP2400 PCI
  57. *************************************************************************/
  58. void __init ixdp2400_pci_preinit(void)
  59. {
  60. ixp2000_reg_write(IXP2000_PCI_ADDR_EXT, 0x00100000);
  61. ixp2000_pci_preinit();
  62. pcibios_setup("firmware");
  63. }
  64. int ixdp2400_pci_setup(int nr, struct pci_sys_data *sys)
  65. {
  66. sys->mem_offset = 0xe0000000;
  67. ixp2000_pci_setup(nr, sys);
  68. return 1;
  69. }
  70. static int __init ixdp2400_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
  71. {
  72. if (ixdp2x00_master_npu()) {
  73. /*
  74. * Root bus devices. Slave NPU is only one with interrupt.
  75. * Everything else, we just return -1 b/c nothing else
  76. * on the root bus has interrupts.
  77. */
  78. if(!dev->bus->self) {
  79. if(dev->devfn == IXDP2X00_SLAVE_NPU_DEVFN )
  80. return IRQ_IXDP2400_INGRESS_NPU;
  81. return -1;
  82. }
  83. /*
  84. * Bridge behind the PMC slot.
  85. * NOTE: Only INTA from the PMC slot is routed. VERY BAD.
  86. */
  87. if(dev->bus->self->devfn == IXDP2X00_PMC_DEVFN &&
  88. dev->bus->parent->self->devfn == IXDP2X00_P2P_DEVFN &&
  89. !dev->bus->parent->self->bus->parent)
  90. return IRQ_IXDP2400_PMC;
  91. /*
  92. * Device behind the first bridge
  93. */
  94. if(dev->bus->self->devfn == IXDP2X00_P2P_DEVFN) {
  95. switch(dev->devfn) {
  96. case IXDP2400_MASTER_ENET_DEVFN:
  97. return IRQ_IXDP2400_ENET;
  98. case IXDP2400_MEDIA_DEVFN:
  99. return IRQ_IXDP2400_MEDIA_PCI;
  100. case IXDP2400_SWITCH_FABRIC_DEVFN:
  101. return IRQ_IXDP2400_SF_PCI;
  102. case IXDP2X00_PMC_DEVFN:
  103. return IRQ_IXDP2400_PMC;
  104. }
  105. }
  106. return -1;
  107. } else return IRQ_IXP2000_PCIB; /* Slave NIC interrupt */
  108. }
  109. static void ixdp2400_pci_postinit(void)
  110. {
  111. struct pci_dev *dev;
  112. if (ixdp2x00_master_npu()) {
  113. dev = pci_get_bus_and_slot(1, IXDP2400_SLAVE_ENET_DEVFN);
  114. pci_remove_bus_device(dev);
  115. pci_dev_put(dev);
  116. } else {
  117. dev = pci_get_bus_and_slot(1, IXDP2400_MASTER_ENET_DEVFN);
  118. pci_remove_bus_device(dev);
  119. pci_dev_put(dev);
  120. ixdp2x00_slave_pci_postinit();
  121. }
  122. }
  123. static struct hw_pci ixdp2400_pci __initdata = {
  124. .nr_controllers = 1,
  125. .setup = ixdp2400_pci_setup,
  126. .preinit = ixdp2400_pci_preinit,
  127. .postinit = ixdp2400_pci_postinit,
  128. .scan = ixp2000_pci_scan_bus,
  129. .map_irq = ixdp2400_pci_map_irq,
  130. };
  131. int __init ixdp2400_pci_init(void)
  132. {
  133. if (machine_is_ixdp2400())
  134. pci_common_init(&ixdp2400_pci);
  135. return 0;
  136. }
  137. subsys_initcall(ixdp2400_pci_init);
  138. void __init ixdp2400_init_irq(void)
  139. {
  140. ixdp2x00_init_irq(IXDP2400_CPLD_INT_STAT, IXDP2400_CPLD_INT_MASK, IXDP2400_NR_IRQS);
  141. }
  142. MACHINE_START(IXDP2400, "Intel IXDP2400 Development Platform")
  143. /* Maintainer: MontaVista Software, Inc. */
  144. .phys_io = IXP2000_UART_PHYS_BASE,
  145. .io_pg_offst = ((IXP2000_UART_VIRT_BASE) >> 18) & 0xfffc,
  146. .boot_params = 0x00000100,
  147. .map_io = ixdp2x00_map_io,
  148. .init_irq = ixdp2400_init_irq,
  149. .timer = &ixdp2400_timer,
  150. .init_machine = ixdp2x00_init_machine,
  151. MACHINE_END