1 /* $Id$
2  *
3  * This file is subject to the terms and conditions of the GNU General Public
4  * License.  See the file "COPYING" in the main directory of this archive
5  * for more details.
6  *
7  * Copyright (C) 1992 - 1997, 2000-2003 Silicon Graphics, Inc. All rights reserved.
8  */
9 
10 #include <linux/config.h>
11 #include <linux/types.h>
12 #include <asm/sn/sgi.h>
13 #include <asm/io.h>
14 #include <asm/sn/invent.h>
15 #include <asm/sn/hcl.h>
16 #include <asm/sn/pci/bridge.h>
17 #include "asm/sn/ioerror_handling.h"
18 #include <asm/sn/xtalk/xbow.h>
19 
20 /* these get called directly in cdl_add_connpt in fops bypass hack */
21 extern int pcibr_attach(vertex_hdl_t);
22 extern int xbow_attach(vertex_hdl_t);
23 extern int pic_attach(vertex_hdl_t);
24 
25 
26 /*
27  *    cdl: Connection and Driver List
28  *
29  *	We are not porting this to Linux.  Devices are registered via
30  *	the normal Linux PCI layer.  This is a very simplified version
31  *	of cdl that will allow us to register and call our very own
32  *	IO Infrastructure Drivers e.g. pcibr.
33  */
34 
35 #define MAX_SGI_IO_INFRA_DRVR 7
36 
37 static struct cdl sgi_infrastructure_drivers[MAX_SGI_IO_INFRA_DRVR] =
38 {
39 	{ XBRIDGE_WIDGET_PART_NUM, XBRIDGE_WIDGET_MFGR_NUM, pcibr_attach /* &pcibr_fops  */},
40 	{ BRIDGE_WIDGET_PART_NUM,  BRIDGE_WIDGET_MFGR_NUM,  pcibr_attach /* &pcibr_fops */},
41 	{ PIC_WIDGET_PART_NUM_BUS0,  PIC_WIDGET_MFGR_NUM,   pic_attach /* &pic_fops */},
42 	{ PIC_WIDGET_PART_NUM_BUS1,  PIC_WIDGET_MFGR_NUM,   pic_attach /* &pic_fops */},
43 	{ XXBOW_WIDGET_PART_NUM,   XXBOW_WIDGET_MFGR_NUM,   xbow_attach /* &xbow_fops */},
44 	{ XBOW_WIDGET_PART_NUM,    XBOW_WIDGET_MFGR_NUM,    xbow_attach /* &xbow_fops */},
45 	{ PXBOW_WIDGET_PART_NUM,   XXBOW_WIDGET_MFGR_NUM,   xbow_attach /* &xbow_fops */},
46 };
47 
48 /*
49  * cdl_add_connpt: We found a device and it's connect point.  Call the
50  * attach routine of that driver.
51  *
52  * May need support for pciba registration here ...
53  *
54  * This routine use to create /hw/.id/pci/.../.. that links to
55  * /hw/module/006c06/Pbrick/xtalk/15/pci/<slotnum> .. do we still need
56  * it?  The specified driver attach routine does not reference these
57  * vertices.
58  */
59 int
cdl_add_connpt(int part_num,int mfg_num,vertex_hdl_t connpt,int drv_flags)60 cdl_add_connpt(int part_num, int mfg_num,
61 	       vertex_hdl_t connpt, int drv_flags)
62 {
63 	int i;
64 
65 	/*
66 	 * Find the driver entry point and call the attach routine.
67 	 */
68 	for (i = 0; i < MAX_SGI_IO_INFRA_DRVR; i++) {
69 		if ( (part_num == sgi_infrastructure_drivers[i].part_num) &&
70 		   ( mfg_num == sgi_infrastructure_drivers[i].mfg_num) ) {
71 			/*
72 			 * Call the device attach routines.
73 			 */
74 			if (sgi_infrastructure_drivers[i].attach) {
75 			    return(sgi_infrastructure_drivers[i].attach(connpt));
76 			}
77 		} else {
78 			continue;
79 		}
80 	}
81 
82 	/* printk("WARNING: cdl_add_connpt: Driver not found for part_num 0x%x mfg_num 0x%x\n", part_num, mfg_num); */
83 
84 	return (0);
85 }
86