1/* $Id: cdl.c,v 1.1.1.1 2008/10/15 03:26:03 james26_jang Exp $
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-2002 Silicon Graphics, Inc. All rights reserved.
8 */
9
10#include <linux/types.h>
11#include <asm/sn/sgi.h>
12#include <asm/io.h>
13#include <asm/sn/invent.h>
14#include <asm/sn/hcl.h>
15#include <asm/sn/pci/bridge.h>
16#include "asm/sn/ioerror_handling.h"
17#include <asm/sn/xtalk/xbow.h>
18
19/* these get called directly in cdl_add_connpt in fops bypass hack */
20extern int pcibr_attach(devfs_handle_t);
21extern int xbow_attach(devfs_handle_t);
22
23/*
24 *    cdl: Connection and Driver List
25 *
26 *	We are not porting this to Linux.  Devices are registered via
27 *	the normal Linux PCI layer.  This is a very simplified version
28 *	of cdl that will allow us to register and call our very own
29 *	IO Infrastructure Drivers e.g. pcibr.
30 */
31
32struct cdl {
33    int		part_num;
34    int		mfg_num;
35    int (*attach) (devfs_handle_t);
36} dummy_reg;
37
38#define MAX_SGI_IO_INFRA_DRVR 4
39struct cdl sgi_infrastructure_drivers[MAX_SGI_IO_INFRA_DRVR] =
40{
41	{ XBRIDGE_WIDGET_PART_NUM, XBRIDGE_WIDGET_MFGR_NUM, pcibr_attach /* &pcibr_fops  */},
42	{ BRIDGE_WIDGET_PART_NUM,  BRIDGE_WIDGET_MFGR_NUM,  pcibr_attach /* &pcibr_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};
46
47/*
48 * cdl_new:  Called by pciio and xtalk.
49 */
50cdl_p
51cdl_new(char *name, char *k1str, char *k2str)
52{
53    /*
54     * Just return a dummy pointer.
55     */
56    return((cdl_p)&dummy_reg);
57}
58
59/*
60 * cdl_del: Do nothing.
61 */
62void
63cdl_del(cdl_p reg)
64{
65	return;
66}
67
68/*
69 * cdl_add_driver: The driver part number and manufacturers number
70 * are statically initialized above.
71 *
72  Do nothing.
73 */
74int
75cdl_add_driver(cdl_p reg, int key1, int key2, char *prefix, int flags, cdl_drv_f *func)
76{
77    return 0;
78}
79
80/*
81 * cdl_del_driver: Not supported.
82 */
83void
84cdl_del_driver(cdl_p reg, char *prefix, cdl_drv_f *func)
85{
86	return;
87}
88
89/*
90 * cdl_add_connpt: We found a device and it's connect point.  Call the
91 * attach routine of that driver.
92 *
93 * May need support for pciba registration here ...
94 *
95 * This routine use to create /hw/.id/pci/.../.. that links to
96 * /hw/module/006c06/Pbrick/xtalk/15/pci/<slotnum> .. do we still need
97 * it?  The specified driver attach routine does not reference these
98 * vertices.
99 */
100int
101cdl_add_connpt(cdl_p reg, int part_num, int mfg_num,
102	       devfs_handle_t connpt, int drv_flags)
103{
104	int i;
105
106	/*
107	 * Find the driver entry point and call the attach routine.
108	 */
109	for (i = 0; i < MAX_SGI_IO_INFRA_DRVR; i++) {
110
111		if ( (part_num == sgi_infrastructure_drivers[i].part_num) &&
112		   ( mfg_num == sgi_infrastructure_drivers[i].mfg_num) ) {
113			/*
114			 * Call the device attach routines.
115			 */
116			if (sgi_infrastructure_drivers[i].attach) {
117			    return(sgi_infrastructure_drivers[i].attach(connpt));
118			}
119		} else {
120			continue;
121		}
122	}
123
124	/* printk("WARNING: cdl_add_connpt: Driver not found for part_num 0x%x mfg_num 0x%x\n", part_num, mfg_num); */
125
126	return (0);
127}
128
129/*
130 * cdl_del_connpt: Not implemented.
131 */
132int
133cdl_del_connpt(cdl_p reg, int key1, int key2, devfs_handle_t connpt, int drv_flags)
134{
135
136	return(0);
137}
138
139/*
140 *    cdl_iterate: Not Implemented.
141 */
142void
143cdl_iterate(cdl_p reg,
144	    char *prefix,
145	    cdl_iter_f * func)
146{
147	return;
148}
149
150async_attach_t
151async_attach_new(void)
152{
153
154	return(0);
155}
156
157void
158async_attach_free(async_attach_t aa)
159{
160	return;
161}
162
163async_attach_t
164async_attach_get_info(devfs_handle_t vhdl)
165{
166
167	return(0);
168}
169
170void
171async_attach_add_info(devfs_handle_t vhdl, async_attach_t aa)
172{
173	return;
174
175}
176
177void
178async_attach_del_info(devfs_handle_t vhdl)
179{
180	return;
181}
182
183void async_attach_signal_start(async_attach_t aa)
184{
185	return;
186}
187
188void async_attach_signal_done(async_attach_t aa)
189{
190	return;
191}
192
193void async_attach_waitall(async_attach_t aa)
194{
195	return;
196}
197
198