110750SShesha.Sreenivasamurthy@Sun.COM /*
210750SShesha.Sreenivasamurthy@Sun.COM * CDDL HEADER START
310750SShesha.Sreenivasamurthy@Sun.COM *
410750SShesha.Sreenivasamurthy@Sun.COM * The contents of this file are subject to the terms of the
510750SShesha.Sreenivasamurthy@Sun.COM * Common Development and Distribution License (the "License").
610750SShesha.Sreenivasamurthy@Sun.COM * You may not use this file except in compliance with the License.
710750SShesha.Sreenivasamurthy@Sun.COM *
810750SShesha.Sreenivasamurthy@Sun.COM * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
910750SShesha.Sreenivasamurthy@Sun.COM * or http://www.opensolaris.org/os/licensing.
1010750SShesha.Sreenivasamurthy@Sun.COM * See the License for the specific language governing permissions
1110750SShesha.Sreenivasamurthy@Sun.COM * and limitations under the License.
1210750SShesha.Sreenivasamurthy@Sun.COM *
1310750SShesha.Sreenivasamurthy@Sun.COM * When distributing Covered Code, include this CDDL HEADER in each
1410750SShesha.Sreenivasamurthy@Sun.COM * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1510750SShesha.Sreenivasamurthy@Sun.COM * If applicable, add the following below this CDDL HEADER, with the
1610750SShesha.Sreenivasamurthy@Sun.COM * fields enclosed by brackets "[]" replaced with your own identifying
1710750SShesha.Sreenivasamurthy@Sun.COM * information: Portions Copyright [yyyy] [name of copyright owner]
1810750SShesha.Sreenivasamurthy@Sun.COM *
1910750SShesha.Sreenivasamurthy@Sun.COM * CDDL HEADER END
2010750SShesha.Sreenivasamurthy@Sun.COM */
2110750SShesha.Sreenivasamurthy@Sun.COM /*
22*12262SAlan.Adamson@Sun.COM * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
2310750SShesha.Sreenivasamurthy@Sun.COM */
2410750SShesha.Sreenivasamurthy@Sun.COM
2510750SShesha.Sreenivasamurthy@Sun.COM #include <sys/types.h>
2610750SShesha.Sreenivasamurthy@Sun.COM #include <sys/ddi.h>
2710750SShesha.Sreenivasamurthy@Sun.COM #include <sys/sunddi.h>
2810750SShesha.Sreenivasamurthy@Sun.COM #include <sys/sunndi.h>
2910750SShesha.Sreenivasamurthy@Sun.COM #include <sys/pcie_impl.h>
3010750SShesha.Sreenivasamurthy@Sun.COM #include <sys/pcie_pwr.h>
3110750SShesha.Sreenivasamurthy@Sun.COM
3210750SShesha.Sreenivasamurthy@Sun.COM void
pcie_init_plat(dev_info_t * dip)3310750SShesha.Sreenivasamurthy@Sun.COM pcie_init_plat(dev_info_t *dip)
3410750SShesha.Sreenivasamurthy@Sun.COM {
35*12262SAlan.Adamson@Sun.COM pcie_bus_t *bus_p = PCIE_DIP2BUS(dip);
36*12262SAlan.Adamson@Sun.COM
37*12262SAlan.Adamson@Sun.COM if (PCIE_IS_PCIE_BDG(bus_p)) {
38*12262SAlan.Adamson@Sun.COM bus_p->bus_pcie2pci_secbus = bus_p->bus_bdg_secbus;
39*12262SAlan.Adamson@Sun.COM } else {
40*12262SAlan.Adamson@Sun.COM dev_info_t *pdip;
41*12262SAlan.Adamson@Sun.COM
42*12262SAlan.Adamson@Sun.COM for (pdip = ddi_get_parent(dip); pdip;
43*12262SAlan.Adamson@Sun.COM pdip = ddi_get_parent(pdip)) {
44*12262SAlan.Adamson@Sun.COM pcie_bus_t *parent_bus_p = PCIE_DIP2BUS(pdip);
45*12262SAlan.Adamson@Sun.COM
46*12262SAlan.Adamson@Sun.COM if (parent_bus_p->bus_pcie2pci_secbus) {
47*12262SAlan.Adamson@Sun.COM bus_p->bus_pcie2pci_secbus =
48*12262SAlan.Adamson@Sun.COM parent_bus_p->bus_pcie2pci_secbus;
49*12262SAlan.Adamson@Sun.COM break;
50*12262SAlan.Adamson@Sun.COM }
51*12262SAlan.Adamson@Sun.COM if (PCIE_IS_ROOT(parent_bus_p))
52*12262SAlan.Adamson@Sun.COM break;
53*12262SAlan.Adamson@Sun.COM }
54*12262SAlan.Adamson@Sun.COM }
5510750SShesha.Sreenivasamurthy@Sun.COM }
5610750SShesha.Sreenivasamurthy@Sun.COM
5710750SShesha.Sreenivasamurthy@Sun.COM void
pcie_fini_plat(dev_info_t * dip)5810750SShesha.Sreenivasamurthy@Sun.COM pcie_fini_plat(dev_info_t *dip)
5910750SShesha.Sreenivasamurthy@Sun.COM {
60*12262SAlan.Adamson@Sun.COM pcie_bus_t *bus_p = PCIE_DIP2BUS(dip);
61*12262SAlan.Adamson@Sun.COM
62*12262SAlan.Adamson@Sun.COM if (PCIE_IS_PCIE_BDG(bus_p))
63*12262SAlan.Adamson@Sun.COM bus_p->bus_pcie2pci_secbus = 0;
6410750SShesha.Sreenivasamurthy@Sun.COM }
6510750SShesha.Sreenivasamurthy@Sun.COM
6610750SShesha.Sreenivasamurthy@Sun.COM int
pcie_plat_pwr_setup(dev_info_t * dip)6710750SShesha.Sreenivasamurthy@Sun.COM pcie_plat_pwr_setup(dev_info_t *dip)
6810750SShesha.Sreenivasamurthy@Sun.COM {
6910750SShesha.Sreenivasamurthy@Sun.COM if (ddi_prop_create(DDI_DEV_T_NONE, dip, DDI_PROP_CANSLEEP,
7010750SShesha.Sreenivasamurthy@Sun.COM "pm-want-child-notification?", NULL, NULL) != DDI_PROP_SUCCESS) {
7110750SShesha.Sreenivasamurthy@Sun.COM PCIE_DBG("%s(%d): can't create pm-want-child-notification \n",
7210750SShesha.Sreenivasamurthy@Sun.COM ddi_driver_name(dip), ddi_get_instance(dip));
7310750SShesha.Sreenivasamurthy@Sun.COM return (DDI_FAILURE);
7410750SShesha.Sreenivasamurthy@Sun.COM }
7510750SShesha.Sreenivasamurthy@Sun.COM return (DDI_SUCCESS);
7610750SShesha.Sreenivasamurthy@Sun.COM }
7710750SShesha.Sreenivasamurthy@Sun.COM
7810750SShesha.Sreenivasamurthy@Sun.COM /*
7910750SShesha.Sreenivasamurthy@Sun.COM * Undo whatever is done in pcie_plat_pwr_common_setup
8010750SShesha.Sreenivasamurthy@Sun.COM */
8110750SShesha.Sreenivasamurthy@Sun.COM void
pcie_plat_pwr_teardown(dev_info_t * dip)8210750SShesha.Sreenivasamurthy@Sun.COM pcie_plat_pwr_teardown(dev_info_t *dip)
8310750SShesha.Sreenivasamurthy@Sun.COM {
8410750SShesha.Sreenivasamurthy@Sun.COM (void) ddi_prop_remove(DDI_DEV_T_NONE, dip,
8510750SShesha.Sreenivasamurthy@Sun.COM "pm-want-child-notification?");
8610750SShesha.Sreenivasamurthy@Sun.COM }
87