summaryrefslogtreecommitdiff
path: root/usr/src/uts/sparc/io/pciex/pcie_sparc.c
blob: de5def9f4a99577361f939f4348934f28628e29d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
 */

#include <sys/types.h>
#include <sys/ddi.h>
#include <sys/sunddi.h>
#include <sys/sunndi.h>
#include <sys/pcie_impl.h>
#include <sys/pcie_pwr.h>

void
pcie_init_plat(dev_info_t *dip)
{
	pcie_bus_t	*bus_p = PCIE_DIP2BUS(dip);

	if (PCIE_IS_PCIE_BDG(bus_p)) {
		bus_p->bus_pcie2pci_secbus = bus_p->bus_bdg_secbus;
	} else {
		dev_info_t *pdip;

		for (pdip = ddi_get_parent(dip); pdip;
		    pdip = ddi_get_parent(pdip)) {
			pcie_bus_t *parent_bus_p = PCIE_DIP2BUS(pdip);

			if (parent_bus_p->bus_pcie2pci_secbus) {
				bus_p->bus_pcie2pci_secbus =
				    parent_bus_p->bus_pcie2pci_secbus;
				break;
			}
			if (PCIE_IS_ROOT(parent_bus_p))
				break;
		}
	}
}

void
pcie_fini_plat(dev_info_t *dip)
{
	pcie_bus_t	*bus_p = PCIE_DIP2BUS(dip);

	if (PCIE_IS_PCIE_BDG(bus_p))
		bus_p->bus_pcie2pci_secbus = 0;
}

int
pcie_plat_pwr_setup(dev_info_t *dip)
{
	if (ddi_prop_create(DDI_DEV_T_NONE, dip, DDI_PROP_CANSLEEP,
	    "pm-want-child-notification?", NULL, NULL) != DDI_PROP_SUCCESS) {
		PCIE_DBG("%s(%d): can't create pm-want-child-notification \n",
		    ddi_driver_name(dip), ddi_get_instance(dip));
		return (DDI_FAILURE);
	}
	return (DDI_SUCCESS);
}

/*
 * Undo whatever is done in pcie_plat_pwr_common_setup
 */
void
pcie_plat_pwr_teardown(dev_info_t *dip)
{
	(void) ddi_prop_remove(DDI_DEV_T_NONE, dip,
	    "pm-want-child-notification?");
}