xref: /titanic_50/usr/src/uts/sparc/io/pciex/pcie_sparc.c (revision 6e1ae2a33c618c4c2b14aec7d2f21743ddea5837)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
23  */
24 
25 #include <sys/types.h>
26 #include <sys/ddi.h>
27 #include <sys/sunddi.h>
28 #include <sys/sunndi.h>
29 #include <sys/pcie_impl.h>
30 #include <sys/pcie_pwr.h>
31 
32 void
33 pcie_init_plat(dev_info_t *dip)
34 {
35 	pcie_bus_t	*bus_p = PCIE_DIP2BUS(dip);
36 
37 	if (PCIE_IS_PCIE_BDG(bus_p)) {
38 		bus_p->bus_pcie2pci_secbus = bus_p->bus_bdg_secbus;
39 	} else {
40 		dev_info_t *pdip;
41 
42 		for (pdip = ddi_get_parent(dip); pdip;
43 		    pdip = ddi_get_parent(pdip)) {
44 			pcie_bus_t *parent_bus_p = PCIE_DIP2BUS(pdip);
45 
46 			if (parent_bus_p->bus_pcie2pci_secbus) {
47 				bus_p->bus_pcie2pci_secbus =
48 				    parent_bus_p->bus_pcie2pci_secbus;
49 				break;
50 			}
51 			if (PCIE_IS_ROOT(parent_bus_p))
52 				break;
53 		}
54 	}
55 }
56 
57 void
58 pcie_fini_plat(dev_info_t *dip)
59 {
60 	pcie_bus_t	*bus_p = PCIE_DIP2BUS(dip);
61 
62 	if (PCIE_IS_PCIE_BDG(bus_p))
63 		bus_p->bus_pcie2pci_secbus = 0;
64 }
65 
66 int
67 pcie_plat_pwr_setup(dev_info_t *dip)
68 {
69 	if (ddi_prop_create(DDI_DEV_T_NONE, dip, DDI_PROP_CANSLEEP,
70 	    "pm-want-child-notification?", NULL, NULL) != DDI_PROP_SUCCESS) {
71 		PCIE_DBG("%s(%d): can't create pm-want-child-notification \n",
72 		    ddi_driver_name(dip), ddi_get_instance(dip));
73 		return (DDI_FAILURE);
74 	}
75 	return (DDI_SUCCESS);
76 }
77 
78 /*
79  * Undo whatever is done in pcie_plat_pwr_common_setup
80  */
81 void
82 pcie_plat_pwr_teardown(dev_info_t *dip)
83 {
84 	(void) ddi_prop_remove(DDI_DEV_T_NONE, dip,
85 	    "pm-want-child-notification?");
86 }
87