1131N/A/*
1131N/A * CDDL HEADER START
1131N/A *
1131N/A * The contents of this file are subject to the terms of the
1131N/A * Common Development and Distribution License (the "License").
1131N/A * You may not use this file except in compliance with the License.
1131N/A *
1131N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
1131N/A * or http://www.opensolaris.org/os/licensing.
1131N/A * See the License for the specific language governing permissions
1131N/A * and limitations under the License.
1131N/A *
1131N/A * When distributing Covered Code, include this CDDL HEADER in each
1131N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1131N/A * If applicable, add the following below this CDDL HEADER, with the
1131N/A * fields enclosed by brackets "[]" replaced with your own identifying
1131N/A * information: Portions Copyright [yyyy] [name of copyright owner]
1131N/A *
1131N/A * CDDL HEADER END
1131N/A */
1131N/A/*
1131N/A * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
1131N/A * Use is subject to license terms.
1131N/A */
3215N/A
1131N/A#ifndef _SYS_OPL_CFG_H
1389N/A#define _SYS_OPL_CFG_H
1131N/A
1131N/A#pragma ident "%Z%%M% %I% %E% SMI"
1131N/A
1418N/A#ifdef __cplusplus
1828N/Aextern "C" {
1828N/A#endif
1828N/A
1828N/A/*
1828N/A * Hardware Descriptor.
1389N/A */
1389N/A
1389N/A#include <sys/opl_hwdesc.h>
1884N/A
1389N/A#define OPL_PSB_MODE 0x0
1389N/A#define OPL_XSB_MODE 0x1
1418N/A
1389N/A#define OPL_LSBID_MASK 0x1f
1828N/A
1828N/A/*
1828N/A * CPU device portid:
1828N/A *
1828N/A * 1 0 0 0 0 0 0 0 0 0 0
1828N/A * 0 9 8 7 6 5 4 3 2 1 0
1828N/A * ---------------------------------------
1828N/A * | 1 | LSB ID | CHIP | CORE | CPU |
1828N/A * ---------------------------------------
1828N/A */
1828N/A#define OPL_CPUID_TO_LSB(devid) ((devid >> 5) & OPL_LSBID_MASK)
1828N/A#define OPL_CPU_CHIP(devid) ((devid >> 3) & 0x3)
1828N/A#define OPL_CORE(devid) ((devid >> 1) & 0x3)
1828N/A#define OPL_CPU(devid) ((devid & 0x001))
1828N/A
1828N/A#define OPL_PORTID(board, chip) ((1 << 10) | (board << 5) | (chip << 3))
1389N/A
1828N/A#define OPL_CPUID(board, chip, core, cpu) \
1828N/A \
1828N/A ((board << 5) | (chip << 3) | (core << 1) | (cpu))
1389N/A
1131N/A/*
1131N/A * Dummy address space for a chip.
1131N/A */
1131N/A#define OPL_PROC_AS(board, chip) \
1828N/A \
1828N/A ((1ULL << 46) | ((uint64_t)board << 40) | (1ULL << 39) | \
1828N/A (1ULL << 33) | ((uint64_t)chip << 4))
1828N/A
1828N/A/*
1131N/A * pseudo-mc portid:
1828N/A *
1131N/A * 1 0 0 0 0 0 0 0 0 0 0
1131N/A * 0 9 8 7 6 5 4 3 2 1 0
1131N/A * -------------------------------------
1131N/A * | 0 | 1 | LSB ID | 0 |
1828N/A * -------------------------------------
1828N/A */
1828N/A#define OPL_LSB_TO_PSEUDOMC_PORTID(board) ((1 << 9) | (board << 4))
1828N/A
1828N/A/*
1828N/A * Dummy address space for a pseudo memory node
1828N/A */
1828N/A#define OPL_MC_AS(board) \
1828N/A \
1828N/A ((1ULL << 46) | ((uint64_t)board << 40) | (1ULL << 39) | \
1828N/A (1ULL << 33))
1828N/A
1828N/A/*
1828N/A * Defines used by the Jupiter bus-specific library (lfc_jupiter.so).
1828N/A * This library gets loaded into the user-level fcode interpreter
1828N/A * and provides bus-specific methods that are used by the Oberon
1828N/A * and the CMU-channel fcode drivers.
1828N/A */
1828N/A/*
1828N/A *
1828N/A * IO port id:
1389N/A *
1389N/A * 1 0 0 0 0 0 0 0 0 0 0
1389N/A * 0 9 8 7 6 5 4 3 2 1 0
1389N/A * ---------------------------------------
1828N/A * | 0 0 | LSB ID | IO CHAN | LEAF |
1389N/A * ---------------------------------------
1828N/A */
1828N/A#define OPL_PORTID_MASK 0x7FF
1389N/A#define OPL_IO_PORTID_TO_LSB(portid) (((portid) >> 4) & OPL_LSBID_MASK)
1828N/A#define OPL_PORTID_TO_CHANNEL(portid) (((portid) >> 1) & 0x7)
1828N/A#define OPL_PORTID_TO_LEAF(portid) ((portid) & 0x1)
1828N/A#define OPL_IO_PORTID(lsb, ch, leaf) \
1389N/A (((lsb & OPL_LSBID_MASK) << 4) | ((ch & 0x7) << 1) | (leaf & 0x1))
1828N/A
1828N/A#define OPL_ADDR_TO_LSB(hi) (((hi) >> 8) & OPL_LSBID_MASK)
1828N/A#define OPL_ADDR_TO_CHANNEL(hi) (((hi) >> 5) & 0x7)
1828N/A#define OPL_ADDR_TO_LEAF(hi, lo) \
1828N/A (!(((hi) >> 7) & 0x1) && (((lo) >> 20) == 0x7))
1828N/A
1389N/A#define OPL_ADDR_HI(lsb, ch) \
1389N/A ((1 << 14) | ((lsb & OPL_LSBID_MASK) << 8) | ((ch & 0x7) << 5))
1828N/A
1828N/A#define OPL_CMU_CHANNEL 4
1828N/A#define OPL_OBERON_CHANNEL(ch) ((ch >= 0) && (ch <= 3))
1389N/A#define OPL_VALID_CHANNEL(ch) ((ch >= 0) && (ch <= 4))
1828N/A#define OPL_VALID_LEAF(leaf) ((leaf == 0) || (leaf == 1))
1828N/A
1828N/A#if defined(_KERNEL)
1828N/A
1828N/A/*
1828N/A * We store the pointers to the following device nodes in this structure:
1828N/A * "pseudo-mc"
1828N/A * "cmp"
1389N/A * "pci"
1389N/A *
1828N/A * These nodes represent the different branches we create in the device
1828N/A * tree for each board during probe. We store them so that when a board
1828N/A * is unprobed, we can easily locate the branches and destroy them.
1389N/A */
1828N/Atypedef struct {
1828N/A dev_info_t *cfg_pseudo_mc;
1828N/A dev_info_t *cfg_cpu_chips[HWD_CPU_CHIPS_PER_CMU];
1828N/A dev_info_t *cfg_cmuch_leaf;
1828N/A fco_handle_t cfg_cmuch_handle;
1828N/A char *cfg_cmuch_probe_str;
1828N/A dev_info_t *cfg_pcich_leaf[HWD_PCI_CHANNELS_PER_SB]
1389N/A [HWD_LEAVES_PER_PCI_CHANNEL];
1389N/A fco_handle_t cfg_pcich_handle[HWD_PCI_CHANNELS_PER_SB]
1828N/A [HWD_LEAVES_PER_PCI_CHANNEL];
1828N/A char *cfg_pcich_probe_str[HWD_PCI_CHANNELS_PER_SB]
1828N/A [HWD_LEAVES_PER_PCI_CHANNEL];
1828N/A void *cfg_hwd;
1828N/A} opl_board_cfg_t;
1828N/A
1828N/A/*
1828N/A * Prototypes for the callback functions used in the DDI functions
1828N/A * used to perform device tree operations.
1828N/A *
1828N/A * init functions are used to find device nodes that are created
1828N/A * by Solaris during boot.
1828N/A *
1828N/A * create functions are used to initialize device nodes during DR.
1828N/A */
1389N/Atypedef int (*opl_init_func_t)(dev_info_t *, char *, int);
1389N/Atypedef int (*opl_create_func_t)(dev_info_t *, void *, uint_t);
1893N/A
1893N/A/*
1893N/A * The following probe structure carries all the information required
1893N/A * at various points during probe. This structure serves two purposes:
1893N/A *
1389N/A * 1. It allows us to streamline functions and have them accept just
1389N/A * a single argument.
1389N/A *
1131N/A * 2. It allows us to pass information to the DDI callbacks. DDI
1131N/A * callbacks are allowed only one argument. It also allows
1828N/A * us to return information from those callbacks.
1828N/A *
1893N/A * The probe structure carries a snapshot of the hardware descriptor
1893N/A * taken at the beginning of a probe.
1828N/A */
1893N/Atypedef struct {
1828N/A hwd_header_t *pr_hdr;
1828N/A hwd_sb_status_t *pr_sb_status;
1828N/A hwd_domain_info_t *pr_dinfo;
1828N/A hwd_sb_t *pr_sb;
1828N/A
1131N/A int pr_board;
1828N/A int pr_cpu_chip;
1131N/A int pr_core;
1828N/A int pr_cpu;
1828N/A int pr_channel;
1131N/A int pr_channel_status;
1131N/A int pr_leaf;
1131N/A int pr_leaf_status;
1131N/A
1131N/A opl_create_func_t pr_create;
1131N/A dev_info_t *pr_parent;
1131N/A dev_info_t *pr_node;
1131N/A int pr_hold;
1131N/A unsigned pr_cpu_impl;
1131N/A} opl_probe_t;
1131N/A
2649N/A#define OPL_STR_LEN 256
1131N/A
1131N/A#define OPL_HI(value) ((uint32_t)((uint64_t)(value) >> 32))
1389N/A#define OPL_LO(value) ((uint32_t)(value))
1389N/A
1389N/Atypedef struct {
1389N/A uint32_t addr_hi;
1389N/A uint32_t addr_lo;
1389N/A} opl_addr_t;
1389N/A
1389N/Atypedef struct {
1389N/A uint32_t rg_addr_hi;
1389N/A uint32_t rg_addr_lo;
1389N/A uint32_t rg_size_hi;
1389N/A uint32_t rg_size_lo;
1389N/A} opl_range_t;
1389N/A
1389N/Atypedef struct {
1389N/A int mc_bank;
1389N/A uint32_t mc_hi;
1389N/A uint32_t mc_lo;
1389N/A} opl_mc_addr_t;
1389N/A
1389N/A/*
1389N/A * Convenience macros for DDI property operations. The functions that
1389N/A * DDI provides for getting and updating properties are not symmetric
1389N/A * either in their names or in the number of arguments. These macros
1389N/A * hide the gory details and provide a symmetric way to get and
1389N/A * set properties.
1389N/A */
1389N/A#define opl_prop_get_string(dip, name, bufp, lenp) \
1389N/A ddi_getlongprop(DDI_DEV_T_ANY, dip, \
1389N/A DDI_PROP_DONTPASS, name, (caddr_t)bufp, lenp)
1389N/A
1389N/A#define opl_prop_get_int(dip, name, value, defvalue) \
1828N/A( \
1828N/A *(value) = ddi_getprop(DDI_DEV_T_ANY, dip, \
1828N/A DDI_PROP_DONTPASS, name, defvalue), \
1828N/A (*(value) == defvalue) ? DDI_PROP_NOT_FOUND : DDI_PROP_SUCCESS \
1828N/A)
1828N/A
1828N/A#define opl_prop_get_int_array(dip, name, data, nelems) \
1828N/A ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip, \
1828N/A DDI_PROP_DONTPASS, name, (int **)&data, (uint_t *)&nelems)
1828N/A
1828N/A#define OPL_GET_PROP(type, dip, name, value, arg) \
1828N/A opl_prop_get_##type(dip, name, value, arg)
1828N/A
1828N/A#define OPL_GET_PROP_ARRAY(type, dip, name, values, nvalues) \
1828N/A opl_prop_get_##type##_array(dip, name, values, nvalues)
1828N/A
1828N/A#define OPL_FREE_PROP(data) \
1828N/A ddi_prop_free((void *)data)
1828N/A
1828N/A#define OPL_UPDATE_PROP_ERR(ret, name) \
1828N/A if (ret != DDI_PROP_SUCCESS) { \
1828N/A cmn_err(CE_WARN, "%s (%d): %s update property error (%d)",\
1828N/A __FILE__, __LINE__, name, ret); \
1828N/A return (DDI_WALK_ERROR); \
1828N/A }
1828N/A
1828N/A#define OPL_UPDATE_PROP(type, dip, name, value) \
1828N/A ret = ndi_prop_update_##type(DDI_DEV_T_NONE, dip, name, value); \
1828N/A OPL_UPDATE_PROP_ERR(ret, name)
1828N/A
1828N/A
1828N/A#define OPL_UPDATE_PROP_ARRAY(type, dip, name, values, nvalues) \
1828N/A ret = ndi_prop_update_##type##_array(DDI_DEV_T_NONE, dip, \
1828N/A name, values, nvalues); \
1828N/A OPL_UPDATE_PROP_ERR(ret, name)
1828N/A
1828N/A/*
1828N/A * Node names for the different nodes supported in OPL.
1828N/A */
1828N/A#define OPL_PSEUDO_MC_NODE "pseudo-mc"
1828N/A#define OPL_CPU_CHIP_NODE "cmp"
1828N/A#define OPL_CORE_NODE "core"
1828N/A#define OPL_CPU_NODE "cpu"
1828N/A#define OPL_PCI_LEAF_NODE "pci"
1828N/A
1828N/Atypedef struct {
1828N/A char *fc_service;
1828N/A fc_ops_t *fc_op;
1828N/A} opl_fc_ops_t;
1828N/A
1828N/A/*
1828N/A * Functions used by drmach
1828N/A */
1828N/Aextern int opl_probe_sb(int, unsigned *);
1828N/Aextern int opl_unprobe_sb(int);
1828N/Aextern int opl_read_hwd(int, hwd_header_t **, hwd_sb_status_t **,
1828N/A hwd_domain_info_t **, hwd_sb_t **);
1828N/Aextern void opl_hold_devtree(void);
1828N/Aextern void opl_release_devtree(void);
1828N/Aextern int oplcfg_pa_swap(int from, int to);
1828N/Aextern int opl_init_cfg();
1828N/A
1828N/A#endif /* _KERNEL */
1828N/A
1828N/A#ifdef __cplusplus
1828N/A}
1828N/A#endif
1828N/A
1828N/A#endif /* _SYS_OPL_CFG_H */
1828N/A