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.
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston * SUNW,OPL-Enterprise platform ioboard topology enumerator
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chuestonstatic int opl_iob_enum(topo_mod_t *hdl, tnode_t *parent, const char *name,
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi topo_instance_t imin, topo_instance_t imax, void *notused1, void *notused2);
78ed97a7b79b59ef2ef41f190c9be35c54d90119jl/* OPL model type */
78ed97a7b79b59ef2ef41f190c9be35c54d90119jltypedef enum {
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston * Turn on module debugging output
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston topo_mod_dprintf(modhdl, "initializing ioboard enumerator\n");
186d582bd9dbcd38e0aeea49036d47d3426a3536Surya Prakki (void) topo_mod_register(modhdl, &IobInfo, TOPO_VERSION);
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston * Checks to see if there's a physical board number property on this
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston * device node.
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi if ((ptp = topo_mod_prominfo(mod)) == DI_PROM_HANDLE_NIL)
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi return (-1);
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston if (strcmp(di_prom_prop_name(pp), OPL_PHYSICAL_BD) == 0) {
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston return (-1);
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston * Creates a map of logical boards to physical location.
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston /* Initialize all entries to no mapping */
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston for (i = 0; i < OPL_IOB_MAX; i++) {
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston * Get LSB-to-PSB (logical-to-physical board) mapping by finding the
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston * memory controller driver per LSB. The MC driver will have a
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston * physical-board# property.
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston for (n = di_drv_first_node(OPL_MC_DRV, opl_devtree);
23a276b1252962c987a613be470dde26561247b8hueston * di_bus_addr returned NULL. This can happen during
23a276b1252962c987a613be470dde26561247b8hueston * DR attach/detach of the mc driver. Just skip this
23a276b1252962c987a613be470dde26561247b8hueston * node for now.
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston /* psb mapping is out of range, skip */
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston * Create the ioboard node. Add fru and label properties, and create room
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston * for child hostbridge nodes.
78ed97a7b79b59ef2ef41f190c9be35c54d90119jl * Only IKKAKU model has different IO topology.
78ed97a7b79b59ef2ef41f190c9be35c54d90119jlopl_iob_node_create(topo_mod_t *mp, tnode_t *parent, int inst,
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston /* Create ioboard FMRI */
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi if ((fmri = topo_mod_hcfmri(mp, parent, FM_HC_SCHEME_VERSION, IOBOARD,
23a276b1252962c987a613be470dde26561247b8hueston topo_mod_dprintf(mp, "create of tnode for ioboard failed: %s\n",
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston /* Create node for this ioboard */
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi ion = topo_node_bind(mp, parent, IOBOARD, inst, fmri);
23a276b1252962c987a613be470dde26561247b8hueston topo_mod_dprintf(mp, "unable to bind ioboard: %s\n",
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston /* Create and add FRU fmri for this ioboard */
78ed97a7b79b59ef2ef41f190c9be35c54d90119jl (void) snprintf(fmri_str, sizeof (fmri_str), IKKAKU_IOBDFRU);
78ed97a7b79b59ef2ef41f190c9be35c54d90119jl (void) snprintf(fmri_str, sizeof (fmri_str), IOBDFRU, inst);
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston /* Add label for this ioboard */
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston /* Create range of hostbridges on this ioboard */
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston if (topo_node_range_create(mp, ion, HOSTBRIDGE, 0, OPL_HB_MAX) != 0) {
23a276b1252962c987a613be470dde26561247b8hueston topo_mod_dprintf(mp, "topo_node_range_create failed: %s\n",
78ed97a7b79b59ef2ef41f190c9be35c54d90119jl * get the OPL model name from rootnode property "model"
78ed97a7b79b59ef2ef41f190c9be35c54d90119jlopl_get_model(topo_mod_t *mp, di_node_t opl_devtree, char *model)
78ed97a7b79b59ef2ef41f190c9be35c54d90119jl return (-1);
78ed97a7b79b59ef2ef41f190c9be35c54d90119jl if (di_prom_prop_lookup_bytes(promh, opl_devtree, "model",
78ed97a7b79b59ef2ef41f190c9be35c54d90119jl return (0);
78ed97a7b79b59ef2ef41f190c9be35c54d90119jl return (-1);
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston/*ARGSUSED*/
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chuestonopl_iob_enum(topo_mod_t *mp, tnode_t *parent, const char *name,
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi topo_instance_t imin, topo_instance_t imax, void *notused1, void *notused2)
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston /* Validate the name is correct */
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston return (-1);
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston /* Make sure we don't exceed OPL_IOB_MAX */
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston return (-1);
78ed97a7b79b59ef2ef41f190c9be35c54d90119jl topo_mod_dprintf(mp, "opl_get_model %s found.\n", model);
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston * Create a mapping from logical board numbers (which are part of
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston * the device node bus address) to physical board numbers, so we
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston * can create meaningful fru labels.
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston * Figure out which boards are installed by finding hostbridges
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston * with matching bus addresses.
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston for (pnode = di_drv_first_node(OPL_PX_DRV, opl_devtree);
864221ad7169608e293fbeaa9df563afc9f345a0kd /* Get the bus address */
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston /* Map logical system board to physical system board */
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston /* If valid psb, note that this board exists */
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston * Now enumerate each existing board Exit loop if retval is
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston * ever set to non-zero.
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston for (inst = imin; inst <= imax && retval == 0; inst++) {
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston /* If this board doesn't contain any hostbridges, skip it */
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston /* Create node for this ioboard */
23a276b1252962c987a613be470dde26561247b8hueston "enumeration of ioboard failed: %s\n",
0b6016e6ff70af39f99c9cc28e0c2207c8f5413chueston /* Enumerate hostbridges on this ioboard, sets errno */