spruce_pci.c
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:3k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. /*
  2.  * arch/ppc/platforms/spruce_pci.c
  3.  * 
  4.  * PCI support for IBM Spruce
  5.  *
  6.  * Author: Johnnie Peters
  7.  *         jpeters@mvista.com
  8.  *
  9.  * Copyright 2000 MontaVista Software Inc.
  10.  *
  11.  * This program is free software; you can redistribute  it and/or modify it
  12.  * under  the terms of  the GNU General Public License as published by the
  13.  * Free Software Foundation;  either version 2 of the  License, or (at your
  14.  * option) any later version.
  15.  *
  16.  * THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR   IMPLIED
  17.  * WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
  18.  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
  19.  * NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT,  INDIRECT,
  20.  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  21.  * NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
  22.  * USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  23.  * ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
  24.  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  25.  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26.  *
  27.  * You should have received a copy of the  GNU General Public License along
  28.  * with this program; if not, write  to the Free Software Foundation, Inc.,
  29.  * 675 Mass Ave, Cambridge, MA 02139, USA.
  30.  */
  31. #include <linux/kernel.h>
  32. #include <linux/init.h>
  33. #include <linux/pci.h>
  34. #include <linux/slab.h>
  35. #include <asm/byteorder.h>
  36. #include <asm/io.h>
  37. #include <asm/uaccess.h>
  38. #include <asm/machdep.h>
  39. #include <asm/pci-bridge.h>
  40. #include <platforms/spruce.h>
  41. #include "cpc700.h"
  42. static inline int
  43. spruce_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
  44. {
  45. static char pci_irq_table[][4] =
  46. /*
  47.  *  PCI IDSEL/INTPIN->INTLINE 
  48.  *  A B C D
  49.  */
  50. {
  51. {23, 24, 25, 26}, /* IDSEL 1 - PCI slot 3 */
  52. {24, 25, 26, 23}, /* IDSEL 2 - PCI slot 2 */
  53. {25, 26, 23, 24}, /* IDSEL 3 - PCI slot 1 */
  54. {26, 23, 24, 25}, /* IDSEL 4 - PCI slot 0 */
  55. };
  56. const long min_idsel = 1, max_idsel = 4, irqs_per_slot = 4;
  57. return PCI_IRQ_TABLE_LOOKUP;
  58. }
  59. void __init
  60. spruce_setup_hose(void)
  61. {
  62. struct pci_controller *hose;
  63. /* Setup hose */
  64. hose = pcibios_alloc_controller();
  65. if (!hose) 
  66. return;
  67. hose->first_busno = 0;
  68. hose->last_busno = 0xff;
  69. pci_init_resource(&hose->io_resource,
  70. SPRUCE_PCI_LOWER_IO,
  71. SPRUCE_PCI_UPPER_IO,
  72. IORESOURCE_IO,
  73. "PCI host bridge");
  74. pci_init_resource(&hose->mem_resources[0],
  75. SPRUCE_PCI_LOWER_MEM,
  76. SPRUCE_PCI_UPPER_MEM,
  77. IORESOURCE_MEM,
  78. "PCI host bridge");
  79. hose->io_space.start = SPRUCE_PCI_LOWER_IO;
  80. hose->io_space.end = SPRUCE_PCI_UPPER_IO;
  81. hose->mem_space.start = SPRUCE_PCI_LOWER_MEM;
  82. hose->mem_space.end = SPRUCE_PCI_UPPER_MEM;
  83. hose->io_base_virt = (void *)SPRUCE_ISA_IO_BASE;
  84. setup_indirect_pci(hose,
  85. SPRUCE_PCI_CONFIG_ADDR,
  86. SPRUCE_PCI_CONFIG_DATA);
  87. hose->last_busno = pciauto_bus_scan(hose, hose->first_busno);
  88. ppc_md.pci_swizzle = common_swizzle;
  89. ppc_md.pci_map_irq = spruce_map_irq;
  90. }