opl_hostbridge.c revision aab83bb83be7342f6cfccaed8d5fe0b2f404855d
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston * CDDL HEADER START
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston * The contents of this file are subject to the terms of the
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston * Common Development and Distribution License (the "License").
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston * You may not use this file except in compliance with the License.
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston * See the License for the specific language governing permissions
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston * and limitations under the License.
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston * When distributing Covered Code, include this CDDL HEADER in each
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston * If applicable, add the following below this CDDL HEADER, with the
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston * fields enclosed by brackets "[]" replaced with your own identifying
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston * information: Portions Copyright [yyyy] [name of copyright owner]
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston * CDDL HEADER END
186d582bd9dbcd38e0aeea49036d47d3426a3536Surya Prakki * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston * Use is subject to license terms.
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi { TOPO_PGROUP_IO, TOPO_STABILITY_PRIVATE, TOPO_STABILITY_PRIVATE, 1 };
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi { TOPO_PGROUP_PCI, TOPO_STABILITY_PRIVATE, TOPO_STABILITY_PRIVATE, 1 };
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston * Check the root complex device node for a slot-names property.
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chuestonconst char *
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi if ((ptp = topo_mod_prominfo(mod)) == DI_PROM_PROP_NIL)
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston if (strcmp(di_prom_prop_name(pp), OPL_SLOT_NAMES) == 0) {
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston if (di_prom_prop_data(pp, &buf) <= sizeof (uint32_t))
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chuestonopl_node_create(topo_mod_t *mp, tnode_t *parent, const char *name, int inst,
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston /* Create FMRI */
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi if ((fmri = topo_mod_hcfmri(mp, parent, FM_HC_SCHEME_VERSION, name,
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi topo_mod_dprintf(mp, "create of tnode for %s failed: %s",
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston /* Create and bind node */
23a276b1252962c987a613be470dde26561247b8hueston topo_mod_dprintf(mp, "unable to bind root complex: %s\n",
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston * Create a root complex node.
0eb822a1c0c2bea495647510b75f77f0e57633ebcindiopl_rc_node_create(topo_mod_t *mp, tnode_t *parent, di_node_t dnode, int inst)
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston const char *slot_name;
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi rcn = opl_node_create(mp, parent, PCIEX_ROOT, inst, (void *)dnode);
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston * If this root complex connects to a slot, it will have a
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston * slot-names property.
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston /* Add FRU fmri */
92ba710950bf6ee35de67e1e0b7f20ec9e528106eschrock (void) snprintf(fru_str, sizeof (fru_str), "hc:///component=%s",
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston /* Add label */
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston (void) topo_node_label_set(rcn, (char *)slot_name, &err);
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston /* Inherit parent FRU's label */
23a276b1252962c987a613be470dde26561247b8hueston * Set ASRU to be the dev-scheme ASRU
23a276b1252962c987a613be470dde26561247b8hueston "dev:///%s fmri creation failed.\n",
23a276b1252962c987a613be470dde26561247b8hueston topo_mod_dprintf(mp, "topo_node_asru_set failed\n");
23a276b1252962c987a613be470dde26561247b8hueston * Set pciexrc properties for root complex nodes
23a276b1252962c987a613be470dde26561247b8hueston /* Add the io and pci property groups */
23a276b1252962c987a613be470dde26561247b8hueston topo_mod_dprintf(mp, "topo_pgroup_create failed\n");
23a276b1252962c987a613be470dde26561247b8hueston topo_mod_dprintf(mp, "topo_pgroup_create failed\n");
23a276b1252962c987a613be470dde26561247b8hueston /* Add the devfs path property */
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi if (topo_prop_set_string(rcn, TOPO_PGROUP_IO, TOPO_IO_DEV,
23a276b1252962c987a613be470dde26561247b8hueston topo_mod_dprintf(mp, "Failed to set DEV property\n");
23a276b1252962c987a613be470dde26561247b8hueston /* Oberon device type is always "pciex" */
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi if (topo_prop_set_string(rcn, TOPO_PGROUP_IO, TOPO_IO_DEVTYPE,
23a276b1252962c987a613be470dde26561247b8hueston topo_mod_dprintf(mp, "Failed to set DEVTYPE property\n");
23a276b1252962c987a613be470dde26561247b8hueston /* Oberon driver is always "px" */
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi if (topo_prop_set_string(rcn, TOPO_PGROUP_IO, TOPO_IO_DRIVER,
23a276b1252962c987a613be470dde26561247b8hueston topo_mod_dprintf(mp, "Failed to set DRIVER property\n");
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi if ((mod = topo_mod_modfmri(mp, FM_MOD_SCHEME_VERSION, OPL_PX_DRV))
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi TOPO_IO_MODULE, TOPO_PROP_IMMUTABLE, mod, &err) != 0) {
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi topo_mod_dprintf(mp, "Failed to set MODULE property\n");
23a276b1252962c987a613be470dde26561247b8hueston /* This is a PCIEX Root Complex */
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi if (topo_prop_set_string(rcn, TOPO_PGROUP_PCI, TOPO_PCI_EXCAP,
23a276b1252962c987a613be470dde26561247b8hueston topo_mod_dprintf(mp, "Failed to set EXCAP property\n");
23a276b1252962c987a613be470dde26561247b8hueston /* BDF of Oberon root complex is constant */
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi TOPO_PCI_BDF, TOPO_PROP_IMMUTABLE, OPL_PX_BDF, &err) != 0) {
23a276b1252962c987a613be470dde26561247b8hueston topo_mod_dprintf(mp, "Failed to set EXCAP property\n");
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston /* Make room for children */
186d582bd9dbcd38e0aeea49036d47d3426a3536Surya Prakki (void) topo_node_range_create(mp, rcn, PCIEX_BUS, 0, OPL_BUS_MAX);
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston * Create a hostbridge node.
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chuestonopl_hb_node_create(topo_mod_t *mp, tnode_t *parent, int inst)
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston hbn = opl_node_create(mp, parent, HOSTBRIDGE, inst, NULL);
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston /* Inherit parent FRU's label */
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston /* Make room for children */
186d582bd9dbcd38e0aeea49036d47d3426a3536Surya Prakki (void) topo_node_range_create(mp, hbn, PCIEX_ROOT, 0, OPL_RC_MAX);
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston * opl_hb_enum gets the ioboard instance passed in, and determines the
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston * hostbridge and root complex instances numbers based on the bus addresses.
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chuestonopl_hb_enum(topo_mod_t *mp, const ioboard_contents_t *iob, tnode_t *ion,
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston /* Load the pcibus module. We'll need it later. */
23a276b1252962c987a613be470dde26561247b8hueston topo_mod_dprintf(mp, "can't load pcibus module: %s\n",
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston return (-1);
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston /* For each hostbridge on an ioboard... */
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston /* For each root complex in a hostbridge... */
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston /* If no root complex, continue */
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston /* The root complex exists! */
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston "/chassis=0/ioboard=%d/hostbridge=%d/pciexrc=%d\n",
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston * If we haven't created a hostbridge node yet, do it
23a276b1252962c987a613be470dde26561247b8hueston "unable to create hbnode: %s\n",
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston return (-1);
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston /* Create the root complex node */
23a276b1252962c987a613be470dde26561247b8hueston "unable to create rcnode: %s\n",
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston return (-1);
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston /* Enumerate pcibus nodes under the root complex */
23a276b1252962c987a613be470dde26561247b8hueston "error enumerating pcibus: %s\n",
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston return (-1);
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston return (0);